]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blame - test/grsecurity-3.1-4.2.4-201510251451.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-3.1-4.2.4-201510251451.patch
CommitLineData
46c36e49
PK
1diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2index 9de9813..1462492 100644
3--- a/Documentation/dontdiff
4+++ b/Documentation/dontdiff
5@@ -3,9 +3,11 @@
6 *.bc
7 *.bin
8 *.bz2
9+*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13+*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17@@ -15,6 +17,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21+*.gmo
22 *.grep
23 *.grp
24 *.gz
25@@ -51,14 +54,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29+*.vim
30 *.xml
31 *.xz
32 *_MODULES
33+*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38-.*
39+.[^g]*
40+.gen*
41 .*.d
42 .mm
43 53c700_d.h
44@@ -72,9 +78,11 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48+PERF*
49 SCCS
50 System.map*
51 TAGS
52+TRACEEVENT-CFLAGS
53 aconf
54 af_names.h
55 aic7*reg.h*
56@@ -83,6 +91,7 @@ aic7*seq.h*
57 aicasm
58 aicdb.h*
59 altivec*.c
60+ashldi3.S
61 asm-offsets.h
62 asm_offsets.h
63 autoconf.h*
64@@ -95,32 +104,40 @@ bounds.h
65 bsetup
66 btfixupprep
67 build
68+builtin-policy.h
69 bvmlinux
70 bzImage*
71 capability_names.h
72 capflags.c
73 classlist.h*
74+clut_vga16.c
75+common-cmds.h
76 comp*.log
77 compile.h*
78 conf
79 config
80 config-*
81 config_data.h*
82+config.c
83 config.mak
84 config.mak.autogen
85+config.tmp
86 conmakehash
87 consolemap_deftbl.c*
88 cpustr.h
89 crc32table.h*
90 cscope.*
91 defkeymap.c
92+devicetable-offsets.h
93 devlist.h*
94 dnotify_test
95 docproc
96 dslm
97+dtc-lexer.lex.c
98 elf2ecoff
99 elfconfig.h*
100 evergreen_reg_safe.h
101+exception_policy.conf
102 fixdep
103 flask.h
104 fore200e_mkfirm
105@@ -128,12 +145,15 @@ fore200e_pca_fw.c*
106 gconf
107 gconf.glade.h
108 gen-devlist
109+gen-kdb_cmds.c
110 gen_crc32table
111 gen_init_cpio
112 generated
113 genheaders
114 genksyms
115 *_gray256.c
116+hash
117+hid-example
118 hpet_example
119 hugepage-mmap
120 hugepage-shm
121@@ -148,14 +168,14 @@ int32.c
122 int4.c
123 int8.c
124 kallsyms
125-kconfig
126+kern_constants.h
127 keywords.c
128 ksym.c*
129 ksym.h*
130 kxgettext
131 lex.c
132 lex.*.c
133-linux
134+lib1funcs.S
135 logo_*.c
136 logo_*_clut224.c
137 logo_*_mono.c
138@@ -165,14 +185,15 @@ mach-types.h
139 machtypes.h
140 map
141 map_hugetlb
142-media
143 mconf
144+mdp
145 miboot*
146 mk_elfconfig
147 mkboot
148 mkbugboot
149 mkcpustr
150 mkdep
151+mkpiggy
152 mkprep
153 mkregtable
154 mktables
155@@ -188,6 +209,8 @@ oui.c*
156 page-types
157 parse.c
158 parse.h
159+parse-events*
160+pasyms.h
161 patches*
162 pca200e.bin
163 pca200e_ecd.bin2
164@@ -197,6 +220,7 @@ perf-archive
165 piggyback
166 piggy.gzip
167 piggy.S
168+pmu-*
169 pnmtologo
170 ppc_defs.h*
171 pss_boot.h
172@@ -206,7 +230,12 @@ r200_reg_safe.h
173 r300_reg_safe.h
174 r420_reg_safe.h
175 r600_reg_safe.h
176+randomize_layout_hash.h
177+randomize_layout_seed.h
178+realmode.lds
179+realmode.relocs
180 recordmcount
181+regdb.c
182 relocs
183 rlim_names.h
184 rn50_reg_safe.h
185@@ -216,8 +245,12 @@ series
186 setup
187 setup.bin
188 setup.elf
189+signing_key*
190+size_overflow_hash.h
191 sImage
192+slabinfo
193 sm_tbl*
194+sortextable
195 split-include
196 syscalltab.h
197 tables.c
198@@ -227,6 +260,7 @@ tftpboot.img
199 timeconst.h
200 times.h*
201 trix_boot.h
202+user_constants.h
203 utsrelease.h*
204 vdso-syms.lds
205 vdso.lds
206@@ -238,13 +272,17 @@ vdso32.lds
207 vdso32.so.dbg
208 vdso64.lds
209 vdso64.so.dbg
210+vdsox32.lds
211+vdsox32-syms.lds
212 version.h*
213 vmImage
214 vmlinux
215 vmlinux-*
216 vmlinux.aout
217 vmlinux.bin.all
218+vmlinux.bin.bz2
219 vmlinux.lds
220+vmlinux.relocs
221 vmlinuz
222 voffset.h
223 vsyscall.lds
224@@ -252,9 +290,12 @@ vsyscall_32.lds
225 wanxlfw.inc
226 uImage
227 unifdef
228+utsrelease.h
229 wakeup.bin
230 wakeup.elf
231 wakeup.lds
232+x509*
233 zImage*
234 zconf.hash.c
235+zconf.lex.c
236 zoffset.h
237diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
238index 13f888a..250729b 100644
239--- a/Documentation/kbuild/makefiles.txt
240+++ b/Documentation/kbuild/makefiles.txt
241@@ -23,10 +23,11 @@ This document describes the Linux kernel Makefiles.
242 === 4 Host Program support
243 --- 4.1 Simple Host Program
244 --- 4.2 Composite Host Programs
245- --- 4.3 Using C++ for host programs
246- --- 4.4 Controlling compiler options for host programs
247- --- 4.5 When host programs are actually built
248- --- 4.6 Using hostprogs-$(CONFIG_FOO)
249+ --- 4.3 Defining shared libraries
250+ --- 4.4 Using C++ for host programs
251+ --- 4.5 Controlling compiler options for host programs
252+ --- 4.6 When host programs are actually built
253+ --- 4.7 Using hostprogs-$(CONFIG_FOO)
254
255 === 5 Kbuild clean infrastructure
256
257@@ -643,7 +644,29 @@ Both possibilities are described in the following.
258 Finally, the two .o files are linked to the executable, lxdialog.
259 Note: The syntax <executable>-y is not permitted for host-programs.
260
261---- 4.3 Using C++ for host programs
262+--- 4.3 Defining shared libraries
263+
264+ Objects with extension .so are considered shared libraries, and
265+ will be compiled as position independent objects.
266+ Kbuild provides support for shared libraries, but the usage
267+ shall be restricted.
268+ In the following example the libkconfig.so shared library is used
269+ to link the executable conf.
270+
271+ Example:
272+ #scripts/kconfig/Makefile
273+ hostprogs-y := conf
274+ conf-objs := conf.o libkconfig.so
275+ libkconfig-objs := expr.o type.o
276+
277+ Shared libraries always require a corresponding -objs line, and
278+ in the example above the shared library libkconfig is composed by
279+ the two objects expr.o and type.o.
280+ expr.o and type.o will be built as position independent code and
281+ linked as a shared library libkconfig.so. C++ is not supported for
282+ shared libraries.
283+
284+--- 4.4 Using C++ for host programs
285
286 kbuild offers support for host programs written in C++. This was
287 introduced solely to support kconfig, and is not recommended
288@@ -666,7 +689,7 @@ Both possibilities are described in the following.
289 qconf-cxxobjs := qconf.o
290 qconf-objs := check.o
291
292---- 4.4 Controlling compiler options for host programs
293+--- 4.5 Controlling compiler options for host programs
294
295 When compiling host programs, it is possible to set specific flags.
296 The programs will always be compiled utilising $(HOSTCC) passed
297@@ -694,7 +717,7 @@ Both possibilities are described in the following.
298 When linking qconf, it will be passed the extra option
299 "-L$(QTDIR)/lib".
300
301---- 4.5 When host programs are actually built
302+--- 4.6 When host programs are actually built
303
304 Kbuild will only build host-programs when they are referenced
305 as a prerequisite.
306@@ -725,7 +748,7 @@ Both possibilities are described in the following.
307 This will tell kbuild to build lxdialog even if not referenced in
308 any rule.
309
310---- 4.6 Using hostprogs-$(CONFIG_FOO)
311+--- 4.7 Using hostprogs-$(CONFIG_FOO)
312
313 A typical pattern in a Kbuild file looks like this:
314
315diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
316index 1d6f045..2714987 100644
317--- a/Documentation/kernel-parameters.txt
318+++ b/Documentation/kernel-parameters.txt
319@@ -1244,6 +1244,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
320 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
321 Default: 1024
322
323+ grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
324+ ignore grsecurity's /proc restrictions
325+
326+ grsec_sysfs_restrict= Format: 0 | 1
327+ Default: 1
328+ Disables GRKERNSEC_SYSFS_RESTRICT if enabled in config
329+
330 hashdist= [KNL,NUMA] Large hashes allocated during boot
331 are distributed across NUMA nodes. Defaults on
332 for 64-bit NUMA, off otherwise.
333@@ -2364,6 +2371,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
334 noexec=on: enable non-executable mappings (default)
335 noexec=off: disable non-executable mappings
336
337+ nopcid [X86-64]
338+ Disable PCID (Process-Context IDentifier) even if it
339+ is supported by the processor.
340+
341 nosmap [X86]
342 Disable SMAP (Supervisor Mode Access Prevention)
343 even if it is supported by processor.
344@@ -2662,6 +2673,30 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
345 the specified number of seconds. This is to be used if
346 your oopses keep scrolling off the screen.
347
348+ pax_nouderef [X86] disables UDEREF. Most likely needed under certain
349+ virtualization environments that don't cope well with the
350+ expand down segment used by UDEREF on X86-32 or the frequent
351+ page table updates on X86-64.
352+
353+ pax_sanitize_slab=
354+ Format: { 0 | 1 | off | fast | full }
355+ Options '0' and '1' are only provided for backward
356+ compatibility, 'off' or 'fast' should be used instead.
357+ 0|off : disable slab object sanitization
358+ 1|fast: enable slab object sanitization excluding
359+ whitelisted slabs (default)
360+ full : sanitize all slabs, even the whitelisted ones
361+
362+ pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
363+
364+ pax_extra_latent_entropy
365+ Enable a very simple form of latent entropy extraction
366+ from the first 4GB of memory as the bootmem allocator
367+ passes the memory pages to the buddy allocator.
368+
369+ pax_weakuderef [X86-64] enables the weaker but faster form of UDEREF
370+ when the processor supports PCID.
371+
372 pcbit= [HW,ISDN]
373
374 pcd. [PARIDE]
375diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
376index 6fccb69..60c7c7a 100644
377--- a/Documentation/sysctl/kernel.txt
378+++ b/Documentation/sysctl/kernel.txt
379@@ -41,6 +41,7 @@ show up in /proc/sys/kernel:
380 - kptr_restrict
381 - kstack_depth_to_print [ X86 only ]
382 - l2cr [ PPC only ]
383+- modify_ldt [ X86 only ]
384 - modprobe ==> Documentation/debugging-modules.txt
385 - modules_disabled
386 - msg_next_id [ sysv ipc ]
387@@ -391,6 +392,20 @@ This flag controls the L2 cache of G3 processor boards. If
388
389 ==============================================================
390
391+modify_ldt: (X86 only)
392+
393+Enables (1) or disables (0) the modify_ldt syscall. Modifying the LDT
394+(Local Descriptor Table) may be needed to run a 16-bit or segmented code
395+such as Dosemu or Wine. This is done via a system call which is not needed
396+to run portable applications, and which can sometimes be abused to exploit
397+some weaknesses of the architecture, opening new vulnerabilities.
398+
399+This sysctl allows one to increase the system's security by disabling the
400+system call, or to restore compatibility with specific applications when it
401+was already disabled.
402+
403+==============================================================
404+
405 modules_disabled:
406
407 A toggle value indicating if modules are allowed to be loaded
408diff --git a/Makefile b/Makefile
409index a952801..9da1dcb 100644
410--- a/Makefile
411+++ b/Makefile
412@@ -298,7 +298,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
413 HOSTCC = gcc
414 HOSTCXX = g++
415 HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
416-HOSTCXXFLAGS = -O2
417+HOSTCFLAGS = -W -Wno-unused-parameter -Wno-missing-field-initializers -fno-delete-null-pointer-checks
418+HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
419+HOSTCXXFLAGS = -O2 -Wall -W -Wno-array-bounds
420
421 ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
422 HOSTCFLAGS += -Wno-unused-value -Wno-unused-parameter \
423@@ -434,8 +436,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
424 # Rules shared between *config targets and build targets
425
426 # Basic helpers built in scripts/
427-PHONY += scripts_basic
428-scripts_basic:
429+PHONY += scripts_basic gcc-plugins
430+scripts_basic: gcc-plugins
431 $(Q)$(MAKE) $(build)=scripts/basic
432 $(Q)rm -f .tmp_quiet_recordmcount
433
434@@ -615,6 +617,74 @@ endif
435 # Tell gcc to never replace conditional load with a non-conditional one
436 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
437
438+ifndef DISABLE_PAX_PLUGINS
439+ifeq ($(call cc-ifversion, -ge, 0408, y), y)
440+PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
441+else
442+PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
443+endif
444+ifneq ($(PLUGINCC),)
445+ifdef CONFIG_PAX_CONSTIFY_PLUGIN
446+CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
447+endif
448+ifdef CONFIG_PAX_MEMORY_STACKLEAK
449+STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
450+STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
451+endif
452+ifdef CONFIG_KALLOCSTAT_PLUGIN
453+KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
454+endif
455+ifdef CONFIG_PAX_KERNEXEC_PLUGIN
456+KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
457+KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
458+KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
459+endif
460+ifdef CONFIG_GRKERNSEC_RANDSTRUCT
461+RANDSTRUCT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/randomize_layout_plugin.so -DRANDSTRUCT_PLUGIN
462+ifdef CONFIG_GRKERNSEC_RANDSTRUCT_PERFORMANCE
463+RANDSTRUCT_PLUGIN_CFLAGS += -fplugin-arg-randomize_layout_plugin-performance-mode
464+endif
465+endif
466+ifdef CONFIG_CHECKER_PLUGIN
467+ifeq ($(call cc-ifversion, -ge, 0406, y), y)
468+CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
469+endif
470+endif
471+COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
472+ifdef CONFIG_PAX_SIZE_OVERFLOW
473+SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
474+endif
475+ifdef CONFIG_PAX_LATENT_ENTROPY
476+LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
477+endif
478+ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
479+STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
480+endif
481+INITIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/initify_plugin.so -DINITIFY_PLUGIN
482+GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
483+GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
484+GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
485+GCC_PLUGINS_CFLAGS += $(INITIFY_PLUGIN_CFLAGS)
486+GCC_PLUGINS_CFLAGS += $(RANDSTRUCT_PLUGIN_CFLAGS)
487+GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
488+export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN LATENT_ENTROPY_PLUGIN_CFLAGS
489+ifeq ($(KBUILD_EXTMOD),)
490+gcc-plugins:
491+ $(Q)$(MAKE) $(build)=tools/gcc
492+else
493+gcc-plugins: ;
494+endif
495+else
496+gcc-plugins:
497+ifeq ($(call cc-ifversion, -ge, 0405, y), y)
498+ $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
499+else
500+ $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
501+endif
502+ $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
503+endif
504+endif
505+
506 ifdef CONFIG_READABLE_ASM
507 # Disable optimizations that make assembler listings hard to read.
508 # reorder blocks reorders the control in the function
509@@ -714,7 +784,7 @@ KBUILD_CFLAGS += $(call cc-option, -gsplit-dwarf, -g)
510 else
511 KBUILD_CFLAGS += -g
512 endif
513-KBUILD_AFLAGS += -Wa,-gdwarf-2
514+KBUILD_AFLAGS += -Wa,--gdwarf-2
515 endif
516 ifdef CONFIG_DEBUG_INFO_DWARF4
517 KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,)
518@@ -886,7 +956,7 @@ export mod_sign_cmd
519
520
521 ifeq ($(KBUILD_EXTMOD),)
522-core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
523+core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
524
525 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
526 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
527@@ -936,6 +1006,8 @@ endif
528
529 # The actual objects are generated when descending,
530 # make sure no implicit rule kicks in
531+$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
532+$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
533 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
534
535 # Handle descending into subdirectories listed in $(vmlinux-dirs)
536@@ -945,7 +1017,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
537 # Error messages still appears in the original language
538
539 PHONY += $(vmlinux-dirs)
540-$(vmlinux-dirs): prepare scripts
541+$(vmlinux-dirs): gcc-plugins prepare scripts
542 $(Q)$(MAKE) $(build)=$@
543
544 define filechk_kernel.release
545@@ -988,10 +1060,13 @@ prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
546
547 archprepare: archheaders archscripts prepare1 scripts_basic
548
549+prepare0: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
550+prepare0: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
551 prepare0: archprepare FORCE
552 $(Q)$(MAKE) $(build)=.
553
554 # All the preparing..
555+prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
556 prepare: prepare0
557
558 # Generate some files
559@@ -1099,6 +1174,8 @@ all: modules
560 # using awk while concatenating to the final file.
561
562 PHONY += modules
563+modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
564+modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
565 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
566 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
567 @$(kecho) ' Building modules, stage 2.';
568@@ -1114,7 +1191,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
569
570 # Target to prepare building external modules
571 PHONY += modules_prepare
572-modules_prepare: prepare scripts
573+modules_prepare: gcc-plugins prepare scripts
574
575 # Target to install modules
576 PHONY += modules_install
577@@ -1180,7 +1257,10 @@ MRPROPER_FILES += .config .config.old .version .old_version \
578 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
579 signing_key.priv signing_key.x509 x509.genkey \
580 extra_certificates signing_key.x509.keyid \
581- signing_key.x509.signer vmlinux-gdb.py
582+ signing_key.x509.signer vmlinux-gdb.py \
583+ tools/gcc/size_overflow_plugin/size_overflow_hash_aux.h \
584+ tools/gcc/size_overflow_plugin/size_overflow_hash.h \
585+ tools/gcc/randomize_layout_seed.h
586
587 # clean - Delete most, but leave enough to build external modules
588 #
589@@ -1219,7 +1299,7 @@ distclean: mrproper
590 @find $(srctree) $(RCS_FIND_IGNORE) \
591 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
592 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
593- -o -name '.*.rej' -o -name '*%' -o -name 'core' \) \
594+ -o -name '.*.rej' -o -name '*.so' -o -name '*%' -o -name 'core' \) \
595 -type f -print | xargs rm -f
596
597
598@@ -1385,6 +1465,8 @@ PHONY += $(module-dirs) modules
599 $(module-dirs): crmodverdir $(objtree)/Module.symvers
600 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
601
602+modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
603+modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
604 modules: $(module-dirs)
605 @$(kecho) ' Building modules, stage 2.';
606 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
607@@ -1525,17 +1607,21 @@ else
608 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
609 endif
610
611-%.s: %.c prepare scripts FORCE
612+%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
613+%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
614+%.s: %.c gcc-plugins prepare scripts FORCE
615 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
616 %.i: %.c prepare scripts FORCE
617 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
618-%.o: %.c prepare scripts FORCE
619+%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
620+%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
621+%.o: %.c gcc-plugins prepare scripts FORCE
622 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
623 %.lst: %.c prepare scripts FORCE
624 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
625-%.s: %.S prepare scripts FORCE
626+%.s: %.S gcc-plugins prepare scripts FORCE
627 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
628-%.o: %.S prepare scripts FORCE
629+%.o: %.S gcc-plugins prepare scripts FORCE
630 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
631 %.symtypes: %.c prepare scripts FORCE
632 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
633@@ -1547,11 +1633,15 @@ endif
634 $(build)=$(build-dir)
635 # Make sure the latest headers are built for Documentation
636 Documentation/: headers_install
637-%/: prepare scripts FORCE
638+%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
639+%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
640+%/: gcc-plugins prepare scripts FORCE
641 $(cmd_crmodverdir)
642 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
643 $(build)=$(build-dir)
644-%.ko: prepare scripts FORCE
645+%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
646+%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
647+%.ko: gcc-plugins prepare scripts FORCE
648 $(cmd_crmodverdir)
649 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
650 $(build)=$(build-dir) $(@:.ko=.o)
651diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
652index 8f8eafb..3405f46 100644
653--- a/arch/alpha/include/asm/atomic.h
654+++ b/arch/alpha/include/asm/atomic.h
655@@ -239,4 +239,14 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
656 #define atomic_dec(v) atomic_sub(1,(v))
657 #define atomic64_dec(v) atomic64_sub(1,(v))
658
659+#define atomic64_read_unchecked(v) atomic64_read(v)
660+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
661+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
662+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
663+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
664+#define atomic64_inc_unchecked(v) atomic64_inc(v)
665+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
666+#define atomic64_dec_unchecked(v) atomic64_dec(v)
667+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
668+
669 #endif /* _ALPHA_ATOMIC_H */
670diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
671index ad368a9..fbe0f25 100644
672--- a/arch/alpha/include/asm/cache.h
673+++ b/arch/alpha/include/asm/cache.h
674@@ -4,19 +4,19 @@
675 #ifndef __ARCH_ALPHA_CACHE_H
676 #define __ARCH_ALPHA_CACHE_H
677
678+#include <linux/const.h>
679
680 /* Bytes per L1 (data) cache line. */
681 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
682-# define L1_CACHE_BYTES 64
683 # define L1_CACHE_SHIFT 6
684 #else
685 /* Both EV4 and EV5 are write-through, read-allocate,
686 direct-mapped, physical.
687 */
688-# define L1_CACHE_BYTES 32
689 # define L1_CACHE_SHIFT 5
690 #endif
691
692+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
693 #define SMP_CACHE_BYTES L1_CACHE_BYTES
694
695 #endif
696diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
697index 968d999..d36b2df 100644
698--- a/arch/alpha/include/asm/elf.h
699+++ b/arch/alpha/include/asm/elf.h
700@@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
701
702 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
703
704+#ifdef CONFIG_PAX_ASLR
705+#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
706+
707+#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
708+#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
709+#endif
710+
711 /* $0 is set by ld.so to a pointer to a function which might be
712 registered using atexit. This provides a mean for the dynamic
713 linker to call DT_FINI functions for shared libraries that have
714diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
715index aab14a0..b4fa3e7 100644
716--- a/arch/alpha/include/asm/pgalloc.h
717+++ b/arch/alpha/include/asm/pgalloc.h
718@@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
719 pgd_set(pgd, pmd);
720 }
721
722+static inline void
723+pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
724+{
725+ pgd_populate(mm, pgd, pmd);
726+}
727+
728 extern pgd_t *pgd_alloc(struct mm_struct *mm);
729
730 static inline void
731diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
732index a9a1195..e9b8417 100644
733--- a/arch/alpha/include/asm/pgtable.h
734+++ b/arch/alpha/include/asm/pgtable.h
735@@ -101,6 +101,17 @@ struct vm_area_struct;
736 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
737 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
738 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
739+
740+#ifdef CONFIG_PAX_PAGEEXEC
741+# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
742+# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
743+# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
744+#else
745+# define PAGE_SHARED_NOEXEC PAGE_SHARED
746+# define PAGE_COPY_NOEXEC PAGE_COPY
747+# define PAGE_READONLY_NOEXEC PAGE_READONLY
748+#endif
749+
750 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
751
752 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
753diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
754index 2fd00b7..cfd5069 100644
755--- a/arch/alpha/kernel/module.c
756+++ b/arch/alpha/kernel/module.c
757@@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
758
759 /* The small sections were sorted to the end of the segment.
760 The following should definitely cover them. */
761- gp = (u64)me->module_core + me->core_size - 0x8000;
762+ gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
763 got = sechdrs[me->arch.gotsecindex].sh_addr;
764
765 for (i = 0; i < n; i++) {
766diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
767index 36dc91a..6769cb0 100644
768--- a/arch/alpha/kernel/osf_sys.c
769+++ b/arch/alpha/kernel/osf_sys.c
770@@ -1295,10 +1295,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
771 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
772
773 static unsigned long
774-arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
775- unsigned long limit)
776+arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
777+ unsigned long limit, unsigned long flags)
778 {
779 struct vm_unmapped_area_info info;
780+ unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
781
782 info.flags = 0;
783 info.length = len;
784@@ -1306,6 +1307,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
785 info.high_limit = limit;
786 info.align_mask = 0;
787 info.align_offset = 0;
788+ info.threadstack_offset = offset;
789 return vm_unmapped_area(&info);
790 }
791
792@@ -1338,20 +1340,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
793 merely specific addresses, but regions of memory -- perhaps
794 this feature should be incorporated into all ports? */
795
796+#ifdef CONFIG_PAX_RANDMMAP
797+ if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
798+#endif
799+
800 if (addr) {
801- addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
802+ addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
803 if (addr != (unsigned long) -ENOMEM)
804 return addr;
805 }
806
807 /* Next, try allocating at TASK_UNMAPPED_BASE. */
808- addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
809- len, limit);
810+ addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
811+
812 if (addr != (unsigned long) -ENOMEM)
813 return addr;
814
815 /* Finally, try allocating in low memory. */
816- addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
817+ addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
818
819 return addr;
820 }
821diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
822index 4a905bd..0a4da53 100644
823--- a/arch/alpha/mm/fault.c
824+++ b/arch/alpha/mm/fault.c
825@@ -52,6 +52,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
826 __reload_thread(pcb);
827 }
828
829+#ifdef CONFIG_PAX_PAGEEXEC
830+/*
831+ * PaX: decide what to do with offenders (regs->pc = fault address)
832+ *
833+ * returns 1 when task should be killed
834+ * 2 when patched PLT trampoline was detected
835+ * 3 when unpatched PLT trampoline was detected
836+ */
837+static int pax_handle_fetch_fault(struct pt_regs *regs)
838+{
839+
840+#ifdef CONFIG_PAX_EMUPLT
841+ int err;
842+
843+ do { /* PaX: patched PLT emulation #1 */
844+ unsigned int ldah, ldq, jmp;
845+
846+ err = get_user(ldah, (unsigned int *)regs->pc);
847+ err |= get_user(ldq, (unsigned int *)(regs->pc+4));
848+ err |= get_user(jmp, (unsigned int *)(regs->pc+8));
849+
850+ if (err)
851+ break;
852+
853+ if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
854+ (ldq & 0xFFFF0000U) == 0xA77B0000U &&
855+ jmp == 0x6BFB0000U)
856+ {
857+ unsigned long r27, addr;
858+ unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
859+ unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
860+
861+ addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
862+ err = get_user(r27, (unsigned long *)addr);
863+ if (err)
864+ break;
865+
866+ regs->r27 = r27;
867+ regs->pc = r27;
868+ return 2;
869+ }
870+ } while (0);
871+
872+ do { /* PaX: patched PLT emulation #2 */
873+ unsigned int ldah, lda, br;
874+
875+ err = get_user(ldah, (unsigned int *)regs->pc);
876+ err |= get_user(lda, (unsigned int *)(regs->pc+4));
877+ err |= get_user(br, (unsigned int *)(regs->pc+8));
878+
879+ if (err)
880+ break;
881+
882+ if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
883+ (lda & 0xFFFF0000U) == 0xA77B0000U &&
884+ (br & 0xFFE00000U) == 0xC3E00000U)
885+ {
886+ unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
887+ unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
888+ unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
889+
890+ regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
891+ regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
892+ return 2;
893+ }
894+ } while (0);
895+
896+ do { /* PaX: unpatched PLT emulation */
897+ unsigned int br;
898+
899+ err = get_user(br, (unsigned int *)regs->pc);
900+
901+ if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
902+ unsigned int br2, ldq, nop, jmp;
903+ unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
904+
905+ addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
906+ err = get_user(br2, (unsigned int *)addr);
907+ err |= get_user(ldq, (unsigned int *)(addr+4));
908+ err |= get_user(nop, (unsigned int *)(addr+8));
909+ err |= get_user(jmp, (unsigned int *)(addr+12));
910+ err |= get_user(resolver, (unsigned long *)(addr+16));
911+
912+ if (err)
913+ break;
914+
915+ if (br2 == 0xC3600000U &&
916+ ldq == 0xA77B000CU &&
917+ nop == 0x47FF041FU &&
918+ jmp == 0x6B7B0000U)
919+ {
920+ regs->r28 = regs->pc+4;
921+ regs->r27 = addr+16;
922+ regs->pc = resolver;
923+ return 3;
924+ }
925+ }
926+ } while (0);
927+#endif
928+
929+ return 1;
930+}
931+
932+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
933+{
934+ unsigned long i;
935+
936+ printk(KERN_ERR "PAX: bytes at PC: ");
937+ for (i = 0; i < 5; i++) {
938+ unsigned int c;
939+ if (get_user(c, (unsigned int *)pc+i))
940+ printk(KERN_CONT "???????? ");
941+ else
942+ printk(KERN_CONT "%08x ", c);
943+ }
944+ printk("\n");
945+}
946+#endif
947
948 /*
949 * This routine handles page faults. It determines the address,
950@@ -132,8 +250,29 @@ retry:
951 good_area:
952 si_code = SEGV_ACCERR;
953 if (cause < 0) {
954- if (!(vma->vm_flags & VM_EXEC))
955+ if (!(vma->vm_flags & VM_EXEC)) {
956+
957+#ifdef CONFIG_PAX_PAGEEXEC
958+ if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
959+ goto bad_area;
960+
961+ up_read(&mm->mmap_sem);
962+ switch (pax_handle_fetch_fault(regs)) {
963+
964+#ifdef CONFIG_PAX_EMUPLT
965+ case 2:
966+ case 3:
967+ return;
968+#endif
969+
970+ }
971+ pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
972+ do_group_exit(SIGKILL);
973+#else
974 goto bad_area;
975+#endif
976+
977+ }
978 } else if (!cause) {
979 /* Allow reads even for write-only mappings */
980 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
981diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
982index bd4670d..920c97a 100644
983--- a/arch/arc/Kconfig
984+++ b/arch/arc/Kconfig
985@@ -485,6 +485,7 @@ config ARC_DBG_TLB_MISS_COUNT
986 bool "Profile TLB Misses"
987 default n
988 select DEBUG_FS
989+ depends on !GRKERNSEC_KMEM
990 help
991 Counts number of I and D TLB Misses and exports them via Debugfs
992 The counters can be cleared via Debugfs as well
993diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
994index ede2526..9e12300 100644
995--- a/arch/arm/Kconfig
996+++ b/arch/arm/Kconfig
997@@ -1770,7 +1770,7 @@ config ALIGNMENT_TRAP
998
999 config UACCESS_WITH_MEMCPY
1000 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
1001- depends on MMU
1002+ depends on MMU && !PAX_MEMORY_UDEREF
1003 default y if CPU_FEROCEON
1004 help
1005 Implement faster copy_to_user and clear_user methods for CPU
1006@@ -2006,6 +2006,7 @@ config KEXEC
1007 bool "Kexec system call (EXPERIMENTAL)"
1008 depends on (!SMP || PM_SLEEP_SMP)
1009 depends on !CPU_V7M
1010+ depends on !GRKERNSEC_KMEM
1011 help
1012 kexec is a system call that implements the ability to shutdown your
1013 current kernel, and to start another kernel. It is like a reboot
1014diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
1015index a2e16f9..b26e911 100644
1016--- a/arch/arm/Kconfig.debug
1017+++ b/arch/arm/Kconfig.debug
1018@@ -7,6 +7,7 @@ config ARM_PTDUMP
1019 depends on DEBUG_KERNEL
1020 depends on MMU
1021 select DEBUG_FS
1022+ depends on !GRKERNSEC_KMEM
1023 ---help---
1024 Say Y here if you want to show the kernel pagetable layout in a
1025 debugfs file. This information is only useful for kernel developers
1026diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
1027index e22c119..abe7041 100644
1028--- a/arch/arm/include/asm/atomic.h
1029+++ b/arch/arm/include/asm/atomic.h
1030@@ -18,17 +18,41 @@
1031 #include <asm/barrier.h>
1032 #include <asm/cmpxchg.h>
1033
1034+#ifdef CONFIG_GENERIC_ATOMIC64
1035+#include <asm-generic/atomic64.h>
1036+#endif
1037+
1038 #define ATOMIC_INIT(i) { (i) }
1039
1040 #ifdef __KERNEL__
1041
1042+#ifdef CONFIG_THUMB2_KERNEL
1043+#define REFCOUNT_TRAP_INSN "bkpt 0xf1"
1044+#else
1045+#define REFCOUNT_TRAP_INSN "bkpt 0xf103"
1046+#endif
1047+
1048+#define _ASM_EXTABLE(from, to) \
1049+" .pushsection __ex_table,\"a\"\n"\
1050+" .align 3\n" \
1051+" .long " #from ", " #to"\n" \
1052+" .popsection"
1053+
1054 /*
1055 * On ARM, ordinary assignment (str instruction) doesn't clear the local
1056 * strex/ldrex monitor on some implementations. The reason we can use it for
1057 * atomic_set() is the clrex or dummy strex done on every exception return.
1058 */
1059 #define atomic_read(v) ACCESS_ONCE((v)->counter)
1060+static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
1061+{
1062+ return ACCESS_ONCE(v->counter);
1063+}
1064 #define atomic_set(v,i) (((v)->counter) = (i))
1065+static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
1066+{
1067+ v->counter = i;
1068+}
1069
1070 #if __LINUX_ARM_ARCH__ >= 6
1071
1072@@ -38,26 +62,50 @@
1073 * to ensure that the update happens.
1074 */
1075
1076-#define ATOMIC_OP(op, c_op, asm_op) \
1077-static inline void atomic_##op(int i, atomic_t *v) \
1078+#ifdef CONFIG_PAX_REFCOUNT
1079+#define __OVERFLOW_POST \
1080+ " bvc 3f\n" \
1081+ "2: " REFCOUNT_TRAP_INSN "\n"\
1082+ "3:\n"
1083+#define __OVERFLOW_POST_RETURN \
1084+ " bvc 3f\n" \
1085+" mov %0, %1\n" \
1086+ "2: " REFCOUNT_TRAP_INSN "\n"\
1087+ "3:\n"
1088+#define __OVERFLOW_EXTABLE \
1089+ "4:\n" \
1090+ _ASM_EXTABLE(2b, 4b)
1091+#else
1092+#define __OVERFLOW_POST
1093+#define __OVERFLOW_POST_RETURN
1094+#define __OVERFLOW_EXTABLE
1095+#endif
1096+
1097+#define __ATOMIC_OP(op, suffix, c_op, asm_op, post_op, extable) \
1098+static inline void atomic_##op##suffix(int i, atomic##suffix##_t *v) \
1099 { \
1100 unsigned long tmp; \
1101 int result; \
1102 \
1103 prefetchw(&v->counter); \
1104- __asm__ __volatile__("@ atomic_" #op "\n" \
1105+ __asm__ __volatile__("@ atomic_" #op #suffix "\n" \
1106 "1: ldrex %0, [%3]\n" \
1107 " " #asm_op " %0, %0, %4\n" \
1108+ post_op \
1109 " strex %1, %0, [%3]\n" \
1110 " teq %1, #0\n" \
1111-" bne 1b" \
1112+" bne 1b\n" \
1113+ extable \
1114 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter) \
1115 : "r" (&v->counter), "Ir" (i) \
1116 : "cc"); \
1117 } \
1118
1119-#define ATOMIC_OP_RETURN(op, c_op, asm_op) \
1120-static inline int atomic_##op##_return(int i, atomic_t *v) \
1121+#define ATOMIC_OP(op, c_op, asm_op) __ATOMIC_OP(op, _unchecked, c_op, asm_op, , )\
1122+ __ATOMIC_OP(op, , c_op, asm_op##s, __OVERFLOW_POST, __OVERFLOW_EXTABLE)
1123+
1124+#define __ATOMIC_OP_RETURN(op, suffix, c_op, asm_op, post_op, extable) \
1125+static inline int atomic_##op##_return##suffix(int i, atomic##suffix##_t *v)\
1126 { \
1127 unsigned long tmp; \
1128 int result; \
1129@@ -65,12 +113,14 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \
1130 smp_mb(); \
1131 prefetchw(&v->counter); \
1132 \
1133- __asm__ __volatile__("@ atomic_" #op "_return\n" \
1134+ __asm__ __volatile__("@ atomic_" #op "_return" #suffix "\n" \
1135 "1: ldrex %0, [%3]\n" \
1136 " " #asm_op " %0, %0, %4\n" \
1137+ post_op \
1138 " strex %1, %0, [%3]\n" \
1139 " teq %1, #0\n" \
1140-" bne 1b" \
1141+" bne 1b\n" \
1142+ extable \
1143 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter) \
1144 : "r" (&v->counter), "Ir" (i) \
1145 : "cc"); \
1146@@ -80,6 +130,9 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \
1147 return result; \
1148 }
1149
1150+#define ATOMIC_OP_RETURN(op, c_op, asm_op) __ATOMIC_OP_RETURN(op, _unchecked, c_op, asm_op, , )\
1151+ __ATOMIC_OP_RETURN(op, , c_op, asm_op##s, __OVERFLOW_POST_RETURN, __OVERFLOW_EXTABLE)
1152+
1153 static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1154 {
1155 int oldval;
1156@@ -115,12 +168,24 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1157 __asm__ __volatile__ ("@ atomic_add_unless\n"
1158 "1: ldrex %0, [%4]\n"
1159 " teq %0, %5\n"
1160-" beq 2f\n"
1161-" add %1, %0, %6\n"
1162+" beq 4f\n"
1163+" adds %1, %0, %6\n"
1164+
1165+#ifdef CONFIG_PAX_REFCOUNT
1166+" bvc 3f\n"
1167+"2: " REFCOUNT_TRAP_INSN "\n"
1168+"3:\n"
1169+#endif
1170+
1171 " strex %2, %1, [%4]\n"
1172 " teq %2, #0\n"
1173 " bne 1b\n"
1174-"2:"
1175+"4:"
1176+
1177+#ifdef CONFIG_PAX_REFCOUNT
1178+ _ASM_EXTABLE(2b, 4b)
1179+#endif
1180+
1181 : "=&r" (oldval), "=&r" (newval), "=&r" (tmp), "+Qo" (v->counter)
1182 : "r" (&v->counter), "r" (u), "r" (a)
1183 : "cc");
1184@@ -131,14 +196,36 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1185 return oldval;
1186 }
1187
1188+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1189+{
1190+ unsigned long oldval, res;
1191+
1192+ smp_mb();
1193+
1194+ do {
1195+ __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1196+ "ldrex %1, [%3]\n"
1197+ "mov %0, #0\n"
1198+ "teq %1, %4\n"
1199+ "strexeq %0, %5, [%3]\n"
1200+ : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1201+ : "r" (&ptr->counter), "Ir" (old), "r" (new)
1202+ : "cc");
1203+ } while (res);
1204+
1205+ smp_mb();
1206+
1207+ return oldval;
1208+}
1209+
1210 #else /* ARM_ARCH_6 */
1211
1212 #ifdef CONFIG_SMP
1213 #error SMP not supported on pre-ARMv6 CPUs
1214 #endif
1215
1216-#define ATOMIC_OP(op, c_op, asm_op) \
1217-static inline void atomic_##op(int i, atomic_t *v) \
1218+#define __ATOMIC_OP(op, suffix, c_op, asm_op) \
1219+static inline void atomic_##op##suffix(int i, atomic##suffix##_t *v) \
1220 { \
1221 unsigned long flags; \
1222 \
1223@@ -147,8 +234,11 @@ static inline void atomic_##op(int i, atomic_t *v) \
1224 raw_local_irq_restore(flags); \
1225 } \
1226
1227-#define ATOMIC_OP_RETURN(op, c_op, asm_op) \
1228-static inline int atomic_##op##_return(int i, atomic_t *v) \
1229+#define ATOMIC_OP(op, c_op, asm_op) __ATOMIC_OP(op, , c_op, asm_op) \
1230+ __ATOMIC_OP(op, _unchecked, c_op, asm_op)
1231+
1232+#define __ATOMIC_OP_RETURN(op, suffix, c_op, asm_op) \
1233+static inline int atomic_##op##_return##suffix(int i, atomic##suffix##_t *v)\
1234 { \
1235 unsigned long flags; \
1236 int val; \
1237@@ -161,6 +251,9 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \
1238 return val; \
1239 }
1240
1241+#define ATOMIC_OP_RETURN(op, c_op, asm_op) __ATOMIC_OP_RETURN(op, , c_op, asm_op)\
1242+ __ATOMIC_OP_RETURN(op, _unchecked, c_op, asm_op)
1243+
1244 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1245 {
1246 int ret;
1247@@ -175,6 +268,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1248 return ret;
1249 }
1250
1251+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1252+{
1253+ return atomic_cmpxchg((atomic_t *)v, old, new);
1254+}
1255+
1256 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1257 {
1258 int c, old;
1259@@ -196,16 +294,38 @@ ATOMIC_OPS(sub, -=, sub)
1260
1261 #undef ATOMIC_OPS
1262 #undef ATOMIC_OP_RETURN
1263+#undef __ATOMIC_OP_RETURN
1264 #undef ATOMIC_OP
1265+#undef __ATOMIC_OP
1266
1267 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1268+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1269+{
1270+ return xchg(&v->counter, new);
1271+}
1272
1273 #define atomic_inc(v) atomic_add(1, v)
1274+static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1275+{
1276+ atomic_add_unchecked(1, v);
1277+}
1278 #define atomic_dec(v) atomic_sub(1, v)
1279+static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1280+{
1281+ atomic_sub_unchecked(1, v);
1282+}
1283
1284 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1285+static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1286+{
1287+ return atomic_add_return_unchecked(1, v) == 0;
1288+}
1289 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1290 #define atomic_inc_return(v) (atomic_add_return(1, v))
1291+static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1292+{
1293+ return atomic_add_return_unchecked(1, v);
1294+}
1295 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1296 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1297
1298@@ -216,6 +336,14 @@ typedef struct {
1299 long long counter;
1300 } atomic64_t;
1301
1302+#ifdef CONFIG_PAX_REFCOUNT
1303+typedef struct {
1304+ long long counter;
1305+} atomic64_unchecked_t;
1306+#else
1307+typedef atomic64_t atomic64_unchecked_t;
1308+#endif
1309+
1310 #define ATOMIC64_INIT(i) { (i) }
1311
1312 #ifdef CONFIG_ARM_LPAE
1313@@ -232,6 +360,19 @@ static inline long long atomic64_read(const atomic64_t *v)
1314 return result;
1315 }
1316
1317+static inline long long atomic64_read_unchecked(const atomic64_unchecked_t *v)
1318+{
1319+ long long result;
1320+
1321+ __asm__ __volatile__("@ atomic64_read_unchecked\n"
1322+" ldrd %0, %H0, [%1]"
1323+ : "=&r" (result)
1324+ : "r" (&v->counter), "Qo" (v->counter)
1325+ );
1326+
1327+ return result;
1328+}
1329+
1330 static inline void atomic64_set(atomic64_t *v, long long i)
1331 {
1332 __asm__ __volatile__("@ atomic64_set\n"
1333@@ -240,6 +381,15 @@ static inline void atomic64_set(atomic64_t *v, long long i)
1334 : "r" (&v->counter), "r" (i)
1335 );
1336 }
1337+
1338+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
1339+{
1340+ __asm__ __volatile__("@ atomic64_set_unchecked\n"
1341+" strd %2, %H2, [%1]"
1342+ : "=Qo" (v->counter)
1343+ : "r" (&v->counter), "r" (i)
1344+ );
1345+}
1346 #else
1347 static inline long long atomic64_read(const atomic64_t *v)
1348 {
1349@@ -254,6 +404,19 @@ static inline long long atomic64_read(const atomic64_t *v)
1350 return result;
1351 }
1352
1353+static inline long long atomic64_read_unchecked(const atomic64_unchecked_t *v)
1354+{
1355+ long long result;
1356+
1357+ __asm__ __volatile__("@ atomic64_read_unchecked\n"
1358+" ldrexd %0, %H0, [%1]"
1359+ : "=&r" (result)
1360+ : "r" (&v->counter), "Qo" (v->counter)
1361+ );
1362+
1363+ return result;
1364+}
1365+
1366 static inline void atomic64_set(atomic64_t *v, long long i)
1367 {
1368 long long tmp;
1369@@ -268,29 +431,57 @@ static inline void atomic64_set(atomic64_t *v, long long i)
1370 : "r" (&v->counter), "r" (i)
1371 : "cc");
1372 }
1373+
1374+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
1375+{
1376+ long long tmp;
1377+
1378+ prefetchw(&v->counter);
1379+ __asm__ __volatile__("@ atomic64_set_unchecked\n"
1380+"1: ldrexd %0, %H0, [%2]\n"
1381+" strexd %0, %3, %H3, [%2]\n"
1382+" teq %0, #0\n"
1383+" bne 1b"
1384+ : "=&r" (tmp), "=Qo" (v->counter)
1385+ : "r" (&v->counter), "r" (i)
1386+ : "cc");
1387+}
1388 #endif
1389
1390-#define ATOMIC64_OP(op, op1, op2) \
1391-static inline void atomic64_##op(long long i, atomic64_t *v) \
1392+#undef __OVERFLOW_POST_RETURN
1393+#define __OVERFLOW_POST_RETURN \
1394+ " bvc 3f\n" \
1395+" mov %0, %1\n" \
1396+" mov %H0, %H1\n" \
1397+ "2: " REFCOUNT_TRAP_INSN "\n"\
1398+ "3:\n"
1399+
1400+#define __ATOMIC64_OP(op, suffix, op1, op2, post_op, extable) \
1401+static inline void atomic64_##op##suffix(long long i, atomic64##suffix##_t *v)\
1402 { \
1403 long long result; \
1404 unsigned long tmp; \
1405 \
1406 prefetchw(&v->counter); \
1407- __asm__ __volatile__("@ atomic64_" #op "\n" \
1408+ __asm__ __volatile__("@ atomic64_" #op #suffix "\n" \
1409 "1: ldrexd %0, %H0, [%3]\n" \
1410 " " #op1 " %Q0, %Q0, %Q4\n" \
1411 " " #op2 " %R0, %R0, %R4\n" \
1412+ post_op \
1413 " strexd %1, %0, %H0, [%3]\n" \
1414 " teq %1, #0\n" \
1415-" bne 1b" \
1416+" bne 1b\n" \
1417+ extable \
1418 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter) \
1419 : "r" (&v->counter), "r" (i) \
1420 : "cc"); \
1421 } \
1422
1423-#define ATOMIC64_OP_RETURN(op, op1, op2) \
1424-static inline long long atomic64_##op##_return(long long i, atomic64_t *v) \
1425+#define ATOMIC64_OP(op, op1, op2) __ATOMIC64_OP(op, _unchecked, op1, op2, , ) \
1426+ __ATOMIC64_OP(op, , op1, op2##s, __OVERFLOW_POST, __OVERFLOW_EXTABLE)
1427+
1428+#define __ATOMIC64_OP_RETURN(op, suffix, op1, op2, post_op, extable) \
1429+static inline long long atomic64_##op##_return##suffix(long long i, atomic64##suffix##_t *v) \
1430 { \
1431 long long result; \
1432 unsigned long tmp; \
1433@@ -298,13 +489,15 @@ static inline long long atomic64_##op##_return(long long i, atomic64_t *v) \
1434 smp_mb(); \
1435 prefetchw(&v->counter); \
1436 \
1437- __asm__ __volatile__("@ atomic64_" #op "_return\n" \
1438+ __asm__ __volatile__("@ atomic64_" #op "_return" #suffix "\n" \
1439 "1: ldrexd %0, %H0, [%3]\n" \
1440 " " #op1 " %Q0, %Q0, %Q4\n" \
1441 " " #op2 " %R0, %R0, %R4\n" \
1442+ post_op \
1443 " strexd %1, %0, %H0, [%3]\n" \
1444 " teq %1, #0\n" \
1445-" bne 1b" \
1446+" bne 1b\n" \
1447+ extable \
1448 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter) \
1449 : "r" (&v->counter), "r" (i) \
1450 : "cc"); \
1451@@ -314,6 +507,9 @@ static inline long long atomic64_##op##_return(long long i, atomic64_t *v) \
1452 return result; \
1453 }
1454
1455+#define ATOMIC64_OP_RETURN(op, op1, op2) __ATOMIC64_OP_RETURN(op, _unchecked, op1, op2, , ) \
1456+ __ATOMIC64_OP_RETURN(op, , op1, op2##s, __OVERFLOW_POST_RETURN, __OVERFLOW_EXTABLE)
1457+
1458 #define ATOMIC64_OPS(op, op1, op2) \
1459 ATOMIC64_OP(op, op1, op2) \
1460 ATOMIC64_OP_RETURN(op, op1, op2)
1461@@ -323,7 +519,12 @@ ATOMIC64_OPS(sub, subs, sbc)
1462
1463 #undef ATOMIC64_OPS
1464 #undef ATOMIC64_OP_RETURN
1465+#undef __ATOMIC64_OP_RETURN
1466 #undef ATOMIC64_OP
1467+#undef __ATOMIC64_OP
1468+#undef __OVERFLOW_EXTABLE
1469+#undef __OVERFLOW_POST_RETURN
1470+#undef __OVERFLOW_POST
1471
1472 static inline long long atomic64_cmpxchg(atomic64_t *ptr, long long old,
1473 long long new)
1474@@ -351,6 +552,31 @@ static inline long long atomic64_cmpxchg(atomic64_t *ptr, long long old,
1475 return oldval;
1476 }
1477
1478+static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, long long old,
1479+ long long new)
1480+{
1481+ long long oldval;
1482+ unsigned long res;
1483+
1484+ smp_mb();
1485+
1486+ do {
1487+ __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1488+ "ldrexd %1, %H1, [%3]\n"
1489+ "mov %0, #0\n"
1490+ "teq %1, %4\n"
1491+ "teqeq %H1, %H4\n"
1492+ "strexdeq %0, %5, %H5, [%3]"
1493+ : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1494+ : "r" (&ptr->counter), "r" (old), "r" (new)
1495+ : "cc");
1496+ } while (res);
1497+
1498+ smp_mb();
1499+
1500+ return oldval;
1501+}
1502+
1503 static inline long long atomic64_xchg(atomic64_t *ptr, long long new)
1504 {
1505 long long result;
1506@@ -376,21 +602,35 @@ static inline long long atomic64_xchg(atomic64_t *ptr, long long new)
1507 static inline long long atomic64_dec_if_positive(atomic64_t *v)
1508 {
1509 long long result;
1510- unsigned long tmp;
1511+ u64 tmp;
1512
1513 smp_mb();
1514 prefetchw(&v->counter);
1515
1516 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1517-"1: ldrexd %0, %H0, [%3]\n"
1518-" subs %Q0, %Q0, #1\n"
1519-" sbc %R0, %R0, #0\n"
1520+"1: ldrexd %1, %H1, [%3]\n"
1521+" subs %Q0, %Q1, #1\n"
1522+" sbcs %R0, %R1, #0\n"
1523+
1524+#ifdef CONFIG_PAX_REFCOUNT
1525+" bvc 3f\n"
1526+" mov %Q0, %Q1\n"
1527+" mov %R0, %R1\n"
1528+"2: " REFCOUNT_TRAP_INSN "\n"
1529+"3:\n"
1530+#endif
1531+
1532 " teq %R0, #0\n"
1533-" bmi 2f\n"
1534+" bmi 4f\n"
1535 " strexd %1, %0, %H0, [%3]\n"
1536 " teq %1, #0\n"
1537 " bne 1b\n"
1538-"2:"
1539+"4:\n"
1540+
1541+#ifdef CONFIG_PAX_REFCOUNT
1542+ _ASM_EXTABLE(2b, 4b)
1543+#endif
1544+
1545 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1546 : "r" (&v->counter)
1547 : "cc");
1548@@ -414,13 +654,25 @@ static inline int atomic64_add_unless(atomic64_t *v, long long a, long long u)
1549 " teq %0, %5\n"
1550 " teqeq %H0, %H5\n"
1551 " moveq %1, #0\n"
1552-" beq 2f\n"
1553+" beq 4f\n"
1554 " adds %Q0, %Q0, %Q6\n"
1555-" adc %R0, %R0, %R6\n"
1556+" adcs %R0, %R0, %R6\n"
1557+
1558+#ifdef CONFIG_PAX_REFCOUNT
1559+" bvc 3f\n"
1560+"2: " REFCOUNT_TRAP_INSN "\n"
1561+"3:\n"
1562+#endif
1563+
1564 " strexd %2, %0, %H0, [%4]\n"
1565 " teq %2, #0\n"
1566 " bne 1b\n"
1567-"2:"
1568+"4:\n"
1569+
1570+#ifdef CONFIG_PAX_REFCOUNT
1571+ _ASM_EXTABLE(2b, 4b)
1572+#endif
1573+
1574 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1575 : "r" (&v->counter), "r" (u), "r" (a)
1576 : "cc");
1577@@ -433,10 +685,13 @@ static inline int atomic64_add_unless(atomic64_t *v, long long a, long long u)
1578
1579 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1580 #define atomic64_inc(v) atomic64_add(1LL, (v))
1581+#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1582 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1583+#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1584 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1585 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1586 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1587+#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1588 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1589 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1590 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1591diff --git a/arch/arm/include/asm/barrier.h b/arch/arm/include/asm/barrier.h
1592index 6c2327e..85beac4 100644
1593--- a/arch/arm/include/asm/barrier.h
1594+++ b/arch/arm/include/asm/barrier.h
1595@@ -67,7 +67,7 @@
1596 do { \
1597 compiletime_assert_atomic_type(*p); \
1598 smp_mb(); \
1599- ACCESS_ONCE(*p) = (v); \
1600+ ACCESS_ONCE_RW(*p) = (v); \
1601 } while (0)
1602
1603 #define smp_load_acquire(p) \
1604diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1605index 75fe66b..ba3dee4 100644
1606--- a/arch/arm/include/asm/cache.h
1607+++ b/arch/arm/include/asm/cache.h
1608@@ -4,8 +4,10 @@
1609 #ifndef __ASMARM_CACHE_H
1610 #define __ASMARM_CACHE_H
1611
1612+#include <linux/const.h>
1613+
1614 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1615-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1616+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1617
1618 /*
1619 * Memory returned by kmalloc() may be used for DMA, so we must make
1620@@ -24,5 +26,6 @@
1621 #endif
1622
1623 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1624+#define __read_only __attribute__ ((__section__(".data..read_only")))
1625
1626 #endif
1627diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1628index 4812cda..9da8116 100644
1629--- a/arch/arm/include/asm/cacheflush.h
1630+++ b/arch/arm/include/asm/cacheflush.h
1631@@ -116,7 +116,7 @@ struct cpu_cache_fns {
1632 void (*dma_unmap_area)(const void *, size_t, int);
1633
1634 void (*dma_flush_range)(const void *, const void *);
1635-};
1636+} __no_const;
1637
1638 /*
1639 * Select the calling method
1640diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1641index 5233151..87a71fa 100644
1642--- a/arch/arm/include/asm/checksum.h
1643+++ b/arch/arm/include/asm/checksum.h
1644@@ -37,7 +37,19 @@ __wsum
1645 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1646
1647 __wsum
1648-csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1649+__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1650+
1651+static inline __wsum
1652+csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1653+{
1654+ __wsum ret;
1655+ pax_open_userland();
1656+ ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1657+ pax_close_userland();
1658+ return ret;
1659+}
1660+
1661+
1662
1663 /*
1664 * Fold a partial checksum without adding pseudo headers
1665diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1666index 1692a05..1835802 100644
1667--- a/arch/arm/include/asm/cmpxchg.h
1668+++ b/arch/arm/include/asm/cmpxchg.h
1669@@ -107,6 +107,10 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1670 (__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), \
1671 sizeof(*(ptr))); \
1672 })
1673+#define xchg_unchecked(ptr, x) ({ \
1674+ (__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), \
1675+ sizeof(*(ptr))); \
1676+})
1677
1678 #include <asm-generic/cmpxchg-local.h>
1679
1680diff --git a/arch/arm/include/asm/cpuidle.h b/arch/arm/include/asm/cpuidle.h
1681index 0f84249..8e83c55 100644
1682--- a/arch/arm/include/asm/cpuidle.h
1683+++ b/arch/arm/include/asm/cpuidle.h
1684@@ -32,7 +32,7 @@ struct device_node;
1685 struct cpuidle_ops {
1686 int (*suspend)(int cpu, unsigned long arg);
1687 int (*init)(struct device_node *, int cpu);
1688-};
1689+} __no_const;
1690
1691 struct of_cpuidle_method {
1692 const char *method;
1693diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1694index 6ddbe44..b5e38b1a 100644
1695--- a/arch/arm/include/asm/domain.h
1696+++ b/arch/arm/include/asm/domain.h
1697@@ -48,18 +48,37 @@
1698 * Domain types
1699 */
1700 #define DOMAIN_NOACCESS 0
1701-#define DOMAIN_CLIENT 1
1702 #ifdef CONFIG_CPU_USE_DOMAINS
1703+#define DOMAIN_USERCLIENT 1
1704+#define DOMAIN_KERNELCLIENT 1
1705 #define DOMAIN_MANAGER 3
1706+#define DOMAIN_VECTORS DOMAIN_USER
1707 #else
1708+
1709+#ifdef CONFIG_PAX_KERNEXEC
1710 #define DOMAIN_MANAGER 1
1711+#define DOMAIN_KERNEXEC 3
1712+#else
1713+#define DOMAIN_MANAGER 1
1714+#endif
1715+
1716+#ifdef CONFIG_PAX_MEMORY_UDEREF
1717+#define DOMAIN_USERCLIENT 0
1718+#define DOMAIN_UDEREF 1
1719+#define DOMAIN_VECTORS DOMAIN_KERNEL
1720+#else
1721+#define DOMAIN_USERCLIENT 1
1722+#define DOMAIN_VECTORS DOMAIN_USER
1723+#endif
1724+#define DOMAIN_KERNELCLIENT 1
1725+
1726 #endif
1727
1728 #define domain_val(dom,type) ((type) << (2*(dom)))
1729
1730 #ifndef __ASSEMBLY__
1731
1732-#ifdef CONFIG_CPU_USE_DOMAINS
1733+#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1734 static inline void set_domain(unsigned val)
1735 {
1736 asm volatile(
1737@@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1738 isb();
1739 }
1740
1741-#define modify_domain(dom,type) \
1742- do { \
1743- struct thread_info *thread = current_thread_info(); \
1744- unsigned int domain = thread->cpu_domain; \
1745- domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1746- thread->cpu_domain = domain | domain_val(dom, type); \
1747- set_domain(thread->cpu_domain); \
1748- } while (0)
1749-
1750+extern void modify_domain(unsigned int dom, unsigned int type);
1751 #else
1752 static inline void set_domain(unsigned val) { }
1753 static inline void modify_domain(unsigned dom, unsigned type) { }
1754diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1755index d2315ff..f60b47b 100644
1756--- a/arch/arm/include/asm/elf.h
1757+++ b/arch/arm/include/asm/elf.h
1758@@ -117,7 +117,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1759 the loader. We need to make sure that it is out of the way of the program
1760 that it will "exec", and that there is sufficient room for the brk. */
1761
1762-#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1763+#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1764+
1765+#ifdef CONFIG_PAX_ASLR
1766+#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1767+
1768+#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1769+#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1770+#endif
1771
1772 /* When the program starts, a1 contains a pointer to a function to be
1773 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1774diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1775index de53547..52b9a28 100644
1776--- a/arch/arm/include/asm/fncpy.h
1777+++ b/arch/arm/include/asm/fncpy.h
1778@@ -81,7 +81,9 @@
1779 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1780 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1781 \
1782+ pax_open_kernel(); \
1783 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1784+ pax_close_kernel(); \
1785 flush_icache_range((unsigned long)(dest_buf), \
1786 (unsigned long)(dest_buf) + (size)); \
1787 \
1788diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1789index 5eed828..365e018 100644
1790--- a/arch/arm/include/asm/futex.h
1791+++ b/arch/arm/include/asm/futex.h
1792@@ -46,6 +46,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1793 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1794 return -EFAULT;
1795
1796+ pax_open_userland();
1797+
1798 smp_mb();
1799 /* Prefetching cannot fault */
1800 prefetchw(uaddr);
1801@@ -63,6 +65,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1802 : "cc", "memory");
1803 smp_mb();
1804
1805+ pax_close_userland();
1806+
1807 *uval = val;
1808 return ret;
1809 }
1810@@ -94,6 +98,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1811 return -EFAULT;
1812
1813 preempt_disable();
1814+ pax_open_userland();
1815+
1816 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1817 "1: " TUSER(ldr) " %1, [%4]\n"
1818 " teq %1, %2\n"
1819@@ -104,6 +110,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1820 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1821 : "cc", "memory");
1822
1823+ pax_close_userland();
1824+
1825 *uval = val;
1826 preempt_enable();
1827
1828@@ -131,6 +139,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1829 preempt_disable();
1830 #endif
1831 pagefault_disable();
1832+ pax_open_userland();
1833
1834 switch (op) {
1835 case FUTEX_OP_SET:
1836@@ -152,6 +161,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1837 ret = -ENOSYS;
1838 }
1839
1840+ pax_close_userland();
1841 pagefault_enable();
1842 #ifndef CONFIG_SMP
1843 preempt_enable();
1844diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1845index 83eb2f7..ed77159 100644
1846--- a/arch/arm/include/asm/kmap_types.h
1847+++ b/arch/arm/include/asm/kmap_types.h
1848@@ -4,6 +4,6 @@
1849 /*
1850 * This is the "bare minimum". AIO seems to require this.
1851 */
1852-#define KM_TYPE_NR 16
1853+#define KM_TYPE_NR 17
1854
1855 #endif
1856diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1857index 9e614a1..3302cca 100644
1858--- a/arch/arm/include/asm/mach/dma.h
1859+++ b/arch/arm/include/asm/mach/dma.h
1860@@ -22,7 +22,7 @@ struct dma_ops {
1861 int (*residue)(unsigned int, dma_t *); /* optional */
1862 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1863 const char *type;
1864-};
1865+} __do_const;
1866
1867 struct dma_struct {
1868 void *addr; /* single DMA address */
1869diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1870index f98c7f3..e5c626d 100644
1871--- a/arch/arm/include/asm/mach/map.h
1872+++ b/arch/arm/include/asm/mach/map.h
1873@@ -23,17 +23,19 @@ struct map_desc {
1874
1875 /* types 0-3 are defined in asm/io.h */
1876 enum {
1877- MT_UNCACHED = 4,
1878- MT_CACHECLEAN,
1879- MT_MINICLEAN,
1880+ MT_UNCACHED_RW = 4,
1881+ MT_CACHECLEAN_RO,
1882+ MT_MINICLEAN_RO,
1883 MT_LOW_VECTORS,
1884 MT_HIGH_VECTORS,
1885- MT_MEMORY_RWX,
1886+ __MT_MEMORY_RWX,
1887 MT_MEMORY_RW,
1888- MT_ROM,
1889- MT_MEMORY_RWX_NONCACHED,
1890+ MT_MEMORY_RX,
1891+ MT_ROM_RX,
1892+ MT_MEMORY_RW_NONCACHED,
1893+ MT_MEMORY_RX_NONCACHED,
1894 MT_MEMORY_RW_DTCM,
1895- MT_MEMORY_RWX_ITCM,
1896+ MT_MEMORY_RX_ITCM,
1897 MT_MEMORY_RW_SO,
1898 MT_MEMORY_DMA_READY,
1899 };
1900diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1901index 563b92f..689d58e 100644
1902--- a/arch/arm/include/asm/outercache.h
1903+++ b/arch/arm/include/asm/outercache.h
1904@@ -39,7 +39,7 @@ struct outer_cache_fns {
1905 /* This is an ARM L2C thing */
1906 void (*write_sec)(unsigned long, unsigned);
1907 void (*configure)(const struct l2x0_regs *);
1908-};
1909+} __no_const;
1910
1911 extern struct outer_cache_fns outer_cache;
1912
1913diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1914index 4355f0e..cd9168e 100644
1915--- a/arch/arm/include/asm/page.h
1916+++ b/arch/arm/include/asm/page.h
1917@@ -23,6 +23,7 @@
1918
1919 #else
1920
1921+#include <linux/compiler.h>
1922 #include <asm/glue.h>
1923
1924 /*
1925@@ -114,7 +115,7 @@ struct cpu_user_fns {
1926 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1927 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1928 unsigned long vaddr, struct vm_area_struct *vma);
1929-};
1930+} __no_const;
1931
1932 #ifdef MULTI_USER
1933 extern struct cpu_user_fns cpu_user;
1934diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1935index 19cfab5..3f5c7e9 100644
1936--- a/arch/arm/include/asm/pgalloc.h
1937+++ b/arch/arm/include/asm/pgalloc.h
1938@@ -17,6 +17,7 @@
1939 #include <asm/processor.h>
1940 #include <asm/cacheflush.h>
1941 #include <asm/tlbflush.h>
1942+#include <asm/system_info.h>
1943
1944 #define check_pgt_cache() do { } while (0)
1945
1946@@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1947 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1948 }
1949
1950+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1951+{
1952+ pud_populate(mm, pud, pmd);
1953+}
1954+
1955 #else /* !CONFIG_ARM_LPAE */
1956
1957 /*
1958@@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1959 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1960 #define pmd_free(mm, pmd) do { } while (0)
1961 #define pud_populate(mm,pmd,pte) BUG()
1962+#define pud_populate_kernel(mm,pmd,pte) BUG()
1963
1964 #endif /* CONFIG_ARM_LPAE */
1965
1966@@ -128,6 +135,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1967 __free_page(pte);
1968 }
1969
1970+static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1971+{
1972+#ifdef CONFIG_ARM_LPAE
1973+ pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1974+#else
1975+ if (addr & SECTION_SIZE)
1976+ pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1977+ else
1978+ pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1979+#endif
1980+ flush_pmd_entry(pmdp);
1981+}
1982+
1983 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1984 pmdval_t prot)
1985 {
1986diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1987index 5e68278..1869bae 100644
1988--- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1989+++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1990@@ -27,7 +27,7 @@
1991 /*
1992 * - section
1993 */
1994-#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1995+#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1996 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1997 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1998 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1999@@ -39,6 +39,7 @@
2000 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
2001 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
2002 #define PMD_SECT_AF (_AT(pmdval_t, 0))
2003+#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
2004
2005 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
2006 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
2007@@ -68,6 +69,7 @@
2008 * - extended small page/tiny page
2009 */
2010 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
2011+#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
2012 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
2013 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
2014 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
2015diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
2016index aeddd28..207745c 100644
2017--- a/arch/arm/include/asm/pgtable-2level.h
2018+++ b/arch/arm/include/asm/pgtable-2level.h
2019@@ -127,6 +127,9 @@
2020 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
2021 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
2022
2023+/* Two-level page tables only have PXN in the PGD, not in the PTE. */
2024+#define L_PTE_PXN (_AT(pteval_t, 0))
2025+
2026 /*
2027 * These are the memory types, defined to be compatible with
2028 * pre-ARMv6 CPUs cacheable and bufferable bits: n/a,n/a,C,B
2029diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
2030index a745a2a..481350a 100644
2031--- a/arch/arm/include/asm/pgtable-3level.h
2032+++ b/arch/arm/include/asm/pgtable-3level.h
2033@@ -80,6 +80,7 @@
2034 #define L_PTE_USER (_AT(pteval_t, 1) << 6) /* AP[1] */
2035 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2036 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
2037+#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2038 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
2039 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55)
2040 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56)
2041@@ -91,10 +92,12 @@
2042 #define L_PMD_SECT_SPLITTING (_AT(pmdval_t, 1) << 56)
2043 #define L_PMD_SECT_NONE (_AT(pmdval_t, 1) << 57)
2044 #define L_PMD_SECT_RDONLY (_AT(pteval_t, 1) << 58)
2045+#define PMD_SECT_RDONLY PMD_SECT_AP2
2046
2047 /*
2048 * To be used in assembly code with the upper page attributes.
2049 */
2050+#define L_PTE_PXN_HIGH (1 << (53 - 32))
2051 #define L_PTE_XN_HIGH (1 << (54 - 32))
2052 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
2053
2054diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
2055index f403541..b10df68 100644
2056--- a/arch/arm/include/asm/pgtable.h
2057+++ b/arch/arm/include/asm/pgtable.h
2058@@ -33,6 +33,9 @@
2059 #include <asm/pgtable-2level.h>
2060 #endif
2061
2062+#define ktla_ktva(addr) (addr)
2063+#define ktva_ktla(addr) (addr)
2064+
2065 /*
2066 * Just any arbitrary offset to the start of the vmalloc VM area: the
2067 * current 8MB value just means that there will be a 8MB "hole" after the
2068@@ -48,6 +51,9 @@
2069 #define LIBRARY_TEXT_START 0x0c000000
2070
2071 #ifndef __ASSEMBLY__
2072+extern pteval_t __supported_pte_mask;
2073+extern pmdval_t __supported_pmd_mask;
2074+
2075 extern void __pte_error(const char *file, int line, pte_t);
2076 extern void __pmd_error(const char *file, int line, pmd_t);
2077 extern void __pgd_error(const char *file, int line, pgd_t);
2078@@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2079 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2080 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2081
2082+#define __HAVE_ARCH_PAX_OPEN_KERNEL
2083+#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2084+
2085+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2086+#include <asm/domain.h>
2087+#include <linux/thread_info.h>
2088+#include <linux/preempt.h>
2089+
2090+static inline int test_domain(int domain, int domaintype)
2091+{
2092+ return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2093+}
2094+#endif
2095+
2096+#ifdef CONFIG_PAX_KERNEXEC
2097+static inline unsigned long pax_open_kernel(void) {
2098+#ifdef CONFIG_ARM_LPAE
2099+ /* TODO */
2100+#else
2101+ preempt_disable();
2102+ BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2103+ modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2104+#endif
2105+ return 0;
2106+}
2107+
2108+static inline unsigned long pax_close_kernel(void) {
2109+#ifdef CONFIG_ARM_LPAE
2110+ /* TODO */
2111+#else
2112+ BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2113+ /* DOMAIN_MANAGER = "client" under KERNEXEC */
2114+ modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2115+ preempt_enable_no_resched();
2116+#endif
2117+ return 0;
2118+}
2119+#else
2120+static inline unsigned long pax_open_kernel(void) { return 0; }
2121+static inline unsigned long pax_close_kernel(void) { return 0; }
2122+#endif
2123+
2124 /*
2125 * This is the lowest virtual address we can permit any user space
2126 * mapping to be mapped at. This is particularly important for
2127@@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2128 /*
2129 * The pgprot_* and protection_map entries will be fixed up in runtime
2130 * to include the cachable and bufferable bits based on memory policy,
2131- * as well as any architecture dependent bits like global/ASID and SMP
2132- * shared mapping bits.
2133+ * as well as any architecture dependent bits like global/ASID, PXN,
2134+ * and SMP shared mapping bits.
2135 */
2136 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2137
2138@@ -307,7 +355,7 @@ static inline pte_t pte_mknexec(pte_t pte)
2139 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2140 {
2141 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2142- L_PTE_NONE | L_PTE_VALID;
2143+ L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2144 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2145 return pte;
2146 }
2147diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2148index c25ef3e..735f14b 100644
2149--- a/arch/arm/include/asm/psci.h
2150+++ b/arch/arm/include/asm/psci.h
2151@@ -32,7 +32,7 @@ struct psci_operations {
2152 int (*affinity_info)(unsigned long target_affinity,
2153 unsigned long lowest_affinity_level);
2154 int (*migrate_info_type)(void);
2155-};
2156+} __no_const;
2157
2158 extern struct psci_operations psci_ops;
2159 extern struct smp_operations psci_smp_ops;
2160diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2161index 2f3ac1b..67182ae0 100644
2162--- a/arch/arm/include/asm/smp.h
2163+++ b/arch/arm/include/asm/smp.h
2164@@ -108,7 +108,7 @@ struct smp_operations {
2165 int (*cpu_disable)(unsigned int cpu);
2166 #endif
2167 #endif
2168-};
2169+} __no_const;
2170
2171 struct of_cpu_method {
2172 const char *method;
2173diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2174index bd32ede..bd90a0b 100644
2175--- a/arch/arm/include/asm/thread_info.h
2176+++ b/arch/arm/include/asm/thread_info.h
2177@@ -74,9 +74,9 @@ struct thread_info {
2178 .flags = 0, \
2179 .preempt_count = INIT_PREEMPT_COUNT, \
2180 .addr_limit = KERNEL_DS, \
2181- .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2182- domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2183- domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2184+ .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2185+ domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2186+ domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2187 }
2188
2189 #define init_thread_info (init_thread_union.thread_info)
2190@@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2191 #define TIF_SYSCALL_AUDIT 9
2192 #define TIF_SYSCALL_TRACEPOINT 10
2193 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2194-#define TIF_NOHZ 12 /* in adaptive nohz mode */
2195+/* within 8 bits of TIF_SYSCALL_TRACE
2196+ * to meet flexible second operand requirements
2197+ */
2198+#define TIF_GRSEC_SETXID 12
2199+#define TIF_NOHZ 13 /* in adaptive nohz mode */
2200 #define TIF_USING_IWMMXT 17
2201 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2202 #define TIF_RESTORE_SIGMASK 20
2203@@ -166,10 +170,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2204 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2205 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2206 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2207+#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2208
2209 /* Checks for any syscall work in entry-common.S */
2210 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2211- _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2212+ _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2213
2214 /*
2215 * Change these and you break ASM code in entry-common.S
2216diff --git a/arch/arm/include/asm/tls.h b/arch/arm/include/asm/tls.h
2217index 5f833f7..76e6644 100644
2218--- a/arch/arm/include/asm/tls.h
2219+++ b/arch/arm/include/asm/tls.h
2220@@ -3,6 +3,7 @@
2221
2222 #include <linux/compiler.h>
2223 #include <asm/thread_info.h>
2224+#include <asm/pgtable.h>
2225
2226 #ifdef __ASSEMBLY__
2227 #include <asm/asm-offsets.h>
2228@@ -89,7 +90,9 @@ static inline void set_tls(unsigned long val)
2229 * at 0xffff0fe0 must be used instead. (see
2230 * entry-armv.S for details)
2231 */
2232+ pax_open_kernel();
2233 *((unsigned int *)0xffff0ff0) = val;
2234+ pax_close_kernel();
2235 #endif
2236 }
2237
2238diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2239index 74b17d0..7e6da4b 100644
2240--- a/arch/arm/include/asm/uaccess.h
2241+++ b/arch/arm/include/asm/uaccess.h
2242@@ -18,6 +18,7 @@
2243 #include <asm/domain.h>
2244 #include <asm/unified.h>
2245 #include <asm/compiler.h>
2246+#include <asm/pgtable.h>
2247
2248 #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2249 #include <asm-generic/uaccess-unaligned.h>
2250@@ -70,11 +71,38 @@ extern int __put_user_bad(void);
2251 static inline void set_fs(mm_segment_t fs)
2252 {
2253 current_thread_info()->addr_limit = fs;
2254- modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2255+ modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2256 }
2257
2258 #define segment_eq(a, b) ((a) == (b))
2259
2260+#define __HAVE_ARCH_PAX_OPEN_USERLAND
2261+#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2262+
2263+static inline void pax_open_userland(void)
2264+{
2265+
2266+#ifdef CONFIG_PAX_MEMORY_UDEREF
2267+ if (segment_eq(get_fs(), USER_DS)) {
2268+ BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2269+ modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2270+ }
2271+#endif
2272+
2273+}
2274+
2275+static inline void pax_close_userland(void)
2276+{
2277+
2278+#ifdef CONFIG_PAX_MEMORY_UDEREF
2279+ if (segment_eq(get_fs(), USER_DS)) {
2280+ BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2281+ modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2282+ }
2283+#endif
2284+
2285+}
2286+
2287 #define __addr_ok(addr) ({ \
2288 unsigned long flag; \
2289 __asm__("cmp %2, %0; movlo %0, #0" \
2290@@ -198,8 +226,12 @@ extern int __get_user_64t_4(void *);
2291
2292 #define get_user(x, p) \
2293 ({ \
2294+ int __e; \
2295 might_fault(); \
2296- __get_user_check(x, p); \
2297+ pax_open_userland(); \
2298+ __e = __get_user_check((x), (p)); \
2299+ pax_close_userland(); \
2300+ __e; \
2301 })
2302
2303 extern int __put_user_1(void *, unsigned int);
2304@@ -244,8 +276,12 @@ extern int __put_user_8(void *, unsigned long long);
2305
2306 #define put_user(x, p) \
2307 ({ \
2308+ int __e; \
2309 might_fault(); \
2310- __put_user_check(x, p); \
2311+ pax_open_userland(); \
2312+ __e = __put_user_check((x), (p)); \
2313+ pax_close_userland(); \
2314+ __e; \
2315 })
2316
2317 #else /* CONFIG_MMU */
2318@@ -269,6 +305,7 @@ static inline void set_fs(mm_segment_t fs)
2319
2320 #endif /* CONFIG_MMU */
2321
2322+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
2323 #define access_ok(type, addr, size) (__range_ok(addr, size) == 0)
2324
2325 #define user_addr_max() \
2326@@ -286,13 +323,17 @@ static inline void set_fs(mm_segment_t fs)
2327 #define __get_user(x, ptr) \
2328 ({ \
2329 long __gu_err = 0; \
2330+ pax_open_userland(); \
2331 __get_user_err((x), (ptr), __gu_err); \
2332+ pax_close_userland(); \
2333 __gu_err; \
2334 })
2335
2336 #define __get_user_error(x, ptr, err) \
2337 ({ \
2338+ pax_open_userland(); \
2339 __get_user_err((x), (ptr), err); \
2340+ pax_close_userland(); \
2341 (void) 0; \
2342 })
2343
2344@@ -368,13 +409,17 @@ do { \
2345 #define __put_user(x, ptr) \
2346 ({ \
2347 long __pu_err = 0; \
2348+ pax_open_userland(); \
2349 __put_user_err((x), (ptr), __pu_err); \
2350+ pax_close_userland(); \
2351 __pu_err; \
2352 })
2353
2354 #define __put_user_error(x, ptr, err) \
2355 ({ \
2356+ pax_open_userland(); \
2357 __put_user_err((x), (ptr), err); \
2358+ pax_close_userland(); \
2359 (void) 0; \
2360 })
2361
2362@@ -474,11 +519,44 @@ do { \
2363
2364
2365 #ifdef CONFIG_MMU
2366-extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2367-extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2368-extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2369-extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2370-extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2371+extern unsigned long __must_check __size_overflow(3) ___copy_from_user(void *to, const void __user *from, unsigned long n);
2372+extern unsigned long __must_check __size_overflow(3) ___copy_to_user(void __user *to, const void *from, unsigned long n);
2373+
2374+static inline unsigned long __must_check __size_overflow(3) __copy_from_user(void *to, const void __user *from, unsigned long n)
2375+{
2376+ unsigned long ret;
2377+
2378+ check_object_size(to, n, false);
2379+ pax_open_userland();
2380+ ret = ___copy_from_user(to, from, n);
2381+ pax_close_userland();
2382+ return ret;
2383+}
2384+
2385+static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2386+{
2387+ unsigned long ret;
2388+
2389+ check_object_size(from, n, true);
2390+ pax_open_userland();
2391+ ret = ___copy_to_user(to, from, n);
2392+ pax_close_userland();
2393+ return ret;
2394+}
2395+
2396+extern unsigned long __must_check __size_overflow(3) __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2397+extern unsigned long __must_check __size_overflow(2) ___clear_user(void __user *addr, unsigned long n);
2398+extern unsigned long __must_check __size_overflow(2) __clear_user_std(void __user *addr, unsigned long n);
2399+
2400+static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2401+{
2402+ unsigned long ret;
2403+ pax_open_userland();
2404+ ret = ___clear_user(addr, n);
2405+ pax_close_userland();
2406+ return ret;
2407+}
2408+
2409 #else
2410 #define __copy_from_user(to, from, n) (memcpy(to, (void __force *)from, n), 0)
2411 #define __copy_to_user(to, from, n) (memcpy((void __force *)to, from, n), 0)
2412@@ -487,6 +565,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2413
2414 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2415 {
2416+ if ((long)n < 0)
2417+ return n;
2418+
2419 if (access_ok(VERIFY_READ, from, n))
2420 n = __copy_from_user(to, from, n);
2421 else /* security hole - plug it */
2422@@ -496,6 +577,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2423
2424 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2425 {
2426+ if ((long)n < 0)
2427+ return n;
2428+
2429 if (access_ok(VERIFY_WRITE, to, n))
2430 n = __copy_to_user(to, from, n);
2431 return n;
2432diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2433index 5af0ed1..cea83883 100644
2434--- a/arch/arm/include/uapi/asm/ptrace.h
2435+++ b/arch/arm/include/uapi/asm/ptrace.h
2436@@ -92,7 +92,7 @@
2437 * ARMv7 groups of PSR bits
2438 */
2439 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2440-#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2441+#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2442 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2443 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2444
2445diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2446index 5e5a51a..b21eeef 100644
2447--- a/arch/arm/kernel/armksyms.c
2448+++ b/arch/arm/kernel/armksyms.c
2449@@ -58,7 +58,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2450
2451 /* networking */
2452 EXPORT_SYMBOL(csum_partial);
2453-EXPORT_SYMBOL(csum_partial_copy_from_user);
2454+EXPORT_SYMBOL(__csum_partial_copy_from_user);
2455 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2456 EXPORT_SYMBOL(__csum_ipv6_magic);
2457
2458@@ -97,9 +97,9 @@ EXPORT_SYMBOL(mmiocpy);
2459 #ifdef CONFIG_MMU
2460 EXPORT_SYMBOL(copy_page);
2461
2462-EXPORT_SYMBOL(__copy_from_user);
2463-EXPORT_SYMBOL(__copy_to_user);
2464-EXPORT_SYMBOL(__clear_user);
2465+EXPORT_SYMBOL(___copy_from_user);
2466+EXPORT_SYMBOL(___copy_to_user);
2467+EXPORT_SYMBOL(___clear_user);
2468
2469 EXPORT_SYMBOL(__get_user_1);
2470 EXPORT_SYMBOL(__get_user_2);
2471diff --git a/arch/arm/kernel/cpuidle.c b/arch/arm/kernel/cpuidle.c
2472index 318da33..373689f 100644
2473--- a/arch/arm/kernel/cpuidle.c
2474+++ b/arch/arm/kernel/cpuidle.c
2475@@ -19,7 +19,7 @@ extern struct of_cpuidle_method __cpuidle_method_of_table[];
2476 static const struct of_cpuidle_method __cpuidle_method_of_table_sentinel
2477 __used __section(__cpuidle_method_of_table_end);
2478
2479-static struct cpuidle_ops cpuidle_ops[NR_CPUS];
2480+static struct cpuidle_ops cpuidle_ops[NR_CPUS] __read_only;
2481
2482 /**
2483 * arm_cpuidle_simple_enter() - a wrapper to cpu_do_idle()
2484diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2485index cb4fb1e..dc7fcaf 100644
2486--- a/arch/arm/kernel/entry-armv.S
2487+++ b/arch/arm/kernel/entry-armv.S
2488@@ -50,6 +50,87 @@
2489 9997:
2490 .endm
2491
2492+ .macro pax_enter_kernel
2493+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2494+ @ make aligned space for saved DACR
2495+ sub sp, sp, #8
2496+ @ save regs
2497+ stmdb sp!, {r1, r2}
2498+ @ read DACR from cpu_domain into r1
2499+ mov r2, sp
2500+ @ assume 8K pages, since we have to split the immediate in two
2501+ bic r2, r2, #(0x1fc0)
2502+ bic r2, r2, #(0x3f)
2503+ ldr r1, [r2, #TI_CPU_DOMAIN]
2504+ @ store old DACR on stack
2505+ str r1, [sp, #8]
2506+#ifdef CONFIG_PAX_KERNEXEC
2507+ @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2508+ bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2509+ orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2510+#endif
2511+#ifdef CONFIG_PAX_MEMORY_UDEREF
2512+ @ set current DOMAIN_USER to DOMAIN_NOACCESS
2513+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2514+#endif
2515+ @ write r1 to current_thread_info()->cpu_domain
2516+ str r1, [r2, #TI_CPU_DOMAIN]
2517+ @ write r1 to DACR
2518+ mcr p15, 0, r1, c3, c0, 0
2519+ @ instruction sync
2520+ instr_sync
2521+ @ restore regs
2522+ ldmia sp!, {r1, r2}
2523+#endif
2524+ .endm
2525+
2526+ .macro pax_open_userland
2527+#ifdef CONFIG_PAX_MEMORY_UDEREF
2528+ @ save regs
2529+ stmdb sp!, {r0, r1}
2530+ @ read DACR from cpu_domain into r1
2531+ mov r0, sp
2532+ @ assume 8K pages, since we have to split the immediate in two
2533+ bic r0, r0, #(0x1fc0)
2534+ bic r0, r0, #(0x3f)
2535+ ldr r1, [r0, #TI_CPU_DOMAIN]
2536+ @ set current DOMAIN_USER to DOMAIN_CLIENT
2537+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2538+ orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2539+ @ write r1 to current_thread_info()->cpu_domain
2540+ str r1, [r0, #TI_CPU_DOMAIN]
2541+ @ write r1 to DACR
2542+ mcr p15, 0, r1, c3, c0, 0
2543+ @ instruction sync
2544+ instr_sync
2545+ @ restore regs
2546+ ldmia sp!, {r0, r1}
2547+#endif
2548+ .endm
2549+
2550+ .macro pax_close_userland
2551+#ifdef CONFIG_PAX_MEMORY_UDEREF
2552+ @ save regs
2553+ stmdb sp!, {r0, r1}
2554+ @ read DACR from cpu_domain into r1
2555+ mov r0, sp
2556+ @ assume 8K pages, since we have to split the immediate in two
2557+ bic r0, r0, #(0x1fc0)
2558+ bic r0, r0, #(0x3f)
2559+ ldr r1, [r0, #TI_CPU_DOMAIN]
2560+ @ set current DOMAIN_USER to DOMAIN_NOACCESS
2561+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2562+ @ write r1 to current_thread_info()->cpu_domain
2563+ str r1, [r0, #TI_CPU_DOMAIN]
2564+ @ write r1 to DACR
2565+ mcr p15, 0, r1, c3, c0, 0
2566+ @ instruction sync
2567+ instr_sync
2568+ @ restore regs
2569+ ldmia sp!, {r0, r1}
2570+#endif
2571+ .endm
2572+
2573 .macro pabt_helper
2574 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2575 #ifdef MULTI_PABORT
2576@@ -92,11 +173,15 @@
2577 * Invalid mode handlers
2578 */
2579 .macro inv_entry, reason
2580+
2581+ pax_enter_kernel
2582+
2583 sub sp, sp, #S_FRAME_SIZE
2584 ARM( stmib sp, {r1 - lr} )
2585 THUMB( stmia sp, {r0 - r12} )
2586 THUMB( str sp, [sp, #S_SP] )
2587 THUMB( str lr, [sp, #S_LR] )
2588+
2589 mov r1, #\reason
2590 .endm
2591
2592@@ -152,7 +237,11 @@ ENDPROC(__und_invalid)
2593 .macro svc_entry, stack_hole=0, trace=1
2594 UNWIND(.fnstart )
2595 UNWIND(.save {r0 - pc} )
2596+
2597+ pax_enter_kernel
2598+
2599 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2600+
2601 #ifdef CONFIG_THUMB2_KERNEL
2602 SPFIX( str r0, [sp] ) @ temporarily saved
2603 SPFIX( mov r0, sp )
2604@@ -167,7 +256,12 @@ ENDPROC(__und_invalid)
2605 ldmia r0, {r3 - r5}
2606 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2607 mov r6, #-1 @ "" "" "" ""
2608+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2609+ @ offset sp by 8 as done in pax_enter_kernel
2610+ add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2611+#else
2612 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2613+#endif
2614 SPFIX( addeq r2, r2, #4 )
2615 str r3, [sp, #-4]! @ save the "real" r0 copied
2616 @ from the exception stack
2617@@ -371,6 +465,9 @@ ENDPROC(__fiq_abt)
2618 .macro usr_entry, trace=1
2619 UNWIND(.fnstart )
2620 UNWIND(.cantunwind ) @ don't unwind the user space
2621+
2622+ pax_enter_kernel_user
2623+
2624 sub sp, sp, #S_FRAME_SIZE
2625 ARM( stmib sp, {r1 - r12} )
2626 THUMB( stmia sp, {r0 - r12} )
2627@@ -481,7 +578,9 @@ __und_usr:
2628 tst r3, #PSR_T_BIT @ Thumb mode?
2629 bne __und_usr_thumb
2630 sub r4, r2, #4 @ ARM instr at LR - 4
2631+ pax_open_userland
2632 1: ldrt r0, [r4]
2633+ pax_close_userland
2634 ARM_BE8(rev r0, r0) @ little endian instruction
2635
2636 @ r0 = 32-bit ARM instruction which caused the exception
2637@@ -515,11 +614,15 @@ __und_usr_thumb:
2638 */
2639 .arch armv6t2
2640 #endif
2641+ pax_open_userland
2642 2: ldrht r5, [r4]
2643+ pax_close_userland
2644 ARM_BE8(rev16 r5, r5) @ little endian instruction
2645 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2646 blo __und_usr_fault_16 @ 16bit undefined instruction
2647+ pax_open_userland
2648 3: ldrht r0, [r2]
2649+ pax_close_userland
2650 ARM_BE8(rev16 r0, r0) @ little endian instruction
2651 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2652 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2653@@ -549,7 +652,8 @@ ENDPROC(__und_usr)
2654 */
2655 .pushsection .text.fixup, "ax"
2656 .align 2
2657-4: str r4, [sp, #S_PC] @ retry current instruction
2658+4: pax_close_userland
2659+ str r4, [sp, #S_PC] @ retry current instruction
2660 ret r9
2661 .popsection
2662 .pushsection __ex_table,"a"
2663@@ -769,7 +873,7 @@ ENTRY(__switch_to)
2664 THUMB( str lr, [ip], #4 )
2665 ldr r4, [r2, #TI_TP_VALUE]
2666 ldr r5, [r2, #TI_TP_VALUE + 4]
2667-#ifdef CONFIG_CPU_USE_DOMAINS
2668+#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2669 ldr r6, [r2, #TI_CPU_DOMAIN]
2670 #endif
2671 switch_tls r1, r4, r5, r3, r7
2672@@ -778,7 +882,7 @@ ENTRY(__switch_to)
2673 ldr r8, =__stack_chk_guard
2674 ldr r7, [r7, #TSK_STACK_CANARY]
2675 #endif
2676-#ifdef CONFIG_CPU_USE_DOMAINS
2677+#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2678 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2679 #endif
2680 mov r5, r0
2681diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2682index b48dd4f..9f9a72f 100644
2683--- a/arch/arm/kernel/entry-common.S
2684+++ b/arch/arm/kernel/entry-common.S
2685@@ -11,18 +11,46 @@
2686 #include <asm/assembler.h>
2687 #include <asm/unistd.h>
2688 #include <asm/ftrace.h>
2689+#include <asm/domain.h>
2690 #include <asm/unwind.h>
2691
2692+#include "entry-header.S"
2693+
2694 #ifdef CONFIG_NEED_RET_TO_USER
2695 #include <mach/entry-macro.S>
2696 #else
2697 .macro arch_ret_to_user, tmp1, tmp2
2698+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2699+ @ save regs
2700+ stmdb sp!, {r1, r2}
2701+ @ read DACR from cpu_domain into r1
2702+ mov r2, sp
2703+ @ assume 8K pages, since we have to split the immediate in two
2704+ bic r2, r2, #(0x1fc0)
2705+ bic r2, r2, #(0x3f)
2706+ ldr r1, [r2, #TI_CPU_DOMAIN]
2707+#ifdef CONFIG_PAX_KERNEXEC
2708+ @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2709+ bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2710+ orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2711+#endif
2712+#ifdef CONFIG_PAX_MEMORY_UDEREF
2713+ @ set current DOMAIN_USER to DOMAIN_UDEREF
2714+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2715+ orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2716+#endif
2717+ @ write r1 to current_thread_info()->cpu_domain
2718+ str r1, [r2, #TI_CPU_DOMAIN]
2719+ @ write r1 to DACR
2720+ mcr p15, 0, r1, c3, c0, 0
2721+ @ instruction sync
2722+ instr_sync
2723+ @ restore regs
2724+ ldmia sp!, {r1, r2}
2725+#endif
2726 .endm
2727 #endif
2728
2729-#include "entry-header.S"
2730-
2731-
2732 .align 5
2733 /*
2734 * This is the fast syscall return path. We do as little as
2735@@ -174,6 +202,12 @@ ENTRY(vector_swi)
2736 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2737 #endif
2738
2739+ /*
2740+ * do this here to avoid a performance hit of wrapping the code above
2741+ * that directly dereferences userland to parse the SWI instruction
2742+ */
2743+ pax_enter_kernel_user
2744+
2745 adr tbl, sys_call_table @ load syscall table pointer
2746
2747 #if defined(CONFIG_OABI_COMPAT)
2748diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2749index 1a0045a..9b4f34d 100644
2750--- a/arch/arm/kernel/entry-header.S
2751+++ b/arch/arm/kernel/entry-header.S
2752@@ -196,6 +196,60 @@
2753 msr cpsr_c, \rtemp @ switch back to the SVC mode
2754 .endm
2755
2756+ .macro pax_enter_kernel_user
2757+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2758+ @ save regs
2759+ stmdb sp!, {r0, r1}
2760+ @ read DACR from cpu_domain into r1
2761+ mov r0, sp
2762+ @ assume 8K pages, since we have to split the immediate in two
2763+ bic r0, r0, #(0x1fc0)
2764+ bic r0, r0, #(0x3f)
2765+ ldr r1, [r0, #TI_CPU_DOMAIN]
2766+#ifdef CONFIG_PAX_MEMORY_UDEREF
2767+ @ set current DOMAIN_USER to DOMAIN_NOACCESS
2768+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2769+#endif
2770+#ifdef CONFIG_PAX_KERNEXEC
2771+ @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2772+ bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2773+ orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2774+#endif
2775+ @ write r1 to current_thread_info()->cpu_domain
2776+ str r1, [r0, #TI_CPU_DOMAIN]
2777+ @ write r1 to DACR
2778+ mcr p15, 0, r1, c3, c0, 0
2779+ @ instruction sync
2780+ instr_sync
2781+ @ restore regs
2782+ ldmia sp!, {r0, r1}
2783+#endif
2784+ .endm
2785+
2786+ .macro pax_exit_kernel
2787+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2788+ @ save regs
2789+ stmdb sp!, {r0, r1}
2790+ @ read old DACR from stack into r1
2791+ ldr r1, [sp, #(8 + S_SP)]
2792+ sub r1, r1, #8
2793+ ldr r1, [r1]
2794+
2795+ @ write r1 to current_thread_info()->cpu_domain
2796+ mov r0, sp
2797+ @ assume 8K pages, since we have to split the immediate in two
2798+ bic r0, r0, #(0x1fc0)
2799+ bic r0, r0, #(0x3f)
2800+ str r1, [r0, #TI_CPU_DOMAIN]
2801+ @ write r1 to DACR
2802+ mcr p15, 0, r1, c3, c0, 0
2803+ @ instruction sync
2804+ instr_sync
2805+ @ restore regs
2806+ ldmia sp!, {r0, r1}
2807+#endif
2808+ .endm
2809+
2810 #ifndef CONFIG_THUMB2_KERNEL
2811 .macro svc_exit, rpsr, irq = 0
2812 .if \irq != 0
2813@@ -215,6 +269,9 @@
2814 blne trace_hardirqs_off
2815 #endif
2816 .endif
2817+
2818+ pax_exit_kernel
2819+
2820 msr spsr_cxsf, \rpsr
2821 #if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_32v6K)
2822 @ We must avoid clrex due to Cortex-A15 erratum #830321
2823@@ -291,6 +348,9 @@
2824 blne trace_hardirqs_off
2825 #endif
2826 .endif
2827+
2828+ pax_exit_kernel
2829+
2830 ldr lr, [sp, #S_SP] @ top of the stack
2831 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2832
2833diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2834index 059c3da..8e45cfc 100644
2835--- a/arch/arm/kernel/fiq.c
2836+++ b/arch/arm/kernel/fiq.c
2837@@ -95,7 +95,10 @@ void set_fiq_handler(void *start, unsigned int length)
2838 void *base = vectors_page;
2839 unsigned offset = FIQ_OFFSET;
2840
2841+ pax_open_kernel();
2842 memcpy(base + offset, start, length);
2843+ pax_close_kernel();
2844+
2845 if (!cache_is_vipt_nonaliasing())
2846 flush_icache_range((unsigned long)base + offset, offset +
2847 length);
2848diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2849index 29e2991..7bc5757 100644
2850--- a/arch/arm/kernel/head.S
2851+++ b/arch/arm/kernel/head.S
2852@@ -467,7 +467,7 @@ __enable_mmu:
2853 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2854 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2855 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2856- domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2857+ domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2858 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2859 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2860 #endif
2861diff --git a/arch/arm/kernel/module-plts.c b/arch/arm/kernel/module-plts.c
2862index 097e2e2..3927085 100644
2863--- a/arch/arm/kernel/module-plts.c
2864+++ b/arch/arm/kernel/module-plts.c
2865@@ -30,17 +30,12 @@ struct plt_entries {
2866 u32 lit[PLT_ENT_COUNT];
2867 };
2868
2869-static bool in_init(const struct module *mod, u32 addr)
2870-{
2871- return addr - (u32)mod->module_init < mod->init_size;
2872-}
2873-
2874 u32 get_module_plt(struct module *mod, unsigned long loc, Elf32_Addr val)
2875 {
2876 struct plt_entries *plt, *plt_end;
2877 int c, *count;
2878
2879- if (in_init(mod, loc)) {
2880+ if (within_module_init(loc, mod)) {
2881 plt = (void *)mod->arch.init_plt->sh_addr;
2882 plt_end = (void *)plt + mod->arch.init_plt->sh_size;
2883 count = &mod->arch.init_plt_count;
2884diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2885index efdddcb..35e58f6 100644
2886--- a/arch/arm/kernel/module.c
2887+++ b/arch/arm/kernel/module.c
2888@@ -38,17 +38,47 @@
2889 #endif
2890
2891 #ifdef CONFIG_MMU
2892-void *module_alloc(unsigned long size)
2893+static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2894 {
2895- void *p = __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2896- GFP_KERNEL, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
2897+ void *p;
2898+
2899+ if (!size || (!IS_ENABLED(CONFIG_ARM_MODULE_PLTS) && PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR))
2900+ return NULL;
2901+
2902+ p = __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2903+ GFP_KERNEL, prot, 0, NUMA_NO_NODE,
2904 __builtin_return_address(0));
2905 if (!IS_ENABLED(CONFIG_ARM_MODULE_PLTS) || p)
2906 return p;
2907 return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END,
2908- GFP_KERNEL, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
2909+ GFP_KERNEL, prot, 0, NUMA_NO_NODE,
2910 __builtin_return_address(0));
2911 }
2912+
2913+void *module_alloc(unsigned long size)
2914+{
2915+
2916+#ifdef CONFIG_PAX_KERNEXEC
2917+ return __module_alloc(size, PAGE_KERNEL);
2918+#else
2919+ return __module_alloc(size, PAGE_KERNEL_EXEC);
2920+#endif
2921+
2922+}
2923+
2924+#ifdef CONFIG_PAX_KERNEXEC
2925+void module_memfree_exec(void *module_region)
2926+{
2927+ module_memfree(module_region);
2928+}
2929+EXPORT_SYMBOL(module_memfree_exec);
2930+
2931+void *module_alloc_exec(unsigned long size)
2932+{
2933+ return __module_alloc(size, PAGE_KERNEL_EXEC);
2934+}
2935+EXPORT_SYMBOL(module_alloc_exec);
2936+#endif
2937 #endif
2938
2939 int
2940diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2941index 69bda1a..755113a 100644
2942--- a/arch/arm/kernel/patch.c
2943+++ b/arch/arm/kernel/patch.c
2944@@ -66,6 +66,7 @@ void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap)
2945 else
2946 __acquire(&patch_lock);
2947
2948+ pax_open_kernel();
2949 if (thumb2 && __opcode_is_thumb16(insn)) {
2950 *(u16 *)waddr = __opcode_to_mem_thumb16(insn);
2951 size = sizeof(u16);
2952@@ -97,6 +98,7 @@ void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap)
2953 *(u32 *)waddr = insn;
2954 size = sizeof(u32);
2955 }
2956+ pax_close_kernel();
2957
2958 if (waddr != addr) {
2959 flush_kernel_vmap_range(waddr, twopage ? size / 2 : size);
2960diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2961index f192a2a..1a40523 100644
2962--- a/arch/arm/kernel/process.c
2963+++ b/arch/arm/kernel/process.c
2964@@ -105,8 +105,8 @@ void __show_regs(struct pt_regs *regs)
2965
2966 show_regs_print_info(KERN_DEFAULT);
2967
2968- print_symbol("PC is at %s\n", instruction_pointer(regs));
2969- print_symbol("LR is at %s\n", regs->ARM_lr);
2970+ printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2971+ printk("LR is at %pA\n", (void *)regs->ARM_lr);
2972 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2973 "sp : %08lx ip : %08lx fp : %08lx\n",
2974 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2975@@ -283,12 +283,6 @@ unsigned long get_wchan(struct task_struct *p)
2976 return 0;
2977 }
2978
2979-unsigned long arch_randomize_brk(struct mm_struct *mm)
2980-{
2981- unsigned long range_end = mm->brk + 0x02000000;
2982- return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2983-}
2984-
2985 #ifdef CONFIG_MMU
2986 #ifdef CONFIG_KUSER_HELPERS
2987 /*
2988@@ -304,7 +298,7 @@ static struct vm_area_struct gate_vma = {
2989
2990 static int __init gate_vma_init(void)
2991 {
2992- gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2993+ gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2994 return 0;
2995 }
2996 arch_initcall(gate_vma_init);
2997@@ -333,91 +327,13 @@ const char *arch_vma_name(struct vm_area_struct *vma)
2998 return is_gate_vma(vma) ? "[vectors]" : NULL;
2999 }
3000
3001-/* If possible, provide a placement hint at a random offset from the
3002- * stack for the sigpage and vdso pages.
3003- */
3004-static unsigned long sigpage_addr(const struct mm_struct *mm,
3005- unsigned int npages)
3006-{
3007- unsigned long offset;
3008- unsigned long first;
3009- unsigned long last;
3010- unsigned long addr;
3011- unsigned int slots;
3012-
3013- first = PAGE_ALIGN(mm->start_stack);
3014-
3015- last = TASK_SIZE - (npages << PAGE_SHIFT);
3016-
3017- /* No room after stack? */
3018- if (first > last)
3019- return 0;
3020-
3021- /* Just enough room? */
3022- if (first == last)
3023- return first;
3024-
3025- slots = ((last - first) >> PAGE_SHIFT) + 1;
3026-
3027- offset = get_random_int() % slots;
3028-
3029- addr = first + (offset << PAGE_SHIFT);
3030-
3031- return addr;
3032-}
3033-
3034-static struct page *signal_page;
3035-extern struct page *get_signal_page(void);
3036-
3037-static const struct vm_special_mapping sigpage_mapping = {
3038- .name = "[sigpage]",
3039- .pages = &signal_page,
3040-};
3041-
3042 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
3043 {
3044 struct mm_struct *mm = current->mm;
3045- struct vm_area_struct *vma;
3046- unsigned long npages;
3047- unsigned long addr;
3048- unsigned long hint;
3049- int ret = 0;
3050-
3051- if (!signal_page)
3052- signal_page = get_signal_page();
3053- if (!signal_page)
3054- return -ENOMEM;
3055-
3056- npages = 1; /* for sigpage */
3057- npages += vdso_total_pages;
3058
3059 down_write(&mm->mmap_sem);
3060- hint = sigpage_addr(mm, npages);
3061- addr = get_unmapped_area(NULL, hint, npages << PAGE_SHIFT, 0, 0);
3062- if (IS_ERR_VALUE(addr)) {
3063- ret = addr;
3064- goto up_fail;
3065- }
3066-
3067- vma = _install_special_mapping(mm, addr, PAGE_SIZE,
3068- VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
3069- &sigpage_mapping);
3070-
3071- if (IS_ERR(vma)) {
3072- ret = PTR_ERR(vma);
3073- goto up_fail;
3074- }
3075-
3076- mm->context.sigpage = addr;
3077-
3078- /* Unlike the sigpage, failure to install the vdso is unlikely
3079- * to be fatal to the process, so no error check needed
3080- * here.
3081- */
3082- arm_install_vdso(mm, addr + PAGE_SIZE);
3083-
3084- up_fail:
3085+ mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
3086 up_write(&mm->mmap_sem);
3087- return ret;
3088+ return 0;
3089 }
3090 #endif
3091diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
3092index f90fdf4..24e8c84 100644
3093--- a/arch/arm/kernel/psci.c
3094+++ b/arch/arm/kernel/psci.c
3095@@ -26,7 +26,7 @@
3096 #include <asm/psci.h>
3097 #include <asm/system_misc.h>
3098
3099-struct psci_operations psci_ops;
3100+struct psci_operations psci_ops __read_only;
3101
3102 static int (*invoke_psci_fn)(u32, u32, u32, u32);
3103 typedef int (*psci_initcall_t)(const struct device_node *);
3104diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
3105index ef9119f..31995a3 100644
3106--- a/arch/arm/kernel/ptrace.c
3107+++ b/arch/arm/kernel/ptrace.c
3108@@ -928,10 +928,19 @@ static void tracehook_report_syscall(struct pt_regs *regs,
3109 regs->ARM_ip = ip;
3110 }
3111
3112+#ifdef CONFIG_GRKERNSEC_SETXID
3113+extern void gr_delayed_cred_worker(void);
3114+#endif
3115+
3116 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
3117 {
3118 current_thread_info()->syscall = scno;
3119
3120+#ifdef CONFIG_GRKERNSEC_SETXID
3121+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
3122+ gr_delayed_cred_worker();
3123+#endif
3124+
3125 /* Do the secure computing check first; failures should be fast. */
3126 #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
3127 if (secure_computing() == -1)
3128diff --git a/arch/arm/kernel/reboot.c b/arch/arm/kernel/reboot.c
3129index 3826935..8ed63ed 100644
3130--- a/arch/arm/kernel/reboot.c
3131+++ b/arch/arm/kernel/reboot.c
3132@@ -122,6 +122,7 @@ void machine_power_off(void)
3133
3134 if (pm_power_off)
3135 pm_power_off();
3136+ while (1);
3137 }
3138
3139 /*
3140diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
3141index 36c18b7..0d78292 100644
3142--- a/arch/arm/kernel/setup.c
3143+++ b/arch/arm/kernel/setup.c
3144@@ -108,21 +108,23 @@ EXPORT_SYMBOL(elf_hwcap);
3145 unsigned int elf_hwcap2 __read_mostly;
3146 EXPORT_SYMBOL(elf_hwcap2);
3147
3148+pteval_t __supported_pte_mask __read_only;
3149+pmdval_t __supported_pmd_mask __read_only;
3150
3151 #ifdef MULTI_CPU
3152-struct processor processor __read_mostly;
3153+struct processor processor __read_only;
3154 #endif
3155 #ifdef MULTI_TLB
3156-struct cpu_tlb_fns cpu_tlb __read_mostly;
3157+struct cpu_tlb_fns cpu_tlb __read_only;
3158 #endif
3159 #ifdef MULTI_USER
3160-struct cpu_user_fns cpu_user __read_mostly;
3161+struct cpu_user_fns cpu_user __read_only;
3162 #endif
3163 #ifdef MULTI_CACHE
3164-struct cpu_cache_fns cpu_cache __read_mostly;
3165+struct cpu_cache_fns cpu_cache __read_only;
3166 #endif
3167 #ifdef CONFIG_OUTER_CACHE
3168-struct outer_cache_fns outer_cache __read_mostly;
3169+struct outer_cache_fns outer_cache __read_only;
3170 EXPORT_SYMBOL(outer_cache);
3171 #endif
3172
3173@@ -253,9 +255,13 @@ static int __get_cpu_architecture(void)
3174 * Register 0 and check for VMSAv7 or PMSAv7 */
3175 unsigned int mmfr0 = read_cpuid_ext(CPUID_EXT_MMFR0);
3176 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3177- (mmfr0 & 0x000000f0) >= 0x00000030)
3178+ (mmfr0 & 0x000000f0) >= 0x00000030) {
3179 cpu_arch = CPU_ARCH_ARMv7;
3180- else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3181+ if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3182+ __supported_pte_mask |= L_PTE_PXN;
3183+ __supported_pmd_mask |= PMD_PXNTABLE;
3184+ }
3185+ } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3186 (mmfr0 & 0x000000f0) == 0x00000020)
3187 cpu_arch = CPU_ARCH_ARMv6;
3188 else
3189diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3190index 586eef2..61aabd4 100644
3191--- a/arch/arm/kernel/signal.c
3192+++ b/arch/arm/kernel/signal.c
3193@@ -24,8 +24,6 @@
3194
3195 extern const unsigned long sigreturn_codes[7];
3196
3197-static unsigned long signal_return_offset;
3198-
3199 #ifdef CONFIG_CRUNCH
3200 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3201 {
3202@@ -390,8 +388,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3203 * except when the MPU has protected the vectors
3204 * page from PL0
3205 */
3206- retcode = mm->context.sigpage + signal_return_offset +
3207- (idx << 2) + thumb;
3208+ retcode = mm->context.sigpage + (idx << 2) + thumb;
3209 } else
3210 #endif
3211 {
3212@@ -597,33 +594,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3213 } while (thread_flags & _TIF_WORK_MASK);
3214 return 0;
3215 }
3216-
3217-struct page *get_signal_page(void)
3218-{
3219- unsigned long ptr;
3220- unsigned offset;
3221- struct page *page;
3222- void *addr;
3223-
3224- page = alloc_pages(GFP_KERNEL, 0);
3225-
3226- if (!page)
3227- return NULL;
3228-
3229- addr = page_address(page);
3230-
3231- /* Give the signal return code some randomness */
3232- offset = 0x200 + (get_random_int() & 0x7fc);
3233- signal_return_offset = offset;
3234-
3235- /*
3236- * Copy signal return handlers into the vector page, and
3237- * set sigreturn to be a pointer to these.
3238- */
3239- memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3240-
3241- ptr = (unsigned long)addr + offset;
3242- flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3243-
3244- return page;
3245-}
3246diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3247index 3d6b782..8b3baeb 100644
3248--- a/arch/arm/kernel/smp.c
3249+++ b/arch/arm/kernel/smp.c
3250@@ -76,7 +76,7 @@ enum ipi_msg_type {
3251
3252 static DECLARE_COMPLETION(cpu_running);
3253
3254-static struct smp_operations smp_ops;
3255+static struct smp_operations smp_ops __read_only;
3256
3257 void __init smp_set_ops(struct smp_operations *ops)
3258 {
3259diff --git a/arch/arm/kernel/tcm.c b/arch/arm/kernel/tcm.c
3260index b10e136..cb5edf9 100644
3261--- a/arch/arm/kernel/tcm.c
3262+++ b/arch/arm/kernel/tcm.c
3263@@ -64,7 +64,7 @@ static struct map_desc itcm_iomap[] __initdata = {
3264 .virtual = ITCM_OFFSET,
3265 .pfn = __phys_to_pfn(ITCM_OFFSET),
3266 .length = 0,
3267- .type = MT_MEMORY_RWX_ITCM,
3268+ .type = MT_MEMORY_RX_ITCM,
3269 }
3270 };
3271
3272@@ -362,7 +362,9 @@ no_dtcm:
3273 start = &__sitcm_text;
3274 end = &__eitcm_text;
3275 ram = &__itcm_start;
3276+ pax_open_kernel();
3277 memcpy(start, ram, itcm_code_sz);
3278+ pax_close_kernel();
3279 pr_debug("CPU ITCM: copied code from %p - %p\n",
3280 start, end);
3281 itcm_present = true;
3282diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3283index d358226..bfd4019 100644
3284--- a/arch/arm/kernel/traps.c
3285+++ b/arch/arm/kernel/traps.c
3286@@ -65,7 +65,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3287 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3288 {
3289 #ifdef CONFIG_KALLSYMS
3290- printk("[<%08lx>] (%ps) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3291+ printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3292 #else
3293 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3294 #endif
3295@@ -267,6 +267,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3296 static int die_owner = -1;
3297 static unsigned int die_nest_count;
3298
3299+extern void gr_handle_kernel_exploit(void);
3300+
3301 static unsigned long oops_begin(void)
3302 {
3303 int cpu;
3304@@ -309,6 +311,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3305 panic("Fatal exception in interrupt");
3306 if (panic_on_oops)
3307 panic("Fatal exception");
3308+
3309+ gr_handle_kernel_exploit();
3310+
3311 if (signr)
3312 do_exit(signr);
3313 }
3314@@ -870,7 +875,11 @@ void __init early_trap_init(void *vectors_base)
3315 kuser_init(vectors_base);
3316
3317 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3318- modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3319+
3320+#ifndef CONFIG_PAX_MEMORY_UDEREF
3321+ modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3322+#endif
3323+
3324 #else /* ifndef CONFIG_CPU_V7M */
3325 /*
3326 * on V7-M there is no need to copy the vector table to a dedicated
3327diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3328index 8b60fde..8d986dd 100644
3329--- a/arch/arm/kernel/vmlinux.lds.S
3330+++ b/arch/arm/kernel/vmlinux.lds.S
3331@@ -37,7 +37,7 @@
3332 #endif
3333
3334 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3335- defined(CONFIG_GENERIC_BUG)
3336+ defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3337 #define ARM_EXIT_KEEP(x) x
3338 #define ARM_EXIT_DISCARD(x)
3339 #else
3340@@ -120,6 +120,8 @@ SECTIONS
3341 #ifdef CONFIG_DEBUG_RODATA
3342 . = ALIGN(1<<SECTION_SHIFT);
3343 #endif
3344+ _etext = .; /* End of text section */
3345+
3346 RO_DATA(PAGE_SIZE)
3347
3348 . = ALIGN(4);
3349@@ -150,8 +152,6 @@ SECTIONS
3350
3351 NOTES
3352
3353- _etext = .; /* End of text and rodata section */
3354-
3355 #ifndef CONFIG_XIP_KERNEL
3356 # ifdef CONFIG_ARM_KERNMEM_PERMS
3357 . = ALIGN(1<<SECTION_SHIFT);
3358diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3359index f9c341c..7430436 100644
3360--- a/arch/arm/kvm/arm.c
3361+++ b/arch/arm/kvm/arm.c
3362@@ -57,7 +57,7 @@ static unsigned long hyp_default_vectors;
3363 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3364
3365 /* The VMID used in the VTTBR */
3366-static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3367+static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3368 static u8 kvm_next_vmid;
3369 static DEFINE_SPINLOCK(kvm_vmid_lock);
3370
3371@@ -372,7 +372,7 @@ void force_vm_exit(const cpumask_t *mask)
3372 */
3373 static bool need_new_vmid_gen(struct kvm *kvm)
3374 {
3375- return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3376+ return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3377 }
3378
3379 /**
3380@@ -405,7 +405,7 @@ static void update_vttbr(struct kvm *kvm)
3381
3382 /* First user of a new VMID generation? */
3383 if (unlikely(kvm_next_vmid == 0)) {
3384- atomic64_inc(&kvm_vmid_gen);
3385+ atomic64_inc_unchecked(&kvm_vmid_gen);
3386 kvm_next_vmid = 1;
3387
3388 /*
3389@@ -422,7 +422,7 @@ static void update_vttbr(struct kvm *kvm)
3390 kvm_call_hyp(__kvm_flush_vm_context);
3391 }
3392
3393- kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3394+ kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3395 kvm->arch.vmid = kvm_next_vmid;
3396 kvm_next_vmid++;
3397
3398@@ -1110,7 +1110,7 @@ struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr)
3399 /**
3400 * Initialize Hyp-mode and memory mappings on all CPUs.
3401 */
3402-int kvm_arch_init(void *opaque)
3403+int kvm_arch_init(const void *opaque)
3404 {
3405 int err;
3406 int ret, cpu;
3407diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3408index 1710fd7..ec3e014 100644
3409--- a/arch/arm/lib/clear_user.S
3410+++ b/arch/arm/lib/clear_user.S
3411@@ -12,14 +12,14 @@
3412
3413 .text
3414
3415-/* Prototype: int __clear_user(void *addr, size_t sz)
3416+/* Prototype: int ___clear_user(void *addr, size_t sz)
3417 * Purpose : clear some user memory
3418 * Params : addr - user memory address to clear
3419 * : sz - number of bytes to clear
3420 * Returns : number of bytes NOT cleared
3421 */
3422 ENTRY(__clear_user_std)
3423-WEAK(__clear_user)
3424+WEAK(___clear_user)
3425 stmfd sp!, {r1, lr}
3426 mov r2, #0
3427 cmp r1, #4
3428@@ -44,7 +44,7 @@ WEAK(__clear_user)
3429 USER( strnebt r2, [r0])
3430 mov r0, #0
3431 ldmfd sp!, {r1, pc}
3432-ENDPROC(__clear_user)
3433+ENDPROC(___clear_user)
3434 ENDPROC(__clear_user_std)
3435
3436 .pushsection .text.fixup,"ax"
3437diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3438index 7a235b9..73a0556 100644
3439--- a/arch/arm/lib/copy_from_user.S
3440+++ b/arch/arm/lib/copy_from_user.S
3441@@ -17,7 +17,7 @@
3442 /*
3443 * Prototype:
3444 *
3445- * size_t __copy_from_user(void *to, const void *from, size_t n)
3446+ * size_t ___copy_from_user(void *to, const void *from, size_t n)
3447 *
3448 * Purpose:
3449 *
3450@@ -89,11 +89,11 @@
3451
3452 .text
3453
3454-ENTRY(__copy_from_user)
3455+ENTRY(___copy_from_user)
3456
3457 #include "copy_template.S"
3458
3459-ENDPROC(__copy_from_user)
3460+ENDPROC(___copy_from_user)
3461
3462 .pushsection .fixup,"ax"
3463 .align 0
3464diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3465index 6ee2f67..d1cce76 100644
3466--- a/arch/arm/lib/copy_page.S
3467+++ b/arch/arm/lib/copy_page.S
3468@@ -10,6 +10,7 @@
3469 * ASM optimised string functions
3470 */
3471 #include <linux/linkage.h>
3472+#include <linux/const.h>
3473 #include <asm/assembler.h>
3474 #include <asm/asm-offsets.h>
3475 #include <asm/cache.h>
3476diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3477index 9648b06..19c333c 100644
3478--- a/arch/arm/lib/copy_to_user.S
3479+++ b/arch/arm/lib/copy_to_user.S
3480@@ -17,7 +17,7 @@
3481 /*
3482 * Prototype:
3483 *
3484- * size_t __copy_to_user(void *to, const void *from, size_t n)
3485+ * size_t ___copy_to_user(void *to, const void *from, size_t n)
3486 *
3487 * Purpose:
3488 *
3489@@ -93,11 +93,11 @@
3490 .text
3491
3492 ENTRY(__copy_to_user_std)
3493-WEAK(__copy_to_user)
3494+WEAK(___copy_to_user)
3495
3496 #include "copy_template.S"
3497
3498-ENDPROC(__copy_to_user)
3499+ENDPROC(___copy_to_user)
3500 ENDPROC(__copy_to_user_std)
3501
3502 .pushsection .text.fixup,"ax"
3503diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3504index 1d0957e..f708846 100644
3505--- a/arch/arm/lib/csumpartialcopyuser.S
3506+++ b/arch/arm/lib/csumpartialcopyuser.S
3507@@ -57,8 +57,8 @@
3508 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3509 */
3510
3511-#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3512-#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3513+#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3514+#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3515
3516 #include "csumpartialcopygeneric.S"
3517
3518diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3519index 8044591..c9b2609 100644
3520--- a/arch/arm/lib/delay.c
3521+++ b/arch/arm/lib/delay.c
3522@@ -29,7 +29,7 @@
3523 /*
3524 * Default to the loop-based delay implementation.
3525 */
3526-struct arm_delay_ops arm_delay_ops = {
3527+struct arm_delay_ops arm_delay_ops __read_only = {
3528 .delay = __loop_delay,
3529 .const_udelay = __loop_const_udelay,
3530 .udelay = __loop_udelay,
3531diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3532index 4b39af2..9ae747d 100644
3533--- a/arch/arm/lib/uaccess_with_memcpy.c
3534+++ b/arch/arm/lib/uaccess_with_memcpy.c
3535@@ -85,7 +85,7 @@ pin_page_for_write(const void __user *_addr, pte_t **ptep, spinlock_t **ptlp)
3536 return 1;
3537 }
3538
3539-static unsigned long noinline
3540+static unsigned long noinline __size_overflow(3)
3541 __copy_to_user_memcpy(void __user *to, const void *from, unsigned long n)
3542 {
3543 int atomic;
3544@@ -136,7 +136,7 @@ out:
3545 }
3546
3547 unsigned long
3548-__copy_to_user(void __user *to, const void *from, unsigned long n)
3549+___copy_to_user(void __user *to, const void *from, unsigned long n)
3550 {
3551 /*
3552 * This test is stubbed out of the main function above to keep
3553@@ -150,7 +150,7 @@ __copy_to_user(void __user *to, const void *from, unsigned long n)
3554 return __copy_to_user_memcpy(to, from, n);
3555 }
3556
3557-static unsigned long noinline
3558+static unsigned long noinline __size_overflow(2)
3559 __clear_user_memset(void __user *addr, unsigned long n)
3560 {
3561 if (unlikely(segment_eq(get_fs(), KERNEL_DS))) {
3562@@ -190,7 +190,7 @@ out:
3563 return n;
3564 }
3565
3566-unsigned long __clear_user(void __user *addr, unsigned long n)
3567+unsigned long ___clear_user(void __user *addr, unsigned long n)
3568 {
3569 /* See rational for this in __copy_to_user() above. */
3570 if (n < 64)
3571diff --git a/arch/arm/mach-exynos/suspend.c b/arch/arm/mach-exynos/suspend.c
3572index f572219..2cf36d5 100644
3573--- a/arch/arm/mach-exynos/suspend.c
3574+++ b/arch/arm/mach-exynos/suspend.c
3575@@ -732,8 +732,10 @@ void __init exynos_pm_init(void)
3576 tmp |= pm_data->wake_disable_mask;
3577 pmu_raw_writel(tmp, S5P_WAKEUP_MASK);
3578
3579- exynos_pm_syscore_ops.suspend = pm_data->pm_suspend;
3580- exynos_pm_syscore_ops.resume = pm_data->pm_resume;
3581+ pax_open_kernel();
3582+ *(void **)&exynos_pm_syscore_ops.suspend = pm_data->pm_suspend;
3583+ *(void **)&exynos_pm_syscore_ops.resume = pm_data->pm_resume;
3584+ pax_close_kernel();
3585
3586 register_syscore_ops(&exynos_pm_syscore_ops);
3587 suspend_set_ops(&exynos_suspend_ops);
3588diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
3589index e46e9ea..9141c83 100644
3590--- a/arch/arm/mach-mvebu/coherency.c
3591+++ b/arch/arm/mach-mvebu/coherency.c
3592@@ -117,7 +117,7 @@ static void __init armada_370_coherency_init(struct device_node *np)
3593
3594 /*
3595 * This ioremap hook is used on Armada 375/38x to ensure that PCIe
3596- * memory areas are mapped as MT_UNCACHED instead of MT_DEVICE. This
3597+ * memory areas are mapped as MT_UNCACHED_RW instead of MT_DEVICE. This
3598 * is needed as a workaround for a deadlock issue between the PCIe
3599 * interface and the cache controller.
3600 */
3601@@ -130,7 +130,7 @@ armada_pcie_wa_ioremap_caller(phys_addr_t phys_addr, size_t size,
3602 mvebu_mbus_get_pcie_mem_aperture(&pcie_mem);
3603
3604 if (pcie_mem.start <= phys_addr && (phys_addr + size) <= pcie_mem.end)
3605- mtype = MT_UNCACHED;
3606+ mtype = MT_UNCACHED_RW;
3607
3608 return __arm_ioremap_caller(phys_addr, size, mtype, caller);
3609 }
3610diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3611index b6443a4..20a0b74 100644
3612--- a/arch/arm/mach-omap2/board-n8x0.c
3613+++ b/arch/arm/mach-omap2/board-n8x0.c
3614@@ -569,7 +569,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3615 }
3616 #endif
3617
3618-struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3619+struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3620 .late_init = n8x0_menelaus_late_init,
3621 };
3622
3623diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3624index 79f49d9..70bf184 100644
3625--- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3626+++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3627@@ -86,7 +86,7 @@ struct cpu_pm_ops {
3628 void (*resume)(void);
3629 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3630 void (*hotplug_restart)(void);
3631-};
3632+} __no_const;
3633
3634 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3635 static struct powerdomain *mpuss_pd;
3636@@ -105,7 +105,7 @@ static void dummy_cpu_resume(void)
3637 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3638 {}
3639
3640-struct cpu_pm_ops omap_pm_ops = {
3641+static struct cpu_pm_ops omap_pm_ops __read_only = {
3642 .finish_suspend = default_finish_suspend,
3643 .resume = dummy_cpu_resume,
3644 .scu_prepare = dummy_scu_prepare,
3645diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
3646index 5305ec7..6d74045 100644
3647--- a/arch/arm/mach-omap2/omap-smp.c
3648+++ b/arch/arm/mach-omap2/omap-smp.c
3649@@ -19,6 +19,7 @@
3650 #include <linux/device.h>
3651 #include <linux/smp.h>
3652 #include <linux/io.h>
3653+#include <linux/irq.h>
3654 #include <linux/irqchip/arm-gic.h>
3655
3656 #include <asm/smp_scu.h>
3657diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3658index e1d2e99..d9b3177 100644
3659--- a/arch/arm/mach-omap2/omap-wakeupgen.c
3660+++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3661@@ -330,7 +330,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3662 return NOTIFY_OK;
3663 }
3664
3665-static struct notifier_block __refdata irq_hotplug_notifier = {
3666+static struct notifier_block irq_hotplug_notifier = {
3667 .notifier_call = irq_cpu_hotplug_notify,
3668 };
3669
3670diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3671index 4cb8fd9..5ce65bc 100644
3672--- a/arch/arm/mach-omap2/omap_device.c
3673+++ b/arch/arm/mach-omap2/omap_device.c
3674@@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3675 struct platform_device __init *omap_device_build(const char *pdev_name,
3676 int pdev_id,
3677 struct omap_hwmod *oh,
3678- void *pdata, int pdata_len)
3679+ const void *pdata, int pdata_len)
3680 {
3681 struct omap_hwmod *ohs[] = { oh };
3682
3683@@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3684 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3685 int pdev_id,
3686 struct omap_hwmod **ohs,
3687- int oh_cnt, void *pdata,
3688+ int oh_cnt, const void *pdata,
3689 int pdata_len)
3690 {
3691 int ret = -ENOMEM;
3692diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3693index 78c02b3..c94109a 100644
3694--- a/arch/arm/mach-omap2/omap_device.h
3695+++ b/arch/arm/mach-omap2/omap_device.h
3696@@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3697 /* Core code interface */
3698
3699 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3700- struct omap_hwmod *oh, void *pdata,
3701+ struct omap_hwmod *oh, const void *pdata,
3702 int pdata_len);
3703
3704 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3705 struct omap_hwmod **oh, int oh_cnt,
3706- void *pdata, int pdata_len);
3707+ const void *pdata, int pdata_len);
3708
3709 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3710 struct omap_hwmod **ohs, int oh_cnt);
3711diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3712index 486cc4d..8d1a0b7 100644
3713--- a/arch/arm/mach-omap2/omap_hwmod.c
3714+++ b/arch/arm/mach-omap2/omap_hwmod.c
3715@@ -199,10 +199,10 @@ struct omap_hwmod_soc_ops {
3716 int (*init_clkdm)(struct omap_hwmod *oh);
3717 void (*update_context_lost)(struct omap_hwmod *oh);
3718 int (*get_context_lost)(struct omap_hwmod *oh);
3719-};
3720+} __no_const;
3721
3722 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3723-static struct omap_hwmod_soc_ops soc_ops;
3724+static struct omap_hwmod_soc_ops soc_ops __read_only;
3725
3726 /* omap_hwmod_list contains all registered struct omap_hwmods */
3727 static LIST_HEAD(omap_hwmod_list);
3728diff --git a/arch/arm/mach-omap2/powerdomains43xx_data.c b/arch/arm/mach-omap2/powerdomains43xx_data.c
3729index 95fee54..cfa9cf1 100644
3730--- a/arch/arm/mach-omap2/powerdomains43xx_data.c
3731+++ b/arch/arm/mach-omap2/powerdomains43xx_data.c
3732@@ -10,6 +10,7 @@
3733
3734 #include <linux/kernel.h>
3735 #include <linux/init.h>
3736+#include <asm/pgtable.h>
3737
3738 #include "powerdomain.h"
3739
3740@@ -129,7 +130,9 @@ static int am43xx_check_vcvp(void)
3741
3742 void __init am43xx_powerdomains_init(void)
3743 {
3744- omap4_pwrdm_operations.pwrdm_has_voltdm = am43xx_check_vcvp;
3745+ pax_open_kernel();
3746+ *(void **)&omap4_pwrdm_operations.pwrdm_has_voltdm = am43xx_check_vcvp;
3747+ pax_close_kernel();
3748 pwrdm_register_platform_funcs(&omap4_pwrdm_operations);
3749 pwrdm_register_pwrdms(powerdomains_am43xx);
3750 pwrdm_complete_init();
3751diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3752index ff0a68c..b312aa0 100644
3753--- a/arch/arm/mach-omap2/wd_timer.c
3754+++ b/arch/arm/mach-omap2/wd_timer.c
3755@@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3756 struct omap_hwmod *oh;
3757 char *oh_name = "wd_timer2";
3758 char *dev_name = "omap_wdt";
3759- struct omap_wd_timer_platform_data pdata;
3760+ static struct omap_wd_timer_platform_data pdata = {
3761+ .read_reset_sources = prm_read_reset_sources
3762+ };
3763
3764 if (!cpu_class_is_omap2() || of_have_populated_dt())
3765 return 0;
3766@@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3767 return -EINVAL;
3768 }
3769
3770- pdata.read_reset_sources = prm_read_reset_sources;
3771-
3772 pdev = omap_device_build(dev_name, id, oh, &pdata,
3773 sizeof(struct omap_wd_timer_platform_data));
3774 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3775diff --git a/arch/arm/mach-shmobile/platsmp-apmu.c b/arch/arm/mach-shmobile/platsmp-apmu.c
3776index b0790fc..71eb21f 100644
3777--- a/arch/arm/mach-shmobile/platsmp-apmu.c
3778+++ b/arch/arm/mach-shmobile/platsmp-apmu.c
3779@@ -22,6 +22,7 @@
3780 #include <asm/proc-fns.h>
3781 #include <asm/smp_plat.h>
3782 #include <asm/suspend.h>
3783+#include <asm/pgtable.h>
3784 #include "common.h"
3785 #include "platsmp-apmu.h"
3786
3787@@ -233,6 +234,8 @@ static int shmobile_smp_apmu_enter_suspend(suspend_state_t state)
3788
3789 void __init shmobile_smp_apmu_suspend_init(void)
3790 {
3791- shmobile_suspend_ops.enter = shmobile_smp_apmu_enter_suspend;
3792+ pax_open_kernel();
3793+ *(void **)&shmobile_suspend_ops.enter = shmobile_smp_apmu_enter_suspend;
3794+ pax_close_kernel();
3795 }
3796 #endif
3797diff --git a/arch/arm/mach-shmobile/pm-r8a7740.c b/arch/arm/mach-shmobile/pm-r8a7740.c
3798index 34608fc..344d7c0 100644
3799--- a/arch/arm/mach-shmobile/pm-r8a7740.c
3800+++ b/arch/arm/mach-shmobile/pm-r8a7740.c
3801@@ -11,6 +11,7 @@
3802 #include <linux/console.h>
3803 #include <linux/io.h>
3804 #include <linux/suspend.h>
3805+#include <asm/pgtable.h>
3806
3807 #include "common.h"
3808 #include "pm-rmobile.h"
3809@@ -117,7 +118,9 @@ static int r8a7740_enter_suspend(suspend_state_t suspend_state)
3810
3811 static void r8a7740_suspend_init(void)
3812 {
3813- shmobile_suspend_ops.enter = r8a7740_enter_suspend;
3814+ pax_open_kernel();
3815+ *(void **)&shmobile_suspend_ops.enter = r8a7740_enter_suspend;
3816+ pax_close_kernel();
3817 }
3818 #else
3819 static void r8a7740_suspend_init(void) {}
3820diff --git a/arch/arm/mach-shmobile/pm-sh73a0.c b/arch/arm/mach-shmobile/pm-sh73a0.c
3821index a7e4668..83334f33 100644
3822--- a/arch/arm/mach-shmobile/pm-sh73a0.c
3823+++ b/arch/arm/mach-shmobile/pm-sh73a0.c
3824@@ -9,6 +9,7 @@
3825 */
3826
3827 #include <linux/suspend.h>
3828+#include <asm/pgtable.h>
3829 #include "common.h"
3830
3831 #ifdef CONFIG_SUSPEND
3832@@ -20,7 +21,9 @@ static int sh73a0_enter_suspend(suspend_state_t suspend_state)
3833
3834 static void sh73a0_suspend_init(void)
3835 {
3836- shmobile_suspend_ops.enter = sh73a0_enter_suspend;
3837+ pax_open_kernel();
3838+ *(void **)&shmobile_suspend_ops.enter = sh73a0_enter_suspend;
3839+ pax_close_kernel();
3840 }
3841 #else
3842 static void sh73a0_suspend_init(void) {}
3843diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3844index 7469347..1ecc350 100644
3845--- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3846+++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3847@@ -177,7 +177,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3848 bool entered_lp2 = false;
3849
3850 if (tegra_pending_sgi())
3851- ACCESS_ONCE(abort_flag) = true;
3852+ ACCESS_ONCE_RW(abort_flag) = true;
3853
3854 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3855
3856diff --git a/arch/arm/mach-tegra/irq.c b/arch/arm/mach-tegra/irq.c
3857index 3b9098d..15b390f 100644
3858--- a/arch/arm/mach-tegra/irq.c
3859+++ b/arch/arm/mach-tegra/irq.c
3860@@ -20,6 +20,7 @@
3861 #include <linux/cpu_pm.h>
3862 #include <linux/interrupt.h>
3863 #include <linux/io.h>
3864+#include <linux/irq.h>
3865 #include <linux/irqchip/arm-gic.h>
3866 #include <linux/irq.h>
3867 #include <linux/kernel.h>
3868diff --git a/arch/arm/mach-ux500/pm.c b/arch/arm/mach-ux500/pm.c
3869index 8538910..2f39bc4 100644
3870--- a/arch/arm/mach-ux500/pm.c
3871+++ b/arch/arm/mach-ux500/pm.c
3872@@ -10,6 +10,7 @@
3873 */
3874
3875 #include <linux/kernel.h>
3876+#include <linux/irq.h>
3877 #include <linux/irqchip/arm-gic.h>
3878 #include <linux/delay.h>
3879 #include <linux/io.h>
3880diff --git a/arch/arm/mach-zynq/platsmp.c b/arch/arm/mach-zynq/platsmp.c
3881index f66816c..228b951 100644
3882--- a/arch/arm/mach-zynq/platsmp.c
3883+++ b/arch/arm/mach-zynq/platsmp.c
3884@@ -24,6 +24,7 @@
3885 #include <linux/io.h>
3886 #include <asm/cacheflush.h>
3887 #include <asm/smp_scu.h>
3888+#include <linux/irq.h>
3889 #include <linux/irqchip/arm-gic.h>
3890 #include "common.h"
3891
3892diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3893index 7c6b976..055db09 100644
3894--- a/arch/arm/mm/Kconfig
3895+++ b/arch/arm/mm/Kconfig
3896@@ -446,6 +446,7 @@ config CPU_32v5
3897
3898 config CPU_32v6
3899 bool
3900+ select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3901 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3902
3903 config CPU_32v6K
3904@@ -600,6 +601,7 @@ config CPU_CP15_MPU
3905
3906 config CPU_USE_DOMAINS
3907 bool
3908+ depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3909 help
3910 This option enables or disables the use of domain switching
3911 via the set_fs() function.
3912@@ -818,7 +820,7 @@ config NEED_KUSER_HELPERS
3913
3914 config KUSER_HELPERS
3915 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3916- depends on MMU
3917+ depends on MMU && (!(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND)
3918 default y
3919 help
3920 Warning: disabling this option may break user programs.
3921@@ -832,7 +834,7 @@ config KUSER_HELPERS
3922 See Documentation/arm/kernel_user_helpers.txt for details.
3923
3924 However, the fixed address nature of these helpers can be used
3925- by ROP (return orientated programming) authors when creating
3926+ by ROP (Return Oriented Programming) authors when creating
3927 exploits.
3928
3929 If all of the binaries and libraries which run on your platform
3930diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3931index 9769f1e..16aaa55 100644
3932--- a/arch/arm/mm/alignment.c
3933+++ b/arch/arm/mm/alignment.c
3934@@ -216,10 +216,12 @@ union offset_union {
3935 #define __get16_unaligned_check(ins,val,addr) \
3936 do { \
3937 unsigned int err = 0, v, a = addr; \
3938+ pax_open_userland(); \
3939 __get8_unaligned_check(ins,v,a,err); \
3940 val = v << ((BE) ? 8 : 0); \
3941 __get8_unaligned_check(ins,v,a,err); \
3942 val |= v << ((BE) ? 0 : 8); \
3943+ pax_close_userland(); \
3944 if (err) \
3945 goto fault; \
3946 } while (0)
3947@@ -233,6 +235,7 @@ union offset_union {
3948 #define __get32_unaligned_check(ins,val,addr) \
3949 do { \
3950 unsigned int err = 0, v, a = addr; \
3951+ pax_open_userland(); \
3952 __get8_unaligned_check(ins,v,a,err); \
3953 val = v << ((BE) ? 24 : 0); \
3954 __get8_unaligned_check(ins,v,a,err); \
3955@@ -241,6 +244,7 @@ union offset_union {
3956 val |= v << ((BE) ? 8 : 16); \
3957 __get8_unaligned_check(ins,v,a,err); \
3958 val |= v << ((BE) ? 0 : 24); \
3959+ pax_close_userland(); \
3960 if (err) \
3961 goto fault; \
3962 } while (0)
3963@@ -254,6 +258,7 @@ union offset_union {
3964 #define __put16_unaligned_check(ins,val,addr) \
3965 do { \
3966 unsigned int err = 0, v = val, a = addr; \
3967+ pax_open_userland(); \
3968 __asm__( FIRST_BYTE_16 \
3969 ARM( "1: "ins" %1, [%2], #1\n" ) \
3970 THUMB( "1: "ins" %1, [%2]\n" ) \
3971@@ -273,6 +278,7 @@ union offset_union {
3972 " .popsection\n" \
3973 : "=r" (err), "=&r" (v), "=&r" (a) \
3974 : "0" (err), "1" (v), "2" (a)); \
3975+ pax_close_userland(); \
3976 if (err) \
3977 goto fault; \
3978 } while (0)
3979@@ -286,6 +292,7 @@ union offset_union {
3980 #define __put32_unaligned_check(ins,val,addr) \
3981 do { \
3982 unsigned int err = 0, v = val, a = addr; \
3983+ pax_open_userland(); \
3984 __asm__( FIRST_BYTE_32 \
3985 ARM( "1: "ins" %1, [%2], #1\n" ) \
3986 THUMB( "1: "ins" %1, [%2]\n" ) \
3987@@ -315,6 +322,7 @@ union offset_union {
3988 " .popsection\n" \
3989 : "=r" (err), "=&r" (v), "=&r" (a) \
3990 : "0" (err), "1" (v), "2" (a)); \
3991+ pax_close_userland(); \
3992 if (err) \
3993 goto fault; \
3994 } while (0)
3995diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
3996index 71b3d33..8af9ade 100644
3997--- a/arch/arm/mm/cache-l2x0.c
3998+++ b/arch/arm/mm/cache-l2x0.c
3999@@ -44,7 +44,7 @@ struct l2c_init_data {
4000 void (*configure)(void __iomem *);
4001 void (*unlock)(void __iomem *, unsigned);
4002 struct outer_cache_fns outer_cache;
4003-};
4004+} __do_const;
4005
4006 #define CACHE_LINE_SIZE 32
4007
4008diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
4009index 845769e..4278fd7 100644
4010--- a/arch/arm/mm/context.c
4011+++ b/arch/arm/mm/context.c
4012@@ -43,7 +43,7 @@
4013 #define NUM_USER_ASIDS ASID_FIRST_VERSION
4014
4015 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
4016-static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
4017+static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
4018 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
4019
4020 static DEFINE_PER_CPU(atomic64_t, active_asids);
4021@@ -178,7 +178,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
4022 {
4023 static u32 cur_idx = 1;
4024 u64 asid = atomic64_read(&mm->context.id);
4025- u64 generation = atomic64_read(&asid_generation);
4026+ u64 generation = atomic64_read_unchecked(&asid_generation);
4027
4028 if (asid != 0) {
4029 /*
4030@@ -208,7 +208,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
4031 */
4032 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, cur_idx);
4033 if (asid == NUM_USER_ASIDS) {
4034- generation = atomic64_add_return(ASID_FIRST_VERSION,
4035+ generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
4036 &asid_generation);
4037 flush_context(cpu);
4038 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
4039@@ -240,14 +240,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
4040 cpu_set_reserved_ttbr0();
4041
4042 asid = atomic64_read(&mm->context.id);
4043- if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
4044+ if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
4045 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
4046 goto switch_mm_fastpath;
4047
4048 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
4049 /* Check that our ASID belongs to the current generation. */
4050 asid = atomic64_read(&mm->context.id);
4051- if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
4052+ if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
4053 asid = new_context(mm, cpu);
4054 atomic64_set(&mm->context.id, asid);
4055 }
4056diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
4057index 0d629b8..01867c8 100644
4058--- a/arch/arm/mm/fault.c
4059+++ b/arch/arm/mm/fault.c
4060@@ -25,6 +25,7 @@
4061 #include <asm/system_misc.h>
4062 #include <asm/system_info.h>
4063 #include <asm/tlbflush.h>
4064+#include <asm/sections.h>
4065
4066 #include "fault.h"
4067
4068@@ -138,6 +139,31 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
4069 if (fixup_exception(regs))
4070 return;
4071
4072+#ifdef CONFIG_PAX_MEMORY_UDEREF
4073+ if (addr < TASK_SIZE) {
4074+ if (current->signal->curr_ip)
4075+ printk(KERN_EMERG "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
4076+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
4077+ else
4078+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
4079+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
4080+ }
4081+#endif
4082+
4083+#ifdef CONFIG_PAX_KERNEXEC
4084+ if ((fsr & FSR_WRITE) &&
4085+ (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
4086+ (MODULES_VADDR <= addr && addr < MODULES_END)))
4087+ {
4088+ if (current->signal->curr_ip)
4089+ printk(KERN_EMERG "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
4090+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
4091+ else
4092+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
4093+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
4094+ }
4095+#endif
4096+
4097 /*
4098 * No handler, we'll have to terminate things with extreme prejudice.
4099 */
4100@@ -173,6 +199,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
4101 }
4102 #endif
4103
4104+#ifdef CONFIG_PAX_PAGEEXEC
4105+ if (fsr & FSR_LNX_PF) {
4106+ pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
4107+ do_group_exit(SIGKILL);
4108+ }
4109+#endif
4110+
4111 tsk->thread.address = addr;
4112 tsk->thread.error_code = fsr;
4113 tsk->thread.trap_no = 14;
4114@@ -400,6 +433,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
4115 }
4116 #endif /* CONFIG_MMU */
4117
4118+#ifdef CONFIG_PAX_PAGEEXEC
4119+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4120+{
4121+ long i;
4122+
4123+ printk(KERN_ERR "PAX: bytes at PC: ");
4124+ for (i = 0; i < 20; i++) {
4125+ unsigned char c;
4126+ if (get_user(c, (__force unsigned char __user *)pc+i))
4127+ printk(KERN_CONT "?? ");
4128+ else
4129+ printk(KERN_CONT "%02x ", c);
4130+ }
4131+ printk("\n");
4132+
4133+ printk(KERN_ERR "PAX: bytes at SP-4: ");
4134+ for (i = -1; i < 20; i++) {
4135+ unsigned long c;
4136+ if (get_user(c, (__force unsigned long __user *)sp+i))
4137+ printk(KERN_CONT "???????? ");
4138+ else
4139+ printk(KERN_CONT "%08lx ", c);
4140+ }
4141+ printk("\n");
4142+}
4143+#endif
4144+
4145 /*
4146 * First Level Translation Fault Handler
4147 *
4148@@ -547,9 +607,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
4149 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
4150 struct siginfo info;
4151
4152+#ifdef CONFIG_PAX_MEMORY_UDEREF
4153+ if (addr < TASK_SIZE && is_domain_fault(fsr)) {
4154+ if (current->signal->curr_ip)
4155+ printk(KERN_EMERG "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
4156+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
4157+ else
4158+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
4159+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
4160+ goto die;
4161+ }
4162+#endif
4163+
4164 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
4165 return;
4166
4167+die:
4168 pr_alert("Unhandled fault: %s (0x%03x) at 0x%08lx\n",
4169 inf->name, fsr, addr);
4170 show_pte(current->mm, addr);
4171@@ -574,15 +647,104 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
4172 ifsr_info[nr].name = name;
4173 }
4174
4175+asmlinkage int sys_sigreturn(struct pt_regs *regs);
4176+asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
4177+
4178 asmlinkage void __exception
4179 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
4180 {
4181 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
4182 struct siginfo info;
4183+ unsigned long pc = instruction_pointer(regs);
4184+
4185+ if (user_mode(regs)) {
4186+ unsigned long sigpage = current->mm->context.sigpage;
4187+
4188+ if (sigpage <= pc && pc < sigpage + 7*4) {
4189+ if (pc < sigpage + 3*4)
4190+ sys_sigreturn(regs);
4191+ else
4192+ sys_rt_sigreturn(regs);
4193+ return;
4194+ }
4195+ if (pc == 0xffff0f60UL) {
4196+ /*
4197+ * PaX: __kuser_cmpxchg64 emulation
4198+ */
4199+ // TODO
4200+ //regs->ARM_pc = regs->ARM_lr;
4201+ //return;
4202+ }
4203+ if (pc == 0xffff0fa0UL) {
4204+ /*
4205+ * PaX: __kuser_memory_barrier emulation
4206+ */
4207+ // dmb(); implied by the exception
4208+ regs->ARM_pc = regs->ARM_lr;
4209+ return;
4210+ }
4211+ if (pc == 0xffff0fc0UL) {
4212+ /*
4213+ * PaX: __kuser_cmpxchg emulation
4214+ */
4215+ // TODO
4216+ //long new;
4217+ //int op;
4218+
4219+ //op = FUTEX_OP_SET << 28;
4220+ //new = futex_atomic_op_inuser(op, regs->ARM_r2);
4221+ //regs->ARM_r0 = old != new;
4222+ //regs->ARM_pc = regs->ARM_lr;
4223+ //return;
4224+ }
4225+ if (pc == 0xffff0fe0UL) {
4226+ /*
4227+ * PaX: __kuser_get_tls emulation
4228+ */
4229+ regs->ARM_r0 = current_thread_info()->tp_value[0];
4230+ regs->ARM_pc = regs->ARM_lr;
4231+ return;
4232+ }
4233+ }
4234+
4235+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4236+ else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
4237+ if (current->signal->curr_ip)
4238+ printk(KERN_EMERG "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
4239+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
4240+ pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
4241+ else
4242+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
4243+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
4244+ pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
4245+ goto die;
4246+ }
4247+#endif
4248+
4249+#ifdef CONFIG_PAX_REFCOUNT
4250+ if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
4251+#ifdef CONFIG_THUMB2_KERNEL
4252+ unsigned short bkpt;
4253+
4254+ if (!probe_kernel_address(pc, bkpt) && cpu_to_le16(bkpt) == 0xbef1) {
4255+#else
4256+ unsigned int bkpt;
4257+
4258+ if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
4259+#endif
4260+ current->thread.error_code = ifsr;
4261+ current->thread.trap_no = 0;
4262+ pax_report_refcount_overflow(regs);
4263+ fixup_exception(regs);
4264+ return;
4265+ }
4266+ }
4267+#endif
4268
4269 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
4270 return;
4271
4272+die:
4273 pr_alert("Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4274 inf->name, ifsr, addr);
4275
4276diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4277index cf08bdf..772656c 100644
4278--- a/arch/arm/mm/fault.h
4279+++ b/arch/arm/mm/fault.h
4280@@ -3,6 +3,7 @@
4281
4282 /*
4283 * Fault status register encodings. We steal bit 31 for our own purposes.
4284+ * Set when the FSR value is from an instruction fault.
4285 */
4286 #define FSR_LNX_PF (1 << 31)
4287 #define FSR_WRITE (1 << 11)
4288@@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4289 }
4290 #endif
4291
4292+/* valid for LPAE and !LPAE */
4293+static inline int is_xn_fault(unsigned int fsr)
4294+{
4295+ return ((fsr_fs(fsr) & 0x3c) == 0xc);
4296+}
4297+
4298+static inline int is_domain_fault(unsigned int fsr)
4299+{
4300+ return ((fsr_fs(fsr) & 0xD) == 0x9);
4301+}
4302+
4303 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4304 unsigned long search_exception_table(unsigned long addr);
4305
4306diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4307index 8a63b4c..6b04370 100644
4308--- a/arch/arm/mm/init.c
4309+++ b/arch/arm/mm/init.c
4310@@ -710,7 +710,46 @@ void free_tcmmem(void)
4311 {
4312 #ifdef CONFIG_HAVE_TCM
4313 extern char __tcm_start, __tcm_end;
4314+#endif
4315
4316+#ifdef CONFIG_PAX_KERNEXEC
4317+ unsigned long addr;
4318+ pgd_t *pgd;
4319+ pud_t *pud;
4320+ pmd_t *pmd;
4321+ int cpu_arch = cpu_architecture();
4322+ unsigned int cr = get_cr();
4323+
4324+ if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4325+ /* make pages tables, etc before .text NX */
4326+ for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4327+ pgd = pgd_offset_k(addr);
4328+ pud = pud_offset(pgd, addr);
4329+ pmd = pmd_offset(pud, addr);
4330+ __section_update(pmd, addr, PMD_SECT_XN);
4331+ }
4332+ /* make init NX */
4333+ for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4334+ pgd = pgd_offset_k(addr);
4335+ pud = pud_offset(pgd, addr);
4336+ pmd = pmd_offset(pud, addr);
4337+ __section_update(pmd, addr, PMD_SECT_XN);
4338+ }
4339+ /* make kernel code/rodata RX */
4340+ for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4341+ pgd = pgd_offset_k(addr);
4342+ pud = pud_offset(pgd, addr);
4343+ pmd = pmd_offset(pud, addr);
4344+#ifdef CONFIG_ARM_LPAE
4345+ __section_update(pmd, addr, PMD_SECT_RDONLY);
4346+#else
4347+ __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4348+#endif
4349+ }
4350+ }
4351+#endif
4352+
4353+#ifdef CONFIG_HAVE_TCM
4354 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4355 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4356 #endif
4357diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4358index 0c81056..97279f7 100644
4359--- a/arch/arm/mm/ioremap.c
4360+++ b/arch/arm/mm/ioremap.c
4361@@ -405,9 +405,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4362 unsigned int mtype;
4363
4364 if (cached)
4365- mtype = MT_MEMORY_RWX;
4366+ mtype = MT_MEMORY_RX;
4367 else
4368- mtype = MT_MEMORY_RWX_NONCACHED;
4369+ mtype = MT_MEMORY_RX_NONCACHED;
4370
4371 return __arm_ioremap_caller(phys_addr, size, mtype,
4372 __builtin_return_address(0));
4373diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4374index 407dc78..047ce9d 100644
4375--- a/arch/arm/mm/mmap.c
4376+++ b/arch/arm/mm/mmap.c
4377@@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4378 struct vm_area_struct *vma;
4379 int do_align = 0;
4380 int aliasing = cache_is_vipt_aliasing();
4381+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4382 struct vm_unmapped_area_info info;
4383
4384 /*
4385@@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4386 if (len > TASK_SIZE)
4387 return -ENOMEM;
4388
4389+#ifdef CONFIG_PAX_RANDMMAP
4390+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4391+#endif
4392+
4393 if (addr) {
4394 if (do_align)
4395 addr = COLOUR_ALIGN(addr, pgoff);
4396@@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4397 addr = PAGE_ALIGN(addr);
4398
4399 vma = find_vma(mm, addr);
4400- if (TASK_SIZE - len >= addr &&
4401- (!vma || addr + len <= vma->vm_start))
4402+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4403 return addr;
4404 }
4405
4406@@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4407 info.high_limit = TASK_SIZE;
4408 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4409 info.align_offset = pgoff << PAGE_SHIFT;
4410+ info.threadstack_offset = offset;
4411 return vm_unmapped_area(&info);
4412 }
4413
4414@@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4415 unsigned long addr = addr0;
4416 int do_align = 0;
4417 int aliasing = cache_is_vipt_aliasing();
4418+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4419 struct vm_unmapped_area_info info;
4420
4421 /*
4422@@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4423 return addr;
4424 }
4425
4426+#ifdef CONFIG_PAX_RANDMMAP
4427+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4428+#endif
4429+
4430 /* requesting a specific address */
4431 if (addr) {
4432 if (do_align)
4433@@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4434 else
4435 addr = PAGE_ALIGN(addr);
4436 vma = find_vma(mm, addr);
4437- if (TASK_SIZE - len >= addr &&
4438- (!vma || addr + len <= vma->vm_start))
4439+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4440 return addr;
4441 }
4442
4443@@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4444 info.high_limit = mm->mmap_base;
4445 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4446 info.align_offset = pgoff << PAGE_SHIFT;
4447+ info.threadstack_offset = offset;
4448 addr = vm_unmapped_area(&info);
4449
4450 /*
4451@@ -183,14 +193,30 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4452 {
4453 unsigned long random_factor = 0UL;
4454
4455+#ifdef CONFIG_PAX_RANDMMAP
4456+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4457+#endif
4458+
4459 if (current->flags & PF_RANDOMIZE)
4460 random_factor = arch_mmap_rnd();
4461
4462 if (mmap_is_legacy()) {
4463 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4464+
4465+#ifdef CONFIG_PAX_RANDMMAP
4466+ if (mm->pax_flags & MF_PAX_RANDMMAP)
4467+ mm->mmap_base += mm->delta_mmap;
4468+#endif
4469+
4470 mm->get_unmapped_area = arch_get_unmapped_area;
4471 } else {
4472 mm->mmap_base = mmap_base(random_factor);
4473+
4474+#ifdef CONFIG_PAX_RANDMMAP
4475+ if (mm->pax_flags & MF_PAX_RANDMMAP)
4476+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4477+#endif
4478+
4479 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4480 }
4481 }
4482diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4483index 870838a..070df1d 100644
4484--- a/arch/arm/mm/mmu.c
4485+++ b/arch/arm/mm/mmu.c
4486@@ -41,6 +41,22 @@
4487 #include "mm.h"
4488 #include "tcm.h"
4489
4490+#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4491+void modify_domain(unsigned int dom, unsigned int type)
4492+{
4493+ struct thread_info *thread = current_thread_info();
4494+ unsigned int domain = thread->cpu_domain;
4495+ /*
4496+ * DOMAIN_MANAGER might be defined to some other value,
4497+ * use the arch-defined constant
4498+ */
4499+ domain &= ~domain_val(dom, 3);
4500+ thread->cpu_domain = domain | domain_val(dom, type);
4501+ set_domain(thread->cpu_domain);
4502+}
4503+EXPORT_SYMBOL(modify_domain);
4504+#endif
4505+
4506 /*
4507 * empty_zero_page is a special page that is used for
4508 * zero-initialized data and COW.
4509@@ -242,7 +258,15 @@ __setup("noalign", noalign_setup);
4510 #define PROT_PTE_S2_DEVICE PROT_PTE_DEVICE
4511 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4512
4513-static struct mem_type mem_types[] = {
4514+#ifdef CONFIG_PAX_KERNEXEC
4515+#define L_PTE_KERNEXEC L_PTE_RDONLY
4516+#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4517+#else
4518+#define L_PTE_KERNEXEC L_PTE_DIRTY
4519+#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4520+#endif
4521+
4522+static struct mem_type mem_types[] __read_only = {
4523 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4524 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4525 L_PTE_SHARED,
4526@@ -271,19 +295,19 @@ static struct mem_type mem_types[] = {
4527 .prot_sect = PROT_SECT_DEVICE,
4528 .domain = DOMAIN_IO,
4529 },
4530- [MT_UNCACHED] = {
4531+ [MT_UNCACHED_RW] = {
4532 .prot_pte = PROT_PTE_DEVICE,
4533 .prot_l1 = PMD_TYPE_TABLE,
4534 .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4535 .domain = DOMAIN_IO,
4536 },
4537- [MT_CACHECLEAN] = {
4538- .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4539+ [MT_CACHECLEAN_RO] = {
4540+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_RDONLY,
4541 .domain = DOMAIN_KERNEL,
4542 },
4543 #ifndef CONFIG_ARM_LPAE
4544- [MT_MINICLEAN] = {
4545- .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4546+ [MT_MINICLEAN_RO] = {
4547+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_XN | PMD_SECT_RDONLY,
4548 .domain = DOMAIN_KERNEL,
4549 },
4550 #endif
4551@@ -291,15 +315,15 @@ static struct mem_type mem_types[] = {
4552 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4553 L_PTE_RDONLY,
4554 .prot_l1 = PMD_TYPE_TABLE,
4555- .domain = DOMAIN_USER,
4556+ .domain = DOMAIN_VECTORS,
4557 },
4558 [MT_HIGH_VECTORS] = {
4559 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4560 L_PTE_USER | L_PTE_RDONLY,
4561 .prot_l1 = PMD_TYPE_TABLE,
4562- .domain = DOMAIN_USER,
4563+ .domain = DOMAIN_VECTORS,
4564 },
4565- [MT_MEMORY_RWX] = {
4566+ [__MT_MEMORY_RWX] = {
4567 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4568 .prot_l1 = PMD_TYPE_TABLE,
4569 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4570@@ -312,17 +336,30 @@ static struct mem_type mem_types[] = {
4571 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4572 .domain = DOMAIN_KERNEL,
4573 },
4574- [MT_ROM] = {
4575- .prot_sect = PMD_TYPE_SECT,
4576+ [MT_MEMORY_RX] = {
4577+ .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4578+ .prot_l1 = PMD_TYPE_TABLE,
4579+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4580+ .domain = DOMAIN_KERNEL,
4581+ },
4582+ [MT_ROM_RX] = {
4583+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4584 .domain = DOMAIN_KERNEL,
4585 },
4586- [MT_MEMORY_RWX_NONCACHED] = {
4587+ [MT_MEMORY_RW_NONCACHED] = {
4588 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4589 L_PTE_MT_BUFFERABLE,
4590 .prot_l1 = PMD_TYPE_TABLE,
4591 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4592 .domain = DOMAIN_KERNEL,
4593 },
4594+ [MT_MEMORY_RX_NONCACHED] = {
4595+ .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4596+ L_PTE_MT_BUFFERABLE,
4597+ .prot_l1 = PMD_TYPE_TABLE,
4598+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4599+ .domain = DOMAIN_KERNEL,
4600+ },
4601 [MT_MEMORY_RW_DTCM] = {
4602 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4603 L_PTE_XN,
4604@@ -330,9 +367,10 @@ static struct mem_type mem_types[] = {
4605 .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4606 .domain = DOMAIN_KERNEL,
4607 },
4608- [MT_MEMORY_RWX_ITCM] = {
4609- .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4610+ [MT_MEMORY_RX_ITCM] = {
4611+ .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4612 .prot_l1 = PMD_TYPE_TABLE,
4613+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4614 .domain = DOMAIN_KERNEL,
4615 },
4616 [MT_MEMORY_RW_SO] = {
4617@@ -544,9 +582,14 @@ static void __init build_mem_type_table(void)
4618 * Mark cache clean areas and XIP ROM read only
4619 * from SVC mode and no access from userspace.
4620 */
4621- mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4622- mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4623- mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4624+ mem_types[MT_ROM_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4625+#ifdef CONFIG_PAX_KERNEXEC
4626+ mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4627+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4628+ mem_types[MT_MEMORY_RX_ITCM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4629+#endif
4630+ mem_types[MT_MINICLEAN_RO].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4631+ mem_types[MT_CACHECLEAN_RO].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4632 #endif
4633
4634 /*
4635@@ -563,13 +606,17 @@ static void __init build_mem_type_table(void)
4636 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4637 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4638 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4639- mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4640- mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4641+ mem_types[__MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4642+ mem_types[__MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4643 mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4644 mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4645+ mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4646+ mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4647 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4648- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= PMD_SECT_S;
4649- mem_types[MT_MEMORY_RWX_NONCACHED].prot_pte |= L_PTE_SHARED;
4650+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |= PMD_SECT_S;
4651+ mem_types[MT_MEMORY_RW_NONCACHED].prot_pte |= L_PTE_SHARED;
4652+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= PMD_SECT_S;
4653+ mem_types[MT_MEMORY_RX_NONCACHED].prot_pte |= L_PTE_SHARED;
4654 }
4655 }
4656
4657@@ -580,15 +627,20 @@ static void __init build_mem_type_table(void)
4658 if (cpu_arch >= CPU_ARCH_ARMv6) {
4659 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4660 /* Non-cacheable Normal is XCB = 001 */
4661- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |=
4662+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |=
4663+ PMD_SECT_BUFFERED;
4664+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |=
4665 PMD_SECT_BUFFERED;
4666 } else {
4667 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4668- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |=
4669+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |=
4670+ PMD_SECT_TEX(1);
4671+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |=
4672 PMD_SECT_TEX(1);
4673 }
4674 } else {
4675- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4676+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4677+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4678 }
4679
4680 #ifdef CONFIG_ARM_LPAE
4681@@ -609,6 +661,8 @@ static void __init build_mem_type_table(void)
4682 user_pgprot |= PTE_EXT_PXN;
4683 #endif
4684
4685+ user_pgprot |= __supported_pte_mask;
4686+
4687 for (i = 0; i < 16; i++) {
4688 pteval_t v = pgprot_val(protection_map[i]);
4689 protection_map[i] = __pgprot(v | user_pgprot);
4690@@ -626,21 +680,24 @@ static void __init build_mem_type_table(void)
4691
4692 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4693 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4694- mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4695- mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4696+ mem_types[__MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4697+ mem_types[__MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4698 mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4699 mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4700+ mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4701+ mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4702 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4703- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= ecc_mask;
4704- mem_types[MT_ROM].prot_sect |= cp->pmd;
4705+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |= ecc_mask;
4706+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= ecc_mask;
4707+ mem_types[MT_ROM_RX].prot_sect |= cp->pmd;
4708
4709 switch (cp->pmd) {
4710 case PMD_SECT_WT:
4711- mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WT;
4712+ mem_types[MT_CACHECLEAN_RO].prot_sect |= PMD_SECT_WT;
4713 break;
4714 case PMD_SECT_WB:
4715 case PMD_SECT_WBWA:
4716- mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WB;
4717+ mem_types[MT_CACHECLEAN_RO].prot_sect |= PMD_SECT_WB;
4718 break;
4719 }
4720 pr_info("Memory policy: %sData cache %s\n",
4721@@ -854,7 +911,7 @@ static void __init create_mapping(struct map_desc *md)
4722 return;
4723 }
4724
4725- if ((md->type == MT_DEVICE || md->type == MT_ROM) &&
4726+ if ((md->type == MT_DEVICE || md->type == MT_ROM_RX) &&
4727 md->virtual >= PAGE_OFFSET &&
4728 (md->virtual < VMALLOC_START || md->virtual >= VMALLOC_END)) {
4729 pr_warn("BUG: mapping for 0x%08llx at 0x%08lx out of vmalloc space\n",
4730@@ -1224,18 +1281,15 @@ void __init arm_mm_memblock_reserve(void)
4731 * called function. This means you can't use any function or debugging
4732 * method which may touch any device, otherwise the kernel _will_ crash.
4733 */
4734+
4735+static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4736+
4737 static void __init devicemaps_init(const struct machine_desc *mdesc)
4738 {
4739 struct map_desc map;
4740 unsigned long addr;
4741- void *vectors;
4742
4743- /*
4744- * Allocate the vector page early.
4745- */
4746- vectors = early_alloc(PAGE_SIZE * 2);
4747-
4748- early_trap_init(vectors);
4749+ early_trap_init(&vectors);
4750
4751 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4752 pmd_clear(pmd_off_k(addr));
4753@@ -1248,7 +1302,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4754 map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK);
4755 map.virtual = MODULES_VADDR;
4756 map.length = ((unsigned long)_etext - map.virtual + ~SECTION_MASK) & SECTION_MASK;
4757- map.type = MT_ROM;
4758+ map.type = MT_ROM_RX;
4759 create_mapping(&map);
4760 #endif
4761
4762@@ -1259,14 +1313,14 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4763 map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS);
4764 map.virtual = FLUSH_BASE;
4765 map.length = SZ_1M;
4766- map.type = MT_CACHECLEAN;
4767+ map.type = MT_CACHECLEAN_RO;
4768 create_mapping(&map);
4769 #endif
4770 #ifdef FLUSH_BASE_MINICACHE
4771 map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + SZ_1M);
4772 map.virtual = FLUSH_BASE_MINICACHE;
4773 map.length = SZ_1M;
4774- map.type = MT_MINICLEAN;
4775+ map.type = MT_MINICLEAN_RO;
4776 create_mapping(&map);
4777 #endif
4778
4779@@ -1275,7 +1329,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4780 * location (0xffff0000). If we aren't using high-vectors, also
4781 * create a mapping at the low-vectors virtual address.
4782 */
4783- map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4784+ map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4785 map.virtual = 0xffff0000;
4786 map.length = PAGE_SIZE;
4787 #ifdef CONFIG_KUSER_HELPERS
4788@@ -1335,8 +1389,10 @@ static void __init kmap_init(void)
4789 static void __init map_lowmem(void)
4790 {
4791 struct memblock_region *reg;
4792+#ifndef CONFIG_PAX_KERNEXEC
4793 phys_addr_t kernel_x_start = round_down(__pa(_stext), SECTION_SIZE);
4794 phys_addr_t kernel_x_end = round_up(__pa(__init_end), SECTION_SIZE);
4795+#endif
4796
4797 /* Map all the lowmem memory banks. */
4798 for_each_memblock(memory, reg) {
4799@@ -1349,11 +1405,48 @@ static void __init map_lowmem(void)
4800 if (start >= end)
4801 break;
4802
4803+#ifdef CONFIG_PAX_KERNEXEC
4804+ map.pfn = __phys_to_pfn(start);
4805+ map.virtual = __phys_to_virt(start);
4806+ map.length = end - start;
4807+
4808+ if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4809+ struct map_desc kernel;
4810+ struct map_desc initmap;
4811+
4812+ /* when freeing initmem we will make this RW */
4813+ initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4814+ initmap.virtual = (unsigned long)__init_begin;
4815+ initmap.length = _sdata - __init_begin;
4816+ initmap.type = __MT_MEMORY_RWX;
4817+ create_mapping(&initmap);
4818+
4819+ /* when freeing initmem we will make this RX */
4820+ kernel.pfn = __phys_to_pfn(__pa(_stext));
4821+ kernel.virtual = (unsigned long)_stext;
4822+ kernel.length = __init_begin - _stext;
4823+ kernel.type = __MT_MEMORY_RWX;
4824+ create_mapping(&kernel);
4825+
4826+ if (map.virtual < (unsigned long)_stext) {
4827+ map.length = (unsigned long)_stext - map.virtual;
4828+ map.type = __MT_MEMORY_RWX;
4829+ create_mapping(&map);
4830+ }
4831+
4832+ map.pfn = __phys_to_pfn(__pa(_sdata));
4833+ map.virtual = (unsigned long)_sdata;
4834+ map.length = end - __pa(_sdata);
4835+ }
4836+
4837+ map.type = MT_MEMORY_RW;
4838+ create_mapping(&map);
4839+#else
4840 if (end < kernel_x_start) {
4841 map.pfn = __phys_to_pfn(start);
4842 map.virtual = __phys_to_virt(start);
4843 map.length = end - start;
4844- map.type = MT_MEMORY_RWX;
4845+ map.type = __MT_MEMORY_RWX;
4846
4847 create_mapping(&map);
4848 } else if (start >= kernel_x_end) {
4849@@ -1377,7 +1470,7 @@ static void __init map_lowmem(void)
4850 map.pfn = __phys_to_pfn(kernel_x_start);
4851 map.virtual = __phys_to_virt(kernel_x_start);
4852 map.length = kernel_x_end - kernel_x_start;
4853- map.type = MT_MEMORY_RWX;
4854+ map.type = __MT_MEMORY_RWX;
4855
4856 create_mapping(&map);
4857
4858@@ -1390,6 +1483,7 @@ static void __init map_lowmem(void)
4859 create_mapping(&map);
4860 }
4861 }
4862+#endif
4863 }
4864 }
4865
4866diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
4867index c011e22..92a0260 100644
4868--- a/arch/arm/net/bpf_jit_32.c
4869+++ b/arch/arm/net/bpf_jit_32.c
4870@@ -20,6 +20,7 @@
4871 #include <asm/cacheflush.h>
4872 #include <asm/hwcap.h>
4873 #include <asm/opcodes.h>
4874+#include <asm/pgtable.h>
4875
4876 #include "bpf_jit_32.h"
4877
4878@@ -72,54 +73,38 @@ struct jit_ctx {
4879 #endif
4880 };
4881
4882+#ifdef CONFIG_GRKERNSEC_BPF_HARDEN
4883+int bpf_jit_enable __read_only;
4884+#else
4885 int bpf_jit_enable __read_mostly;
4886+#endif
4887
4888-static inline int call_neg_helper(struct sk_buff *skb, int offset, void *ret,
4889- unsigned int size)
4890-{
4891- void *ptr = bpf_internal_load_pointer_neg_helper(skb, offset, size);
4892-
4893- if (!ptr)
4894- return -EFAULT;
4895- memcpy(ret, ptr, size);
4896- return 0;
4897-}
4898-
4899-static u64 jit_get_skb_b(struct sk_buff *skb, int offset)
4900+static u64 jit_get_skb_b(struct sk_buff *skb, unsigned offset)
4901 {
4902 u8 ret;
4903 int err;
4904
4905- if (offset < 0)
4906- err = call_neg_helper(skb, offset, &ret, 1);
4907- else
4908- err = skb_copy_bits(skb, offset, &ret, 1);
4909+ err = skb_copy_bits(skb, offset, &ret, 1);
4910
4911 return (u64)err << 32 | ret;
4912 }
4913
4914-static u64 jit_get_skb_h(struct sk_buff *skb, int offset)
4915+static u64 jit_get_skb_h(struct sk_buff *skb, unsigned offset)
4916 {
4917 u16 ret;
4918 int err;
4919
4920- if (offset < 0)
4921- err = call_neg_helper(skb, offset, &ret, 2);
4922- else
4923- err = skb_copy_bits(skb, offset, &ret, 2);
4924+ err = skb_copy_bits(skb, offset, &ret, 2);
4925
4926 return (u64)err << 32 | ntohs(ret);
4927 }
4928
4929-static u64 jit_get_skb_w(struct sk_buff *skb, int offset)
4930+static u64 jit_get_skb_w(struct sk_buff *skb, unsigned offset)
4931 {
4932 u32 ret;
4933 int err;
4934
4935- if (offset < 0)
4936- err = call_neg_helper(skb, offset, &ret, 4);
4937- else
4938- err = skb_copy_bits(skb, offset, &ret, 4);
4939+ err = skb_copy_bits(skb, offset, &ret, 4);
4940
4941 return (u64)err << 32 | ntohl(ret);
4942 }
4943@@ -199,8 +184,10 @@ static void jit_fill_hole(void *area, unsigned int size)
4944 {
4945 u32 *ptr;
4946 /* We are guaranteed to have aligned memory. */
4947+ pax_open_kernel();
4948 for (ptr = area; size >= sizeof(u32); size -= sizeof(u32))
4949 *ptr++ = __opcode_to_mem_arm(ARM_INST_UDF);
4950+ pax_close_kernel();
4951 }
4952
4953 static void build_prologue(struct jit_ctx *ctx)
4954@@ -556,6 +543,9 @@ static int build_body(struct jit_ctx *ctx)
4955 case BPF_LD | BPF_B | BPF_ABS:
4956 load_order = 0;
4957 load:
4958+ /* the interpreter will deal with the negative K */
4959+ if ((int)k < 0)
4960+ return -ENOTSUPP;
4961 emit_mov_i(r_off, k, ctx);
4962 load_common:
4963 ctx->seen |= SEEN_DATA | SEEN_CALL;
4964@@ -570,18 +560,6 @@ load_common:
4965 condt = ARM_COND_HI;
4966 }
4967
4968- /*
4969- * test for negative offset, only if we are
4970- * currently scheduled to take the fast
4971- * path. this will update the flags so that
4972- * the slowpath instruction are ignored if the
4973- * offset is negative.
4974- *
4975- * for loard_order == 0 the HI condition will
4976- * make loads at offset 0 take the slow path too.
4977- */
4978- _emit(condt, ARM_CMP_I(r_off, 0), ctx);
4979-
4980 _emit(condt, ARM_ADD_R(r_scratch, r_off, r_skb_data),
4981 ctx);
4982
4983diff --git a/arch/arm/plat-iop/setup.c b/arch/arm/plat-iop/setup.c
4984index 5b217f4..c23f40e 100644
4985--- a/arch/arm/plat-iop/setup.c
4986+++ b/arch/arm/plat-iop/setup.c
4987@@ -24,7 +24,7 @@ static struct map_desc iop3xx_std_desc[] __initdata = {
4988 .virtual = IOP3XX_PERIPHERAL_VIRT_BASE,
4989 .pfn = __phys_to_pfn(IOP3XX_PERIPHERAL_PHYS_BASE),
4990 .length = IOP3XX_PERIPHERAL_SIZE,
4991- .type = MT_UNCACHED,
4992+ .type = MT_UNCACHED_RW,
4993 },
4994 };
4995
4996diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4997index a5bc92d..0bb4730 100644
4998--- a/arch/arm/plat-omap/sram.c
4999+++ b/arch/arm/plat-omap/sram.c
5000@@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
5001 * Looks like we need to preserve some bootloader code at the
5002 * beginning of SRAM for jumping to flash for reboot to work...
5003 */
5004+ pax_open_kernel();
5005 memset_io(omap_sram_base + omap_sram_skip, 0,
5006 omap_sram_size - omap_sram_skip);
5007+ pax_close_kernel();
5008 }
5009diff --git a/arch/arm64/Kconfig.debug b/arch/arm64/Kconfig.debug
5010index d6285ef..b684dac 100644
5011--- a/arch/arm64/Kconfig.debug
5012+++ b/arch/arm64/Kconfig.debug
5013@@ -10,6 +10,7 @@ config ARM64_PTDUMP
5014 bool "Export kernel pagetable layout to userspace via debugfs"
5015 depends on DEBUG_KERNEL
5016 select DEBUG_FS
5017+ depends on !GRKERNSEC_KMEM
5018 help
5019 Say Y here if you want to show the kernel pagetable layout in a
5020 debugfs file. This information is only useful for kernel developers
5021diff --git a/arch/arm64/include/asm/atomic.h b/arch/arm64/include/asm/atomic.h
5022index 7047051..44e8675 100644
5023--- a/arch/arm64/include/asm/atomic.h
5024+++ b/arch/arm64/include/asm/atomic.h
5025@@ -252,5 +252,15 @@ static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
5026 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
5027 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
5028
5029+#define atomic64_read_unchecked(v) atomic64_read(v)
5030+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5031+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5032+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5033+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5034+#define atomic64_inc_unchecked(v) atomic64_inc(v)
5035+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5036+#define atomic64_dec_unchecked(v) atomic64_dec(v)
5037+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5038+
5039 #endif
5040 #endif
5041diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h
5042index 0fa47c4..b167938 100644
5043--- a/arch/arm64/include/asm/barrier.h
5044+++ b/arch/arm64/include/asm/barrier.h
5045@@ -44,7 +44,7 @@
5046 do { \
5047 compiletime_assert_atomic_type(*p); \
5048 barrier(); \
5049- ACCESS_ONCE(*p) = (v); \
5050+ ACCESS_ONCE_RW(*p) = (v); \
5051 } while (0)
5052
5053 #define smp_load_acquire(p) \
5054diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h
5055index 4fde8c1..441f84f 100644
5056--- a/arch/arm64/include/asm/percpu.h
5057+++ b/arch/arm64/include/asm/percpu.h
5058@@ -135,16 +135,16 @@ static inline void __percpu_write(void *ptr, unsigned long val, int size)
5059 {
5060 switch (size) {
5061 case 1:
5062- ACCESS_ONCE(*(u8 *)ptr) = (u8)val;
5063+ ACCESS_ONCE_RW(*(u8 *)ptr) = (u8)val;
5064 break;
5065 case 2:
5066- ACCESS_ONCE(*(u16 *)ptr) = (u16)val;
5067+ ACCESS_ONCE_RW(*(u16 *)ptr) = (u16)val;
5068 break;
5069 case 4:
5070- ACCESS_ONCE(*(u32 *)ptr) = (u32)val;
5071+ ACCESS_ONCE_RW(*(u32 *)ptr) = (u32)val;
5072 break;
5073 case 8:
5074- ACCESS_ONCE(*(u64 *)ptr) = (u64)val;
5075+ ACCESS_ONCE_RW(*(u64 *)ptr) = (u64)val;
5076 break;
5077 default:
5078 BUILD_BUG();
5079diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h
5080index 7642056..bffc904 100644
5081--- a/arch/arm64/include/asm/pgalloc.h
5082+++ b/arch/arm64/include/asm/pgalloc.h
5083@@ -46,6 +46,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5084 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
5085 }
5086
5087+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5088+{
5089+ pud_populate(mm, pud, pmd);
5090+}
5091+
5092 #endif /* CONFIG_PGTABLE_LEVELS > 2 */
5093
5094 #if CONFIG_PGTABLE_LEVELS > 3
5095diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
5096index 07e1ba44..ec8cbbb 100644
5097--- a/arch/arm64/include/asm/uaccess.h
5098+++ b/arch/arm64/include/asm/uaccess.h
5099@@ -99,6 +99,7 @@ static inline void set_fs(mm_segment_t fs)
5100 flag; \
5101 })
5102
5103+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
5104 #define access_ok(type, addr, size) __range_ok(addr, size)
5105 #define user_addr_max get_fs
5106
5107diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
5108index d16a1ce..a5acc60 100644
5109--- a/arch/arm64/mm/dma-mapping.c
5110+++ b/arch/arm64/mm/dma-mapping.c
5111@@ -134,7 +134,7 @@ static void __dma_free_coherent(struct device *dev, size_t size,
5112 phys_to_page(paddr),
5113 size >> PAGE_SHIFT);
5114 if (!freed)
5115- swiotlb_free_coherent(dev, size, vaddr, dma_handle);
5116+ swiotlb_free_coherent(dev, size, vaddr, dma_handle, attrs);
5117 }
5118
5119 static void *__dma_alloc(struct device *dev, size_t size,
5120diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
5121index c3a58a1..78fbf54 100644
5122--- a/arch/avr32/include/asm/cache.h
5123+++ b/arch/avr32/include/asm/cache.h
5124@@ -1,8 +1,10 @@
5125 #ifndef __ASM_AVR32_CACHE_H
5126 #define __ASM_AVR32_CACHE_H
5127
5128+#include <linux/const.h>
5129+
5130 #define L1_CACHE_SHIFT 5
5131-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5132+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5133
5134 /*
5135 * Memory returned by kmalloc() may be used for DMA, so we must make
5136diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
5137index 0388ece..87c8df1 100644
5138--- a/arch/avr32/include/asm/elf.h
5139+++ b/arch/avr32/include/asm/elf.h
5140@@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
5141 the loader. We need to make sure that it is out of the way of the program
5142 that it will "exec", and that there is sufficient room for the brk. */
5143
5144-#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5145+#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5146
5147+#ifdef CONFIG_PAX_ASLR
5148+#define PAX_ELF_ET_DYN_BASE 0x00001000UL
5149+
5150+#define PAX_DELTA_MMAP_LEN 15
5151+#define PAX_DELTA_STACK_LEN 15
5152+#endif
5153
5154 /* This yields a mask that user programs can use to figure out what
5155 instruction set this CPU supports. This could be done in user space,
5156diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
5157index 479330b..53717a8 100644
5158--- a/arch/avr32/include/asm/kmap_types.h
5159+++ b/arch/avr32/include/asm/kmap_types.h
5160@@ -2,9 +2,9 @@
5161 #define __ASM_AVR32_KMAP_TYPES_H
5162
5163 #ifdef CONFIG_DEBUG_HIGHMEM
5164-# define KM_TYPE_NR 29
5165+# define KM_TYPE_NR 30
5166 #else
5167-# define KM_TYPE_NR 14
5168+# define KM_TYPE_NR 15
5169 #endif
5170
5171 #endif /* __ASM_AVR32_KMAP_TYPES_H */
5172diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
5173index c035339..e1fa594 100644
5174--- a/arch/avr32/mm/fault.c
5175+++ b/arch/avr32/mm/fault.c
5176@@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
5177
5178 int exception_trace = 1;
5179
5180+#ifdef CONFIG_PAX_PAGEEXEC
5181+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5182+{
5183+ unsigned long i;
5184+
5185+ printk(KERN_ERR "PAX: bytes at PC: ");
5186+ for (i = 0; i < 20; i++) {
5187+ unsigned char c;
5188+ if (get_user(c, (unsigned char *)pc+i))
5189+ printk(KERN_CONT "???????? ");
5190+ else
5191+ printk(KERN_CONT "%02x ", c);
5192+ }
5193+ printk("\n");
5194+}
5195+#endif
5196+
5197 /*
5198 * This routine handles page faults. It determines the address and the
5199 * problem, and then passes it off to one of the appropriate routines.
5200@@ -178,6 +195,16 @@ bad_area:
5201 up_read(&mm->mmap_sem);
5202
5203 if (user_mode(regs)) {
5204+
5205+#ifdef CONFIG_PAX_PAGEEXEC
5206+ if (mm->pax_flags & MF_PAX_PAGEEXEC) {
5207+ if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
5208+ pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
5209+ do_group_exit(SIGKILL);
5210+ }
5211+ }
5212+#endif
5213+
5214 if (exception_trace && printk_ratelimit())
5215 printk("%s%s[%d]: segfault at %08lx pc %08lx "
5216 "sp %08lx ecr %lu\n",
5217diff --git a/arch/blackfin/Kconfig.debug b/arch/blackfin/Kconfig.debug
5218index f3337ee..15b6f8d 100644
5219--- a/arch/blackfin/Kconfig.debug
5220+++ b/arch/blackfin/Kconfig.debug
5221@@ -18,6 +18,7 @@ config DEBUG_VERBOSE
5222 config DEBUG_MMRS
5223 tristate "Generate Blackfin MMR tree"
5224 select DEBUG_FS
5225+ depends on !GRKERNSEC_KMEM
5226 help
5227 Create a tree of Blackfin MMRs via the debugfs tree. If
5228 you enable this, you will find all MMRs laid out in the
5229diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
5230index 568885a..f8008df 100644
5231--- a/arch/blackfin/include/asm/cache.h
5232+++ b/arch/blackfin/include/asm/cache.h
5233@@ -7,6 +7,7 @@
5234 #ifndef __ARCH_BLACKFIN_CACHE_H
5235 #define __ARCH_BLACKFIN_CACHE_H
5236
5237+#include <linux/const.h>
5238 #include <linux/linkage.h> /* for asmlinkage */
5239
5240 /*
5241@@ -14,7 +15,7 @@
5242 * Blackfin loads 32 bytes for cache
5243 */
5244 #define L1_CACHE_SHIFT 5
5245-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5246+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5247 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5248
5249 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5250diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
5251index aea2718..3639a60 100644
5252--- a/arch/cris/include/arch-v10/arch/cache.h
5253+++ b/arch/cris/include/arch-v10/arch/cache.h
5254@@ -1,8 +1,9 @@
5255 #ifndef _ASM_ARCH_CACHE_H
5256 #define _ASM_ARCH_CACHE_H
5257
5258+#include <linux/const.h>
5259 /* Etrax 100LX have 32-byte cache-lines. */
5260-#define L1_CACHE_BYTES 32
5261 #define L1_CACHE_SHIFT 5
5262+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5263
5264 #endif /* _ASM_ARCH_CACHE_H */
5265diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
5266index 7caf25d..ee65ac5 100644
5267--- a/arch/cris/include/arch-v32/arch/cache.h
5268+++ b/arch/cris/include/arch-v32/arch/cache.h
5269@@ -1,11 +1,12 @@
5270 #ifndef _ASM_CRIS_ARCH_CACHE_H
5271 #define _ASM_CRIS_ARCH_CACHE_H
5272
5273+#include <linux/const.h>
5274 #include <arch/hwregs/dma.h>
5275
5276 /* A cache-line is 32 bytes. */
5277-#define L1_CACHE_BYTES 32
5278 #define L1_CACHE_SHIFT 5
5279+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5280
5281 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
5282
5283diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
5284index 102190a..5334cea 100644
5285--- a/arch/frv/include/asm/atomic.h
5286+++ b/arch/frv/include/asm/atomic.h
5287@@ -181,6 +181,16 @@ static inline void atomic64_dec(atomic64_t *v)
5288 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
5289 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
5290
5291+#define atomic64_read_unchecked(v) atomic64_read(v)
5292+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5293+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5294+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5295+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5296+#define atomic64_inc_unchecked(v) atomic64_inc(v)
5297+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5298+#define atomic64_dec_unchecked(v) atomic64_dec(v)
5299+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5300+
5301 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5302 {
5303 int c, old;
5304diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
5305index 2797163..c2a401df9 100644
5306--- a/arch/frv/include/asm/cache.h
5307+++ b/arch/frv/include/asm/cache.h
5308@@ -12,10 +12,11 @@
5309 #ifndef __ASM_CACHE_H
5310 #define __ASM_CACHE_H
5311
5312+#include <linux/const.h>
5313
5314 /* bytes per L1 cache line */
5315 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
5316-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5317+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5318
5319 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
5320 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
5321diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
5322index 43901f2..0d8b865 100644
5323--- a/arch/frv/include/asm/kmap_types.h
5324+++ b/arch/frv/include/asm/kmap_types.h
5325@@ -2,6 +2,6 @@
5326 #ifndef _ASM_KMAP_TYPES_H
5327 #define _ASM_KMAP_TYPES_H
5328
5329-#define KM_TYPE_NR 17
5330+#define KM_TYPE_NR 18
5331
5332 #endif
5333diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
5334index 836f147..4cf23f5 100644
5335--- a/arch/frv/mm/elf-fdpic.c
5336+++ b/arch/frv/mm/elf-fdpic.c
5337@@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5338 {
5339 struct vm_area_struct *vma;
5340 struct vm_unmapped_area_info info;
5341+ unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5342
5343 if (len > TASK_SIZE)
5344 return -ENOMEM;
5345@@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5346 if (addr) {
5347 addr = PAGE_ALIGN(addr);
5348 vma = find_vma(current->mm, addr);
5349- if (TASK_SIZE - len >= addr &&
5350- (!vma || addr + len <= vma->vm_start))
5351+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
5352 goto success;
5353 }
5354
5355@@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5356 info.high_limit = (current->mm->start_stack - 0x00200000);
5357 info.align_mask = 0;
5358 info.align_offset = 0;
5359+ info.threadstack_offset = offset;
5360 addr = vm_unmapped_area(&info);
5361 if (!(addr & ~PAGE_MASK))
5362 goto success;
5363diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
5364index 69952c18..4fa2908 100644
5365--- a/arch/hexagon/include/asm/cache.h
5366+++ b/arch/hexagon/include/asm/cache.h
5367@@ -21,9 +21,11 @@
5368 #ifndef __ASM_CACHE_H
5369 #define __ASM_CACHE_H
5370
5371+#include <linux/const.h>
5372+
5373 /* Bytes per L1 cache line */
5374-#define L1_CACHE_SHIFT (5)
5375-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5376+#define L1_CACHE_SHIFT 5
5377+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5378
5379 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5380
5381diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
5382index 42a91a7..29d446e 100644
5383--- a/arch/ia64/Kconfig
5384+++ b/arch/ia64/Kconfig
5385@@ -518,6 +518,7 @@ source "drivers/sn/Kconfig"
5386 config KEXEC
5387 bool "kexec system call"
5388 depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
5389+ depends on !GRKERNSEC_KMEM
5390 help
5391 kexec is a system call that implements the ability to shutdown your
5392 current kernel, and to start another kernel. It is like a reboot
5393diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
5394index 970d0bd..e750b9b 100644
5395--- a/arch/ia64/Makefile
5396+++ b/arch/ia64/Makefile
5397@@ -98,5 +98,6 @@ endef
5398 archprepare: make_nr_irqs_h FORCE
5399 PHONY += make_nr_irqs_h FORCE
5400
5401+make_nr_irqs_h: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
5402 make_nr_irqs_h: FORCE
5403 $(Q)$(MAKE) $(build)=arch/ia64/kernel include/generated/nr-irqs.h
5404diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
5405index 0bf0350..2ad1957 100644
5406--- a/arch/ia64/include/asm/atomic.h
5407+++ b/arch/ia64/include/asm/atomic.h
5408@@ -193,4 +193,14 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
5409 #define atomic64_inc(v) atomic64_add(1, (v))
5410 #define atomic64_dec(v) atomic64_sub(1, (v))
5411
5412+#define atomic64_read_unchecked(v) atomic64_read(v)
5413+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5414+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5415+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5416+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5417+#define atomic64_inc_unchecked(v) atomic64_inc(v)
5418+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5419+#define atomic64_dec_unchecked(v) atomic64_dec(v)
5420+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5421+
5422 #endif /* _ASM_IA64_ATOMIC_H */
5423diff --git a/arch/ia64/include/asm/barrier.h b/arch/ia64/include/asm/barrier.h
5424index 843ba43..fa118fb 100644
5425--- a/arch/ia64/include/asm/barrier.h
5426+++ b/arch/ia64/include/asm/barrier.h
5427@@ -66,7 +66,7 @@
5428 do { \
5429 compiletime_assert_atomic_type(*p); \
5430 barrier(); \
5431- ACCESS_ONCE(*p) = (v); \
5432+ ACCESS_ONCE_RW(*p) = (v); \
5433 } while (0)
5434
5435 #define smp_load_acquire(p) \
5436diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
5437index 988254a..e1ee885 100644
5438--- a/arch/ia64/include/asm/cache.h
5439+++ b/arch/ia64/include/asm/cache.h
5440@@ -1,6 +1,7 @@
5441 #ifndef _ASM_IA64_CACHE_H
5442 #define _ASM_IA64_CACHE_H
5443
5444+#include <linux/const.h>
5445
5446 /*
5447 * Copyright (C) 1998-2000 Hewlett-Packard Co
5448@@ -9,7 +10,7 @@
5449
5450 /* Bytes per L1 (data) cache line. */
5451 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
5452-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5453+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5454
5455 #ifdef CONFIG_SMP
5456 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5457diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
5458index 5a83c5c..4d7f553 100644
5459--- a/arch/ia64/include/asm/elf.h
5460+++ b/arch/ia64/include/asm/elf.h
5461@@ -42,6 +42,13 @@
5462 */
5463 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
5464
5465+#ifdef CONFIG_PAX_ASLR
5466+#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
5467+
5468+#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
5469+#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
5470+#endif
5471+
5472 #define PT_IA_64_UNWIND 0x70000001
5473
5474 /* IA-64 relocations: */
5475diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
5476index f5e70e9..624fad5 100644
5477--- a/arch/ia64/include/asm/pgalloc.h
5478+++ b/arch/ia64/include/asm/pgalloc.h
5479@@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
5480 pgd_val(*pgd_entry) = __pa(pud);
5481 }
5482
5483+static inline void
5484+pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
5485+{
5486+ pgd_populate(mm, pgd_entry, pud);
5487+}
5488+
5489 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
5490 {
5491 return quicklist_alloc(0, GFP_KERNEL, NULL);
5492@@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
5493 pud_val(*pud_entry) = __pa(pmd);
5494 }
5495
5496+static inline void
5497+pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
5498+{
5499+ pud_populate(mm, pud_entry, pmd);
5500+}
5501+
5502 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
5503 {
5504 return quicklist_alloc(0, GFP_KERNEL, NULL);
5505diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
5506index 9f3ed9e..c99b418 100644
5507--- a/arch/ia64/include/asm/pgtable.h
5508+++ b/arch/ia64/include/asm/pgtable.h
5509@@ -12,7 +12,7 @@
5510 * David Mosberger-Tang <davidm@hpl.hp.com>
5511 */
5512
5513-
5514+#include <linux/const.h>
5515 #include <asm/mman.h>
5516 #include <asm/page.h>
5517 #include <asm/processor.h>
5518@@ -139,6 +139,17 @@
5519 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5520 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5521 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
5522+
5523+#ifdef CONFIG_PAX_PAGEEXEC
5524+# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
5525+# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5526+# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5527+#else
5528+# define PAGE_SHARED_NOEXEC PAGE_SHARED
5529+# define PAGE_READONLY_NOEXEC PAGE_READONLY
5530+# define PAGE_COPY_NOEXEC PAGE_COPY
5531+#endif
5532+
5533 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
5534 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
5535 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
5536diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
5537index 45698cd..e8e2dbc 100644
5538--- a/arch/ia64/include/asm/spinlock.h
5539+++ b/arch/ia64/include/asm/spinlock.h
5540@@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
5541 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
5542
5543 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
5544- ACCESS_ONCE(*p) = (tmp + 2) & ~1;
5545+ ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
5546 }
5547
5548 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
5549diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
5550index 4f3fb6cc..254055e 100644
5551--- a/arch/ia64/include/asm/uaccess.h
5552+++ b/arch/ia64/include/asm/uaccess.h
5553@@ -70,6 +70,7 @@
5554 && ((segment).seg == KERNEL_DS.seg \
5555 || likely(REGION_OFFSET((unsigned long) (addr)) < RGN_MAP_LIMIT))); \
5556 })
5557+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
5558 #define access_ok(type, addr, size) __access_ok((addr), (size), get_fs())
5559
5560 /*
5561@@ -241,12 +242,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
5562 static inline unsigned long
5563 __copy_to_user (void __user *to, const void *from, unsigned long count)
5564 {
5565+ if (count > INT_MAX)
5566+ return count;
5567+
5568+ if (!__builtin_constant_p(count))
5569+ check_object_size(from, count, true);
5570+
5571 return __copy_user(to, (__force void __user *) from, count);
5572 }
5573
5574 static inline unsigned long
5575 __copy_from_user (void *to, const void __user *from, unsigned long count)
5576 {
5577+ if (count > INT_MAX)
5578+ return count;
5579+
5580+ if (!__builtin_constant_p(count))
5581+ check_object_size(to, count, false);
5582+
5583 return __copy_user((__force void __user *) to, from, count);
5584 }
5585
5586@@ -256,10 +269,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5587 ({ \
5588 void __user *__cu_to = (to); \
5589 const void *__cu_from = (from); \
5590- long __cu_len = (n); \
5591+ unsigned long __cu_len = (n); \
5592 \
5593- if (__access_ok(__cu_to, __cu_len, get_fs())) \
5594+ if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5595+ if (!__builtin_constant_p(n)) \
5596+ check_object_size(__cu_from, __cu_len, true); \
5597 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5598+ } \
5599 __cu_len; \
5600 })
5601
5602@@ -267,11 +283,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5603 ({ \
5604 void *__cu_to = (to); \
5605 const void __user *__cu_from = (from); \
5606- long __cu_len = (n); \
5607+ unsigned long __cu_len = (n); \
5608 \
5609 __chk_user_ptr(__cu_from); \
5610- if (__access_ok(__cu_from, __cu_len, get_fs())) \
5611+ if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5612+ if (!__builtin_constant_p(n)) \
5613+ check_object_size(__cu_to, __cu_len, false); \
5614 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5615+ } \
5616 __cu_len; \
5617 })
5618
5619diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5620index b15933c..098b1c8 100644
5621--- a/arch/ia64/kernel/module.c
5622+++ b/arch/ia64/kernel/module.c
5623@@ -484,15 +484,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5624 }
5625
5626 static inline int
5627+in_init_rx (const struct module *mod, uint64_t addr)
5628+{
5629+ return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5630+}
5631+
5632+static inline int
5633+in_init_rw (const struct module *mod, uint64_t addr)
5634+{
5635+ return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5636+}
5637+
5638+static inline int
5639 in_init (const struct module *mod, uint64_t addr)
5640 {
5641- return addr - (uint64_t) mod->module_init < mod->init_size;
5642+ return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5643+}
5644+
5645+static inline int
5646+in_core_rx (const struct module *mod, uint64_t addr)
5647+{
5648+ return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5649+}
5650+
5651+static inline int
5652+in_core_rw (const struct module *mod, uint64_t addr)
5653+{
5654+ return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5655 }
5656
5657 static inline int
5658 in_core (const struct module *mod, uint64_t addr)
5659 {
5660- return addr - (uint64_t) mod->module_core < mod->core_size;
5661+ return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5662 }
5663
5664 static inline int
5665@@ -675,7 +699,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5666 break;
5667
5668 case RV_BDREL:
5669- val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5670+ if (in_init_rx(mod, val))
5671+ val -= (uint64_t) mod->module_init_rx;
5672+ else if (in_init_rw(mod, val))
5673+ val -= (uint64_t) mod->module_init_rw;
5674+ else if (in_core_rx(mod, val))
5675+ val -= (uint64_t) mod->module_core_rx;
5676+ else if (in_core_rw(mod, val))
5677+ val -= (uint64_t) mod->module_core_rw;
5678 break;
5679
5680 case RV_LTV:
5681@@ -810,15 +841,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5682 * addresses have been selected...
5683 */
5684 uint64_t gp;
5685- if (mod->core_size > MAX_LTOFF)
5686+ if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5687 /*
5688 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5689 * at the end of the module.
5690 */
5691- gp = mod->core_size - MAX_LTOFF / 2;
5692+ gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5693 else
5694- gp = mod->core_size / 2;
5695- gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5696+ gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5697+ gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5698 mod->arch.gp = gp;
5699 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5700 }
5701diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5702index c39c3cd..3c77738 100644
5703--- a/arch/ia64/kernel/palinfo.c
5704+++ b/arch/ia64/kernel/palinfo.c
5705@@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5706 return NOTIFY_OK;
5707 }
5708
5709-static struct notifier_block __refdata palinfo_cpu_notifier =
5710+static struct notifier_block palinfo_cpu_notifier =
5711 {
5712 .notifier_call = palinfo_cpu_callback,
5713 .priority = 0,
5714diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5715index 41e33f8..65180b2a 100644
5716--- a/arch/ia64/kernel/sys_ia64.c
5717+++ b/arch/ia64/kernel/sys_ia64.c
5718@@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5719 unsigned long align_mask = 0;
5720 struct mm_struct *mm = current->mm;
5721 struct vm_unmapped_area_info info;
5722+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5723
5724 if (len > RGN_MAP_LIMIT)
5725 return -ENOMEM;
5726@@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5727 if (REGION_NUMBER(addr) == RGN_HPAGE)
5728 addr = 0;
5729 #endif
5730+
5731+#ifdef CONFIG_PAX_RANDMMAP
5732+ if (mm->pax_flags & MF_PAX_RANDMMAP)
5733+ addr = mm->free_area_cache;
5734+ else
5735+#endif
5736+
5737 if (!addr)
5738 addr = TASK_UNMAPPED_BASE;
5739
5740@@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5741 info.high_limit = TASK_SIZE;
5742 info.align_mask = align_mask;
5743 info.align_offset = 0;
5744+ info.threadstack_offset = offset;
5745 return vm_unmapped_area(&info);
5746 }
5747
5748diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5749index dc506b0..39baade 100644
5750--- a/arch/ia64/kernel/vmlinux.lds.S
5751+++ b/arch/ia64/kernel/vmlinux.lds.S
5752@@ -171,7 +171,7 @@ SECTIONS {
5753 /* Per-cpu data: */
5754 . = ALIGN(PERCPU_PAGE_SIZE);
5755 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5756- __phys_per_cpu_start = __per_cpu_load;
5757+ __phys_per_cpu_start = per_cpu_load;
5758 /*
5759 * ensure percpu data fits
5760 * into percpu page size
5761diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5762index 70b40d1..01a9a28 100644
5763--- a/arch/ia64/mm/fault.c
5764+++ b/arch/ia64/mm/fault.c
5765@@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5766 return pte_present(pte);
5767 }
5768
5769+#ifdef CONFIG_PAX_PAGEEXEC
5770+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5771+{
5772+ unsigned long i;
5773+
5774+ printk(KERN_ERR "PAX: bytes at PC: ");
5775+ for (i = 0; i < 8; i++) {
5776+ unsigned int c;
5777+ if (get_user(c, (unsigned int *)pc+i))
5778+ printk(KERN_CONT "???????? ");
5779+ else
5780+ printk(KERN_CONT "%08x ", c);
5781+ }
5782+ printk("\n");
5783+}
5784+#endif
5785+
5786 # define VM_READ_BIT 0
5787 # define VM_WRITE_BIT 1
5788 # define VM_EXEC_BIT 2
5789@@ -151,8 +168,21 @@ retry:
5790 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5791 goto bad_area;
5792
5793- if ((vma->vm_flags & mask) != mask)
5794+ if ((vma->vm_flags & mask) != mask) {
5795+
5796+#ifdef CONFIG_PAX_PAGEEXEC
5797+ if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5798+ if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5799+ goto bad_area;
5800+
5801+ up_read(&mm->mmap_sem);
5802+ pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5803+ do_group_exit(SIGKILL);
5804+ }
5805+#endif
5806+
5807 goto bad_area;
5808+ }
5809
5810 /*
5811 * If for any reason at all we couldn't handle the fault, make
5812diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5813index f50d4b3..c7975ee 100644
5814--- a/arch/ia64/mm/hugetlbpage.c
5815+++ b/arch/ia64/mm/hugetlbpage.c
5816@@ -138,6 +138,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5817 unsigned long pgoff, unsigned long flags)
5818 {
5819 struct vm_unmapped_area_info info;
5820+ unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5821
5822 if (len > RGN_MAP_LIMIT)
5823 return -ENOMEM;
5824@@ -161,6 +162,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5825 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5826 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5827 info.align_offset = 0;
5828+ info.threadstack_offset = offset;
5829 return vm_unmapped_area(&info);
5830 }
5831
5832diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5833index 97e48b0..fc59c36 100644
5834--- a/arch/ia64/mm/init.c
5835+++ b/arch/ia64/mm/init.c
5836@@ -119,6 +119,19 @@ ia64_init_addr_space (void)
5837 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5838 vma->vm_end = vma->vm_start + PAGE_SIZE;
5839 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5840+
5841+#ifdef CONFIG_PAX_PAGEEXEC
5842+ if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5843+ vma->vm_flags &= ~VM_EXEC;
5844+
5845+#ifdef CONFIG_PAX_MPROTECT
5846+ if (current->mm->pax_flags & MF_PAX_MPROTECT)
5847+ vma->vm_flags &= ~VM_MAYEXEC;
5848+#endif
5849+
5850+ }
5851+#endif
5852+
5853 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5854 down_write(&current->mm->mmap_sem);
5855 if (insert_vm_struct(current->mm, vma)) {
5856@@ -279,7 +292,7 @@ static int __init gate_vma_init(void)
5857 gate_vma.vm_start = FIXADDR_USER_START;
5858 gate_vma.vm_end = FIXADDR_USER_END;
5859 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
5860- gate_vma.vm_page_prot = __P101;
5861+ gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
5862
5863 return 0;
5864 }
5865diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5866index 40b3ee98..8c2c112 100644
5867--- a/arch/m32r/include/asm/cache.h
5868+++ b/arch/m32r/include/asm/cache.h
5869@@ -1,8 +1,10 @@
5870 #ifndef _ASM_M32R_CACHE_H
5871 #define _ASM_M32R_CACHE_H
5872
5873+#include <linux/const.h>
5874+
5875 /* L1 cache line size */
5876 #define L1_CACHE_SHIFT 4
5877-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5878+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5879
5880 #endif /* _ASM_M32R_CACHE_H */
5881diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5882index 82abd15..d95ae5d 100644
5883--- a/arch/m32r/lib/usercopy.c
5884+++ b/arch/m32r/lib/usercopy.c
5885@@ -14,6 +14,9 @@
5886 unsigned long
5887 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5888 {
5889+ if ((long)n < 0)
5890+ return n;
5891+
5892 prefetch(from);
5893 if (access_ok(VERIFY_WRITE, to, n))
5894 __copy_user(to,from,n);
5895@@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5896 unsigned long
5897 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5898 {
5899+ if ((long)n < 0)
5900+ return n;
5901+
5902 prefetchw(to);
5903 if (access_ok(VERIFY_READ, from, n))
5904 __copy_user_zeroing(to,from,n);
5905diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5906index 0395c51..5f26031 100644
5907--- a/arch/m68k/include/asm/cache.h
5908+++ b/arch/m68k/include/asm/cache.h
5909@@ -4,9 +4,11 @@
5910 #ifndef __ARCH_M68K_CACHE_H
5911 #define __ARCH_M68K_CACHE_H
5912
5913+#include <linux/const.h>
5914+
5915 /* bytes per L1 cache line */
5916 #define L1_CACHE_SHIFT 4
5917-#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5918+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5919
5920 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5921
5922diff --git a/arch/metag/include/asm/barrier.h b/arch/metag/include/asm/barrier.h
5923index 5a696e5..070490d 100644
5924--- a/arch/metag/include/asm/barrier.h
5925+++ b/arch/metag/include/asm/barrier.h
5926@@ -90,7 +90,7 @@ static inline void fence(void)
5927 do { \
5928 compiletime_assert_atomic_type(*p); \
5929 smp_mb(); \
5930- ACCESS_ONCE(*p) = (v); \
5931+ ACCESS_ONCE_RW(*p) = (v); \
5932 } while (0)
5933
5934 #define smp_load_acquire(p) \
5935diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5936index 53f0f6c..2dc07fd 100644
5937--- a/arch/metag/mm/hugetlbpage.c
5938+++ b/arch/metag/mm/hugetlbpage.c
5939@@ -189,6 +189,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5940 info.high_limit = TASK_SIZE;
5941 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5942 info.align_offset = 0;
5943+ info.threadstack_offset = 0;
5944 return vm_unmapped_area(&info);
5945 }
5946
5947diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5948index 4efe96a..60e8699 100644
5949--- a/arch/microblaze/include/asm/cache.h
5950+++ b/arch/microblaze/include/asm/cache.h
5951@@ -13,11 +13,12 @@
5952 #ifndef _ASM_MICROBLAZE_CACHE_H
5953 #define _ASM_MICROBLAZE_CACHE_H
5954
5955+#include <linux/const.h>
5956 #include <asm/registers.h>
5957
5958 #define L1_CACHE_SHIFT 5
5959 /* word-granular cache in microblaze */
5960-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5961+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5962
5963 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5964
5965diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
5966index 199a835..822b487 100644
5967--- a/arch/mips/Kconfig
5968+++ b/arch/mips/Kconfig
5969@@ -2591,6 +2591,7 @@ source "kernel/Kconfig.preempt"
5970
5971 config KEXEC
5972 bool "Kexec system call"
5973+ depends on !GRKERNSEC_KMEM
5974 help
5975 kexec is a system call that implements the ability to shutdown your
5976 current kernel, and to start another kernel. It is like a reboot
5977diff --git a/arch/mips/cavium-octeon/dma-octeon.c b/arch/mips/cavium-octeon/dma-octeon.c
5978index d8960d4..77dbd31 100644
5979--- a/arch/mips/cavium-octeon/dma-octeon.c
5980+++ b/arch/mips/cavium-octeon/dma-octeon.c
5981@@ -199,7 +199,7 @@ static void octeon_dma_free_coherent(struct device *dev, size_t size,
5982 if (dma_release_from_coherent(dev, order, vaddr))
5983 return;
5984
5985- swiotlb_free_coherent(dev, size, vaddr, dma_handle);
5986+ swiotlb_free_coherent(dev, size, vaddr, dma_handle, attrs);
5987 }
5988
5989 static dma_addr_t octeon_unity_phys_to_dma(struct device *dev, phys_addr_t paddr)
5990diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5991index 26d4363..3c9a82e 100644
5992--- a/arch/mips/include/asm/atomic.h
5993+++ b/arch/mips/include/asm/atomic.h
5994@@ -22,15 +22,39 @@
5995 #include <asm/cmpxchg.h>
5996 #include <asm/war.h>
5997
5998+#ifdef CONFIG_GENERIC_ATOMIC64
5999+#include <asm-generic/atomic64.h>
6000+#endif
6001+
6002 #define ATOMIC_INIT(i) { (i) }
6003
6004+#ifdef CONFIG_64BIT
6005+#define _ASM_EXTABLE(from, to) \
6006+" .section __ex_table,\"a\"\n" \
6007+" .dword " #from ", " #to"\n" \
6008+" .previous\n"
6009+#else
6010+#define _ASM_EXTABLE(from, to) \
6011+" .section __ex_table,\"a\"\n" \
6012+" .word " #from ", " #to"\n" \
6013+" .previous\n"
6014+#endif
6015+
6016 /*
6017 * atomic_read - read atomic variable
6018 * @v: pointer of type atomic_t
6019 *
6020 * Atomically reads the value of @v.
6021 */
6022-#define atomic_read(v) ACCESS_ONCE((v)->counter)
6023+static inline int atomic_read(const atomic_t *v)
6024+{
6025+ return ACCESS_ONCE(v->counter);
6026+}
6027+
6028+static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
6029+{
6030+ return ACCESS_ONCE(v->counter);
6031+}
6032
6033 /*
6034 * atomic_set - set atomic variable
6035@@ -39,47 +63,77 @@
6036 *
6037 * Atomically sets the value of @v to @i.
6038 */
6039-#define atomic_set(v, i) ((v)->counter = (i))
6040+static inline void atomic_set(atomic_t *v, int i)
6041+{
6042+ v->counter = i;
6043+}
6044
6045-#define ATOMIC_OP(op, c_op, asm_op) \
6046-static __inline__ void atomic_##op(int i, atomic_t * v) \
6047+static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
6048+{
6049+ v->counter = i;
6050+}
6051+
6052+#ifdef CONFIG_PAX_REFCOUNT
6053+#define __OVERFLOW_POST \
6054+ " b 4f \n" \
6055+ " .set noreorder \n" \
6056+ "3: b 5f \n" \
6057+ " move %0, %1 \n" \
6058+ " .set reorder \n"
6059+#define __OVERFLOW_EXTABLE \
6060+ "3:\n" \
6061+ _ASM_EXTABLE(2b, 3b)
6062+#else
6063+#define __OVERFLOW_POST
6064+#define __OVERFLOW_EXTABLE
6065+#endif
6066+
6067+#define __ATOMIC_OP(op, suffix, asm_op, extable) \
6068+static inline void atomic_##op##suffix(int i, atomic##suffix##_t * v) \
6069 { \
6070 if (kernel_uses_llsc && R10000_LLSC_WAR) { \
6071 int temp; \
6072 \
6073 __asm__ __volatile__( \
6074- " .set arch=r4000 \n" \
6075- "1: ll %0, %1 # atomic_" #op " \n" \
6076- " " #asm_op " %0, %2 \n" \
6077+ " .set mips3 \n" \
6078+ "1: ll %0, %1 # atomic_" #op #suffix "\n" \
6079+ "2: " #asm_op " %0, %2 \n" \
6080 " sc %0, %1 \n" \
6081 " beqzl %0, 1b \n" \
6082+ extable \
6083 " .set mips0 \n" \
6084 : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6085 : "Ir" (i)); \
6086 } else if (kernel_uses_llsc) { \
6087 int temp; \
6088 \
6089- do { \
6090- __asm__ __volatile__( \
6091- " .set "MIPS_ISA_LEVEL" \n" \
6092- " ll %0, %1 # atomic_" #op "\n" \
6093- " " #asm_op " %0, %2 \n" \
6094- " sc %0, %1 \n" \
6095- " .set mips0 \n" \
6096- : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6097- : "Ir" (i)); \
6098- } while (unlikely(!temp)); \
6099+ __asm__ __volatile__( \
6100+ " .set "MIPS_ISA_LEVEL" \n" \
6101+ "1: ll %0, %1 # atomic_" #op #suffix "\n" \
6102+ "2: " #asm_op " %0, %2 \n" \
6103+ " sc %0, %1 \n" \
6104+ " beqz %0, 1b \n" \
6105+ extable \
6106+ " .set mips0 \n" \
6107+ : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6108+ : "Ir" (i)); \
6109 } else { \
6110 unsigned long flags; \
6111 \
6112 raw_local_irq_save(flags); \
6113- v->counter c_op i; \
6114+ __asm__ __volatile__( \
6115+ "2: " #asm_op " %0, %1 \n" \
6116+ extable \
6117+ : "+r" (v->counter) : "Ir" (i)); \
6118 raw_local_irq_restore(flags); \
6119 } \
6120 }
6121
6122-#define ATOMIC_OP_RETURN(op, c_op, asm_op) \
6123-static __inline__ int atomic_##op##_return(int i, atomic_t * v) \
6124+#define ATOMIC_OP(op, asm_op) __ATOMIC_OP(op, _unchecked, asm_op##u, ) \
6125+ __ATOMIC_OP(op, , asm_op, __OVERFLOW_EXTABLE)
6126+
6127+#define __ATOMIC_OP_RETURN(op, suffix, asm_op, post_op, extable) \
6128+static inline int atomic_##op##_return##suffix(int i, atomic##suffix##_t * v) \
6129 { \
6130 int result; \
6131 \
6132@@ -89,12 +143,15 @@ static __inline__ int atomic_##op##_return(int i, atomic_t * v) \
6133 int temp; \
6134 \
6135 __asm__ __volatile__( \
6136- " .set arch=r4000 \n" \
6137- "1: ll %1, %2 # atomic_" #op "_return \n" \
6138- " " #asm_op " %0, %1, %3 \n" \
6139+ " .set mips3 \n" \
6140+ "1: ll %1, %2 # atomic_" #op "_return" #suffix"\n" \
6141+ "2: " #asm_op " %0, %1, %3 \n" \
6142 " sc %0, %2 \n" \
6143 " beqzl %0, 1b \n" \
6144- " " #asm_op " %0, %1, %3 \n" \
6145+ post_op \
6146+ extable \
6147+ "4: " #asm_op " %0, %1, %3 \n" \
6148+ "5: \n" \
6149 " .set mips0 \n" \
6150 : "=&r" (result), "=&r" (temp), \
6151 "+" GCC_OFF_SMALL_ASM() (v->counter) \
6152@@ -102,26 +159,33 @@ static __inline__ int atomic_##op##_return(int i, atomic_t * v) \
6153 } else if (kernel_uses_llsc) { \
6154 int temp; \
6155 \
6156- do { \
6157- __asm__ __volatile__( \
6158- " .set "MIPS_ISA_LEVEL" \n" \
6159- " ll %1, %2 # atomic_" #op "_return \n" \
6160- " " #asm_op " %0, %1, %3 \n" \
6161- " sc %0, %2 \n" \
6162- " .set mips0 \n" \
6163- : "=&r" (result), "=&r" (temp), \
6164- "+" GCC_OFF_SMALL_ASM() (v->counter) \
6165- : "Ir" (i)); \
6166- } while (unlikely(!result)); \
6167+ __asm__ __volatile__( \
6168+ " .set "MIPS_ISA_LEVEL" \n" \
6169+ "1: ll %1, %2 # atomic_" #op "_return" #suffix "\n" \
6170+ "2: " #asm_op " %0, %1, %3 \n" \
6171+ " sc %0, %2 \n" \
6172+ post_op \
6173+ extable \
6174+ "4: " #asm_op " %0, %1, %3 \n" \
6175+ "5: \n" \
6176+ " .set mips0 \n" \
6177+ : "=&r" (result), "=&r" (temp), \
6178+ "+" GCC_OFF_SMALL_ASM() (v->counter) \
6179+ : "Ir" (i)); \
6180 \
6181 result = temp; result c_op i; \
6182 } else { \
6183 unsigned long flags; \
6184 \
6185 raw_local_irq_save(flags); \
6186- result = v->counter; \
6187- result c_op i; \
6188- v->counter = result; \
6189+ __asm__ __volatile__( \
6190+ " lw %0, %1 \n" \
6191+ "2: " #asm_op " %0, %1, %2 \n" \
6192+ " sw %0, %1 \n" \
6193+ "3: \n" \
6194+ extable \
6195+ : "=&r" (result), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6196+ : "Ir" (i)); \
6197 raw_local_irq_restore(flags); \
6198 } \
6199 \
6200@@ -130,16 +194,21 @@ static __inline__ int atomic_##op##_return(int i, atomic_t * v) \
6201 return result; \
6202 }
6203
6204-#define ATOMIC_OPS(op, c_op, asm_op) \
6205- ATOMIC_OP(op, c_op, asm_op) \
6206- ATOMIC_OP_RETURN(op, c_op, asm_op)
6207+#define ATOMIC_OP_RETURN(op, asm_op) __ATOMIC_OP_RETURN(op, _unchecked, asm_op##u, , ) \
6208+ __ATOMIC_OP_RETURN(op, , asm_op, __OVERFLOW_POST, __OVERFLOW_EXTABLE)
6209
6210-ATOMIC_OPS(add, +=, addu)
6211-ATOMIC_OPS(sub, -=, subu)
6212+#define ATOMIC_OPS(op, asm_op) \
6213+ ATOMIC_OP(op, asm_op) \
6214+ ATOMIC_OP_RETURN(op, asm_op)
6215+
6216+ATOMIC_OPS(add, add)
6217+ATOMIC_OPS(sub, sub)
6218
6219 #undef ATOMIC_OPS
6220 #undef ATOMIC_OP_RETURN
6221+#undef __ATOMIC_OP_RETURN
6222 #undef ATOMIC_OP
6223+#undef __ATOMIC_OP
6224
6225 /*
6226 * atomic_sub_if_positive - conditionally subtract integer from atomic variable
6227@@ -149,7 +218,7 @@ ATOMIC_OPS(sub, -=, subu)
6228 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6229 * The function returns the old value of @v minus @i.
6230 */
6231-static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
6232+static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
6233 {
6234 int result;
6235
6236@@ -159,7 +228,7 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
6237 int temp;
6238
6239 __asm__ __volatile__(
6240- " .set arch=r4000 \n"
6241+ " .set "MIPS_ISA_LEVEL" \n"
6242 "1: ll %1, %2 # atomic_sub_if_positive\n"
6243 " subu %0, %1, %3 \n"
6244 " bltz %0, 1f \n"
6245@@ -208,8 +277,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
6246 return result;
6247 }
6248
6249-#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
6250-#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
6251+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
6252+{
6253+ return cmpxchg(&v->counter, old, new);
6254+}
6255+
6256+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
6257+ int new)
6258+{
6259+ return cmpxchg(&(v->counter), old, new);
6260+}
6261+
6262+static inline int atomic_xchg(atomic_t *v, int new)
6263+{
6264+ return xchg(&v->counter, new);
6265+}
6266+
6267+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
6268+{
6269+ return xchg(&(v->counter), new);
6270+}
6271
6272 /**
6273 * __atomic_add_unless - add unless the number is a given value
6274@@ -237,6 +324,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6275
6276 #define atomic_dec_return(v) atomic_sub_return(1, (v))
6277 #define atomic_inc_return(v) atomic_add_return(1, (v))
6278+static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
6279+{
6280+ return atomic_add_return_unchecked(1, v);
6281+}
6282
6283 /*
6284 * atomic_sub_and_test - subtract value from variable and test result
6285@@ -258,6 +349,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6286 * other cases.
6287 */
6288 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
6289+static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
6290+{
6291+ return atomic_add_return_unchecked(1, v) == 0;
6292+}
6293
6294 /*
6295 * atomic_dec_and_test - decrement by 1 and test
6296@@ -282,6 +377,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6297 * Atomically increments @v by 1.
6298 */
6299 #define atomic_inc(v) atomic_add(1, (v))
6300+static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
6301+{
6302+ atomic_add_unchecked(1, v);
6303+}
6304
6305 /*
6306 * atomic_dec - decrement and test
6307@@ -290,6 +389,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6308 * Atomically decrements @v by 1.
6309 */
6310 #define atomic_dec(v) atomic_sub(1, (v))
6311+static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
6312+{
6313+ atomic_sub_unchecked(1, v);
6314+}
6315
6316 /*
6317 * atomic_add_negative - add and test if negative
6318@@ -311,54 +414,77 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6319 * @v: pointer of type atomic64_t
6320 *
6321 */
6322-#define atomic64_read(v) ACCESS_ONCE((v)->counter)
6323+static inline long atomic64_read(const atomic64_t *v)
6324+{
6325+ return ACCESS_ONCE(v->counter);
6326+}
6327+
6328+static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
6329+{
6330+ return ACCESS_ONCE(v->counter);
6331+}
6332
6333 /*
6334 * atomic64_set - set atomic variable
6335 * @v: pointer of type atomic64_t
6336 * @i: required value
6337 */
6338-#define atomic64_set(v, i) ((v)->counter = (i))
6339+static inline void atomic64_set(atomic64_t *v, long i)
6340+{
6341+ v->counter = i;
6342+}
6343
6344-#define ATOMIC64_OP(op, c_op, asm_op) \
6345-static __inline__ void atomic64_##op(long i, atomic64_t * v) \
6346+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
6347+{
6348+ v->counter = i;
6349+}
6350+
6351+#define __ATOMIC64_OP(op, suffix, asm_op, extable) \
6352+static inline void atomic64_##op##suffix(long i, atomic64##suffix##_t * v) \
6353 { \
6354 if (kernel_uses_llsc && R10000_LLSC_WAR) { \
6355 long temp; \
6356 \
6357 __asm__ __volatile__( \
6358- " .set arch=r4000 \n" \
6359- "1: lld %0, %1 # atomic64_" #op " \n" \
6360- " " #asm_op " %0, %2 \n" \
6361+ " .set "MIPS_ISA_LEVEL" \n" \
6362+ "1: lld %0, %1 # atomic64_" #op #suffix "\n" \
6363+ "2: " #asm_op " %0, %2 \n" \
6364 " scd %0, %1 \n" \
6365 " beqzl %0, 1b \n" \
6366+ extable \
6367 " .set mips0 \n" \
6368 : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6369 : "Ir" (i)); \
6370 } else if (kernel_uses_llsc) { \
6371 long temp; \
6372 \
6373- do { \
6374- __asm__ __volatile__( \
6375- " .set "MIPS_ISA_LEVEL" \n" \
6376- " lld %0, %1 # atomic64_" #op "\n" \
6377- " " #asm_op " %0, %2 \n" \
6378- " scd %0, %1 \n" \
6379- " .set mips0 \n" \
6380- : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6381- : "Ir" (i)); \
6382- } while (unlikely(!temp)); \
6383+ __asm__ __volatile__( \
6384+ " .set "MIPS_ISA_LEVEL" \n" \
6385+ "1: lld %0, %1 # atomic64_" #op #suffix "\n" \
6386+ "2: " #asm_op " %0, %2 \n" \
6387+ " scd %0, %1 \n" \
6388+ " beqz %0, 1b \n" \
6389+ extable \
6390+ " .set mips0 \n" \
6391+ : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6392+ : "Ir" (i)); \
6393 } else { \
6394 unsigned long flags; \
6395 \
6396 raw_local_irq_save(flags); \
6397- v->counter c_op i; \
6398+ __asm__ __volatile__( \
6399+ "2: " #asm_op " %0, %1 \n" \
6400+ extable \
6401+ : "+" GCC_OFF_SMALL_ASM() (v->counter) : "Ir" (i)); \
6402 raw_local_irq_restore(flags); \
6403 } \
6404 }
6405
6406-#define ATOMIC64_OP_RETURN(op, c_op, asm_op) \
6407-static __inline__ long atomic64_##op##_return(long i, atomic64_t * v) \
6408+#define ATOMIC64_OP(op, asm_op) __ATOMIC64_OP(op, _unchecked, asm_op##u, ) \
6409+ __ATOMIC64_OP(op, , asm_op, __OVERFLOW_EXTABLE)
6410+
6411+#define __ATOMIC64_OP_RETURN(op, suffix, asm_op, post_op, extable) \
6412+static inline long atomic64_##op##_return##suffix(long i, atomic64##suffix##_t * v)\
6413 { \
6414 long result; \
6415 \
6416@@ -368,12 +494,15 @@ static __inline__ long atomic64_##op##_return(long i, atomic64_t * v) \
6417 long temp; \
6418 \
6419 __asm__ __volatile__( \
6420- " .set arch=r4000 \n" \
6421+ " .set mips3 \n" \
6422 "1: lld %1, %2 # atomic64_" #op "_return\n" \
6423- " " #asm_op " %0, %1, %3 \n" \
6424+ "2: " #asm_op " %0, %1, %3 \n" \
6425 " scd %0, %2 \n" \
6426 " beqzl %0, 1b \n" \
6427- " " #asm_op " %0, %1, %3 \n" \
6428+ post_op \
6429+ extable \
6430+ "4: " #asm_op " %0, %1, %3 \n" \
6431+ "5: \n" \
6432 " .set mips0 \n" \
6433 : "=&r" (result), "=&r" (temp), \
6434 "+" GCC_OFF_SMALL_ASM() (v->counter) \
6435@@ -381,27 +510,35 @@ static __inline__ long atomic64_##op##_return(long i, atomic64_t * v) \
6436 } else if (kernel_uses_llsc) { \
6437 long temp; \
6438 \
6439- do { \
6440- __asm__ __volatile__( \
6441- " .set "MIPS_ISA_LEVEL" \n" \
6442- " lld %1, %2 # atomic64_" #op "_return\n" \
6443- " " #asm_op " %0, %1, %3 \n" \
6444- " scd %0, %2 \n" \
6445- " .set mips0 \n" \
6446- : "=&r" (result), "=&r" (temp), \
6447- "=" GCC_OFF_SMALL_ASM() (v->counter) \
6448- : "Ir" (i), GCC_OFF_SMALL_ASM() (v->counter) \
6449- : "memory"); \
6450- } while (unlikely(!result)); \
6451+ __asm__ __volatile__( \
6452+ " .set "MIPS_ISA_LEVEL" \n" \
6453+ "1: lld %1, %2 # atomic64_" #op "_return" #suffix "\n"\
6454+ "2: " #asm_op " %0, %1, %3 \n" \
6455+ " scd %0, %2 \n" \
6456+ " beqz %0, 1b \n" \
6457+ post_op \
6458+ extable \
6459+ "4: " #asm_op " %0, %1, %3 \n" \
6460+ "5: \n" \
6461+ " .set mips0 \n" \
6462+ : "=&r" (result), "=&r" (temp), \
6463+ "=" GCC_OFF_SMALL_ASM() (v->counter) \
6464+ : "Ir" (i), GCC_OFF_SMALL_ASM() (v->counter) \
6465+ : "memory"); \
6466 \
6467 result = temp; result c_op i; \
6468 } else { \
6469 unsigned long flags; \
6470 \
6471 raw_local_irq_save(flags); \
6472- result = v->counter; \
6473- result c_op i; \
6474- v->counter = result; \
6475+ __asm__ __volatile__( \
6476+ " ld %0, %1 \n" \
6477+ "2: " #asm_op " %0, %1, %2 \n" \
6478+ " sd %0, %1 \n" \
6479+ "3: \n" \
6480+ extable \
6481+ : "=&r" (result), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6482+ : "Ir" (i)); \
6483 raw_local_irq_restore(flags); \
6484 } \
6485 \
6486@@ -410,16 +547,23 @@ static __inline__ long atomic64_##op##_return(long i, atomic64_t * v) \
6487 return result; \
6488 }
6489
6490-#define ATOMIC64_OPS(op, c_op, asm_op) \
6491- ATOMIC64_OP(op, c_op, asm_op) \
6492- ATOMIC64_OP_RETURN(op, c_op, asm_op)
6493+#define ATOMIC64_OP_RETURN(op, asm_op) __ATOMIC64_OP_RETURN(op, _unchecked, asm_op##u, , ) \
6494+ __ATOMIC64_OP_RETURN(op, , asm_op, __OVERFLOW_POST, __OVERFLOW_EXTABLE)
6495
6496-ATOMIC64_OPS(add, +=, daddu)
6497-ATOMIC64_OPS(sub, -=, dsubu)
6498+#define ATOMIC64_OPS(op, asm_op) \
6499+ ATOMIC64_OP(op, asm_op) \
6500+ ATOMIC64_OP_RETURN(op, asm_op)
6501+
6502+ATOMIC64_OPS(add, dadd)
6503+ATOMIC64_OPS(sub, dsub)
6504
6505 #undef ATOMIC64_OPS
6506 #undef ATOMIC64_OP_RETURN
6507+#undef __ATOMIC64_OP_RETURN
6508 #undef ATOMIC64_OP
6509+#undef __ATOMIC64_OP
6510+#undef __OVERFLOW_EXTABLE
6511+#undef __OVERFLOW_POST
6512
6513 /*
6514 * atomic64_sub_if_positive - conditionally subtract integer from atomic
6515@@ -430,7 +574,7 @@ ATOMIC64_OPS(sub, -=, dsubu)
6516 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6517 * The function returns the old value of @v minus @i.
6518 */
6519-static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6520+static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6521 {
6522 long result;
6523
6524@@ -440,7 +584,7 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6525 long temp;
6526
6527 __asm__ __volatile__(
6528- " .set arch=r4000 \n"
6529+ " .set "MIPS_ISA_LEVEL" \n"
6530 "1: lld %1, %2 # atomic64_sub_if_positive\n"
6531 " dsubu %0, %1, %3 \n"
6532 " bltz %0, 1f \n"
6533@@ -489,9 +633,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6534 return result;
6535 }
6536
6537-#define atomic64_cmpxchg(v, o, n) \
6538- ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6539-#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6540+static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6541+{
6542+ return cmpxchg(&v->counter, old, new);
6543+}
6544+
6545+static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6546+ long new)
6547+{
6548+ return cmpxchg(&(v->counter), old, new);
6549+}
6550+
6551+static inline long atomic64_xchg(atomic64_t *v, long new)
6552+{
6553+ return xchg(&v->counter, new);
6554+}
6555+
6556+static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6557+{
6558+ return xchg(&(v->counter), new);
6559+}
6560
6561 /**
6562 * atomic64_add_unless - add unless the number is a given value
6563@@ -521,6 +682,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6564
6565 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6566 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6567+#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6568
6569 /*
6570 * atomic64_sub_and_test - subtract value from variable and test result
6571@@ -542,6 +704,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6572 * other cases.
6573 */
6574 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6575+#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6576
6577 /*
6578 * atomic64_dec_and_test - decrement by 1 and test
6579@@ -566,6 +729,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6580 * Atomically increments @v by 1.
6581 */
6582 #define atomic64_inc(v) atomic64_add(1, (v))
6583+#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6584
6585 /*
6586 * atomic64_dec - decrement and test
6587@@ -574,6 +738,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6588 * Atomically decrements @v by 1.
6589 */
6590 #define atomic64_dec(v) atomic64_sub(1, (v))
6591+#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6592
6593 /*
6594 * atomic64_add_negative - add and test if negative
6595diff --git a/arch/mips/include/asm/barrier.h b/arch/mips/include/asm/barrier.h
6596index 7ecba84..21774af 100644
6597--- a/arch/mips/include/asm/barrier.h
6598+++ b/arch/mips/include/asm/barrier.h
6599@@ -133,7 +133,7 @@
6600 do { \
6601 compiletime_assert_atomic_type(*p); \
6602 smp_mb(); \
6603- ACCESS_ONCE(*p) = (v); \
6604+ ACCESS_ONCE_RW(*p) = (v); \
6605 } while (0)
6606
6607 #define smp_load_acquire(p) \
6608diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6609index b4db69f..8f3b093 100644
6610--- a/arch/mips/include/asm/cache.h
6611+++ b/arch/mips/include/asm/cache.h
6612@@ -9,10 +9,11 @@
6613 #ifndef _ASM_CACHE_H
6614 #define _ASM_CACHE_H
6615
6616+#include <linux/const.h>
6617 #include <kmalloc.h>
6618
6619 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6620-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6621+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6622
6623 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6624 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6625diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6626index f19e890..a4f8177 100644
6627--- a/arch/mips/include/asm/elf.h
6628+++ b/arch/mips/include/asm/elf.h
6629@@ -417,6 +417,13 @@ extern const char *__elf_platform;
6630 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6631 #endif
6632
6633+#ifdef CONFIG_PAX_ASLR
6634+#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6635+
6636+#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6637+#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6638+#endif
6639+
6640 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6641 struct linux_binprm;
6642 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6643diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6644index c1f6afa..38cc6e9 100644
6645--- a/arch/mips/include/asm/exec.h
6646+++ b/arch/mips/include/asm/exec.h
6647@@ -12,6 +12,6 @@
6648 #ifndef _ASM_EXEC_H
6649 #define _ASM_EXEC_H
6650
6651-extern unsigned long arch_align_stack(unsigned long sp);
6652+#define arch_align_stack(x) ((x) & ~0xfUL)
6653
6654 #endif /* _ASM_EXEC_H */
6655diff --git a/arch/mips/include/asm/hw_irq.h b/arch/mips/include/asm/hw_irq.h
6656index 9e8ef59..1139d6b 100644
6657--- a/arch/mips/include/asm/hw_irq.h
6658+++ b/arch/mips/include/asm/hw_irq.h
6659@@ -10,7 +10,7 @@
6660
6661 #include <linux/atomic.h>
6662
6663-extern atomic_t irq_err_count;
6664+extern atomic_unchecked_t irq_err_count;
6665
6666 /*
6667 * interrupt-retrigger: NOP for now. This may not be appropriate for all
6668diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6669index 8feaed6..1bd8a64 100644
6670--- a/arch/mips/include/asm/local.h
6671+++ b/arch/mips/include/asm/local.h
6672@@ -13,15 +13,25 @@ typedef struct
6673 atomic_long_t a;
6674 } local_t;
6675
6676+typedef struct {
6677+ atomic_long_unchecked_t a;
6678+} local_unchecked_t;
6679+
6680 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6681
6682 #define local_read(l) atomic_long_read(&(l)->a)
6683+#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6684 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6685+#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6686
6687 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6688+#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6689 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6690+#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6691 #define local_inc(l) atomic_long_inc(&(l)->a)
6692+#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6693 #define local_dec(l) atomic_long_dec(&(l)->a)
6694+#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6695
6696 /*
6697 * Same as above, but return the result value
6698@@ -71,6 +81,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6699 return result;
6700 }
6701
6702+static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6703+{
6704+ unsigned long result;
6705+
6706+ if (kernel_uses_llsc && R10000_LLSC_WAR) {
6707+ unsigned long temp;
6708+
6709+ __asm__ __volatile__(
6710+ " .set mips3 \n"
6711+ "1:" __LL "%1, %2 # local_add_return \n"
6712+ " addu %0, %1, %3 \n"
6713+ __SC "%0, %2 \n"
6714+ " beqzl %0, 1b \n"
6715+ " addu %0, %1, %3 \n"
6716+ " .set mips0 \n"
6717+ : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6718+ : "Ir" (i), "m" (l->a.counter)
6719+ : "memory");
6720+ } else if (kernel_uses_llsc) {
6721+ unsigned long temp;
6722+
6723+ __asm__ __volatile__(
6724+ " .set mips3 \n"
6725+ "1:" __LL "%1, %2 # local_add_return \n"
6726+ " addu %0, %1, %3 \n"
6727+ __SC "%0, %2 \n"
6728+ " beqz %0, 1b \n"
6729+ " addu %0, %1, %3 \n"
6730+ " .set mips0 \n"
6731+ : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6732+ : "Ir" (i), "m" (l->a.counter)
6733+ : "memory");
6734+ } else {
6735+ unsigned long flags;
6736+
6737+ local_irq_save(flags);
6738+ result = l->a.counter;
6739+ result += i;
6740+ l->a.counter = result;
6741+ local_irq_restore(flags);
6742+ }
6743+
6744+ return result;
6745+}
6746+
6747 static __inline__ long local_sub_return(long i, local_t * l)
6748 {
6749 unsigned long result;
6750@@ -118,6 +173,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6751
6752 #define local_cmpxchg(l, o, n) \
6753 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6754+#define local_cmpxchg_unchecked(l, o, n) \
6755+ ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6756 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6757
6758 /**
6759diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6760index 89dd7fe..a123c97 100644
6761--- a/arch/mips/include/asm/page.h
6762+++ b/arch/mips/include/asm/page.h
6763@@ -118,7 +118,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6764 #ifdef CONFIG_CPU_MIPS32
6765 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6766 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6767- #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6768+ #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6769 #else
6770 typedef struct { unsigned long long pte; } pte_t;
6771 #define pte_val(x) ((x).pte)
6772diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6773index b336037..5b874cc 100644
6774--- a/arch/mips/include/asm/pgalloc.h
6775+++ b/arch/mips/include/asm/pgalloc.h
6776@@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6777 {
6778 set_pud(pud, __pud((unsigned long)pmd));
6779 }
6780+
6781+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6782+{
6783+ pud_populate(mm, pud, pmd);
6784+}
6785 #endif
6786
6787 /*
6788diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
6789index ae85694..4cdbba8 100644
6790--- a/arch/mips/include/asm/pgtable.h
6791+++ b/arch/mips/include/asm/pgtable.h
6792@@ -20,6 +20,9 @@
6793 #include <asm/io.h>
6794 #include <asm/pgtable-bits.h>
6795
6796+#define ktla_ktva(addr) (addr)
6797+#define ktva_ktla(addr) (addr)
6798+
6799 struct mm_struct;
6800 struct vm_area_struct;
6801
6802diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6803index 9c0014e..5101ef5 100644
6804--- a/arch/mips/include/asm/thread_info.h
6805+++ b/arch/mips/include/asm/thread_info.h
6806@@ -100,6 +100,9 @@ static inline struct thread_info *current_thread_info(void)
6807 #define TIF_SECCOMP 4 /* secure computing */
6808 #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */
6809 #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */
6810+/* li takes a 32bit immediate */
6811+#define TIF_GRSEC_SETXID 10 /* update credentials on syscall entry/exit */
6812+
6813 #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
6814 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
6815 #define TIF_NOHZ 19 /* in adaptive nohz mode */
6816@@ -135,14 +138,16 @@ static inline struct thread_info *current_thread_info(void)
6817 #define _TIF_USEDMSA (1<<TIF_USEDMSA)
6818 #define _TIF_MSA_CTX_LIVE (1<<TIF_MSA_CTX_LIVE)
6819 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6820+#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6821
6822 #define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6823 _TIF_SYSCALL_AUDIT | \
6824- _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
6825+ _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
6826+ _TIF_GRSEC_SETXID)
6827
6828 /* work to do in syscall_trace_leave() */
6829 #define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6830- _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT)
6831+ _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
6832
6833 /* work to do on interrupt/exception return */
6834 #define _TIF_WORK_MASK \
6835@@ -150,7 +155,7 @@ static inline struct thread_info *current_thread_info(void)
6836 /* work to do on any return to u-space */
6837 #define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6838 _TIF_WORK_SYSCALL_EXIT | \
6839- _TIF_SYSCALL_TRACEPOINT)
6840+ _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
6841
6842 /*
6843 * We stash processor id into a COP0 register to retrieve it fast
6844diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h
6845index 5305d69..1da2bf5 100644
6846--- a/arch/mips/include/asm/uaccess.h
6847+++ b/arch/mips/include/asm/uaccess.h
6848@@ -146,6 +146,7 @@ static inline bool eva_kernel_access(void)
6849 __ok == 0; \
6850 })
6851
6852+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
6853 #define access_ok(type, addr, size) \
6854 likely(__access_ok((addr), (size), __access_mask))
6855
6856diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6857index 1188e00..41cf144 100644
6858--- a/arch/mips/kernel/binfmt_elfn32.c
6859+++ b/arch/mips/kernel/binfmt_elfn32.c
6860@@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6861 #undef ELF_ET_DYN_BASE
6862 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6863
6864+#ifdef CONFIG_PAX_ASLR
6865+#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6866+
6867+#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6868+#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6869+#endif
6870+
6871 #include <asm/processor.h>
6872 #include <linux/module.h>
6873 #include <linux/elfcore.h>
6874diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6875index 9287678..f870e47 100644
6876--- a/arch/mips/kernel/binfmt_elfo32.c
6877+++ b/arch/mips/kernel/binfmt_elfo32.c
6878@@ -70,6 +70,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6879 #undef ELF_ET_DYN_BASE
6880 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6881
6882+#ifdef CONFIG_PAX_ASLR
6883+#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6884+
6885+#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6886+#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6887+#endif
6888+
6889 #include <asm/processor.h>
6890
6891 #include <linux/module.h>
6892diff --git a/arch/mips/kernel/i8259.c b/arch/mips/kernel/i8259.c
6893index 74f6752..f3d7a47 100644
6894--- a/arch/mips/kernel/i8259.c
6895+++ b/arch/mips/kernel/i8259.c
6896@@ -205,7 +205,7 @@ spurious_8259A_irq:
6897 printk(KERN_DEBUG "spurious 8259A interrupt: IRQ%d.\n", irq);
6898 spurious_irq_mask |= irqmask;
6899 }
6900- atomic_inc(&irq_err_count);
6901+ atomic_inc_unchecked(&irq_err_count);
6902 /*
6903 * Theoretically we do not have to handle this IRQ,
6904 * but in Linux this does not cause problems and is
6905diff --git a/arch/mips/kernel/irq-gt641xx.c b/arch/mips/kernel/irq-gt641xx.c
6906index 44a1f79..2bd6aa3 100644
6907--- a/arch/mips/kernel/irq-gt641xx.c
6908+++ b/arch/mips/kernel/irq-gt641xx.c
6909@@ -110,7 +110,7 @@ void gt641xx_irq_dispatch(void)
6910 }
6911 }
6912
6913- atomic_inc(&irq_err_count);
6914+ atomic_inc_unchecked(&irq_err_count);
6915 }
6916
6917 void __init gt641xx_irq_init(void)
6918diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6919index 8eb5af8..2baf465 100644
6920--- a/arch/mips/kernel/irq.c
6921+++ b/arch/mips/kernel/irq.c
6922@@ -34,17 +34,17 @@ void ack_bad_irq(unsigned int irq)
6923 printk("unexpected IRQ # %d\n", irq);
6924 }
6925
6926-atomic_t irq_err_count;
6927+atomic_unchecked_t irq_err_count;
6928
6929 int arch_show_interrupts(struct seq_file *p, int prec)
6930 {
6931- seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6932+ seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6933 return 0;
6934 }
6935
6936 asmlinkage void spurious_interrupt(void)
6937 {
6938- atomic_inc(&irq_err_count);
6939+ atomic_inc_unchecked(&irq_err_count);
6940 }
6941
6942 void __init init_IRQ(void)
6943@@ -58,6 +58,8 @@ void __init init_IRQ(void)
6944 }
6945
6946 #ifdef CONFIG_DEBUG_STACKOVERFLOW
6947+
6948+extern void gr_handle_kernel_exploit(void);
6949 static inline void check_stack_overflow(void)
6950 {
6951 unsigned long sp;
6952@@ -73,6 +75,7 @@ static inline void check_stack_overflow(void)
6953 printk("do_IRQ: stack overflow: %ld\n",
6954 sp - sizeof(struct thread_info));
6955 dump_stack();
6956+ gr_handle_kernel_exploit();
6957 }
6958 }
6959 #else
6960diff --git a/arch/mips/kernel/pm-cps.c b/arch/mips/kernel/pm-cps.c
6961index 0614717..002fa43 100644
6962--- a/arch/mips/kernel/pm-cps.c
6963+++ b/arch/mips/kernel/pm-cps.c
6964@@ -172,7 +172,7 @@ int cps_pm_enter_state(enum cps_pm_state state)
6965 nc_core_ready_count = nc_addr;
6966
6967 /* Ensure ready_count is zero-initialised before the assembly runs */
6968- ACCESS_ONCE(*nc_core_ready_count) = 0;
6969+ ACCESS_ONCE_RW(*nc_core_ready_count) = 0;
6970 coupled_barrier(&per_cpu(pm_barrier, core), online);
6971
6972 /* Run the generated entry code */
6973diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6974index f2975d4..f61d355 100644
6975--- a/arch/mips/kernel/process.c
6976+++ b/arch/mips/kernel/process.c
6977@@ -541,18 +541,6 @@ out:
6978 return pc;
6979 }
6980
6981-/*
6982- * Don't forget that the stack pointer must be aligned on a 8 bytes
6983- * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6984- */
6985-unsigned long arch_align_stack(unsigned long sp)
6986-{
6987- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6988- sp -= get_random_int() & ~PAGE_MASK;
6989-
6990- return sp & ALMASK;
6991-}
6992-
6993 static void arch_dump_stack(void *info)
6994 {
6995 struct pt_regs *regs;
6996diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6997index e933a30..0d02625 100644
6998--- a/arch/mips/kernel/ptrace.c
6999+++ b/arch/mips/kernel/ptrace.c
7000@@ -785,6 +785,10 @@ long arch_ptrace(struct task_struct *child, long request,
7001 return ret;
7002 }
7003
7004+#ifdef CONFIG_GRKERNSEC_SETXID
7005+extern void gr_delayed_cred_worker(void);
7006+#endif
7007+
7008 /*
7009 * Notification of system call entry/exit
7010 * - triggered by current->work.syscall_trace
7011@@ -803,6 +807,11 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
7012 tracehook_report_syscall_entry(regs))
7013 ret = -1;
7014
7015+#ifdef CONFIG_GRKERNSEC_SETXID
7016+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7017+ gr_delayed_cred_worker();
7018+#endif
7019+
7020 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
7021 trace_sys_enter(regs, regs->regs[2]);
7022
7023diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
7024index 2242bdd..b284048 100644
7025--- a/arch/mips/kernel/sync-r4k.c
7026+++ b/arch/mips/kernel/sync-r4k.c
7027@@ -18,8 +18,8 @@
7028 #include <asm/mipsregs.h>
7029
7030 static atomic_t count_start_flag = ATOMIC_INIT(0);
7031-static atomic_t count_count_start = ATOMIC_INIT(0);
7032-static atomic_t count_count_stop = ATOMIC_INIT(0);
7033+static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
7034+static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
7035 static atomic_t count_reference = ATOMIC_INIT(0);
7036
7037 #define COUNTON 100
7038@@ -58,13 +58,13 @@ void synchronise_count_master(int cpu)
7039
7040 for (i = 0; i < NR_LOOPS; i++) {
7041 /* slaves loop on '!= 2' */
7042- while (atomic_read(&count_count_start) != 1)
7043+ while (atomic_read_unchecked(&count_count_start) != 1)
7044 mb();
7045- atomic_set(&count_count_stop, 0);
7046+ atomic_set_unchecked(&count_count_stop, 0);
7047 smp_wmb();
7048
7049 /* this lets the slaves write their count register */
7050- atomic_inc(&count_count_start);
7051+ atomic_inc_unchecked(&count_count_start);
7052
7053 /*
7054 * Everyone initialises count in the last loop:
7055@@ -75,11 +75,11 @@ void synchronise_count_master(int cpu)
7056 /*
7057 * Wait for all slaves to leave the synchronization point:
7058 */
7059- while (atomic_read(&count_count_stop) != 1)
7060+ while (atomic_read_unchecked(&count_count_stop) != 1)
7061 mb();
7062- atomic_set(&count_count_start, 0);
7063+ atomic_set_unchecked(&count_count_start, 0);
7064 smp_wmb();
7065- atomic_inc(&count_count_stop);
7066+ atomic_inc_unchecked(&count_count_stop);
7067 }
7068 /* Arrange for an interrupt in a short while */
7069 write_c0_compare(read_c0_count() + COUNTON);
7070@@ -112,8 +112,8 @@ void synchronise_count_slave(int cpu)
7071 initcount = atomic_read(&count_reference);
7072
7073 for (i = 0; i < NR_LOOPS; i++) {
7074- atomic_inc(&count_count_start);
7075- while (atomic_read(&count_count_start) != 2)
7076+ atomic_inc_unchecked(&count_count_start);
7077+ while (atomic_read_unchecked(&count_count_start) != 2)
7078 mb();
7079
7080 /*
7081@@ -122,8 +122,8 @@ void synchronise_count_slave(int cpu)
7082 if (i == NR_LOOPS-1)
7083 write_c0_count(initcount);
7084
7085- atomic_inc(&count_count_stop);
7086- while (atomic_read(&count_count_stop) != 2)
7087+ atomic_inc_unchecked(&count_count_stop);
7088+ while (atomic_read_unchecked(&count_count_stop) != 2)
7089 mb();
7090 }
7091 /* Arrange for an interrupt in a short while */
7092diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
7093index 8ea28e6..c8873d5 100644
7094--- a/arch/mips/kernel/traps.c
7095+++ b/arch/mips/kernel/traps.c
7096@@ -697,7 +697,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
7097 siginfo_t info;
7098
7099 prev_state = exception_enter();
7100- die_if_kernel("Integer overflow", regs);
7101+ if (unlikely(!user_mode(regs))) {
7102+
7103+#ifdef CONFIG_PAX_REFCOUNT
7104+ if (fixup_exception(regs)) {
7105+ pax_report_refcount_overflow(regs);
7106+ exception_exit(prev_state);
7107+ return;
7108+ }
7109+#endif
7110+
7111+ die("Integer overflow", regs);
7112+ }
7113
7114 info.si_code = FPE_INTOVF;
7115 info.si_signo = SIGFPE;
7116diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
7117index cd4c129..290c518 100644
7118--- a/arch/mips/kvm/mips.c
7119+++ b/arch/mips/kvm/mips.c
7120@@ -1016,7 +1016,7 @@ long kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
7121 return r;
7122 }
7123
7124-int kvm_arch_init(void *opaque)
7125+int kvm_arch_init(const void *opaque)
7126 {
7127 if (kvm_mips_callbacks) {
7128 kvm_err("kvm: module already exists\n");
7129diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
7130index 852a41c..75b9d38 100644
7131--- a/arch/mips/mm/fault.c
7132+++ b/arch/mips/mm/fault.c
7133@@ -31,6 +31,23 @@
7134
7135 int show_unhandled_signals = 1;
7136
7137+#ifdef CONFIG_PAX_PAGEEXEC
7138+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7139+{
7140+ unsigned long i;
7141+
7142+ printk(KERN_ERR "PAX: bytes at PC: ");
7143+ for (i = 0; i < 5; i++) {
7144+ unsigned int c;
7145+ if (get_user(c, (unsigned int *)pc+i))
7146+ printk(KERN_CONT "???????? ");
7147+ else
7148+ printk(KERN_CONT "%08x ", c);
7149+ }
7150+ printk("\n");
7151+}
7152+#endif
7153+
7154 /*
7155 * This routine handles page faults. It determines the address,
7156 * and the problem, and then passes it off to one of the appropriate
7157@@ -207,6 +224,14 @@ bad_area:
7158 bad_area_nosemaphore:
7159 /* User mode accesses just cause a SIGSEGV */
7160 if (user_mode(regs)) {
7161+
7162+#ifdef CONFIG_PAX_PAGEEXEC
7163+ if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
7164+ pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
7165+ do_group_exit(SIGKILL);
7166+ }
7167+#endif
7168+
7169 tsk->thread.cp0_badvaddr = address;
7170 tsk->thread.error_code = write;
7171 if (show_unhandled_signals &&
7172diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
7173index 5c81fdd..db158d3 100644
7174--- a/arch/mips/mm/mmap.c
7175+++ b/arch/mips/mm/mmap.c
7176@@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
7177 struct vm_area_struct *vma;
7178 unsigned long addr = addr0;
7179 int do_color_align;
7180+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7181 struct vm_unmapped_area_info info;
7182
7183 if (unlikely(len > TASK_SIZE))
7184@@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
7185 do_color_align = 1;
7186
7187 /* requesting a specific address */
7188+
7189+#ifdef CONFIG_PAX_RANDMMAP
7190+ if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
7191+#endif
7192+
7193 if (addr) {
7194 if (do_color_align)
7195 addr = COLOUR_ALIGN(addr, pgoff);
7196@@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
7197 addr = PAGE_ALIGN(addr);
7198
7199 vma = find_vma(mm, addr);
7200- if (TASK_SIZE - len >= addr &&
7201- (!vma || addr + len <= vma->vm_start))
7202+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7203 return addr;
7204 }
7205
7206 info.length = len;
7207 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
7208 info.align_offset = pgoff << PAGE_SHIFT;
7209+ info.threadstack_offset = offset;
7210
7211 if (dir == DOWN) {
7212 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
7213@@ -160,45 +166,34 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7214 {
7215 unsigned long random_factor = 0UL;
7216
7217+#ifdef CONFIG_PAX_RANDMMAP
7218+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7219+#endif
7220+
7221 if (current->flags & PF_RANDOMIZE)
7222 random_factor = arch_mmap_rnd();
7223
7224 if (mmap_is_legacy()) {
7225 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
7226+
7227+#ifdef CONFIG_PAX_RANDMMAP
7228+ if (mm->pax_flags & MF_PAX_RANDMMAP)
7229+ mm->mmap_base += mm->delta_mmap;
7230+#endif
7231+
7232 mm->get_unmapped_area = arch_get_unmapped_area;
7233 } else {
7234 mm->mmap_base = mmap_base(random_factor);
7235+
7236+#ifdef CONFIG_PAX_RANDMMAP
7237+ if (mm->pax_flags & MF_PAX_RANDMMAP)
7238+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7239+#endif
7240+
7241 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7242 }
7243 }
7244
7245-static inline unsigned long brk_rnd(void)
7246-{
7247- unsigned long rnd = get_random_int();
7248-
7249- rnd = rnd << PAGE_SHIFT;
7250- /* 8MB for 32bit, 256MB for 64bit */
7251- if (TASK_IS_32BIT_ADDR)
7252- rnd = rnd & 0x7ffffful;
7253- else
7254- rnd = rnd & 0xffffffful;
7255-
7256- return rnd;
7257-}
7258-
7259-unsigned long arch_randomize_brk(struct mm_struct *mm)
7260-{
7261- unsigned long base = mm->brk;
7262- unsigned long ret;
7263-
7264- ret = PAGE_ALIGN(base + brk_rnd());
7265-
7266- if (ret < mm->brk)
7267- return mm->brk;
7268-
7269- return ret;
7270-}
7271-
7272 int __virt_addr_valid(const volatile void *kaddr)
7273 {
7274 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
7275diff --git a/arch/mips/net/bpf_jit_asm.S b/arch/mips/net/bpf_jit_asm.S
7276index dabf417..0be1d6d 100644
7277--- a/arch/mips/net/bpf_jit_asm.S
7278+++ b/arch/mips/net/bpf_jit_asm.S
7279@@ -62,7 +62,9 @@ sk_load_word_positive:
7280 is_offset_in_header(4, word)
7281 /* Offset within header boundaries */
7282 PTR_ADDU t1, $r_skb_data, offset
7283+ .set reorder
7284 lw $r_A, 0(t1)
7285+ .set noreorder
7286 #ifdef CONFIG_CPU_LITTLE_ENDIAN
7287 # if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
7288 wsbh t0, $r_A
7289@@ -90,7 +92,9 @@ sk_load_half_positive:
7290 is_offset_in_header(2, half)
7291 /* Offset within header boundaries */
7292 PTR_ADDU t1, $r_skb_data, offset
7293+ .set reorder
7294 lh $r_A, 0(t1)
7295+ .set noreorder
7296 #ifdef CONFIG_CPU_LITTLE_ENDIAN
7297 # if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
7298 wsbh t0, $r_A
7299diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
7300index a2358b4..7cead4f 100644
7301--- a/arch/mips/sgi-ip27/ip27-nmi.c
7302+++ b/arch/mips/sgi-ip27/ip27-nmi.c
7303@@ -187,9 +187,9 @@ void
7304 cont_nmi_dump(void)
7305 {
7306 #ifndef REAL_NMI_SIGNAL
7307- static atomic_t nmied_cpus = ATOMIC_INIT(0);
7308+ static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
7309
7310- atomic_inc(&nmied_cpus);
7311+ atomic_inc_unchecked(&nmied_cpus);
7312 #endif
7313 /*
7314 * Only allow 1 cpu to proceed
7315@@ -233,7 +233,7 @@ cont_nmi_dump(void)
7316 udelay(10000);
7317 }
7318 #else
7319- while (atomic_read(&nmied_cpus) != num_online_cpus());
7320+ while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
7321 #endif
7322
7323 /*
7324diff --git a/arch/mips/sni/rm200.c b/arch/mips/sni/rm200.c
7325index a046b30..6799527 100644
7326--- a/arch/mips/sni/rm200.c
7327+++ b/arch/mips/sni/rm200.c
7328@@ -270,7 +270,7 @@ spurious_8259A_irq:
7329 "spurious RM200 8259A interrupt: IRQ%d.\n", irq);
7330 spurious_irq_mask |= irqmask;
7331 }
7332- atomic_inc(&irq_err_count);
7333+ atomic_inc_unchecked(&irq_err_count);
7334 /*
7335 * Theoretically we do not have to handle this IRQ,
7336 * but in Linux this does not cause problems and is
7337diff --git a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c
7338index 41e873b..34d33a7 100644
7339--- a/arch/mips/vr41xx/common/icu.c
7340+++ b/arch/mips/vr41xx/common/icu.c
7341@@ -653,7 +653,7 @@ static int icu_get_irq(unsigned int irq)
7342
7343 printk(KERN_ERR "spurious ICU interrupt: %04x,%04x\n", pend1, pend2);
7344
7345- atomic_inc(&irq_err_count);
7346+ atomic_inc_unchecked(&irq_err_count);
7347
7348 return -1;
7349 }
7350diff --git a/arch/mips/vr41xx/common/irq.c b/arch/mips/vr41xx/common/irq.c
7351index ae0e4ee..e8f0692 100644
7352--- a/arch/mips/vr41xx/common/irq.c
7353+++ b/arch/mips/vr41xx/common/irq.c
7354@@ -64,7 +64,7 @@ static void irq_dispatch(unsigned int irq)
7355 irq_cascade_t *cascade;
7356
7357 if (irq >= NR_IRQS) {
7358- atomic_inc(&irq_err_count);
7359+ atomic_inc_unchecked(&irq_err_count);
7360 return;
7361 }
7362
7363@@ -84,7 +84,7 @@ static void irq_dispatch(unsigned int irq)
7364 ret = cascade->get_irq(irq);
7365 irq = ret;
7366 if (ret < 0)
7367- atomic_inc(&irq_err_count);
7368+ atomic_inc_unchecked(&irq_err_count);
7369 else
7370 irq_dispatch(irq);
7371 if (!irqd_irq_disabled(idata) && chip->irq_unmask)
7372diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
7373index 967d144..db12197 100644
7374--- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
7375+++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
7376@@ -11,12 +11,14 @@
7377 #ifndef _ASM_PROC_CACHE_H
7378 #define _ASM_PROC_CACHE_H
7379
7380+#include <linux/const.h>
7381+
7382 /* L1 cache */
7383
7384 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
7385 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
7386-#define L1_CACHE_BYTES 16 /* bytes per entry */
7387 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
7388+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
7389 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
7390
7391 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
7392diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7393index bcb5df2..84fabd2 100644
7394--- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7395+++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7396@@ -16,13 +16,15 @@
7397 #ifndef _ASM_PROC_CACHE_H
7398 #define _ASM_PROC_CACHE_H
7399
7400+#include <linux/const.h>
7401+
7402 /*
7403 * L1 cache
7404 */
7405 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
7406 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
7407-#define L1_CACHE_BYTES 32 /* bytes per entry */
7408 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
7409+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
7410 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
7411
7412 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
7413diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
7414index 4ce7a01..449202a 100644
7415--- a/arch/openrisc/include/asm/cache.h
7416+++ b/arch/openrisc/include/asm/cache.h
7417@@ -19,11 +19,13 @@
7418 #ifndef __ASM_OPENRISC_CACHE_H
7419 #define __ASM_OPENRISC_CACHE_H
7420
7421+#include <linux/const.h>
7422+
7423 /* FIXME: How can we replace these with values from the CPU...
7424 * they shouldn't be hard-coded!
7425 */
7426
7427-#define L1_CACHE_BYTES 16
7428 #define L1_CACHE_SHIFT 4
7429+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7430
7431 #endif /* __ASM_OPENRISC_CACHE_H */
7432diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
7433index 226f8ca9..9d9b87d 100644
7434--- a/arch/parisc/include/asm/atomic.h
7435+++ b/arch/parisc/include/asm/atomic.h
7436@@ -273,6 +273,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
7437 return dec;
7438 }
7439
7440+#define atomic64_read_unchecked(v) atomic64_read(v)
7441+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7442+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7443+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7444+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7445+#define atomic64_inc_unchecked(v) atomic64_inc(v)
7446+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7447+#define atomic64_dec_unchecked(v) atomic64_dec(v)
7448+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7449+
7450 #endif /* !CONFIG_64BIT */
7451
7452
7453diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
7454index 47f11c7..3420df2 100644
7455--- a/arch/parisc/include/asm/cache.h
7456+++ b/arch/parisc/include/asm/cache.h
7457@@ -5,6 +5,7 @@
7458 #ifndef __ARCH_PARISC_CACHE_H
7459 #define __ARCH_PARISC_CACHE_H
7460
7461+#include <linux/const.h>
7462
7463 /*
7464 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
7465@@ -15,13 +16,13 @@
7466 * just ruin performance.
7467 */
7468 #ifdef CONFIG_PA20
7469-#define L1_CACHE_BYTES 64
7470 #define L1_CACHE_SHIFT 6
7471 #else
7472-#define L1_CACHE_BYTES 32
7473 #define L1_CACHE_SHIFT 5
7474 #endif
7475
7476+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7477+
7478 #ifndef __ASSEMBLY__
7479
7480 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7481diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7482index 78c9fd3..42fa66a 100644
7483--- a/arch/parisc/include/asm/elf.h
7484+++ b/arch/parisc/include/asm/elf.h
7485@@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7486
7487 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7488
7489+#ifdef CONFIG_PAX_ASLR
7490+#define PAX_ELF_ET_DYN_BASE 0x10000UL
7491+
7492+#define PAX_DELTA_MMAP_LEN 16
7493+#define PAX_DELTA_STACK_LEN 16
7494+#endif
7495+
7496 /* This yields a mask that user programs can use to figure out what
7497 instruction set this CPU supports. This could be done in user space,
7498 but it's not easy, and we've already done it here. */
7499diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7500index 3edbb9f..08fef28 100644
7501--- a/arch/parisc/include/asm/pgalloc.h
7502+++ b/arch/parisc/include/asm/pgalloc.h
7503@@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7504 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7505 }
7506
7507+static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7508+{
7509+ pgd_populate(mm, pgd, pmd);
7510+}
7511+
7512 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7513 {
7514 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7515@@ -97,6 +102,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7516 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7517 #define pmd_free(mm, x) do { } while (0)
7518 #define pgd_populate(mm, pmd, pte) BUG()
7519+#define pgd_populate_kernel(mm, pmd, pte) BUG()
7520
7521 #endif
7522
7523diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7524index f93c4a4..cfd5663 100644
7525--- a/arch/parisc/include/asm/pgtable.h
7526+++ b/arch/parisc/include/asm/pgtable.h
7527@@ -231,6 +231,17 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
7528 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7529 #define PAGE_COPY PAGE_EXECREAD
7530 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7531+
7532+#ifdef CONFIG_PAX_PAGEEXEC
7533+# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7534+# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7535+# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7536+#else
7537+# define PAGE_SHARED_NOEXEC PAGE_SHARED
7538+# define PAGE_COPY_NOEXEC PAGE_COPY
7539+# define PAGE_READONLY_NOEXEC PAGE_READONLY
7540+#endif
7541+
7542 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7543 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7544 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7545diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7546index 0abdd4c..1af92f0 100644
7547--- a/arch/parisc/include/asm/uaccess.h
7548+++ b/arch/parisc/include/asm/uaccess.h
7549@@ -243,10 +243,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7550 const void __user *from,
7551 unsigned long n)
7552 {
7553- int sz = __compiletime_object_size(to);
7554+ size_t sz = __compiletime_object_size(to);
7555 int ret = -EFAULT;
7556
7557- if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7558+ if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7559 ret = __copy_from_user(to, from, n);
7560 else
7561 copy_from_user_overflow();
7562diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7563index 3c63a82..b1d6ee9 100644
7564--- a/arch/parisc/kernel/module.c
7565+++ b/arch/parisc/kernel/module.c
7566@@ -98,16 +98,38 @@
7567
7568 /* three functions to determine where in the module core
7569 * or init pieces the location is */
7570+static inline int in_init_rx(struct module *me, void *loc)
7571+{
7572+ return (loc >= me->module_init_rx &&
7573+ loc < (me->module_init_rx + me->init_size_rx));
7574+}
7575+
7576+static inline int in_init_rw(struct module *me, void *loc)
7577+{
7578+ return (loc >= me->module_init_rw &&
7579+ loc < (me->module_init_rw + me->init_size_rw));
7580+}
7581+
7582 static inline int in_init(struct module *me, void *loc)
7583 {
7584- return (loc >= me->module_init &&
7585- loc <= (me->module_init + me->init_size));
7586+ return in_init_rx(me, loc) || in_init_rw(me, loc);
7587+}
7588+
7589+static inline int in_core_rx(struct module *me, void *loc)
7590+{
7591+ return (loc >= me->module_core_rx &&
7592+ loc < (me->module_core_rx + me->core_size_rx));
7593+}
7594+
7595+static inline int in_core_rw(struct module *me, void *loc)
7596+{
7597+ return (loc >= me->module_core_rw &&
7598+ loc < (me->module_core_rw + me->core_size_rw));
7599 }
7600
7601 static inline int in_core(struct module *me, void *loc)
7602 {
7603- return (loc >= me->module_core &&
7604- loc <= (me->module_core + me->core_size));
7605+ return in_core_rx(me, loc) || in_core_rw(me, loc);
7606 }
7607
7608 static inline int in_local(struct module *me, void *loc)
7609@@ -367,13 +389,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7610 }
7611
7612 /* align things a bit */
7613- me->core_size = ALIGN(me->core_size, 16);
7614- me->arch.got_offset = me->core_size;
7615- me->core_size += gots * sizeof(struct got_entry);
7616+ me->core_size_rw = ALIGN(me->core_size_rw, 16);
7617+ me->arch.got_offset = me->core_size_rw;
7618+ me->core_size_rw += gots * sizeof(struct got_entry);
7619
7620- me->core_size = ALIGN(me->core_size, 16);
7621- me->arch.fdesc_offset = me->core_size;
7622- me->core_size += fdescs * sizeof(Elf_Fdesc);
7623+ me->core_size_rw = ALIGN(me->core_size_rw, 16);
7624+ me->arch.fdesc_offset = me->core_size_rw;
7625+ me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7626
7627 me->arch.got_max = gots;
7628 me->arch.fdesc_max = fdescs;
7629@@ -391,7 +413,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7630
7631 BUG_ON(value == 0);
7632
7633- got = me->module_core + me->arch.got_offset;
7634+ got = me->module_core_rw + me->arch.got_offset;
7635 for (i = 0; got[i].addr; i++)
7636 if (got[i].addr == value)
7637 goto out;
7638@@ -409,7 +431,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7639 #ifdef CONFIG_64BIT
7640 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7641 {
7642- Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7643+ Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7644
7645 if (!value) {
7646 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7647@@ -427,7 +449,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7648
7649 /* Create new one */
7650 fdesc->addr = value;
7651- fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7652+ fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7653 return (Elf_Addr)fdesc;
7654 }
7655 #endif /* CONFIG_64BIT */
7656@@ -839,7 +861,7 @@ register_unwind_table(struct module *me,
7657
7658 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7659 end = table + sechdrs[me->arch.unwind_section].sh_size;
7660- gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7661+ gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7662
7663 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7664 me->arch.unwind_section, table, end, gp);
7665diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7666index 5aba01a..47cdd5a 100644
7667--- a/arch/parisc/kernel/sys_parisc.c
7668+++ b/arch/parisc/kernel/sys_parisc.c
7669@@ -92,6 +92,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7670 unsigned long task_size = TASK_SIZE;
7671 int do_color_align, last_mmap;
7672 struct vm_unmapped_area_info info;
7673+ unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7674
7675 if (len > task_size)
7676 return -ENOMEM;
7677@@ -109,6 +110,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7678 goto found_addr;
7679 }
7680
7681+#ifdef CONFIG_PAX_RANDMMAP
7682+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7683+#endif
7684+
7685 if (addr) {
7686 if (do_color_align && last_mmap)
7687 addr = COLOR_ALIGN(addr, last_mmap, pgoff);
7688@@ -127,6 +132,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7689 info.high_limit = mmap_upper_limit();
7690 info.align_mask = last_mmap ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0;
7691 info.align_offset = shared_align_offset(last_mmap, pgoff);
7692+ info.threadstack_offset = offset;
7693 addr = vm_unmapped_area(&info);
7694
7695 found_addr:
7696@@ -146,6 +152,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7697 unsigned long addr = addr0;
7698 int do_color_align, last_mmap;
7699 struct vm_unmapped_area_info info;
7700+ unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7701
7702 #ifdef CONFIG_64BIT
7703 /* This should only ever run for 32-bit processes. */
7704@@ -170,6 +177,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7705 }
7706
7707 /* requesting a specific address */
7708+#ifdef CONFIG_PAX_RANDMMAP
7709+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7710+#endif
7711+
7712 if (addr) {
7713 if (do_color_align && last_mmap)
7714 addr = COLOR_ALIGN(addr, last_mmap, pgoff);
7715@@ -187,6 +198,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7716 info.high_limit = mm->mmap_base;
7717 info.align_mask = last_mmap ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0;
7718 info.align_offset = shared_align_offset(last_mmap, pgoff);
7719+ info.threadstack_offset = offset;
7720 addr = vm_unmapped_area(&info);
7721 if (!(addr & ~PAGE_MASK))
7722 goto found_addr;
7723@@ -252,6 +264,13 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7724 mm->mmap_legacy_base = mmap_legacy_base();
7725 mm->mmap_base = mmap_upper_limit();
7726
7727+#ifdef CONFIG_PAX_RANDMMAP
7728+ if (mm->pax_flags & MF_PAX_RANDMMAP) {
7729+ mm->mmap_legacy_base += mm->delta_mmap;
7730+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7731+ }
7732+#endif
7733+
7734 if (mmap_is_legacy()) {
7735 mm->mmap_base = mm->mmap_legacy_base;
7736 mm->get_unmapped_area = arch_get_unmapped_area;
7737diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7738index b99b39f..e3915ae 100644
7739--- a/arch/parisc/kernel/traps.c
7740+++ b/arch/parisc/kernel/traps.c
7741@@ -722,9 +722,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7742
7743 down_read(&current->mm->mmap_sem);
7744 vma = find_vma(current->mm,regs->iaoq[0]);
7745- if (vma && (regs->iaoq[0] >= vma->vm_start)
7746- && (vma->vm_flags & VM_EXEC)) {
7747-
7748+ if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7749 fault_address = regs->iaoq[0];
7750 fault_space = regs->iasq[0];
7751
7752diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7753index 15503ad..4b1b8b6 100644
7754--- a/arch/parisc/mm/fault.c
7755+++ b/arch/parisc/mm/fault.c
7756@@ -16,6 +16,7 @@
7757 #include <linux/interrupt.h>
7758 #include <linux/module.h>
7759 #include <linux/uaccess.h>
7760+#include <linux/unistd.h>
7761
7762 #include <asm/traps.h>
7763
7764@@ -50,7 +51,7 @@ int show_unhandled_signals = 1;
7765 static unsigned long
7766 parisc_acctyp(unsigned long code, unsigned int inst)
7767 {
7768- if (code == 6 || code == 16)
7769+ if (code == 6 || code == 7 || code == 16)
7770 return VM_EXEC;
7771
7772 switch (inst & 0xf0000000) {
7773@@ -136,6 +137,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7774 }
7775 #endif
7776
7777+#ifdef CONFIG_PAX_PAGEEXEC
7778+/*
7779+ * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7780+ *
7781+ * returns 1 when task should be killed
7782+ * 2 when rt_sigreturn trampoline was detected
7783+ * 3 when unpatched PLT trampoline was detected
7784+ */
7785+static int pax_handle_fetch_fault(struct pt_regs *regs)
7786+{
7787+
7788+#ifdef CONFIG_PAX_EMUPLT
7789+ int err;
7790+
7791+ do { /* PaX: unpatched PLT emulation */
7792+ unsigned int bl, depwi;
7793+
7794+ err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7795+ err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7796+
7797+ if (err)
7798+ break;
7799+
7800+ if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7801+ unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7802+
7803+ err = get_user(ldw, (unsigned int *)addr);
7804+ err |= get_user(bv, (unsigned int *)(addr+4));
7805+ err |= get_user(ldw2, (unsigned int *)(addr+8));
7806+
7807+ if (err)
7808+ break;
7809+
7810+ if (ldw == 0x0E801096U &&
7811+ bv == 0xEAC0C000U &&
7812+ ldw2 == 0x0E881095U)
7813+ {
7814+ unsigned int resolver, map;
7815+
7816+ err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7817+ err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7818+ if (err)
7819+ break;
7820+
7821+ regs->gr[20] = instruction_pointer(regs)+8;
7822+ regs->gr[21] = map;
7823+ regs->gr[22] = resolver;
7824+ regs->iaoq[0] = resolver | 3UL;
7825+ regs->iaoq[1] = regs->iaoq[0] + 4;
7826+ return 3;
7827+ }
7828+ }
7829+ } while (0);
7830+#endif
7831+
7832+#ifdef CONFIG_PAX_EMUTRAMP
7833+
7834+#ifndef CONFIG_PAX_EMUSIGRT
7835+ if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7836+ return 1;
7837+#endif
7838+
7839+ do { /* PaX: rt_sigreturn emulation */
7840+ unsigned int ldi1, ldi2, bel, nop;
7841+
7842+ err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7843+ err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7844+ err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7845+ err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7846+
7847+ if (err)
7848+ break;
7849+
7850+ if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7851+ ldi2 == 0x3414015AU &&
7852+ bel == 0xE4008200U &&
7853+ nop == 0x08000240U)
7854+ {
7855+ regs->gr[25] = (ldi1 & 2) >> 1;
7856+ regs->gr[20] = __NR_rt_sigreturn;
7857+ regs->gr[31] = regs->iaoq[1] + 16;
7858+ regs->sr[0] = regs->iasq[1];
7859+ regs->iaoq[0] = 0x100UL;
7860+ regs->iaoq[1] = regs->iaoq[0] + 4;
7861+ regs->iasq[0] = regs->sr[2];
7862+ regs->iasq[1] = regs->sr[2];
7863+ return 2;
7864+ }
7865+ } while (0);
7866+#endif
7867+
7868+ return 1;
7869+}
7870+
7871+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7872+{
7873+ unsigned long i;
7874+
7875+ printk(KERN_ERR "PAX: bytes at PC: ");
7876+ for (i = 0; i < 5; i++) {
7877+ unsigned int c;
7878+ if (get_user(c, (unsigned int *)pc+i))
7879+ printk(KERN_CONT "???????? ");
7880+ else
7881+ printk(KERN_CONT "%08x ", c);
7882+ }
7883+ printk("\n");
7884+}
7885+#endif
7886+
7887 int fixup_exception(struct pt_regs *regs)
7888 {
7889 const struct exception_table_entry *fix;
7890@@ -234,8 +345,33 @@ retry:
7891
7892 good_area:
7893
7894- if ((vma->vm_flags & acc_type) != acc_type)
7895+ if ((vma->vm_flags & acc_type) != acc_type) {
7896+
7897+#ifdef CONFIG_PAX_PAGEEXEC
7898+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7899+ (address & ~3UL) == instruction_pointer(regs))
7900+ {
7901+ up_read(&mm->mmap_sem);
7902+ switch (pax_handle_fetch_fault(regs)) {
7903+
7904+#ifdef CONFIG_PAX_EMUPLT
7905+ case 3:
7906+ return;
7907+#endif
7908+
7909+#ifdef CONFIG_PAX_EMUTRAMP
7910+ case 2:
7911+ return;
7912+#endif
7913+
7914+ }
7915+ pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7916+ do_group_exit(SIGKILL);
7917+ }
7918+#endif
7919+
7920 goto bad_area;
7921+ }
7922
7923 /*
7924 * If for any reason at all we couldn't handle the fault, make
7925diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
7926index 5ef2711..21be2c3 100644
7927--- a/arch/powerpc/Kconfig
7928+++ b/arch/powerpc/Kconfig
7929@@ -415,6 +415,7 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
7930 config KEXEC
7931 bool "kexec system call"
7932 depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP))
7933+ depends on !GRKERNSEC_KMEM
7934 help
7935 kexec is a system call that implements the ability to shutdown your
7936 current kernel, and to start another kernel. It is like a reboot
7937diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7938index 512d278..d31fadd 100644
7939--- a/arch/powerpc/include/asm/atomic.h
7940+++ b/arch/powerpc/include/asm/atomic.h
7941@@ -12,6 +12,11 @@
7942
7943 #define ATOMIC_INIT(i) { (i) }
7944
7945+#define _ASM_EXTABLE(from, to) \
7946+" .section __ex_table,\"a\"\n" \
7947+ PPC_LONG" " #from ", " #to"\n" \
7948+" .previous\n"
7949+
7950 static __inline__ int atomic_read(const atomic_t *v)
7951 {
7952 int t;
7953@@ -21,39 +26,80 @@ static __inline__ int atomic_read(const atomic_t *v)
7954 return t;
7955 }
7956
7957+static __inline__ int atomic_read_unchecked(const atomic_unchecked_t *v)
7958+{
7959+ int t;
7960+
7961+ __asm__ __volatile__("lwz%U1%X1 %0,%1" : "=r"(t) : "m"(v->counter));
7962+
7963+ return t;
7964+}
7965+
7966 static __inline__ void atomic_set(atomic_t *v, int i)
7967 {
7968 __asm__ __volatile__("stw%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i));
7969 }
7970
7971-#define ATOMIC_OP(op, asm_op) \
7972-static __inline__ void atomic_##op(int a, atomic_t *v) \
7973+static __inline__ void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7974+{
7975+ __asm__ __volatile__("stw%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i));
7976+}
7977+
7978+#ifdef CONFIG_PAX_REFCOUNT
7979+#define __REFCOUNT_OP(op) op##o.
7980+#define __OVERFLOW_PRE \
7981+ " mcrxr cr0\n"
7982+#define __OVERFLOW_POST \
7983+ " bf 4*cr0+so, 3f\n" \
7984+ "2: .long 0x00c00b00\n" \
7985+ "3:\n"
7986+#define __OVERFLOW_EXTABLE \
7987+ "\n4:\n"
7988+ _ASM_EXTABLE(2b, 4b)
7989+#else
7990+#define __REFCOUNT_OP(op) op
7991+#define __OVERFLOW_PRE
7992+#define __OVERFLOW_POST
7993+#define __OVERFLOW_EXTABLE
7994+#endif
7995+
7996+#define __ATOMIC_OP(op, suffix, pre_op, asm_op, post_op, extable) \
7997+static inline void atomic_##op##suffix(int a, atomic##suffix##_t *v) \
7998 { \
7999 int t; \
8000 \
8001 __asm__ __volatile__( \
8002-"1: lwarx %0,0,%3 # atomic_" #op "\n" \
8003+"1: lwarx %0,0,%3 # atomic_" #op #suffix "\n" \
8004+ pre_op \
8005 #asm_op " %0,%2,%0\n" \
8006+ post_op \
8007 PPC405_ERR77(0,%3) \
8008 " stwcx. %0,0,%3 \n" \
8009 " bne- 1b\n" \
8010+ extable \
8011 : "=&r" (t), "+m" (v->counter) \
8012 : "r" (a), "r" (&v->counter) \
8013 : "cc"); \
8014 } \
8015
8016-#define ATOMIC_OP_RETURN(op, asm_op) \
8017-static __inline__ int atomic_##op##_return(int a, atomic_t *v) \
8018+#define ATOMIC_OP(op, asm_op) __ATOMIC_OP(op, , , asm_op, , ) \
8019+ __ATOMIC_OP(op, _unchecked, __OVERFLOW_PRE, __REFCOUNT_OP(asm_op), __OVERFLOW_POST, __OVERFLOW_EXTABLE)
8020+
8021+#define __ATOMIC_OP_RETURN(op, suffix, pre_op, asm_op, post_op, extable)\
8022+static inline int atomic_##op##_return##suffix(int a, atomic##suffix##_t *v)\
8023 { \
8024 int t; \
8025 \
8026 __asm__ __volatile__( \
8027 PPC_ATOMIC_ENTRY_BARRIER \
8028-"1: lwarx %0,0,%2 # atomic_" #op "_return\n" \
8029+"1: lwarx %0,0,%2 # atomic_" #op "_return" #suffix "\n" \
8030+ pre_op \
8031 #asm_op " %0,%1,%0\n" \
8032+ post_op \
8033 PPC405_ERR77(0,%2) \
8034 " stwcx. %0,0,%2 \n" \
8035 " bne- 1b\n" \
8036+ extable \
8037 PPC_ATOMIC_EXIT_BARRIER \
8038 : "=&r" (t) \
8039 : "r" (a), "r" (&v->counter) \
8040@@ -62,6 +108,9 @@ static __inline__ int atomic_##op##_return(int a, atomic_t *v) \
8041 return t; \
8042 }
8043
8044+#define ATOMIC_OP_RETURN(op, asm_op) __ATOMIC_OP_RETURN(op, , , asm_op, , )\
8045+ __ATOMIC_OP_RETURN(op, _unchecked, __OVERFLOW_PRE, __REFCOUNT_OP(asm_op), __OVERFLOW_POST, __OVERFLOW_EXTABLE)
8046+
8047 #define ATOMIC_OPS(op, asm_op) ATOMIC_OP(op, asm_op) ATOMIC_OP_RETURN(op, asm_op)
8048
8049 ATOMIC_OPS(add, add)
8050@@ -69,42 +118,29 @@ ATOMIC_OPS(sub, subf)
8051
8052 #undef ATOMIC_OPS
8053 #undef ATOMIC_OP_RETURN
8054+#undef __ATOMIC_OP_RETURN
8055 #undef ATOMIC_OP
8056+#undef __ATOMIC_OP
8057
8058 #define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
8059
8060-static __inline__ void atomic_inc(atomic_t *v)
8061-{
8062- int t;
8063+/*
8064+ * atomic_inc - increment atomic variable
8065+ * @v: pointer of type atomic_t
8066+ *
8067+ * Automatically increments @v by 1
8068+ */
8069+#define atomic_inc(v) atomic_add(1, (v))
8070+#define atomic_inc_return(v) atomic_add_return(1, (v))
8071
8072- __asm__ __volatile__(
8073-"1: lwarx %0,0,%2 # atomic_inc\n\
8074- addic %0,%0,1\n"
8075- PPC405_ERR77(0,%2)
8076-" stwcx. %0,0,%2 \n\
8077- bne- 1b"
8078- : "=&r" (t), "+m" (v->counter)
8079- : "r" (&v->counter)
8080- : "cc", "xer");
8081+static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8082+{
8083+ atomic_add_unchecked(1, v);
8084 }
8085
8086-static __inline__ int atomic_inc_return(atomic_t *v)
8087+static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8088 {
8089- int t;
8090-
8091- __asm__ __volatile__(
8092- PPC_ATOMIC_ENTRY_BARRIER
8093-"1: lwarx %0,0,%1 # atomic_inc_return\n\
8094- addic %0,%0,1\n"
8095- PPC405_ERR77(0,%1)
8096-" stwcx. %0,0,%1 \n\
8097- bne- 1b"
8098- PPC_ATOMIC_EXIT_BARRIER
8099- : "=&r" (t)
8100- : "r" (&v->counter)
8101- : "cc", "xer", "memory");
8102-
8103- return t;
8104+ return atomic_add_return_unchecked(1, v);
8105 }
8106
8107 /*
8108@@ -117,43 +153,38 @@ static __inline__ int atomic_inc_return(atomic_t *v)
8109 */
8110 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8111
8112-static __inline__ void atomic_dec(atomic_t *v)
8113+static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8114 {
8115- int t;
8116-
8117- __asm__ __volatile__(
8118-"1: lwarx %0,0,%2 # atomic_dec\n\
8119- addic %0,%0,-1\n"
8120- PPC405_ERR77(0,%2)\
8121-" stwcx. %0,0,%2\n\
8122- bne- 1b"
8123- : "=&r" (t), "+m" (v->counter)
8124- : "r" (&v->counter)
8125- : "cc", "xer");
8126+ return atomic_add_return_unchecked(1, v) == 0;
8127 }
8128
8129-static __inline__ int atomic_dec_return(atomic_t *v)
8130+/*
8131+ * atomic_dec - decrement atomic variable
8132+ * @v: pointer of type atomic_t
8133+ *
8134+ * Atomically decrements @v by 1
8135+ */
8136+#define atomic_dec(v) atomic_sub(1, (v))
8137+#define atomic_dec_return(v) atomic_sub_return(1, (v))
8138+
8139+static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
8140 {
8141- int t;
8142-
8143- __asm__ __volatile__(
8144- PPC_ATOMIC_ENTRY_BARRIER
8145-"1: lwarx %0,0,%1 # atomic_dec_return\n\
8146- addic %0,%0,-1\n"
8147- PPC405_ERR77(0,%1)
8148-" stwcx. %0,0,%1\n\
8149- bne- 1b"
8150- PPC_ATOMIC_EXIT_BARRIER
8151- : "=&r" (t)
8152- : "r" (&v->counter)
8153- : "cc", "xer", "memory");
8154-
8155- return t;
8156+ atomic_sub_unchecked(1, v);
8157 }
8158
8159 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8160 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8161
8162+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8163+{
8164+ return cmpxchg(&(v->counter), old, new);
8165+}
8166+
8167+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8168+{
8169+ return xchg(&(v->counter), new);
8170+}
8171+
8172 /**
8173 * __atomic_add_unless - add unless the number is a given value
8174 * @v: pointer of type atomic_t
8175@@ -171,11 +202,27 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
8176 PPC_ATOMIC_ENTRY_BARRIER
8177 "1: lwarx %0,0,%1 # __atomic_add_unless\n\
8178 cmpw 0,%0,%3 \n\
8179- beq- 2f \n\
8180- add %0,%2,%0 \n"
8181+ beq- 2f \n"
8182+
8183+#ifdef CONFIG_PAX_REFCOUNT
8184+" mcrxr cr0\n"
8185+" addo. %0,%2,%0\n"
8186+" bf 4*cr0+so, 4f\n"
8187+"3:.long " "0x00c00b00""\n"
8188+"4:\n"
8189+#else
8190+ "add %0,%2,%0 \n"
8191+#endif
8192+
8193 PPC405_ERR77(0,%2)
8194 " stwcx. %0,0,%1 \n\
8195 bne- 1b \n"
8196+"5:"
8197+
8198+#ifdef CONFIG_PAX_REFCOUNT
8199+ _ASM_EXTABLE(3b, 5b)
8200+#endif
8201+
8202 PPC_ATOMIC_EXIT_BARRIER
8203 " subf %0,%2,%0 \n\
8204 2:"
8205@@ -248,6 +295,11 @@ static __inline__ int atomic_dec_if_positive(atomic_t *v)
8206 }
8207 #define atomic_dec_if_positive atomic_dec_if_positive
8208
8209+#define smp_mb__before_atomic_dec() smp_mb()
8210+#define smp_mb__after_atomic_dec() smp_mb()
8211+#define smp_mb__before_atomic_inc() smp_mb()
8212+#define smp_mb__after_atomic_inc() smp_mb()
8213+
8214 #ifdef __powerpc64__
8215
8216 #define ATOMIC64_INIT(i) { (i) }
8217@@ -261,37 +313,60 @@ static __inline__ long atomic64_read(const atomic64_t *v)
8218 return t;
8219 }
8220
8221+static __inline__ long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8222+{
8223+ long t;
8224+
8225+ __asm__ __volatile__("ld%U1%X1 %0,%1" : "=r"(t) : "m"(v->counter));
8226+
8227+ return t;
8228+}
8229+
8230 static __inline__ void atomic64_set(atomic64_t *v, long i)
8231 {
8232 __asm__ __volatile__("std%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i));
8233 }
8234
8235-#define ATOMIC64_OP(op, asm_op) \
8236-static __inline__ void atomic64_##op(long a, atomic64_t *v) \
8237+static __inline__ void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8238+{
8239+ __asm__ __volatile__("std%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i));
8240+}
8241+
8242+#define __ATOMIC64_OP(op, suffix, pre_op, asm_op, post_op, extable) \
8243+static inline void atomic64_##op##suffix(long a, atomic64##suffix##_t *v)\
8244 { \
8245 long t; \
8246 \
8247 __asm__ __volatile__( \
8248 "1: ldarx %0,0,%3 # atomic64_" #op "\n" \
8249+ pre_op \
8250 #asm_op " %0,%2,%0\n" \
8251+ post_op \
8252 " stdcx. %0,0,%3 \n" \
8253 " bne- 1b\n" \
8254+ extable \
8255 : "=&r" (t), "+m" (v->counter) \
8256 : "r" (a), "r" (&v->counter) \
8257 : "cc"); \
8258 }
8259
8260-#define ATOMIC64_OP_RETURN(op, asm_op) \
8261-static __inline__ long atomic64_##op##_return(long a, atomic64_t *v) \
8262+#define ATOMIC64_OP(op, asm_op) __ATOMIC64_OP(op, , , asm_op, , ) \
8263+ __ATOMIC64_OP(op, _unchecked, __OVERFLOW_PRE, __REFCOUNT_OP(asm_op), __OVERFLOW_POST, __OVERFLOW_EXTABLE)
8264+
8265+#define __ATOMIC64_OP_RETURN(op, suffix, pre_op, asm_op, post_op, extable)\
8266+static inline long atomic64_##op##_return##suffix(long a, atomic64##suffix##_t *v)\
8267 { \
8268 long t; \
8269 \
8270 __asm__ __volatile__( \
8271 PPC_ATOMIC_ENTRY_BARRIER \
8272 "1: ldarx %0,0,%2 # atomic64_" #op "_return\n" \
8273+ pre_op \
8274 #asm_op " %0,%1,%0\n" \
8275+ post_op \
8276 " stdcx. %0,0,%2 \n" \
8277 " bne- 1b\n" \
8278+ extable \
8279 PPC_ATOMIC_EXIT_BARRIER \
8280 : "=&r" (t) \
8281 : "r" (a), "r" (&v->counter) \
8282@@ -300,6 +375,9 @@ static __inline__ long atomic64_##op##_return(long a, atomic64_t *v) \
8283 return t; \
8284 }
8285
8286+#define ATOMIC64_OP_RETURN(op, asm_op) __ATOMIC64_OP_RETURN(op, , , asm_op, , )\
8287+ __ATOMIC64_OP_RETURN(op, _unchecked, __OVERFLOW_PRE, __REFCOUNT_OP(asm_op), __OVERFLOW_POST, __OVERFLOW_EXTABLE)
8288+
8289 #define ATOMIC64_OPS(op, asm_op) ATOMIC64_OP(op, asm_op) ATOMIC64_OP_RETURN(op, asm_op)
8290
8291 ATOMIC64_OPS(add, add)
8292@@ -307,40 +385,33 @@ ATOMIC64_OPS(sub, subf)
8293
8294 #undef ATOMIC64_OPS
8295 #undef ATOMIC64_OP_RETURN
8296+#undef __ATOMIC64_OP_RETURN
8297 #undef ATOMIC64_OP
8298+#undef __ATOMIC64_OP
8299+#undef __OVERFLOW_EXTABLE
8300+#undef __OVERFLOW_POST
8301+#undef __OVERFLOW_PRE
8302+#undef __REFCOUNT_OP
8303
8304 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
8305
8306-static __inline__ void atomic64_inc(atomic64_t *v)
8307-{
8308- long t;
8309+/*
8310+ * atomic64_inc - increment atomic variable
8311+ * @v: pointer of type atomic64_t
8312+ *
8313+ * Automatically increments @v by 1
8314+ */
8315+#define atomic64_inc(v) atomic64_add(1, (v))
8316+#define atomic64_inc_return(v) atomic64_add_return(1, (v))
8317
8318- __asm__ __volatile__(
8319-"1: ldarx %0,0,%2 # atomic64_inc\n\
8320- addic %0,%0,1\n\
8321- stdcx. %0,0,%2 \n\
8322- bne- 1b"
8323- : "=&r" (t), "+m" (v->counter)
8324- : "r" (&v->counter)
8325- : "cc", "xer");
8326+static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8327+{
8328+ atomic64_add_unchecked(1, v);
8329 }
8330
8331-static __inline__ long atomic64_inc_return(atomic64_t *v)
8332+static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8333 {
8334- long t;
8335-
8336- __asm__ __volatile__(
8337- PPC_ATOMIC_ENTRY_BARRIER
8338-"1: ldarx %0,0,%1 # atomic64_inc_return\n\
8339- addic %0,%0,1\n\
8340- stdcx. %0,0,%1 \n\
8341- bne- 1b"
8342- PPC_ATOMIC_EXIT_BARRIER
8343- : "=&r" (t)
8344- : "r" (&v->counter)
8345- : "cc", "xer", "memory");
8346-
8347- return t;
8348+ return atomic64_add_return_unchecked(1, v);
8349 }
8350
8351 /*
8352@@ -353,36 +424,18 @@ static __inline__ long atomic64_inc_return(atomic64_t *v)
8353 */
8354 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8355
8356-static __inline__ void atomic64_dec(atomic64_t *v)
8357+/*
8358+ * atomic64_dec - decrement atomic variable
8359+ * @v: pointer of type atomic64_t
8360+ *
8361+ * Atomically decrements @v by 1
8362+ */
8363+#define atomic64_dec(v) atomic64_sub(1, (v))
8364+#define atomic64_dec_return(v) atomic64_sub_return(1, (v))
8365+
8366+static __inline__ void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8367 {
8368- long t;
8369-
8370- __asm__ __volatile__(
8371-"1: ldarx %0,0,%2 # atomic64_dec\n\
8372- addic %0,%0,-1\n\
8373- stdcx. %0,0,%2\n\
8374- bne- 1b"
8375- : "=&r" (t), "+m" (v->counter)
8376- : "r" (&v->counter)
8377- : "cc", "xer");
8378-}
8379-
8380-static __inline__ long atomic64_dec_return(atomic64_t *v)
8381-{
8382- long t;
8383-
8384- __asm__ __volatile__(
8385- PPC_ATOMIC_ENTRY_BARRIER
8386-"1: ldarx %0,0,%1 # atomic64_dec_return\n\
8387- addic %0,%0,-1\n\
8388- stdcx. %0,0,%1\n\
8389- bne- 1b"
8390- PPC_ATOMIC_EXIT_BARRIER
8391- : "=&r" (t)
8392- : "r" (&v->counter)
8393- : "cc", "xer", "memory");
8394-
8395- return t;
8396+ atomic64_sub_unchecked(1, v);
8397 }
8398
8399 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
8400@@ -415,6 +468,16 @@ static __inline__ long atomic64_dec_if_positive(atomic64_t *v)
8401 #define atomic64_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8402 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8403
8404+static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
8405+{
8406+ return cmpxchg(&(v->counter), old, new);
8407+}
8408+
8409+static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8410+{
8411+ return xchg(&(v->counter), new);
8412+}
8413+
8414 /**
8415 * atomic64_add_unless - add unless the number is a given value
8416 * @v: pointer of type atomic64_t
8417@@ -430,13 +493,29 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
8418
8419 __asm__ __volatile__ (
8420 PPC_ATOMIC_ENTRY_BARRIER
8421-"1: ldarx %0,0,%1 # __atomic_add_unless\n\
8422+"1: ldarx %0,0,%1 # atomic64_add_unless\n\
8423 cmpd 0,%0,%3 \n\
8424- beq- 2f \n\
8425- add %0,%2,%0 \n"
8426+ beq- 2f \n"
8427+
8428+#ifdef CONFIG_PAX_REFCOUNT
8429+" mcrxr cr0\n"
8430+" addo. %0,%2,%0\n"
8431+" bf 4*cr0+so, 4f\n"
8432+"3:.long " "0x00c00b00""\n"
8433+"4:\n"
8434+#else
8435+ "add %0,%2,%0 \n"
8436+#endif
8437+
8438 " stdcx. %0,0,%1 \n\
8439 bne- 1b \n"
8440 PPC_ATOMIC_EXIT_BARRIER
8441+"5:"
8442+
8443+#ifdef CONFIG_PAX_REFCOUNT
8444+ _ASM_EXTABLE(3b, 5b)
8445+#endif
8446+
8447 " subf %0,%2,%0 \n\
8448 2:"
8449 : "=&r" (t)
8450diff --git a/arch/powerpc/include/asm/barrier.h b/arch/powerpc/include/asm/barrier.h
8451index 51ccc72..35de789 100644
8452--- a/arch/powerpc/include/asm/barrier.h
8453+++ b/arch/powerpc/include/asm/barrier.h
8454@@ -76,7 +76,7 @@
8455 do { \
8456 compiletime_assert_atomic_type(*p); \
8457 smp_lwsync(); \
8458- ACCESS_ONCE(*p) = (v); \
8459+ ACCESS_ONCE_RW(*p) = (v); \
8460 } while (0)
8461
8462 #define smp_load_acquire(p) \
8463diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
8464index 0dc42c5..b80a3a1 100644
8465--- a/arch/powerpc/include/asm/cache.h
8466+++ b/arch/powerpc/include/asm/cache.h
8467@@ -4,6 +4,7 @@
8468 #ifdef __KERNEL__
8469
8470 #include <asm/reg.h>
8471+#include <linux/const.h>
8472
8473 /* bytes per L1 cache line */
8474 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
8475@@ -23,7 +24,7 @@
8476 #define L1_CACHE_SHIFT 7
8477 #endif
8478
8479-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8480+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8481
8482 #define SMP_CACHE_BYTES L1_CACHE_BYTES
8483
8484diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
8485index ee46ffe..b36c98c 100644
8486--- a/arch/powerpc/include/asm/elf.h
8487+++ b/arch/powerpc/include/asm/elf.h
8488@@ -30,6 +30,18 @@
8489
8490 #define ELF_ET_DYN_BASE 0x20000000
8491
8492+#ifdef CONFIG_PAX_ASLR
8493+#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
8494+
8495+#ifdef __powerpc64__
8496+#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
8497+#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
8498+#else
8499+#define PAX_DELTA_MMAP_LEN 15
8500+#define PAX_DELTA_STACK_LEN 15
8501+#endif
8502+#endif
8503+
8504 #define ELF_CORE_EFLAGS (is_elf2_task() ? 2 : 0)
8505
8506 /*
8507diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
8508index 8196e9c..d83a9f3 100644
8509--- a/arch/powerpc/include/asm/exec.h
8510+++ b/arch/powerpc/include/asm/exec.h
8511@@ -4,6 +4,6 @@
8512 #ifndef _ASM_POWERPC_EXEC_H
8513 #define _ASM_POWERPC_EXEC_H
8514
8515-extern unsigned long arch_align_stack(unsigned long sp);
8516+#define arch_align_stack(x) ((x) & ~0xfUL)
8517
8518 #endif /* _ASM_POWERPC_EXEC_H */
8519diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
8520index 5acabbd..7ea14fa 100644
8521--- a/arch/powerpc/include/asm/kmap_types.h
8522+++ b/arch/powerpc/include/asm/kmap_types.h
8523@@ -10,7 +10,7 @@
8524 * 2 of the License, or (at your option) any later version.
8525 */
8526
8527-#define KM_TYPE_NR 16
8528+#define KM_TYPE_NR 17
8529
8530 #endif /* __KERNEL__ */
8531 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
8532diff --git a/arch/powerpc/include/asm/local.h b/arch/powerpc/include/asm/local.h
8533index b8da913..c02b593 100644
8534--- a/arch/powerpc/include/asm/local.h
8535+++ b/arch/powerpc/include/asm/local.h
8536@@ -9,21 +9,65 @@ typedef struct
8537 atomic_long_t a;
8538 } local_t;
8539
8540+typedef struct
8541+{
8542+ atomic_long_unchecked_t a;
8543+} local_unchecked_t;
8544+
8545 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
8546
8547 #define local_read(l) atomic_long_read(&(l)->a)
8548+#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
8549 #define local_set(l,i) atomic_long_set(&(l)->a, (i))
8550+#define local_set_unchecked(l,i) atomic_long_set_unchecked(&(l)->a, (i))
8551
8552 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
8553+#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
8554 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
8555+#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
8556 #define local_inc(l) atomic_long_inc(&(l)->a)
8557+#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
8558 #define local_dec(l) atomic_long_dec(&(l)->a)
8559+#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
8560
8561 static __inline__ long local_add_return(long a, local_t *l)
8562 {
8563 long t;
8564
8565 __asm__ __volatile__(
8566+"1:" PPC_LLARX(%0,0,%2,0) " # local_add_return\n"
8567+
8568+#ifdef CONFIG_PAX_REFCOUNT
8569+" mcrxr cr0\n"
8570+" addo. %0,%1,%0\n"
8571+" bf 4*cr0+so, 3f\n"
8572+"2:.long " "0x00c00b00""\n"
8573+#else
8574+" add %0,%1,%0\n"
8575+#endif
8576+
8577+"3:\n"
8578+ PPC405_ERR77(0,%2)
8579+ PPC_STLCX "%0,0,%2 \n\
8580+ bne- 1b"
8581+
8582+#ifdef CONFIG_PAX_REFCOUNT
8583+"\n4:\n"
8584+ _ASM_EXTABLE(2b, 4b)
8585+#endif
8586+
8587+ : "=&r" (t)
8588+ : "r" (a), "r" (&(l->a.counter))
8589+ : "cc", "memory");
8590+
8591+ return t;
8592+}
8593+
8594+static __inline__ long local_add_return_unchecked(long a, local_unchecked_t *l)
8595+{
8596+ long t;
8597+
8598+ __asm__ __volatile__(
8599 "1:" PPC_LLARX(%0,0,%2,0) " # local_add_return\n\
8600 add %0,%1,%0\n"
8601 PPC405_ERR77(0,%2)
8602@@ -101,6 +145,8 @@ static __inline__ long local_dec_return(local_t *l)
8603
8604 #define local_cmpxchg(l, o, n) \
8605 (cmpxchg_local(&((l)->a.counter), (o), (n)))
8606+#define local_cmpxchg_unchecked(l, o, n) \
8607+ (cmpxchg_local(&((l)->a.counter), (o), (n)))
8608 #define local_xchg(l, n) (xchg_local(&((l)->a.counter), (n)))
8609
8610 /**
8611diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
8612index 8565c25..2865190 100644
8613--- a/arch/powerpc/include/asm/mman.h
8614+++ b/arch/powerpc/include/asm/mman.h
8615@@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
8616 }
8617 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
8618
8619-static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
8620+static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
8621 {
8622 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
8623 }
8624diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
8625index 71294a6..9e40aca 100644
8626--- a/arch/powerpc/include/asm/page.h
8627+++ b/arch/powerpc/include/asm/page.h
8628@@ -227,8 +227,9 @@ extern long long virt_phys_offset;
8629 * and needs to be executable. This means the whole heap ends
8630 * up being executable.
8631 */
8632-#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
8633- VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8634+#define VM_DATA_DEFAULT_FLAGS32 \
8635+ (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
8636+ VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8637
8638 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
8639 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8640@@ -256,6 +257,9 @@ extern long long virt_phys_offset;
8641 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
8642 #endif
8643
8644+#define ktla_ktva(addr) (addr)
8645+#define ktva_ktla(addr) (addr)
8646+
8647 #ifndef CONFIG_PPC_BOOK3S_64
8648 /*
8649 * Use the top bit of the higher-level page table entries to indicate whether
8650diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
8651index d908a46..3753f71 100644
8652--- a/arch/powerpc/include/asm/page_64.h
8653+++ b/arch/powerpc/include/asm/page_64.h
8654@@ -172,15 +172,18 @@ do { \
8655 * stack by default, so in the absence of a PT_GNU_STACK program header
8656 * we turn execute permission off.
8657 */
8658-#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
8659- VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8660+#define VM_STACK_DEFAULT_FLAGS32 \
8661+ (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
8662+ VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8663
8664 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
8665 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8666
8667+#ifndef CONFIG_PAX_PAGEEXEC
8668 #define VM_STACK_DEFAULT_FLAGS \
8669 (is_32bit_task() ? \
8670 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
8671+#endif
8672
8673 #include <asm-generic/getorder.h>
8674
8675diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
8676index 4b0be20..c15a27d 100644
8677--- a/arch/powerpc/include/asm/pgalloc-64.h
8678+++ b/arch/powerpc/include/asm/pgalloc-64.h
8679@@ -54,6 +54,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
8680 #ifndef CONFIG_PPC_64K_PAGES
8681
8682 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
8683+#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
8684
8685 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
8686 {
8687@@ -71,6 +72,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
8688 pud_set(pud, (unsigned long)pmd);
8689 }
8690
8691+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
8692+{
8693+ pud_populate(mm, pud, pmd);
8694+}
8695+
8696 #define pmd_populate(mm, pmd, pte_page) \
8697 pmd_populate_kernel(mm, pmd, page_address(pte_page))
8698 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
8699@@ -173,6 +179,7 @@ extern void __tlb_remove_table(void *_table);
8700 #endif
8701
8702 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
8703+#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
8704
8705 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
8706 pte_t *pte)
8707diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
8708index 11a3863..108f194 100644
8709--- a/arch/powerpc/include/asm/pgtable.h
8710+++ b/arch/powerpc/include/asm/pgtable.h
8711@@ -2,6 +2,7 @@
8712 #define _ASM_POWERPC_PGTABLE_H
8713 #ifdef __KERNEL__
8714
8715+#include <linux/const.h>
8716 #ifndef __ASSEMBLY__
8717 #include <linux/mmdebug.h>
8718 #include <linux/mmzone.h>
8719diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
8720index 62cfb0c..50c6402 100644
8721--- a/arch/powerpc/include/asm/pte-hash32.h
8722+++ b/arch/powerpc/include/asm/pte-hash32.h
8723@@ -20,6 +20,7 @@
8724 #define _PAGE_HASHPTE 0x002 /* hash_page has made an HPTE for this pte */
8725 #define _PAGE_USER 0x004 /* usermode access allowed */
8726 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
8727+#define _PAGE_EXEC _PAGE_GUARDED
8728 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
8729 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
8730 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
8731diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
8732index af56b5c..f86f3f6 100644
8733--- a/arch/powerpc/include/asm/reg.h
8734+++ b/arch/powerpc/include/asm/reg.h
8735@@ -253,6 +253,7 @@
8736 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
8737 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
8738 #define DSISR_NOHPTE 0x40000000 /* no translation found */
8739+#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
8740 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
8741 #define DSISR_ISSTORE 0x02000000 /* access was a store */
8742 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
8743diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
8744index 825663c..f9e9134 100644
8745--- a/arch/powerpc/include/asm/smp.h
8746+++ b/arch/powerpc/include/asm/smp.h
8747@@ -51,7 +51,7 @@ struct smp_ops_t {
8748 int (*cpu_disable)(void);
8749 void (*cpu_die)(unsigned int nr);
8750 int (*cpu_bootable)(unsigned int nr);
8751-};
8752+} __no_const;
8753
8754 extern void smp_send_debugger_break(void);
8755 extern void start_secondary_resume(void);
8756diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
8757index 4dbe072..b803275 100644
8758--- a/arch/powerpc/include/asm/spinlock.h
8759+++ b/arch/powerpc/include/asm/spinlock.h
8760@@ -204,13 +204,29 @@ static inline long __arch_read_trylock(arch_rwlock_t *rw)
8761 __asm__ __volatile__(
8762 "1: " PPC_LWARX(%0,0,%1,1) "\n"
8763 __DO_SIGN_EXTEND
8764-" addic. %0,%0,1\n\
8765- ble- 2f\n"
8766+
8767+#ifdef CONFIG_PAX_REFCOUNT
8768+" mcrxr cr0\n"
8769+" addico. %0,%0,1\n"
8770+" bf 4*cr0+so, 3f\n"
8771+"2:.long " "0x00c00b00""\n"
8772+#else
8773+" addic. %0,%0,1\n"
8774+#endif
8775+
8776+"3:\n"
8777+ "ble- 4f\n"
8778 PPC405_ERR77(0,%1)
8779 " stwcx. %0,0,%1\n\
8780 bne- 1b\n"
8781 PPC_ACQUIRE_BARRIER
8782-"2:" : "=&r" (tmp)
8783+"4:"
8784+
8785+#ifdef CONFIG_PAX_REFCOUNT
8786+ _ASM_EXTABLE(2b,4b)
8787+#endif
8788+
8789+ : "=&r" (tmp)
8790 : "r" (&rw->lock)
8791 : "cr0", "xer", "memory");
8792
8793@@ -286,11 +302,27 @@ static inline void arch_read_unlock(arch_rwlock_t *rw)
8794 __asm__ __volatile__(
8795 "# read_unlock\n\t"
8796 PPC_RELEASE_BARRIER
8797-"1: lwarx %0,0,%1\n\
8798- addic %0,%0,-1\n"
8799+"1: lwarx %0,0,%1\n"
8800+
8801+#ifdef CONFIG_PAX_REFCOUNT
8802+" mcrxr cr0\n"
8803+" addico. %0,%0,-1\n"
8804+" bf 4*cr0+so, 3f\n"
8805+"2:.long " "0x00c00b00""\n"
8806+#else
8807+" addic. %0,%0,-1\n"
8808+#endif
8809+
8810+"3:\n"
8811 PPC405_ERR77(0,%1)
8812 " stwcx. %0,0,%1\n\
8813 bne- 1b"
8814+
8815+#ifdef CONFIG_PAX_REFCOUNT
8816+"\n4:\n"
8817+ _ASM_EXTABLE(2b, 4b)
8818+#endif
8819+
8820 : "=&r"(tmp)
8821 : "r"(&rw->lock)
8822 : "cr0", "xer", "memory");
8823diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
8824index 7efee4a..48d47cc 100644
8825--- a/arch/powerpc/include/asm/thread_info.h
8826+++ b/arch/powerpc/include/asm/thread_info.h
8827@@ -101,6 +101,8 @@ static inline struct thread_info *current_thread_info(void)
8828 #if defined(CONFIG_PPC64)
8829 #define TIF_ELF2ABI 18 /* function descriptors must die! */
8830 #endif
8831+/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
8832+#define TIF_GRSEC_SETXID 6 /* update credentials on syscall entry/exit */
8833
8834 /* as above, but as bit values */
8835 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
8836@@ -119,9 +121,10 @@ static inline struct thread_info *current_thread_info(void)
8837 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8838 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
8839 #define _TIF_NOHZ (1<<TIF_NOHZ)
8840+#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8841 #define _TIF_SYSCALL_DOTRACE (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
8842 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
8843- _TIF_NOHZ)
8844+ _TIF_NOHZ | _TIF_GRSEC_SETXID)
8845
8846 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
8847 _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
8848diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
8849index 2a8ebae..5643c6f 100644
8850--- a/arch/powerpc/include/asm/uaccess.h
8851+++ b/arch/powerpc/include/asm/uaccess.h
8852@@ -58,6 +58,7 @@
8853
8854 #endif
8855
8856+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
8857 #define access_ok(type, addr, size) \
8858 (__chk_user_ptr(addr), \
8859 __access_ok((__force unsigned long)(addr), (size), get_fs()))
8860@@ -318,52 +319,6 @@ do { \
8861 extern unsigned long __copy_tofrom_user(void __user *to,
8862 const void __user *from, unsigned long size);
8863
8864-#ifndef __powerpc64__
8865-
8866-static inline unsigned long copy_from_user(void *to,
8867- const void __user *from, unsigned long n)
8868-{
8869- unsigned long over;
8870-
8871- if (access_ok(VERIFY_READ, from, n))
8872- return __copy_tofrom_user((__force void __user *)to, from, n);
8873- if ((unsigned long)from < TASK_SIZE) {
8874- over = (unsigned long)from + n - TASK_SIZE;
8875- return __copy_tofrom_user((__force void __user *)to, from,
8876- n - over) + over;
8877- }
8878- return n;
8879-}
8880-
8881-static inline unsigned long copy_to_user(void __user *to,
8882- const void *from, unsigned long n)
8883-{
8884- unsigned long over;
8885-
8886- if (access_ok(VERIFY_WRITE, to, n))
8887- return __copy_tofrom_user(to, (__force void __user *)from, n);
8888- if ((unsigned long)to < TASK_SIZE) {
8889- over = (unsigned long)to + n - TASK_SIZE;
8890- return __copy_tofrom_user(to, (__force void __user *)from,
8891- n - over) + over;
8892- }
8893- return n;
8894-}
8895-
8896-#else /* __powerpc64__ */
8897-
8898-#define __copy_in_user(to, from, size) \
8899- __copy_tofrom_user((to), (from), (size))
8900-
8901-extern unsigned long copy_from_user(void *to, const void __user *from,
8902- unsigned long n);
8903-extern unsigned long copy_to_user(void __user *to, const void *from,
8904- unsigned long n);
8905-extern unsigned long copy_in_user(void __user *to, const void __user *from,
8906- unsigned long n);
8907-
8908-#endif /* __powerpc64__ */
8909-
8910 static inline unsigned long __copy_from_user_inatomic(void *to,
8911 const void __user *from, unsigned long n)
8912 {
8913@@ -387,6 +342,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
8914 if (ret == 0)
8915 return 0;
8916 }
8917+
8918+ if (!__builtin_constant_p(n))
8919+ check_object_size(to, n, false);
8920+
8921 return __copy_tofrom_user((__force void __user *)to, from, n);
8922 }
8923
8924@@ -413,6 +372,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
8925 if (ret == 0)
8926 return 0;
8927 }
8928+
8929+ if (!__builtin_constant_p(n))
8930+ check_object_size(from, n, true);
8931+
8932 return __copy_tofrom_user(to, (__force const void __user *)from, n);
8933 }
8934
8935@@ -430,6 +393,92 @@ static inline unsigned long __copy_to_user(void __user *to,
8936 return __copy_to_user_inatomic(to, from, size);
8937 }
8938
8939+#ifndef __powerpc64__
8940+
8941+static inline unsigned long __must_check copy_from_user(void *to,
8942+ const void __user *from, unsigned long n)
8943+{
8944+ unsigned long over;
8945+
8946+ if ((long)n < 0)
8947+ return n;
8948+
8949+ if (access_ok(VERIFY_READ, from, n)) {
8950+ if (!__builtin_constant_p(n))
8951+ check_object_size(to, n, false);
8952+ return __copy_tofrom_user((__force void __user *)to, from, n);
8953+ }
8954+ if ((unsigned long)from < TASK_SIZE) {
8955+ over = (unsigned long)from + n - TASK_SIZE;
8956+ if (!__builtin_constant_p(n - over))
8957+ check_object_size(to, n - over, false);
8958+ return __copy_tofrom_user((__force void __user *)to, from,
8959+ n - over) + over;
8960+ }
8961+ return n;
8962+}
8963+
8964+static inline unsigned long __must_check copy_to_user(void __user *to,
8965+ const void *from, unsigned long n)
8966+{
8967+ unsigned long over;
8968+
8969+ if ((long)n < 0)
8970+ return n;
8971+
8972+ if (access_ok(VERIFY_WRITE, to, n)) {
8973+ if (!__builtin_constant_p(n))
8974+ check_object_size(from, n, true);
8975+ return __copy_tofrom_user(to, (__force void __user *)from, n);
8976+ }
8977+ if ((unsigned long)to < TASK_SIZE) {
8978+ over = (unsigned long)to + n - TASK_SIZE;
8979+ if (!__builtin_constant_p(n))
8980+ check_object_size(from, n - over, true);
8981+ return __copy_tofrom_user(to, (__force void __user *)from,
8982+ n - over) + over;
8983+ }
8984+ return n;
8985+}
8986+
8987+#else /* __powerpc64__ */
8988+
8989+#define __copy_in_user(to, from, size) \
8990+ __copy_tofrom_user((to), (from), (size))
8991+
8992+static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
8993+{
8994+ if ((long)n < 0 || n > INT_MAX)
8995+ return n;
8996+
8997+ if (!__builtin_constant_p(n))
8998+ check_object_size(to, n, false);
8999+
9000+ if (likely(access_ok(VERIFY_READ, from, n)))
9001+ n = __copy_from_user(to, from, n);
9002+ else
9003+ memset(to, 0, n);
9004+ return n;
9005+}
9006+
9007+static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
9008+{
9009+ if ((long)n < 0 || n > INT_MAX)
9010+ return n;
9011+
9012+ if (likely(access_ok(VERIFY_WRITE, to, n))) {
9013+ if (!__builtin_constant_p(n))
9014+ check_object_size(from, n, true);
9015+ n = __copy_to_user(to, from, n);
9016+ }
9017+ return n;
9018+}
9019+
9020+extern unsigned long copy_in_user(void __user *to, const void __user *from,
9021+ unsigned long n);
9022+
9023+#endif /* __powerpc64__ */
9024+
9025 extern unsigned long __clear_user(void __user *addr, unsigned long size);
9026
9027 static inline unsigned long clear_user(void __user *addr, unsigned long size)
9028diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
9029index 12868b1..5155667 100644
9030--- a/arch/powerpc/kernel/Makefile
9031+++ b/arch/powerpc/kernel/Makefile
9032@@ -14,6 +14,11 @@ CFLAGS_prom_init.o += -fPIC
9033 CFLAGS_btext.o += -fPIC
9034 endif
9035
9036+CFLAGS_REMOVE_cputable.o = $(LATENT_ENTROPY_PLUGIN_CFLAGS)
9037+CFLAGS_REMOVE_prom_init.o = $(LATENT_ENTROPY_PLUGIN_CFLAGS)
9038+CFLAGS_REMOVE_btext.o = $(LATENT_ENTROPY_PLUGIN_CFLAGS)
9039+CFLAGS_REMOVE_prom.o = $(LATENT_ENTROPY_PLUGIN_CFLAGS)
9040+
9041 ifdef CONFIG_FUNCTION_TRACER
9042 # Do not trace early boot code
9043 CFLAGS_REMOVE_cputable.o = -pg -mno-sched-epilog
9044@@ -26,6 +31,8 @@ CFLAGS_REMOVE_ftrace.o = -pg -mno-sched-epilog
9045 CFLAGS_REMOVE_time.o = -pg -mno-sched-epilog
9046 endif
9047
9048+CFLAGS_REMOVE_prom_init.o += $(LATENT_ENTROPY_PLUGIN_CFLAGS)
9049+
9050 obj-y := cputable.o ptrace.o syscalls.o \
9051 irq.o align.o signal_32.o pmc.o vdso.o \
9052 process.o systbl.o idle.o \
9053diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
9054index 3e68d1c..72a5ee6 100644
9055--- a/arch/powerpc/kernel/exceptions-64e.S
9056+++ b/arch/powerpc/kernel/exceptions-64e.S
9057@@ -1010,6 +1010,7 @@ storage_fault_common:
9058 std r14,_DAR(r1)
9059 std r15,_DSISR(r1)
9060 addi r3,r1,STACK_FRAME_OVERHEAD
9061+ bl save_nvgprs
9062 mr r4,r14
9063 mr r5,r15
9064 ld r14,PACA_EXGEN+EX_R14(r13)
9065@@ -1018,8 +1019,7 @@ storage_fault_common:
9066 cmpdi r3,0
9067 bne- 1f
9068 b ret_from_except_lite
9069-1: bl save_nvgprs
9070- mr r5,r3
9071+1: mr r5,r3
9072 addi r3,r1,STACK_FRAME_OVERHEAD
9073 ld r4,_DAR(r1)
9074 bl bad_page_fault
9075diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
9076index 0a0399c2..262a2e6 100644
9077--- a/arch/powerpc/kernel/exceptions-64s.S
9078+++ b/arch/powerpc/kernel/exceptions-64s.S
9079@@ -1591,10 +1591,10 @@ handle_page_fault:
9080 11: ld r4,_DAR(r1)
9081 ld r5,_DSISR(r1)
9082 addi r3,r1,STACK_FRAME_OVERHEAD
9083+ bl save_nvgprs
9084 bl do_page_fault
9085 cmpdi r3,0
9086 beq+ 12f
9087- bl save_nvgprs
9088 mr r5,r3
9089 addi r3,r1,STACK_FRAME_OVERHEAD
9090 lwz r4,_DAR(r1)
9091diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
9092index 4509603..cdb491f 100644
9093--- a/arch/powerpc/kernel/irq.c
9094+++ b/arch/powerpc/kernel/irq.c
9095@@ -460,6 +460,8 @@ void migrate_irqs(void)
9096 }
9097 #endif
9098
9099+extern void gr_handle_kernel_exploit(void);
9100+
9101 static inline void check_stack_overflow(void)
9102 {
9103 #ifdef CONFIG_DEBUG_STACKOVERFLOW
9104@@ -472,6 +474,7 @@ static inline void check_stack_overflow(void)
9105 pr_err("do_IRQ: stack overflow: %ld\n",
9106 sp - sizeof(struct thread_info));
9107 dump_stack();
9108+ gr_handle_kernel_exploit();
9109 }
9110 #endif
9111 }
9112diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
9113index c94d2e0..992a9ce 100644
9114--- a/arch/powerpc/kernel/module_32.c
9115+++ b/arch/powerpc/kernel/module_32.c
9116@@ -158,7 +158,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
9117 me->arch.core_plt_section = i;
9118 }
9119 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
9120- pr_err("Module doesn't contain .plt or .init.plt sections.\n");
9121+ pr_err("Module $s doesn't contain .plt or .init.plt sections.\n", me->name);
9122 return -ENOEXEC;
9123 }
9124
9125@@ -188,11 +188,16 @@ static uint32_t do_plt_call(void *location,
9126
9127 pr_debug("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
9128 /* Init, or core PLT? */
9129- if (location >= mod->module_core
9130- && location < mod->module_core + mod->core_size)
9131+ if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
9132+ (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
9133 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
9134- else
9135+ else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
9136+ (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
9137 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
9138+ else {
9139+ printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
9140+ return ~0UL;
9141+ }
9142
9143 /* Find this entry, or if that fails, the next avail. entry */
9144 while (entry->jump[0]) {
9145@@ -296,7 +301,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
9146 }
9147 #ifdef CONFIG_DYNAMIC_FTRACE
9148 module->arch.tramp =
9149- do_plt_call(module->module_core,
9150+ do_plt_call(module->module_core_rx,
9151 (unsigned long)ftrace_caller,
9152 sechdrs, module);
9153 #endif
9154diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
9155index 64e6e9d..cf90ed5 100644
9156--- a/arch/powerpc/kernel/process.c
9157+++ b/arch/powerpc/kernel/process.c
9158@@ -1033,8 +1033,8 @@ void show_regs(struct pt_regs * regs)
9159 * Lookup NIP late so we have the best change of getting the
9160 * above info out without failing
9161 */
9162- printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
9163- printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
9164+ printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
9165+ printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
9166 #endif
9167 show_stack(current, (unsigned long *) regs->gpr[1]);
9168 if (!user_mode(regs))
9169@@ -1550,10 +1550,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
9170 newsp = stack[0];
9171 ip = stack[STACK_FRAME_LR_SAVE];
9172 if (!firstframe || ip != lr) {
9173- printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
9174+ printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
9175 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
9176 if ((ip == rth) && curr_frame >= 0) {
9177- printk(" (%pS)",
9178+ printk(" (%pA)",
9179 (void *)current->ret_stack[curr_frame].ret);
9180 curr_frame--;
9181 }
9182@@ -1573,7 +1573,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
9183 struct pt_regs *regs = (struct pt_regs *)
9184 (sp + STACK_FRAME_OVERHEAD);
9185 lr = regs->link;
9186- printk("--- interrupt: %lx at %pS\n LR = %pS\n",
9187+ printk("--- interrupt: %lx at %pA\n LR = %pA\n",
9188 regs->trap, (void *)regs->nip, (void *)lr);
9189 firstframe = 1;
9190 }
9191@@ -1609,49 +1609,3 @@ void notrace __ppc64_runlatch_off(void)
9192 mtspr(SPRN_CTRLT, ctrl);
9193 }
9194 #endif /* CONFIG_PPC64 */
9195-
9196-unsigned long arch_align_stack(unsigned long sp)
9197-{
9198- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
9199- sp -= get_random_int() & ~PAGE_MASK;
9200- return sp & ~0xf;
9201-}
9202-
9203-static inline unsigned long brk_rnd(void)
9204-{
9205- unsigned long rnd = 0;
9206-
9207- /* 8MB for 32bit, 1GB for 64bit */
9208- if (is_32bit_task())
9209- rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
9210- else
9211- rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
9212-
9213- return rnd << PAGE_SHIFT;
9214-}
9215-
9216-unsigned long arch_randomize_brk(struct mm_struct *mm)
9217-{
9218- unsigned long base = mm->brk;
9219- unsigned long ret;
9220-
9221-#ifdef CONFIG_PPC_STD_MMU_64
9222- /*
9223- * If we are using 1TB segments and we are allowed to randomise
9224- * the heap, we can put it above 1TB so it is backed by a 1TB
9225- * segment. Otherwise the heap will be in the bottom 1TB
9226- * which always uses 256MB segments and this may result in a
9227- * performance penalty.
9228- */
9229- if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
9230- base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
9231-#endif
9232-
9233- ret = PAGE_ALIGN(base + brk_rnd());
9234-
9235- if (ret < mm->brk)
9236- return mm->brk;
9237-
9238- return ret;
9239-}
9240-
9241diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
9242index f21897b..28c0428 100644
9243--- a/arch/powerpc/kernel/ptrace.c
9244+++ b/arch/powerpc/kernel/ptrace.c
9245@@ -1762,6 +1762,10 @@ long arch_ptrace(struct task_struct *child, long request,
9246 return ret;
9247 }
9248
9249+#ifdef CONFIG_GRKERNSEC_SETXID
9250+extern void gr_delayed_cred_worker(void);
9251+#endif
9252+
9253 /*
9254 * We must return the syscall number to actually look up in the table.
9255 * This can be -1L to skip running any syscall at all.
9256@@ -1774,6 +1778,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
9257
9258 secure_computing_strict(regs->gpr[0]);
9259
9260+#ifdef CONFIG_GRKERNSEC_SETXID
9261+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9262+ gr_delayed_cred_worker();
9263+#endif
9264+
9265 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
9266 tracehook_report_syscall_entry(regs))
9267 /*
9268@@ -1805,6 +1814,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
9269 {
9270 int step;
9271
9272+#ifdef CONFIG_GRKERNSEC_SETXID
9273+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9274+ gr_delayed_cred_worker();
9275+#endif
9276+
9277 audit_syscall_exit(regs);
9278
9279 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9280diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
9281index da50e0c..5ff6307 100644
9282--- a/arch/powerpc/kernel/signal_32.c
9283+++ b/arch/powerpc/kernel/signal_32.c
9284@@ -1009,7 +1009,7 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset,
9285 /* Save user registers on the stack */
9286 frame = &rt_sf->uc.uc_mcontext;
9287 addr = frame;
9288- if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
9289+ if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
9290 sigret = 0;
9291 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
9292 } else {
9293diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
9294index c7c24d2..1bf7039 100644
9295--- a/arch/powerpc/kernel/signal_64.c
9296+++ b/arch/powerpc/kernel/signal_64.c
9297@@ -754,7 +754,7 @@ int handle_rt_signal64(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs
9298 current->thread.fp_state.fpscr = 0;
9299
9300 /* Set up to return from userspace. */
9301- if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
9302+ if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
9303 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
9304 } else {
9305 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
9306diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
9307index 37de90f..12472ac 100644
9308--- a/arch/powerpc/kernel/traps.c
9309+++ b/arch/powerpc/kernel/traps.c
9310@@ -36,6 +36,7 @@
9311 #include <linux/debugfs.h>
9312 #include <linux/ratelimit.h>
9313 #include <linux/context_tracking.h>
9314+#include <linux/uaccess.h>
9315
9316 #include <asm/emulated_ops.h>
9317 #include <asm/pgtable.h>
9318@@ -142,6 +143,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
9319 return flags;
9320 }
9321
9322+extern void gr_handle_kernel_exploit(void);
9323+
9324 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
9325 int signr)
9326 {
9327@@ -191,6 +194,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
9328 panic("Fatal exception in interrupt");
9329 if (panic_on_oops)
9330 panic("Fatal exception");
9331+
9332+ gr_handle_kernel_exploit();
9333+
9334 do_exit(signr);
9335 }
9336
9337@@ -1139,6 +1145,26 @@ void __kprobes program_check_exception(struct pt_regs *regs)
9338 enum ctx_state prev_state = exception_enter();
9339 unsigned int reason = get_reason(regs);
9340
9341+#ifdef CONFIG_PAX_REFCOUNT
9342+ unsigned int bkpt;
9343+ const struct exception_table_entry *entry;
9344+
9345+ if (reason & REASON_ILLEGAL) {
9346+ /* Check if PaX bad instruction */
9347+ if (!probe_kernel_address(regs->nip, bkpt) && bkpt == 0xc00b00) {
9348+ current->thread.trap_nr = 0;
9349+ pax_report_refcount_overflow(regs);
9350+ /* fixup_exception() for PowerPC does not exist, simulate its job */
9351+ if ((entry = search_exception_tables(regs->nip)) != NULL) {
9352+ regs->nip = entry->fixup;
9353+ return;
9354+ }
9355+ /* fixup_exception() could not handle */
9356+ goto bail;
9357+ }
9358+ }
9359+#endif
9360+
9361 /* We can now get here via a FP Unavailable exception if the core
9362 * has no FPU, in that case the reason flags will be 0 */
9363
9364diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
9365index b457bfa..9018cde 100644
9366--- a/arch/powerpc/kernel/vdso.c
9367+++ b/arch/powerpc/kernel/vdso.c
9368@@ -34,6 +34,7 @@
9369 #include <asm/vdso.h>
9370 #include <asm/vdso_datapage.h>
9371 #include <asm/setup.h>
9372+#include <asm/mman.h>
9373
9374 #undef DEBUG
9375
9376@@ -179,7 +180,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
9377 vdso_base = VDSO32_MBASE;
9378 #endif
9379
9380- current->mm->context.vdso_base = 0;
9381+ current->mm->context.vdso_base = ~0UL;
9382
9383 /* vDSO has a problem and was disabled, just don't "enable" it for the
9384 * process
9385@@ -199,7 +200,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
9386 vdso_base = get_unmapped_area(NULL, vdso_base,
9387 (vdso_pages << PAGE_SHIFT) +
9388 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
9389- 0, 0);
9390+ 0, MAP_PRIVATE | MAP_EXECUTABLE);
9391 if (IS_ERR_VALUE(vdso_base)) {
9392 rc = vdso_base;
9393 goto fail_mmapsem;
9394diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
9395index e5dde32..557af3d 100644
9396--- a/arch/powerpc/kvm/powerpc.c
9397+++ b/arch/powerpc/kvm/powerpc.c
9398@@ -1404,7 +1404,7 @@ void kvmppc_init_lpid(unsigned long nr_lpids_param)
9399 }
9400 EXPORT_SYMBOL_GPL(kvmppc_init_lpid);
9401
9402-int kvm_arch_init(void *opaque)
9403+int kvm_arch_init(const void *opaque)
9404 {
9405 return 0;
9406 }
9407diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
9408index 5eea6f3..5d10396 100644
9409--- a/arch/powerpc/lib/usercopy_64.c
9410+++ b/arch/powerpc/lib/usercopy_64.c
9411@@ -9,22 +9,6 @@
9412 #include <linux/module.h>
9413 #include <asm/uaccess.h>
9414
9415-unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9416-{
9417- if (likely(access_ok(VERIFY_READ, from, n)))
9418- n = __copy_from_user(to, from, n);
9419- else
9420- memset(to, 0, n);
9421- return n;
9422-}
9423-
9424-unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9425-{
9426- if (likely(access_ok(VERIFY_WRITE, to, n)))
9427- n = __copy_to_user(to, from, n);
9428- return n;
9429-}
9430-
9431 unsigned long copy_in_user(void __user *to, const void __user *from,
9432 unsigned long n)
9433 {
9434@@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
9435 return n;
9436 }
9437
9438-EXPORT_SYMBOL(copy_from_user);
9439-EXPORT_SYMBOL(copy_to_user);
9440 EXPORT_SYMBOL(copy_in_user);
9441
9442diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
9443index a67c6d7..a662e6d 100644
9444--- a/arch/powerpc/mm/fault.c
9445+++ b/arch/powerpc/mm/fault.c
9446@@ -34,6 +34,10 @@
9447 #include <linux/context_tracking.h>
9448 #include <linux/hugetlb.h>
9449 #include <linux/uaccess.h>
9450+#include <linux/slab.h>
9451+#include <linux/pagemap.h>
9452+#include <linux/compiler.h>
9453+#include <linux/unistd.h>
9454
9455 #include <asm/firmware.h>
9456 #include <asm/page.h>
9457@@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
9458 }
9459 #endif
9460
9461+#ifdef CONFIG_PAX_PAGEEXEC
9462+/*
9463+ * PaX: decide what to do with offenders (regs->nip = fault address)
9464+ *
9465+ * returns 1 when task should be killed
9466+ */
9467+static int pax_handle_fetch_fault(struct pt_regs *regs)
9468+{
9469+ return 1;
9470+}
9471+
9472+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9473+{
9474+ unsigned long i;
9475+
9476+ printk(KERN_ERR "PAX: bytes at PC: ");
9477+ for (i = 0; i < 5; i++) {
9478+ unsigned int c;
9479+ if (get_user(c, (unsigned int __user *)pc+i))
9480+ printk(KERN_CONT "???????? ");
9481+ else
9482+ printk(KERN_CONT "%08x ", c);
9483+ }
9484+ printk("\n");
9485+}
9486+#endif
9487+
9488 /*
9489 * Check whether the instruction at regs->nip is a store using
9490 * an update addressing form which will update r1.
9491@@ -227,7 +258,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
9492 * indicate errors in DSISR but can validly be set in SRR1.
9493 */
9494 if (trap == 0x400)
9495- error_code &= 0x48200000;
9496+ error_code &= 0x58200000;
9497 else
9498 is_write = error_code & DSISR_ISSTORE;
9499 #else
9500@@ -384,12 +415,16 @@ good_area:
9501 * "undefined". Of those that can be set, this is the only
9502 * one which seems bad.
9503 */
9504- if (error_code & 0x10000000)
9505+ if (error_code & DSISR_GUARDED)
9506 /* Guarded storage error. */
9507 goto bad_area;
9508 #endif /* CONFIG_8xx */
9509
9510 if (is_exec) {
9511+#ifdef CONFIG_PPC_STD_MMU
9512+ if (error_code & DSISR_GUARDED)
9513+ goto bad_area;
9514+#endif
9515 /*
9516 * Allow execution from readable areas if the MMU does not
9517 * provide separate controls over reading and executing.
9518@@ -484,6 +519,23 @@ bad_area:
9519 bad_area_nosemaphore:
9520 /* User mode accesses cause a SIGSEGV */
9521 if (user_mode(regs)) {
9522+
9523+#ifdef CONFIG_PAX_PAGEEXEC
9524+ if (mm->pax_flags & MF_PAX_PAGEEXEC) {
9525+#ifdef CONFIG_PPC_STD_MMU
9526+ if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
9527+#else
9528+ if (is_exec && regs->nip == address) {
9529+#endif
9530+ switch (pax_handle_fetch_fault(regs)) {
9531+ }
9532+
9533+ pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
9534+ do_group_exit(SIGKILL);
9535+ }
9536+ }
9537+#endif
9538+
9539 _exception(SIGSEGV, regs, code, address);
9540 goto bail;
9541 }
9542diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
9543index 0f0502e..bc3e7a3 100644
9544--- a/arch/powerpc/mm/mmap.c
9545+++ b/arch/powerpc/mm/mmap.c
9546@@ -86,6 +86,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9547 {
9548 unsigned long random_factor = 0UL;
9549
9550+#ifdef CONFIG_PAX_RANDMMAP
9551+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9552+#endif
9553+
9554 if (current->flags & PF_RANDOMIZE)
9555 random_factor = arch_mmap_rnd();
9556
9557@@ -95,9 +99,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9558 */
9559 if (mmap_is_legacy()) {
9560 mm->mmap_base = TASK_UNMAPPED_BASE;
9561+
9562+#ifdef CONFIG_PAX_RANDMMAP
9563+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9564+ mm->mmap_base += mm->delta_mmap;
9565+#endif
9566+
9567 mm->get_unmapped_area = arch_get_unmapped_area;
9568 } else {
9569 mm->mmap_base = mmap_base(random_factor);
9570+
9571+#ifdef CONFIG_PAX_RANDMMAP
9572+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9573+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9574+#endif
9575+
9576 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9577 }
9578 }
9579diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
9580index 0f432a7..abfe841 100644
9581--- a/arch/powerpc/mm/slice.c
9582+++ b/arch/powerpc/mm/slice.c
9583@@ -105,7 +105,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
9584 if ((mm->task_size - len) < addr)
9585 return 0;
9586 vma = find_vma(mm, addr);
9587- return (!vma || (addr + len) <= vma->vm_start);
9588+ return check_heap_stack_gap(vma, addr, len, 0);
9589 }
9590
9591 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
9592@@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
9593 info.align_offset = 0;
9594
9595 addr = TASK_UNMAPPED_BASE;
9596+
9597+#ifdef CONFIG_PAX_RANDMMAP
9598+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9599+ addr += mm->delta_mmap;
9600+#endif
9601+
9602 while (addr < TASK_SIZE) {
9603 info.low_limit = addr;
9604 if (!slice_scan_available(addr, available, 1, &addr))
9605@@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
9606 if (fixed && addr > (mm->task_size - len))
9607 return -ENOMEM;
9608
9609+#ifdef CONFIG_PAX_RANDMMAP
9610+ if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
9611+ addr = 0;
9612+#endif
9613+
9614 /* If hint, make sure it matches our alignment restrictions */
9615 if (!fixed && addr) {
9616 addr = _ALIGN_UP(addr, 1ul << pshift);
9617diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
9618index d966bbe..372124a 100644
9619--- a/arch/powerpc/platforms/cell/spufs/file.c
9620+++ b/arch/powerpc/platforms/cell/spufs/file.c
9621@@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9622 return VM_FAULT_NOPAGE;
9623 }
9624
9625-static int spufs_mem_mmap_access(struct vm_area_struct *vma,
9626+static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
9627 unsigned long address,
9628- void *buf, int len, int write)
9629+ void *buf, size_t len, int write)
9630 {
9631 struct spu_context *ctx = vma->vm_file->private_data;
9632 unsigned long offset = address - vma->vm_start;
9633diff --git a/arch/s390/Kconfig.debug b/arch/s390/Kconfig.debug
9634index c56878e..073d04e 100644
9635--- a/arch/s390/Kconfig.debug
9636+++ b/arch/s390/Kconfig.debug
9637@@ -21,6 +21,7 @@ config S390_PTDUMP
9638 bool "Export kernel pagetable layout to userspace via debugfs"
9639 depends on DEBUG_KERNEL
9640 select DEBUG_FS
9641+ depends on !GRKERNSEC_KMEM
9642 ---help---
9643 Say Y here if you want to show the kernel pagetable layout in a
9644 debugfs file. This information is only useful for kernel developers
9645diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
9646index adbe380..adb7516 100644
9647--- a/arch/s390/include/asm/atomic.h
9648+++ b/arch/s390/include/asm/atomic.h
9649@@ -317,4 +317,14 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
9650 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
9651 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9652
9653+#define atomic64_read_unchecked(v) atomic64_read(v)
9654+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
9655+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
9656+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
9657+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
9658+#define atomic64_inc_unchecked(v) atomic64_inc(v)
9659+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
9660+#define atomic64_dec_unchecked(v) atomic64_dec(v)
9661+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
9662+
9663 #endif /* __ARCH_S390_ATOMIC__ */
9664diff --git a/arch/s390/include/asm/barrier.h b/arch/s390/include/asm/barrier.h
9665index e6f8615..4a66339 100644
9666--- a/arch/s390/include/asm/barrier.h
9667+++ b/arch/s390/include/asm/barrier.h
9668@@ -42,7 +42,7 @@
9669 do { \
9670 compiletime_assert_atomic_type(*p); \
9671 barrier(); \
9672- ACCESS_ONCE(*p) = (v); \
9673+ ACCESS_ONCE_RW(*p) = (v); \
9674 } while (0)
9675
9676 #define smp_load_acquire(p) \
9677diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
9678index 4d7ccac..d03d0ad 100644
9679--- a/arch/s390/include/asm/cache.h
9680+++ b/arch/s390/include/asm/cache.h
9681@@ -9,8 +9,10 @@
9682 #ifndef __ARCH_S390_CACHE_H
9683 #define __ARCH_S390_CACHE_H
9684
9685-#define L1_CACHE_BYTES 256
9686+#include <linux/const.h>
9687+
9688 #define L1_CACHE_SHIFT 8
9689+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9690 #define NET_SKB_PAD 32
9691
9692 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
9693diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
9694index 3ad48f2..64cc6f3 100644
9695--- a/arch/s390/include/asm/elf.h
9696+++ b/arch/s390/include/asm/elf.h
9697@@ -163,6 +163,13 @@ extern unsigned int vdso_enabled;
9698 (STACK_TOP / 3 * 2) : \
9699 (STACK_TOP / 3 * 2) & ~((1UL << 32) - 1))
9700
9701+#ifdef CONFIG_PAX_ASLR
9702+#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
9703+
9704+#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
9705+#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
9706+#endif
9707+
9708 /* This yields a mask that user programs can use to figure out what
9709 instruction set this CPU supports. */
9710
9711diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
9712index c4a93d6..4d2a9b4 100644
9713--- a/arch/s390/include/asm/exec.h
9714+++ b/arch/s390/include/asm/exec.h
9715@@ -7,6 +7,6 @@
9716 #ifndef __ASM_EXEC_H
9717 #define __ASM_EXEC_H
9718
9719-extern unsigned long arch_align_stack(unsigned long sp);
9720+#define arch_align_stack(x) ((x) & ~0xfUL)
9721
9722 #endif /* __ASM_EXEC_H */
9723diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
9724index 9dd4cc4..36f4b84 100644
9725--- a/arch/s390/include/asm/uaccess.h
9726+++ b/arch/s390/include/asm/uaccess.h
9727@@ -59,6 +59,7 @@ static inline int __range_ok(unsigned long addr, unsigned long size)
9728 __range_ok((unsigned long)(addr), (size)); \
9729 })
9730
9731+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
9732 #define access_ok(type, addr, size) __access_ok(addr, size)
9733
9734 /*
9735@@ -278,6 +279,10 @@ static inline unsigned long __must_check
9736 copy_to_user(void __user *to, const void *from, unsigned long n)
9737 {
9738 might_fault();
9739+
9740+ if ((long)n < 0)
9741+ return n;
9742+
9743 return __copy_to_user(to, from, n);
9744 }
9745
9746@@ -307,10 +312,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
9747 static inline unsigned long __must_check
9748 copy_from_user(void *to, const void __user *from, unsigned long n)
9749 {
9750- unsigned int sz = __compiletime_object_size(to);
9751+ size_t sz = __compiletime_object_size(to);
9752
9753 might_fault();
9754- if (unlikely(sz != -1 && sz < n)) {
9755+
9756+ if ((long)n < 0)
9757+ return n;
9758+
9759+ if (unlikely(sz != (size_t)-1 && sz < n)) {
9760 copy_from_user_overflow();
9761 return n;
9762 }
9763diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
9764index 0c1a679..e1df357 100644
9765--- a/arch/s390/kernel/module.c
9766+++ b/arch/s390/kernel/module.c
9767@@ -159,11 +159,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
9768
9769 /* Increase core size by size of got & plt and set start
9770 offsets for got and plt. */
9771- me->core_size = ALIGN(me->core_size, 4);
9772- me->arch.got_offset = me->core_size;
9773- me->core_size += me->arch.got_size;
9774- me->arch.plt_offset = me->core_size;
9775- me->core_size += me->arch.plt_size;
9776+ me->core_size_rw = ALIGN(me->core_size_rw, 4);
9777+ me->arch.got_offset = me->core_size_rw;
9778+ me->core_size_rw += me->arch.got_size;
9779+ me->arch.plt_offset = me->core_size_rx;
9780+ me->core_size_rx += me->arch.plt_size;
9781 return 0;
9782 }
9783
9784@@ -279,7 +279,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9785 if (info->got_initialized == 0) {
9786 Elf_Addr *gotent;
9787
9788- gotent = me->module_core + me->arch.got_offset +
9789+ gotent = me->module_core_rw + me->arch.got_offset +
9790 info->got_offset;
9791 *gotent = val;
9792 info->got_initialized = 1;
9793@@ -302,7 +302,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9794 rc = apply_rela_bits(loc, val, 0, 64, 0);
9795 else if (r_type == R_390_GOTENT ||
9796 r_type == R_390_GOTPLTENT) {
9797- val += (Elf_Addr) me->module_core - loc;
9798+ val += (Elf_Addr) me->module_core_rw - loc;
9799 rc = apply_rela_bits(loc, val, 1, 32, 1);
9800 }
9801 break;
9802@@ -315,7 +315,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9803 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
9804 if (info->plt_initialized == 0) {
9805 unsigned int *ip;
9806- ip = me->module_core + me->arch.plt_offset +
9807+ ip = me->module_core_rx + me->arch.plt_offset +
9808 info->plt_offset;
9809 ip[0] = 0x0d10e310; /* basr 1,0; lg 1,10(1); br 1 */
9810 ip[1] = 0x100a0004;
9811@@ -334,7 +334,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9812 val - loc + 0xffffUL < 0x1ffffeUL) ||
9813 (r_type == R_390_PLT32DBL &&
9814 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
9815- val = (Elf_Addr) me->module_core +
9816+ val = (Elf_Addr) me->module_core_rx +
9817 me->arch.plt_offset +
9818 info->plt_offset;
9819 val += rela->r_addend - loc;
9820@@ -356,7 +356,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9821 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
9822 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
9823 val = val + rela->r_addend -
9824- ((Elf_Addr) me->module_core + me->arch.got_offset);
9825+ ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
9826 if (r_type == R_390_GOTOFF16)
9827 rc = apply_rela_bits(loc, val, 0, 16, 0);
9828 else if (r_type == R_390_GOTOFF32)
9829@@ -366,7 +366,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9830 break;
9831 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
9832 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
9833- val = (Elf_Addr) me->module_core + me->arch.got_offset +
9834+ val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
9835 rela->r_addend - loc;
9836 if (r_type == R_390_GOTPC)
9837 rc = apply_rela_bits(loc, val, 1, 32, 0);
9838diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
9839index 8f587d8..0642516b 100644
9840--- a/arch/s390/kernel/process.c
9841+++ b/arch/s390/kernel/process.c
9842@@ -200,27 +200,3 @@ unsigned long get_wchan(struct task_struct *p)
9843 }
9844 return 0;
9845 }
9846-
9847-unsigned long arch_align_stack(unsigned long sp)
9848-{
9849- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
9850- sp -= get_random_int() & ~PAGE_MASK;
9851- return sp & ~0xf;
9852-}
9853-
9854-static inline unsigned long brk_rnd(void)
9855-{
9856- /* 8MB for 32bit, 1GB for 64bit */
9857- if (is_32bit_task())
9858- return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
9859- else
9860- return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
9861-}
9862-
9863-unsigned long arch_randomize_brk(struct mm_struct *mm)
9864-{
9865- unsigned long ret;
9866-
9867- ret = PAGE_ALIGN(mm->brk + brk_rnd());
9868- return (ret > mm->brk) ? ret : mm->brk;
9869-}
9870diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
9871index 6e552af..3e608a1 100644
9872--- a/arch/s390/mm/mmap.c
9873+++ b/arch/s390/mm/mmap.c
9874@@ -239,6 +239,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9875 {
9876 unsigned long random_factor = 0UL;
9877
9878+#ifdef CONFIG_PAX_RANDMMAP
9879+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9880+#endif
9881+
9882 if (current->flags & PF_RANDOMIZE)
9883 random_factor = arch_mmap_rnd();
9884
9885@@ -248,9 +252,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9886 */
9887 if (mmap_is_legacy()) {
9888 mm->mmap_base = mmap_base_legacy(random_factor);
9889+
9890+#ifdef CONFIG_PAX_RANDMMAP
9891+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9892+ mm->mmap_base += mm->delta_mmap;
9893+#endif
9894+
9895 mm->get_unmapped_area = s390_get_unmapped_area;
9896 } else {
9897 mm->mmap_base = mmap_base(random_factor);
9898+
9899+#ifdef CONFIG_PAX_RANDMMAP
9900+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9901+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9902+#endif
9903+
9904 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
9905 }
9906 }
9907diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
9908index ae3d59f..f65f075 100644
9909--- a/arch/score/include/asm/cache.h
9910+++ b/arch/score/include/asm/cache.h
9911@@ -1,7 +1,9 @@
9912 #ifndef _ASM_SCORE_CACHE_H
9913 #define _ASM_SCORE_CACHE_H
9914
9915+#include <linux/const.h>
9916+
9917 #define L1_CACHE_SHIFT 4
9918-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
9919+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9920
9921 #endif /* _ASM_SCORE_CACHE_H */
9922diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
9923index f9f3cd5..58ff438 100644
9924--- a/arch/score/include/asm/exec.h
9925+++ b/arch/score/include/asm/exec.h
9926@@ -1,6 +1,6 @@
9927 #ifndef _ASM_SCORE_EXEC_H
9928 #define _ASM_SCORE_EXEC_H
9929
9930-extern unsigned long arch_align_stack(unsigned long sp);
9931+#define arch_align_stack(x) (x)
9932
9933 #endif /* _ASM_SCORE_EXEC_H */
9934diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
9935index a1519ad3..e8ac1ff 100644
9936--- a/arch/score/kernel/process.c
9937+++ b/arch/score/kernel/process.c
9938@@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
9939
9940 return task_pt_regs(task)->cp0_epc;
9941 }
9942-
9943-unsigned long arch_align_stack(unsigned long sp)
9944-{
9945- return sp;
9946-}
9947diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
9948index ef9e555..331bd29 100644
9949--- a/arch/sh/include/asm/cache.h
9950+++ b/arch/sh/include/asm/cache.h
9951@@ -9,10 +9,11 @@
9952 #define __ASM_SH_CACHE_H
9953 #ifdef __KERNEL__
9954
9955+#include <linux/const.h>
9956 #include <linux/init.h>
9957 #include <cpu/cache.h>
9958
9959-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
9960+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9961
9962 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
9963
9964diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
9965index 6777177..cb5e44f 100644
9966--- a/arch/sh/mm/mmap.c
9967+++ b/arch/sh/mm/mmap.c
9968@@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
9969 struct mm_struct *mm = current->mm;
9970 struct vm_area_struct *vma;
9971 int do_colour_align;
9972+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9973 struct vm_unmapped_area_info info;
9974
9975 if (flags & MAP_FIXED) {
9976@@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
9977 if (filp || (flags & MAP_SHARED))
9978 do_colour_align = 1;
9979
9980+#ifdef CONFIG_PAX_RANDMMAP
9981+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9982+#endif
9983+
9984 if (addr) {
9985 if (do_colour_align)
9986 addr = COLOUR_ALIGN(addr, pgoff);
9987@@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
9988 addr = PAGE_ALIGN(addr);
9989
9990 vma = find_vma(mm, addr);
9991- if (TASK_SIZE - len >= addr &&
9992- (!vma || addr + len <= vma->vm_start))
9993+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9994 return addr;
9995 }
9996
9997 info.flags = 0;
9998 info.length = len;
9999- info.low_limit = TASK_UNMAPPED_BASE;
10000+ info.low_limit = mm->mmap_base;
10001 info.high_limit = TASK_SIZE;
10002 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
10003 info.align_offset = pgoff << PAGE_SHIFT;
10004@@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10005 struct mm_struct *mm = current->mm;
10006 unsigned long addr = addr0;
10007 int do_colour_align;
10008+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
10009 struct vm_unmapped_area_info info;
10010
10011 if (flags & MAP_FIXED) {
10012@@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10013 if (filp || (flags & MAP_SHARED))
10014 do_colour_align = 1;
10015
10016+#ifdef CONFIG_PAX_RANDMMAP
10017+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10018+#endif
10019+
10020 /* requesting a specific address */
10021 if (addr) {
10022 if (do_colour_align)
10023@@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10024 addr = PAGE_ALIGN(addr);
10025
10026 vma = find_vma(mm, addr);
10027- if (TASK_SIZE - len >= addr &&
10028- (!vma || addr + len <= vma->vm_start))
10029+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10030 return addr;
10031 }
10032
10033@@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10034 VM_BUG_ON(addr != -ENOMEM);
10035 info.flags = 0;
10036 info.low_limit = TASK_UNMAPPED_BASE;
10037+
10038+#ifdef CONFIG_PAX_RANDMMAP
10039+ if (mm->pax_flags & MF_PAX_RANDMMAP)
10040+ info.low_limit += mm->delta_mmap;
10041+#endif
10042+
10043 info.high_limit = TASK_SIZE;
10044 addr = vm_unmapped_area(&info);
10045 }
10046diff --git a/arch/sparc/crypto/aes_glue.c b/arch/sparc/crypto/aes_glue.c
10047index 2e48eb8..c90930d 100644
10048--- a/arch/sparc/crypto/aes_glue.c
10049+++ b/arch/sparc/crypto/aes_glue.c
10050@@ -433,6 +433,7 @@ static struct crypto_alg algs[] = { {
10051 .blkcipher = {
10052 .min_keysize = AES_MIN_KEY_SIZE,
10053 .max_keysize = AES_MAX_KEY_SIZE,
10054+ .ivsize = AES_BLOCK_SIZE,
10055 .setkey = aes_set_key,
10056 .encrypt = cbc_encrypt,
10057 .decrypt = cbc_decrypt,
10058@@ -452,6 +453,7 @@ static struct crypto_alg algs[] = { {
10059 .blkcipher = {
10060 .min_keysize = AES_MIN_KEY_SIZE,
10061 .max_keysize = AES_MAX_KEY_SIZE,
10062+ .ivsize = AES_BLOCK_SIZE,
10063 .setkey = aes_set_key,
10064 .encrypt = ctr_crypt,
10065 .decrypt = ctr_crypt,
10066diff --git a/arch/sparc/crypto/camellia_glue.c b/arch/sparc/crypto/camellia_glue.c
10067index 6bf2479..561a84d 100644
10068--- a/arch/sparc/crypto/camellia_glue.c
10069+++ b/arch/sparc/crypto/camellia_glue.c
10070@@ -274,6 +274,7 @@ static struct crypto_alg algs[] = { {
10071 .blkcipher = {
10072 .min_keysize = CAMELLIA_MIN_KEY_SIZE,
10073 .max_keysize = CAMELLIA_MAX_KEY_SIZE,
10074+ .ivsize = CAMELLIA_BLOCK_SIZE,
10075 .setkey = camellia_set_key,
10076 .encrypt = cbc_encrypt,
10077 .decrypt = cbc_decrypt,
10078diff --git a/arch/sparc/crypto/des_glue.c b/arch/sparc/crypto/des_glue.c
10079index dd6a34f..61af794 100644
10080--- a/arch/sparc/crypto/des_glue.c
10081+++ b/arch/sparc/crypto/des_glue.c
10082@@ -429,6 +429,7 @@ static struct crypto_alg algs[] = { {
10083 .blkcipher = {
10084 .min_keysize = DES_KEY_SIZE,
10085 .max_keysize = DES_KEY_SIZE,
10086+ .ivsize = DES_BLOCK_SIZE,
10087 .setkey = des_set_key,
10088 .encrypt = cbc_encrypt,
10089 .decrypt = cbc_decrypt,
10090@@ -485,6 +486,7 @@ static struct crypto_alg algs[] = { {
10091 .blkcipher = {
10092 .min_keysize = DES3_EDE_KEY_SIZE,
10093 .max_keysize = DES3_EDE_KEY_SIZE,
10094+ .ivsize = DES3_EDE_BLOCK_SIZE,
10095 .setkey = des3_ede_set_key,
10096 .encrypt = cbc3_encrypt,
10097 .decrypt = cbc3_decrypt,
10098diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
10099index 4082749..fd97781 100644
10100--- a/arch/sparc/include/asm/atomic_64.h
10101+++ b/arch/sparc/include/asm/atomic_64.h
10102@@ -15,18 +15,38 @@
10103 #define ATOMIC64_INIT(i) { (i) }
10104
10105 #define atomic_read(v) ACCESS_ONCE((v)->counter)
10106+static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
10107+{
10108+ return ACCESS_ONCE(v->counter);
10109+}
10110 #define atomic64_read(v) ACCESS_ONCE((v)->counter)
10111+static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
10112+{
10113+ return ACCESS_ONCE(v->counter);
10114+}
10115
10116 #define atomic_set(v, i) (((v)->counter) = i)
10117+static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
10118+{
10119+ v->counter = i;
10120+}
10121 #define atomic64_set(v, i) (((v)->counter) = i)
10122+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
10123+{
10124+ v->counter = i;
10125+}
10126
10127-#define ATOMIC_OP(op) \
10128-void atomic_##op(int, atomic_t *); \
10129-void atomic64_##op(long, atomic64_t *);
10130+#define __ATOMIC_OP(op, suffix) \
10131+void atomic_##op##suffix(int, atomic##suffix##_t *); \
10132+void atomic64_##op##suffix(long, atomic64##suffix##_t *);
10133
10134-#define ATOMIC_OP_RETURN(op) \
10135-int atomic_##op##_return(int, atomic_t *); \
10136-long atomic64_##op##_return(long, atomic64_t *);
10137+#define ATOMIC_OP(op) __ATOMIC_OP(op, ) __ATOMIC_OP(op, _unchecked)
10138+
10139+#define __ATOMIC_OP_RETURN(op, suffix) \
10140+int atomic_##op##_return##suffix(int, atomic##suffix##_t *); \
10141+long atomic64_##op##_return##suffix(long, atomic64##suffix##_t *);
10142+
10143+#define ATOMIC_OP_RETURN(op) __ATOMIC_OP_RETURN(op, ) __ATOMIC_OP_RETURN(op, _unchecked)
10144
10145 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_OP_RETURN(op)
10146
10147@@ -35,13 +55,23 @@ ATOMIC_OPS(sub)
10148
10149 #undef ATOMIC_OPS
10150 #undef ATOMIC_OP_RETURN
10151+#undef __ATOMIC_OP_RETURN
10152 #undef ATOMIC_OP
10153+#undef __ATOMIC_OP
10154
10155 #define atomic_dec_return(v) atomic_sub_return(1, v)
10156 #define atomic64_dec_return(v) atomic64_sub_return(1, v)
10157
10158 #define atomic_inc_return(v) atomic_add_return(1, v)
10159+static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
10160+{
10161+ return atomic_add_return_unchecked(1, v);
10162+}
10163 #define atomic64_inc_return(v) atomic64_add_return(1, v)
10164+static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
10165+{
10166+ return atomic64_add_return_unchecked(1, v);
10167+}
10168
10169 /*
10170 * atomic_inc_and_test - increment and test
10171@@ -52,6 +82,10 @@ ATOMIC_OPS(sub)
10172 * other cases.
10173 */
10174 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
10175+static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
10176+{
10177+ return atomic_inc_return_unchecked(v) == 0;
10178+}
10179 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
10180
10181 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
10182@@ -61,25 +95,60 @@ ATOMIC_OPS(sub)
10183 #define atomic64_dec_and_test(v) (atomic64_sub_return(1, v) == 0)
10184
10185 #define atomic_inc(v) atomic_add(1, v)
10186+static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
10187+{
10188+ atomic_add_unchecked(1, v);
10189+}
10190 #define atomic64_inc(v) atomic64_add(1, v)
10191+static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
10192+{
10193+ atomic64_add_unchecked(1, v);
10194+}
10195
10196 #define atomic_dec(v) atomic_sub(1, v)
10197+static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
10198+{
10199+ atomic_sub_unchecked(1, v);
10200+}
10201 #define atomic64_dec(v) atomic64_sub(1, v)
10202+static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
10203+{
10204+ atomic64_sub_unchecked(1, v);
10205+}
10206
10207 #define atomic_add_negative(i, v) (atomic_add_return(i, v) < 0)
10208 #define atomic64_add_negative(i, v) (atomic64_add_return(i, v) < 0)
10209
10210 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
10211+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
10212+{
10213+ return cmpxchg(&v->counter, old, new);
10214+}
10215 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
10216+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
10217+{
10218+ return xchg(&v->counter, new);
10219+}
10220
10221 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
10222 {
10223- int c, old;
10224+ int c, old, new;
10225 c = atomic_read(v);
10226 for (;;) {
10227- if (unlikely(c == (u)))
10228+ if (unlikely(c == u))
10229 break;
10230- old = atomic_cmpxchg((v), c, c + (a));
10231+
10232+ asm volatile("addcc %2, %0, %0\n"
10233+
10234+#ifdef CONFIG_PAX_REFCOUNT
10235+ "tvs %%icc, 6\n"
10236+#endif
10237+
10238+ : "=r" (new)
10239+ : "0" (c), "ir" (a)
10240+ : "cc");
10241+
10242+ old = atomic_cmpxchg(v, c, new);
10243 if (likely(old == c))
10244 break;
10245 c = old;
10246@@ -90,20 +159,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
10247 #define atomic64_cmpxchg(v, o, n) \
10248 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
10249 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
10250+static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
10251+{
10252+ return xchg(&v->counter, new);
10253+}
10254
10255 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10256 {
10257- long c, old;
10258+ long c, old, new;
10259 c = atomic64_read(v);
10260 for (;;) {
10261- if (unlikely(c == (u)))
10262+ if (unlikely(c == u))
10263 break;
10264- old = atomic64_cmpxchg((v), c, c + (a));
10265+
10266+ asm volatile("addcc %2, %0, %0\n"
10267+
10268+#ifdef CONFIG_PAX_REFCOUNT
10269+ "tvs %%xcc, 6\n"
10270+#endif
10271+
10272+ : "=r" (new)
10273+ : "0" (c), "ir" (a)
10274+ : "cc");
10275+
10276+ old = atomic64_cmpxchg(v, c, new);
10277 if (likely(old == c))
10278 break;
10279 c = old;
10280 }
10281- return c != (u);
10282+ return c != u;
10283 }
10284
10285 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10286diff --git a/arch/sparc/include/asm/barrier_64.h b/arch/sparc/include/asm/barrier_64.h
10287index 809941e..b443309 100644
10288--- a/arch/sparc/include/asm/barrier_64.h
10289+++ b/arch/sparc/include/asm/barrier_64.h
10290@@ -60,7 +60,7 @@ do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \
10291 do { \
10292 compiletime_assert_atomic_type(*p); \
10293 barrier(); \
10294- ACCESS_ONCE(*p) = (v); \
10295+ ACCESS_ONCE_RW(*p) = (v); \
10296 } while (0)
10297
10298 #define smp_load_acquire(p) \
10299diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
10300index 5bb6991..5c2132e 100644
10301--- a/arch/sparc/include/asm/cache.h
10302+++ b/arch/sparc/include/asm/cache.h
10303@@ -7,10 +7,12 @@
10304 #ifndef _SPARC_CACHE_H
10305 #define _SPARC_CACHE_H
10306
10307+#include <linux/const.h>
10308+
10309 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
10310
10311 #define L1_CACHE_SHIFT 5
10312-#define L1_CACHE_BYTES 32
10313+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10314
10315 #ifdef CONFIG_SPARC32
10316 #define SMP_CACHE_BYTES_SHIFT 5
10317diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
10318index a24e41f..47677ff 100644
10319--- a/arch/sparc/include/asm/elf_32.h
10320+++ b/arch/sparc/include/asm/elf_32.h
10321@@ -114,6 +114,13 @@ typedef struct {
10322
10323 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
10324
10325+#ifdef CONFIG_PAX_ASLR
10326+#define PAX_ELF_ET_DYN_BASE 0x10000UL
10327+
10328+#define PAX_DELTA_MMAP_LEN 16
10329+#define PAX_DELTA_STACK_LEN 16
10330+#endif
10331+
10332 /* This yields a mask that user programs can use to figure out what
10333 instruction set this cpu supports. This can NOT be done in userspace
10334 on Sparc. */
10335diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
10336index 370ca1e..d4f4a98 100644
10337--- a/arch/sparc/include/asm/elf_64.h
10338+++ b/arch/sparc/include/asm/elf_64.h
10339@@ -189,6 +189,13 @@ typedef struct {
10340 #define ELF_ET_DYN_BASE 0x0000010000000000UL
10341 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
10342
10343+#ifdef CONFIG_PAX_ASLR
10344+#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
10345+
10346+#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
10347+#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
10348+#endif
10349+
10350 extern unsigned long sparc64_elf_hwcap;
10351 #define ELF_HWCAP sparc64_elf_hwcap
10352
10353diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
10354index a3890da..f6a408e 100644
10355--- a/arch/sparc/include/asm/pgalloc_32.h
10356+++ b/arch/sparc/include/asm/pgalloc_32.h
10357@@ -35,6 +35,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
10358 }
10359
10360 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
10361+#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
10362
10363 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
10364 unsigned long address)
10365diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
10366index 5e31871..13469c6 100644
10367--- a/arch/sparc/include/asm/pgalloc_64.h
10368+++ b/arch/sparc/include/asm/pgalloc_64.h
10369@@ -21,6 +21,7 @@ static inline void __pgd_populate(pgd_t *pgd, pud_t *pud)
10370 }
10371
10372 #define pgd_populate(MM, PGD, PUD) __pgd_populate(PGD, PUD)
10373+#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
10374
10375 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
10376 {
10377@@ -38,6 +39,7 @@ static inline void __pud_populate(pud_t *pud, pmd_t *pmd)
10378 }
10379
10380 #define pud_populate(MM, PUD, PMD) __pud_populate(PUD, PMD)
10381+#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
10382
10383 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
10384 {
10385diff --git a/arch/sparc/include/asm/pgtable.h b/arch/sparc/include/asm/pgtable.h
10386index 59ba6f6..4518128 100644
10387--- a/arch/sparc/include/asm/pgtable.h
10388+++ b/arch/sparc/include/asm/pgtable.h
10389@@ -5,4 +5,8 @@
10390 #else
10391 #include <asm/pgtable_32.h>
10392 #endif
10393+
10394+#define ktla_ktva(addr) (addr)
10395+#define ktva_ktla(addr) (addr)
10396+
10397 #endif
10398diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
10399index f06b36a..bca3189 100644
10400--- a/arch/sparc/include/asm/pgtable_32.h
10401+++ b/arch/sparc/include/asm/pgtable_32.h
10402@@ -51,6 +51,9 @@ unsigned long __init bootmem_init(unsigned long *pages_avail);
10403 #define PAGE_SHARED SRMMU_PAGE_SHARED
10404 #define PAGE_COPY SRMMU_PAGE_COPY
10405 #define PAGE_READONLY SRMMU_PAGE_RDONLY
10406+#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
10407+#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
10408+#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
10409 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
10410
10411 /* Top-level page directory - dummy used by init-mm.
10412@@ -63,18 +66,18 @@ extern unsigned long ptr_in_current_pgd;
10413
10414 /* xwr */
10415 #define __P000 PAGE_NONE
10416-#define __P001 PAGE_READONLY
10417-#define __P010 PAGE_COPY
10418-#define __P011 PAGE_COPY
10419+#define __P001 PAGE_READONLY_NOEXEC
10420+#define __P010 PAGE_COPY_NOEXEC
10421+#define __P011 PAGE_COPY_NOEXEC
10422 #define __P100 PAGE_READONLY
10423 #define __P101 PAGE_READONLY
10424 #define __P110 PAGE_COPY
10425 #define __P111 PAGE_COPY
10426
10427 #define __S000 PAGE_NONE
10428-#define __S001 PAGE_READONLY
10429-#define __S010 PAGE_SHARED
10430-#define __S011 PAGE_SHARED
10431+#define __S001 PAGE_READONLY_NOEXEC
10432+#define __S010 PAGE_SHARED_NOEXEC
10433+#define __S011 PAGE_SHARED_NOEXEC
10434 #define __S100 PAGE_READONLY
10435 #define __S101 PAGE_READONLY
10436 #define __S110 PAGE_SHARED
10437diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
10438index ae51a11..eadfd03 100644
10439--- a/arch/sparc/include/asm/pgtsrmmu.h
10440+++ b/arch/sparc/include/asm/pgtsrmmu.h
10441@@ -111,6 +111,11 @@
10442 SRMMU_EXEC | SRMMU_REF)
10443 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
10444 SRMMU_EXEC | SRMMU_REF)
10445+
10446+#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
10447+#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
10448+#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
10449+
10450 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
10451 SRMMU_DIRTY | SRMMU_REF)
10452
10453diff --git a/arch/sparc/include/asm/setup.h b/arch/sparc/include/asm/setup.h
10454index 29d64b1..4272fe8 100644
10455--- a/arch/sparc/include/asm/setup.h
10456+++ b/arch/sparc/include/asm/setup.h
10457@@ -55,8 +55,8 @@ int handle_ldf_stq(u32 insn, struct pt_regs *regs);
10458 void handle_ld_nf(u32 insn, struct pt_regs *regs);
10459
10460 /* init_64.c */
10461-extern atomic_t dcpage_flushes;
10462-extern atomic_t dcpage_flushes_xcall;
10463+extern atomic_unchecked_t dcpage_flushes;
10464+extern atomic_unchecked_t dcpage_flushes_xcall;
10465
10466 extern int sysctl_tsb_ratio;
10467 #endif
10468diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
10469index 9689176..63c18ea 100644
10470--- a/arch/sparc/include/asm/spinlock_64.h
10471+++ b/arch/sparc/include/asm/spinlock_64.h
10472@@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
10473
10474 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
10475
10476-static void inline arch_read_lock(arch_rwlock_t *lock)
10477+static inline void arch_read_lock(arch_rwlock_t *lock)
10478 {
10479 unsigned long tmp1, tmp2;
10480
10481 __asm__ __volatile__ (
10482 "1: ldsw [%2], %0\n"
10483 " brlz,pn %0, 2f\n"
10484-"4: add %0, 1, %1\n"
10485+"4: addcc %0, 1, %1\n"
10486+
10487+#ifdef CONFIG_PAX_REFCOUNT
10488+" tvs %%icc, 6\n"
10489+#endif
10490+
10491 " cas [%2], %0, %1\n"
10492 " cmp %0, %1\n"
10493 " bne,pn %%icc, 1b\n"
10494@@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
10495 " .previous"
10496 : "=&r" (tmp1), "=&r" (tmp2)
10497 : "r" (lock)
10498- : "memory");
10499+ : "memory", "cc");
10500 }
10501
10502-static int inline arch_read_trylock(arch_rwlock_t *lock)
10503+static inline int arch_read_trylock(arch_rwlock_t *lock)
10504 {
10505 int tmp1, tmp2;
10506
10507@@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
10508 "1: ldsw [%2], %0\n"
10509 " brlz,a,pn %0, 2f\n"
10510 " mov 0, %0\n"
10511-" add %0, 1, %1\n"
10512+" addcc %0, 1, %1\n"
10513+
10514+#ifdef CONFIG_PAX_REFCOUNT
10515+" tvs %%icc, 6\n"
10516+#endif
10517+
10518 " cas [%2], %0, %1\n"
10519 " cmp %0, %1\n"
10520 " bne,pn %%icc, 1b\n"
10521@@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
10522 return tmp1;
10523 }
10524
10525-static void inline arch_read_unlock(arch_rwlock_t *lock)
10526+static inline void arch_read_unlock(arch_rwlock_t *lock)
10527 {
10528 unsigned long tmp1, tmp2;
10529
10530 __asm__ __volatile__(
10531 "1: lduw [%2], %0\n"
10532-" sub %0, 1, %1\n"
10533+" subcc %0, 1, %1\n"
10534+
10535+#ifdef CONFIG_PAX_REFCOUNT
10536+" tvs %%icc, 6\n"
10537+#endif
10538+
10539 " cas [%2], %0, %1\n"
10540 " cmp %0, %1\n"
10541 " bne,pn %%xcc, 1b\n"
10542@@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
10543 : "memory");
10544 }
10545
10546-static void inline arch_write_lock(arch_rwlock_t *lock)
10547+static inline void arch_write_lock(arch_rwlock_t *lock)
10548 {
10549 unsigned long mask, tmp1, tmp2;
10550
10551@@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
10552 : "memory");
10553 }
10554
10555-static void inline arch_write_unlock(arch_rwlock_t *lock)
10556+static inline void arch_write_unlock(arch_rwlock_t *lock)
10557 {
10558 __asm__ __volatile__(
10559 " stw %%g0, [%0]"
10560@@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
10561 : "memory");
10562 }
10563
10564-static int inline arch_write_trylock(arch_rwlock_t *lock)
10565+static inline int arch_write_trylock(arch_rwlock_t *lock)
10566 {
10567 unsigned long mask, tmp1, tmp2, result;
10568
10569diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
10570index 229475f..2fca9163 100644
10571--- a/arch/sparc/include/asm/thread_info_32.h
10572+++ b/arch/sparc/include/asm/thread_info_32.h
10573@@ -48,6 +48,7 @@ struct thread_info {
10574 struct reg_window32 reg_window[NSWINS]; /* align for ldd! */
10575 unsigned long rwbuf_stkptrs[NSWINS];
10576 unsigned long w_saved;
10577+ unsigned long lowest_stack;
10578 };
10579
10580 /*
10581diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
10582index bde5982..9cbb56d 100644
10583--- a/arch/sparc/include/asm/thread_info_64.h
10584+++ b/arch/sparc/include/asm/thread_info_64.h
10585@@ -59,6 +59,8 @@ struct thread_info {
10586 struct pt_regs *kern_una_regs;
10587 unsigned int kern_una_insn;
10588
10589+ unsigned long lowest_stack;
10590+
10591 unsigned long fpregs[(7 * 256) / sizeof(unsigned long)]
10592 __attribute__ ((aligned(64)));
10593 };
10594@@ -180,12 +182,13 @@ register struct thread_info *current_thread_info_reg asm("g6");
10595 #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
10596 /* flag bit 4 is available */
10597 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
10598-/* flag bit 6 is available */
10599+#define TIF_GRSEC_SETXID 6 /* update credentials on syscall entry/exit */
10600 #define TIF_32BIT 7 /* 32-bit binary */
10601 #define TIF_NOHZ 8 /* in adaptive nohz mode */
10602 #define TIF_SECCOMP 9 /* secure computing */
10603 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
10604 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
10605+
10606 /* NOTE: Thread flags >= 12 should be ones we have no interest
10607 * in using in assembly, else we can't use the mask as
10608 * an immediate value in instructions such as andcc.
10609@@ -205,12 +208,17 @@ register struct thread_info *current_thread_info_reg asm("g6");
10610 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
10611 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
10612 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
10613+#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
10614
10615 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
10616 _TIF_DO_NOTIFY_RESUME_MASK | \
10617 _TIF_NEED_RESCHED)
10618 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
10619
10620+#define _TIF_WORK_SYSCALL \
10621+ (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
10622+ _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
10623+
10624 #define is_32bit_task() (test_thread_flag(TIF_32BIT))
10625
10626 /*
10627diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
10628index bd56c28..4b63d83 100644
10629--- a/arch/sparc/include/asm/uaccess.h
10630+++ b/arch/sparc/include/asm/uaccess.h
10631@@ -1,5 +1,6 @@
10632 #ifndef ___ASM_SPARC_UACCESS_H
10633 #define ___ASM_SPARC_UACCESS_H
10634+
10635 #if defined(__sparc__) && defined(__arch64__)
10636 #include <asm/uaccess_64.h>
10637 #else
10638diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
10639index 64ee103..388aef0 100644
10640--- a/arch/sparc/include/asm/uaccess_32.h
10641+++ b/arch/sparc/include/asm/uaccess_32.h
10642@@ -47,6 +47,7 @@
10643 #define __user_ok(addr, size) ({ (void)(size); (addr) < STACK_TOP; })
10644 #define __kernel_ok (segment_eq(get_fs(), KERNEL_DS))
10645 #define __access_ok(addr, size) (__user_ok((addr) & get_fs().seg, (size)))
10646+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
10647 #define access_ok(type, addr, size) \
10648 ({ (void)(type); __access_ok((unsigned long)(addr), size); })
10649
10650@@ -313,27 +314,46 @@ unsigned long __copy_user(void __user *to, const void __user *from, unsigned lon
10651
10652 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
10653 {
10654- if (n && __access_ok((unsigned long) to, n))
10655+ if ((long)n < 0)
10656+ return n;
10657+
10658+ if (n && __access_ok((unsigned long) to, n)) {
10659+ if (!__builtin_constant_p(n))
10660+ check_object_size(from, n, true);
10661 return __copy_user(to, (__force void __user *) from, n);
10662- else
10663+ } else
10664 return n;
10665 }
10666
10667 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
10668 {
10669+ if ((long)n < 0)
10670+ return n;
10671+
10672+ if (!__builtin_constant_p(n))
10673+ check_object_size(from, n, true);
10674+
10675 return __copy_user(to, (__force void __user *) from, n);
10676 }
10677
10678 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
10679 {
10680- if (n && __access_ok((unsigned long) from, n))
10681+ if ((long)n < 0)
10682+ return n;
10683+
10684+ if (n && __access_ok((unsigned long) from, n)) {
10685+ if (!__builtin_constant_p(n))
10686+ check_object_size(to, n, false);
10687 return __copy_user((__force void __user *) to, from, n);
10688- else
10689+ } else
10690 return n;
10691 }
10692
10693 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
10694 {
10695+ if ((long)n < 0)
10696+ return n;
10697+
10698 return __copy_user((__force void __user *) to, from, n);
10699 }
10700
10701diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
10702index ea6e9a2..5703598 100644
10703--- a/arch/sparc/include/asm/uaccess_64.h
10704+++ b/arch/sparc/include/asm/uaccess_64.h
10705@@ -10,6 +10,7 @@
10706 #include <linux/compiler.h>
10707 #include <linux/string.h>
10708 #include <linux/thread_info.h>
10709+#include <linux/kernel.h>
10710 #include <asm/asi.h>
10711 #include <asm/spitfire.h>
10712 #include <asm-generic/uaccess-unaligned.h>
10713@@ -76,6 +77,11 @@ static inline int __access_ok(const void __user * addr, unsigned long size)
10714 return 1;
10715 }
10716
10717+static inline int access_ok_noprefault(int type, const void __user * addr, unsigned long size)
10718+{
10719+ return 1;
10720+}
10721+
10722 static inline int access_ok(int type, const void __user * addr, unsigned long size)
10723 {
10724 return 1;
10725@@ -250,8 +256,15 @@ unsigned long copy_from_user_fixup(void *to, const void __user *from,
10726 static inline unsigned long __must_check
10727 copy_from_user(void *to, const void __user *from, unsigned long size)
10728 {
10729- unsigned long ret = ___copy_from_user(to, from, size);
10730+ unsigned long ret;
10731
10732+ if ((long)size < 0 || size > INT_MAX)
10733+ return size;
10734+
10735+ if (!__builtin_constant_p(size))
10736+ check_object_size(to, size, false);
10737+
10738+ ret = ___copy_from_user(to, from, size);
10739 if (unlikely(ret))
10740 ret = copy_from_user_fixup(to, from, size);
10741
10742@@ -267,8 +280,15 @@ unsigned long copy_to_user_fixup(void __user *to, const void *from,
10743 static inline unsigned long __must_check
10744 copy_to_user(void __user *to, const void *from, unsigned long size)
10745 {
10746- unsigned long ret = ___copy_to_user(to, from, size);
10747+ unsigned long ret;
10748
10749+ if ((long)size < 0 || size > INT_MAX)
10750+ return size;
10751+
10752+ if (!__builtin_constant_p(size))
10753+ check_object_size(from, size, true);
10754+
10755+ ret = ___copy_to_user(to, from, size);
10756 if (unlikely(ret))
10757 ret = copy_to_user_fixup(to, from, size);
10758 return ret;
10759diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
10760index 7cf9c6e..6206648 100644
10761--- a/arch/sparc/kernel/Makefile
10762+++ b/arch/sparc/kernel/Makefile
10763@@ -4,7 +4,7 @@
10764 #
10765
10766 asflags-y := -ansi
10767-ccflags-y := -Werror
10768+#ccflags-y := -Werror
10769
10770 extra-y := head_$(BITS).o
10771
10772diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
10773index 50e7b62..79fae35 100644
10774--- a/arch/sparc/kernel/process_32.c
10775+++ b/arch/sparc/kernel/process_32.c
10776@@ -123,14 +123,14 @@ void show_regs(struct pt_regs *r)
10777
10778 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
10779 r->psr, r->pc, r->npc, r->y, print_tainted());
10780- printk("PC: <%pS>\n", (void *) r->pc);
10781+ printk("PC: <%pA>\n", (void *) r->pc);
10782 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10783 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
10784 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
10785 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10786 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
10787 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
10788- printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
10789+ printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
10790
10791 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10792 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
10793@@ -167,7 +167,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10794 rw = (struct reg_window32 *) fp;
10795 pc = rw->ins[7];
10796 printk("[%08lx : ", pc);
10797- printk("%pS ] ", (void *) pc);
10798+ printk("%pA ] ", (void *) pc);
10799 fp = rw->ins[6];
10800 } while (++count < 16);
10801 printk("\n");
10802diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
10803index 46a5964..a35c62c 100644
10804--- a/arch/sparc/kernel/process_64.c
10805+++ b/arch/sparc/kernel/process_64.c
10806@@ -161,7 +161,7 @@ static void show_regwindow(struct pt_regs *regs)
10807 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
10808 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
10809 if (regs->tstate & TSTATE_PRIV)
10810- printk("I7: <%pS>\n", (void *) rwk->ins[7]);
10811+ printk("I7: <%pA>\n", (void *) rwk->ins[7]);
10812 }
10813
10814 void show_regs(struct pt_regs *regs)
10815@@ -170,7 +170,7 @@ void show_regs(struct pt_regs *regs)
10816
10817 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
10818 regs->tpc, regs->tnpc, regs->y, print_tainted());
10819- printk("TPC: <%pS>\n", (void *) regs->tpc);
10820+ printk("TPC: <%pA>\n", (void *) regs->tpc);
10821 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
10822 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
10823 regs->u_regs[3]);
10824@@ -183,7 +183,7 @@ void show_regs(struct pt_regs *regs)
10825 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
10826 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
10827 regs->u_regs[15]);
10828- printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
10829+ printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
10830 show_regwindow(regs);
10831 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
10832 }
10833@@ -278,7 +278,7 @@ void arch_trigger_all_cpu_backtrace(bool include_self)
10834 ((tp && tp->task) ? tp->task->pid : -1));
10835
10836 if (gp->tstate & TSTATE_PRIV) {
10837- printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
10838+ printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
10839 (void *) gp->tpc,
10840 (void *) gp->o7,
10841 (void *) gp->i7,
10842diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
10843index 79cc0d1..ec62734 100644
10844--- a/arch/sparc/kernel/prom_common.c
10845+++ b/arch/sparc/kernel/prom_common.c
10846@@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
10847
10848 unsigned int prom_early_allocated __initdata;
10849
10850-static struct of_pdt_ops prom_sparc_ops __initdata = {
10851+static struct of_pdt_ops prom_sparc_ops __initconst = {
10852 .nextprop = prom_common_nextprop,
10853 .getproplen = prom_getproplen,
10854 .getproperty = prom_getproperty,
10855diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
10856index 9ddc492..27a5619 100644
10857--- a/arch/sparc/kernel/ptrace_64.c
10858+++ b/arch/sparc/kernel/ptrace_64.c
10859@@ -1060,6 +1060,10 @@ long arch_ptrace(struct task_struct *child, long request,
10860 return ret;
10861 }
10862
10863+#ifdef CONFIG_GRKERNSEC_SETXID
10864+extern void gr_delayed_cred_worker(void);
10865+#endif
10866+
10867 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
10868 {
10869 int ret = 0;
10870@@ -1070,6 +1074,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
10871 if (test_thread_flag(TIF_NOHZ))
10872 user_exit();
10873
10874+#ifdef CONFIG_GRKERNSEC_SETXID
10875+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
10876+ gr_delayed_cred_worker();
10877+#endif
10878+
10879 if (test_thread_flag(TIF_SYSCALL_TRACE))
10880 ret = tracehook_report_syscall_entry(regs);
10881
10882@@ -1088,6 +1097,11 @@ asmlinkage void syscall_trace_leave(struct pt_regs *regs)
10883 if (test_thread_flag(TIF_NOHZ))
10884 user_exit();
10885
10886+#ifdef CONFIG_GRKERNSEC_SETXID
10887+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
10888+ gr_delayed_cred_worker();
10889+#endif
10890+
10891 audit_syscall_exit(regs);
10892
10893 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
10894diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
10895index 19cd08d..ff21e99 100644
10896--- a/arch/sparc/kernel/smp_64.c
10897+++ b/arch/sparc/kernel/smp_64.c
10898@@ -891,7 +891,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
10899 return;
10900
10901 #ifdef CONFIG_DEBUG_DCFLUSH
10902- atomic_inc(&dcpage_flushes);
10903+ atomic_inc_unchecked(&dcpage_flushes);
10904 #endif
10905
10906 this_cpu = get_cpu();
10907@@ -915,7 +915,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
10908 xcall_deliver(data0, __pa(pg_addr),
10909 (u64) pg_addr, cpumask_of(cpu));
10910 #ifdef CONFIG_DEBUG_DCFLUSH
10911- atomic_inc(&dcpage_flushes_xcall);
10912+ atomic_inc_unchecked(&dcpage_flushes_xcall);
10913 #endif
10914 }
10915 }
10916@@ -934,7 +934,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
10917 preempt_disable();
10918
10919 #ifdef CONFIG_DEBUG_DCFLUSH
10920- atomic_inc(&dcpage_flushes);
10921+ atomic_inc_unchecked(&dcpage_flushes);
10922 #endif
10923 data0 = 0;
10924 pg_addr = page_address(page);
10925@@ -951,7 +951,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
10926 xcall_deliver(data0, __pa(pg_addr),
10927 (u64) pg_addr, cpu_online_mask);
10928 #ifdef CONFIG_DEBUG_DCFLUSH
10929- atomic_inc(&dcpage_flushes_xcall);
10930+ atomic_inc_unchecked(&dcpage_flushes_xcall);
10931 #endif
10932 }
10933 __local_flush_dcache_page(page);
10934diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
10935index 646988d..b88905f 100644
10936--- a/arch/sparc/kernel/sys_sparc_32.c
10937+++ b/arch/sparc/kernel/sys_sparc_32.c
10938@@ -54,7 +54,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10939 if (len > TASK_SIZE - PAGE_SIZE)
10940 return -ENOMEM;
10941 if (!addr)
10942- addr = TASK_UNMAPPED_BASE;
10943+ addr = current->mm->mmap_base;
10944
10945 info.flags = 0;
10946 info.length = len;
10947diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
10948index 30e7ddb..266a3b0 100644
10949--- a/arch/sparc/kernel/sys_sparc_64.c
10950+++ b/arch/sparc/kernel/sys_sparc_64.c
10951@@ -89,13 +89,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10952 struct vm_area_struct * vma;
10953 unsigned long task_size = TASK_SIZE;
10954 int do_color_align;
10955+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
10956 struct vm_unmapped_area_info info;
10957
10958 if (flags & MAP_FIXED) {
10959 /* We do not accept a shared mapping if it would violate
10960 * cache aliasing constraints.
10961 */
10962- if ((flags & MAP_SHARED) &&
10963+ if ((filp || (flags & MAP_SHARED)) &&
10964 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
10965 return -EINVAL;
10966 return addr;
10967@@ -110,6 +111,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10968 if (filp || (flags & MAP_SHARED))
10969 do_color_align = 1;
10970
10971+#ifdef CONFIG_PAX_RANDMMAP
10972+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10973+#endif
10974+
10975 if (addr) {
10976 if (do_color_align)
10977 addr = COLOR_ALIGN(addr, pgoff);
10978@@ -117,22 +122,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10979 addr = PAGE_ALIGN(addr);
10980
10981 vma = find_vma(mm, addr);
10982- if (task_size - len >= addr &&
10983- (!vma || addr + len <= vma->vm_start))
10984+ if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10985 return addr;
10986 }
10987
10988 info.flags = 0;
10989 info.length = len;
10990- info.low_limit = TASK_UNMAPPED_BASE;
10991+ info.low_limit = mm->mmap_base;
10992 info.high_limit = min(task_size, VA_EXCLUDE_START);
10993 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
10994 info.align_offset = pgoff << PAGE_SHIFT;
10995+ info.threadstack_offset = offset;
10996 addr = vm_unmapped_area(&info);
10997
10998 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10999 VM_BUG_ON(addr != -ENOMEM);
11000 info.low_limit = VA_EXCLUDE_END;
11001+
11002+#ifdef CONFIG_PAX_RANDMMAP
11003+ if (mm->pax_flags & MF_PAX_RANDMMAP)
11004+ info.low_limit += mm->delta_mmap;
11005+#endif
11006+
11007 info.high_limit = task_size;
11008 addr = vm_unmapped_area(&info);
11009 }
11010@@ -150,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11011 unsigned long task_size = STACK_TOP32;
11012 unsigned long addr = addr0;
11013 int do_color_align;
11014+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
11015 struct vm_unmapped_area_info info;
11016
11017 /* This should only ever run for 32-bit processes. */
11018@@ -159,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11019 /* We do not accept a shared mapping if it would violate
11020 * cache aliasing constraints.
11021 */
11022- if ((flags & MAP_SHARED) &&
11023+ if ((filp || (flags & MAP_SHARED)) &&
11024 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
11025 return -EINVAL;
11026 return addr;
11027@@ -172,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11028 if (filp || (flags & MAP_SHARED))
11029 do_color_align = 1;
11030
11031+#ifdef CONFIG_PAX_RANDMMAP
11032+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11033+#endif
11034+
11035 /* requesting a specific address */
11036 if (addr) {
11037 if (do_color_align)
11038@@ -180,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11039 addr = PAGE_ALIGN(addr);
11040
11041 vma = find_vma(mm, addr);
11042- if (task_size - len >= addr &&
11043- (!vma || addr + len <= vma->vm_start))
11044+ if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11045 return addr;
11046 }
11047
11048@@ -191,6 +206,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11049 info.high_limit = mm->mmap_base;
11050 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
11051 info.align_offset = pgoff << PAGE_SHIFT;
11052+ info.threadstack_offset = offset;
11053 addr = vm_unmapped_area(&info);
11054
11055 /*
11056@@ -203,6 +219,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11057 VM_BUG_ON(addr != -ENOMEM);
11058 info.flags = 0;
11059 info.low_limit = TASK_UNMAPPED_BASE;
11060+
11061+#ifdef CONFIG_PAX_RANDMMAP
11062+ if (mm->pax_flags & MF_PAX_RANDMMAP)
11063+ info.low_limit += mm->delta_mmap;
11064+#endif
11065+
11066 info.high_limit = STACK_TOP32;
11067 addr = vm_unmapped_area(&info);
11068 }
11069@@ -259,10 +281,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
11070 EXPORT_SYMBOL(get_fb_unmapped_area);
11071
11072 /* Essentially the same as PowerPC. */
11073-static unsigned long mmap_rnd(void)
11074+static unsigned long mmap_rnd(struct mm_struct *mm)
11075 {
11076 unsigned long rnd = 0UL;
11077
11078+#ifdef CONFIG_PAX_RANDMMAP
11079+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11080+#endif
11081+
11082 if (current->flags & PF_RANDOMIZE) {
11083 unsigned long val = get_random_int();
11084 if (test_thread_flag(TIF_32BIT))
11085@@ -275,7 +301,7 @@ static unsigned long mmap_rnd(void)
11086
11087 void arch_pick_mmap_layout(struct mm_struct *mm)
11088 {
11089- unsigned long random_factor = mmap_rnd();
11090+ unsigned long random_factor = mmap_rnd(mm);
11091 unsigned long gap;
11092
11093 /*
11094@@ -288,6 +314,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
11095 gap == RLIM_INFINITY ||
11096 sysctl_legacy_va_layout) {
11097 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
11098+
11099+#ifdef CONFIG_PAX_RANDMMAP
11100+ if (mm->pax_flags & MF_PAX_RANDMMAP)
11101+ mm->mmap_base += mm->delta_mmap;
11102+#endif
11103+
11104 mm->get_unmapped_area = arch_get_unmapped_area;
11105 } else {
11106 /* We know it's 32-bit */
11107@@ -299,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
11108 gap = (task_size / 6 * 5);
11109
11110 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
11111+
11112+#ifdef CONFIG_PAX_RANDMMAP
11113+ if (mm->pax_flags & MF_PAX_RANDMMAP)
11114+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
11115+#endif
11116+
11117 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
11118 }
11119 }
11120diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
11121index bb00089..e0ea580 100644
11122--- a/arch/sparc/kernel/syscalls.S
11123+++ b/arch/sparc/kernel/syscalls.S
11124@@ -62,7 +62,7 @@ sys32_rt_sigreturn:
11125 #endif
11126 .align 32
11127 1: ldx [%g6 + TI_FLAGS], %l5
11128- andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
11129+ andcc %l5, _TIF_WORK_SYSCALL, %g0
11130 be,pt %icc, rtrap
11131 nop
11132 call syscall_trace_leave
11133@@ -194,7 +194,7 @@ linux_sparc_syscall32:
11134
11135 srl %i3, 0, %o3 ! IEU0
11136 srl %i2, 0, %o2 ! IEU0 Group
11137- andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
11138+ andcc %l0, _TIF_WORK_SYSCALL, %g0
11139 bne,pn %icc, linux_syscall_trace32 ! CTI
11140 mov %i0, %l5 ! IEU1
11141 5: call %l7 ! CTI Group brk forced
11142@@ -218,7 +218,7 @@ linux_sparc_syscall:
11143
11144 mov %i3, %o3 ! IEU1
11145 mov %i4, %o4 ! IEU0 Group
11146- andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
11147+ andcc %l0, _TIF_WORK_SYSCALL, %g0
11148 bne,pn %icc, linux_syscall_trace ! CTI Group
11149 mov %i0, %l5 ! IEU0
11150 2: call %l7 ! CTI Group brk forced
11151@@ -233,7 +233,7 @@ ret_sys_call:
11152
11153 cmp %o0, -ERESTART_RESTARTBLOCK
11154 bgeu,pn %xcc, 1f
11155- andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
11156+ andcc %l0, _TIF_WORK_SYSCALL, %g0
11157 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
11158
11159 2:
11160diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
11161index 4f21df7..0a374da 100644
11162--- a/arch/sparc/kernel/traps_32.c
11163+++ b/arch/sparc/kernel/traps_32.c
11164@@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
11165 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
11166 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
11167
11168+extern void gr_handle_kernel_exploit(void);
11169+
11170 void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11171 {
11172 static int die_counter;
11173@@ -76,15 +78,17 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11174 count++ < 30 &&
11175 (((unsigned long) rw) >= PAGE_OFFSET) &&
11176 !(((unsigned long) rw) & 0x7)) {
11177- printk("Caller[%08lx]: %pS\n", rw->ins[7],
11178+ printk("Caller[%08lx]: %pA\n", rw->ins[7],
11179 (void *) rw->ins[7]);
11180 rw = (struct reg_window32 *)rw->ins[6];
11181 }
11182 }
11183 printk("Instruction DUMP:");
11184 instruction_dump ((unsigned long *) regs->pc);
11185- if(regs->psr & PSR_PS)
11186+ if(regs->psr & PSR_PS) {
11187+ gr_handle_kernel_exploit();
11188 do_exit(SIGKILL);
11189+ }
11190 do_exit(SIGSEGV);
11191 }
11192
11193diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
11194index d21cd62..00a4a17 100644
11195--- a/arch/sparc/kernel/traps_64.c
11196+++ b/arch/sparc/kernel/traps_64.c
11197@@ -79,7 +79,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
11198 i + 1,
11199 p->trapstack[i].tstate, p->trapstack[i].tpc,
11200 p->trapstack[i].tnpc, p->trapstack[i].tt);
11201- printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
11202+ printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
11203 }
11204 }
11205
11206@@ -99,6 +99,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
11207
11208 lvl -= 0x100;
11209 if (regs->tstate & TSTATE_PRIV) {
11210+
11211+#ifdef CONFIG_PAX_REFCOUNT
11212+ if (lvl == 6)
11213+ pax_report_refcount_overflow(regs);
11214+#endif
11215+
11216 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
11217 die_if_kernel(buffer, regs);
11218 }
11219@@ -117,11 +123,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
11220 void bad_trap_tl1(struct pt_regs *regs, long lvl)
11221 {
11222 char buffer[32];
11223-
11224+
11225 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
11226 0, lvl, SIGTRAP) == NOTIFY_STOP)
11227 return;
11228
11229+#ifdef CONFIG_PAX_REFCOUNT
11230+ if (lvl == 6)
11231+ pax_report_refcount_overflow(regs);
11232+#endif
11233+
11234 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
11235
11236 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
11237@@ -1151,7 +1162,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
11238 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
11239 printk("%s" "ERROR(%d): ",
11240 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
11241- printk("TPC<%pS>\n", (void *) regs->tpc);
11242+ printk("TPC<%pA>\n", (void *) regs->tpc);
11243 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
11244 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
11245 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
11246@@ -1758,7 +1769,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
11247 smp_processor_id(),
11248 (type & 0x1) ? 'I' : 'D',
11249 regs->tpc);
11250- printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
11251+ printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
11252 panic("Irrecoverable Cheetah+ parity error.");
11253 }
11254
11255@@ -1766,7 +1777,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
11256 smp_processor_id(),
11257 (type & 0x1) ? 'I' : 'D',
11258 regs->tpc);
11259- printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
11260+ printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
11261 }
11262
11263 struct sun4v_error_entry {
11264@@ -1839,8 +1850,8 @@ struct sun4v_error_entry {
11265 /*0x38*/u64 reserved_5;
11266 };
11267
11268-static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
11269-static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
11270+static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
11271+static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
11272
11273 static const char *sun4v_err_type_to_str(u8 type)
11274 {
11275@@ -1932,7 +1943,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
11276 }
11277
11278 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
11279- int cpu, const char *pfx, atomic_t *ocnt)
11280+ int cpu, const char *pfx, atomic_unchecked_t *ocnt)
11281 {
11282 u64 *raw_ptr = (u64 *) ent;
11283 u32 attrs;
11284@@ -1990,8 +2001,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
11285
11286 show_regs(regs);
11287
11288- if ((cnt = atomic_read(ocnt)) != 0) {
11289- atomic_set(ocnt, 0);
11290+ if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
11291+ atomic_set_unchecked(ocnt, 0);
11292 wmb();
11293 printk("%s: Queue overflowed %d times.\n",
11294 pfx, cnt);
11295@@ -2048,7 +2059,7 @@ out:
11296 */
11297 void sun4v_resum_overflow(struct pt_regs *regs)
11298 {
11299- atomic_inc(&sun4v_resum_oflow_cnt);
11300+ atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
11301 }
11302
11303 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
11304@@ -2101,7 +2112,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
11305 /* XXX Actually even this can make not that much sense. Perhaps
11306 * XXX we should just pull the plug and panic directly from here?
11307 */
11308- atomic_inc(&sun4v_nonresum_oflow_cnt);
11309+ atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
11310 }
11311
11312 static void sun4v_tlb_error(struct pt_regs *regs)
11313@@ -2120,9 +2131,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
11314
11315 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
11316 regs->tpc, tl);
11317- printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
11318+ printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
11319 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
11320- printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
11321+ printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
11322 (void *) regs->u_regs[UREG_I7]);
11323 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
11324 "pte[%lx] error[%lx]\n",
11325@@ -2143,9 +2154,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
11326
11327 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
11328 regs->tpc, tl);
11329- printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
11330+ printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
11331 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
11332- printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
11333+ printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
11334 (void *) regs->u_regs[UREG_I7]);
11335 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
11336 "pte[%lx] error[%lx]\n",
11337@@ -2362,13 +2373,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
11338 fp = (unsigned long)sf->fp + STACK_BIAS;
11339 }
11340
11341- printk(" [%016lx] %pS\n", pc, (void *) pc);
11342+ printk(" [%016lx] %pA\n", pc, (void *) pc);
11343 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
11344 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
11345 int index = tsk->curr_ret_stack;
11346 if (tsk->ret_stack && index >= graph) {
11347 pc = tsk->ret_stack[index - graph].ret;
11348- printk(" [%016lx] %pS\n", pc, (void *) pc);
11349+ printk(" [%016lx] %pA\n", pc, (void *) pc);
11350 graph++;
11351 }
11352 }
11353@@ -2386,6 +2397,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
11354 return (struct reg_window *) (fp + STACK_BIAS);
11355 }
11356
11357+extern void gr_handle_kernel_exploit(void);
11358+
11359 void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11360 {
11361 static int die_counter;
11362@@ -2414,7 +2427,7 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11363 while (rw &&
11364 count++ < 30 &&
11365 kstack_valid(tp, (unsigned long) rw)) {
11366- printk("Caller[%016lx]: %pS\n", rw->ins[7],
11367+ printk("Caller[%016lx]: %pA\n", rw->ins[7],
11368 (void *) rw->ins[7]);
11369
11370 rw = kernel_stack_up(rw);
11371@@ -2429,8 +2442,10 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11372 }
11373 if (panic_on_oops)
11374 panic("Fatal exception");
11375- if (regs->tstate & TSTATE_PRIV)
11376+ if (regs->tstate & TSTATE_PRIV) {
11377+ gr_handle_kernel_exploit();
11378 do_exit(SIGKILL);
11379+ }
11380 do_exit(SIGSEGV);
11381 }
11382 EXPORT_SYMBOL(die_if_kernel);
11383diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
11384index 62098a8..547ab2c 100644
11385--- a/arch/sparc/kernel/unaligned_64.c
11386+++ b/arch/sparc/kernel/unaligned_64.c
11387@@ -297,7 +297,7 @@ static void log_unaligned(struct pt_regs *regs)
11388 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
11389
11390 if (__ratelimit(&ratelimit)) {
11391- printk("Kernel unaligned access at TPC[%lx] %pS\n",
11392+ printk("Kernel unaligned access at TPC[%lx] %pA\n",
11393 regs->tpc, (void *) regs->tpc);
11394 }
11395 }
11396diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
11397index 3269b02..64f5231 100644
11398--- a/arch/sparc/lib/Makefile
11399+++ b/arch/sparc/lib/Makefile
11400@@ -2,7 +2,7 @@
11401 #
11402
11403 asflags-y := -ansi -DST_DIV0=0x02
11404-ccflags-y := -Werror
11405+#ccflags-y := -Werror
11406
11407 lib-$(CONFIG_SPARC32) += ashrdi3.o
11408 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
11409diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
11410index 05dac43..76f8ed4 100644
11411--- a/arch/sparc/lib/atomic_64.S
11412+++ b/arch/sparc/lib/atomic_64.S
11413@@ -15,11 +15,22 @@
11414 * a value and does the barriers.
11415 */
11416
11417-#define ATOMIC_OP(op) \
11418-ENTRY(atomic_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11419+#ifdef CONFIG_PAX_REFCOUNT
11420+#define __REFCOUNT_OP(op) op##cc
11421+#define __OVERFLOW_IOP tvs %icc, 6;
11422+#define __OVERFLOW_XOP tvs %xcc, 6;
11423+#else
11424+#define __REFCOUNT_OP(op) op
11425+#define __OVERFLOW_IOP
11426+#define __OVERFLOW_XOP
11427+#endif
11428+
11429+#define __ATOMIC_OP(op, suffix, asm_op, post_op) \
11430+ENTRY(atomic_##op##suffix) /* %o0 = increment, %o1 = atomic_ptr */ \
11431 BACKOFF_SETUP(%o2); \
11432 1: lduw [%o1], %g1; \
11433- op %g1, %o0, %g7; \
11434+ asm_op %g1, %o0, %g7; \
11435+ post_op \
11436 cas [%o1], %g1, %g7; \
11437 cmp %g1, %g7; \
11438 bne,pn %icc, BACKOFF_LABEL(2f, 1b); \
11439@@ -29,11 +40,15 @@ ENTRY(atomic_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11440 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11441 ENDPROC(atomic_##op); \
11442
11443-#define ATOMIC_OP_RETURN(op) \
11444-ENTRY(atomic_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11445+#define ATOMIC_OP(op) __ATOMIC_OP(op, , op, ) \
11446+ __ATOMIC_OP(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_IOP)
11447+
11448+#define __ATOMIC_OP_RETURN(op, suffix, asm_op, post_op) \
11449+ENTRY(atomic_##op##_return##suffix) /* %o0 = increment, %o1 = atomic_ptr */\
11450 BACKOFF_SETUP(%o2); \
11451 1: lduw [%o1], %g1; \
11452- op %g1, %o0, %g7; \
11453+ asm_op %g1, %o0, %g7; \
11454+ post_op \
11455 cas [%o1], %g1, %g7; \
11456 cmp %g1, %g7; \
11457 bne,pn %icc, BACKOFF_LABEL(2f, 1b); \
11458@@ -43,6 +58,9 @@ ENTRY(atomic_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11459 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11460 ENDPROC(atomic_##op##_return);
11461
11462+#define ATOMIC_OP_RETURN(op) __ATOMIC_OP_RETURN(op, , op, ) \
11463+ __ATOMIC_OP_RETURN(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_IOP)
11464+
11465 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_OP_RETURN(op)
11466
11467 ATOMIC_OPS(add)
11468@@ -50,13 +68,16 @@ ATOMIC_OPS(sub)
11469
11470 #undef ATOMIC_OPS
11471 #undef ATOMIC_OP_RETURN
11472+#undef __ATOMIC_OP_RETURN
11473 #undef ATOMIC_OP
11474+#undef __ATOMIC_OP
11475
11476-#define ATOMIC64_OP(op) \
11477-ENTRY(atomic64_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11478+#define __ATOMIC64_OP(op, suffix, asm_op, post_op) \
11479+ENTRY(atomic64_##op##suffix) /* %o0 = increment, %o1 = atomic_ptr */ \
11480 BACKOFF_SETUP(%o2); \
11481 1: ldx [%o1], %g1; \
11482- op %g1, %o0, %g7; \
11483+ asm_op %g1, %o0, %g7; \
11484+ post_op \
11485 casx [%o1], %g1, %g7; \
11486 cmp %g1, %g7; \
11487 bne,pn %xcc, BACKOFF_LABEL(2f, 1b); \
11488@@ -66,11 +87,15 @@ ENTRY(atomic64_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11489 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11490 ENDPROC(atomic64_##op); \
11491
11492-#define ATOMIC64_OP_RETURN(op) \
11493-ENTRY(atomic64_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11494+#define ATOMIC64_OP(op) __ATOMIC64_OP(op, , op, ) \
11495+ __ATOMIC64_OP(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_XOP)
11496+
11497+#define __ATOMIC64_OP_RETURN(op, suffix, asm_op, post_op) \
11498+ENTRY(atomic64_##op##_return##suffix) /* %o0 = increment, %o1 = atomic_ptr */\
11499 BACKOFF_SETUP(%o2); \
11500 1: ldx [%o1], %g1; \
11501- op %g1, %o0, %g7; \
11502+ asm_op %g1, %o0, %g7; \
11503+ post_op \
11504 casx [%o1], %g1, %g7; \
11505 cmp %g1, %g7; \
11506 bne,pn %xcc, BACKOFF_LABEL(2f, 1b); \
11507@@ -80,6 +105,9 @@ ENTRY(atomic64_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11508 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11509 ENDPROC(atomic64_##op##_return);
11510
11511+#define ATOMIC64_OP_RETURN(op) __ATOMIC64_OP_RETURN(op, , op, ) \
11512+i __ATOMIC64_OP_RETURN(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_XOP)
11513+
11514 #define ATOMIC64_OPS(op) ATOMIC64_OP(op) ATOMIC64_OP_RETURN(op)
11515
11516 ATOMIC64_OPS(add)
11517@@ -87,7 +115,12 @@ ATOMIC64_OPS(sub)
11518
11519 #undef ATOMIC64_OPS
11520 #undef ATOMIC64_OP_RETURN
11521+#undef __ATOMIC64_OP_RETURN
11522 #undef ATOMIC64_OP
11523+#undef __ATOMIC64_OP
11524+#undef __OVERFLOW_XOP
11525+#undef __OVERFLOW_IOP
11526+#undef __REFCOUNT_OP
11527
11528 ENTRY(atomic64_dec_if_positive) /* %o0 = atomic_ptr */
11529 BACKOFF_SETUP(%o2)
11530diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
11531index 8069ce1..c2e23c4 100644
11532--- a/arch/sparc/lib/ksyms.c
11533+++ b/arch/sparc/lib/ksyms.c
11534@@ -101,7 +101,9 @@ EXPORT_SYMBOL(__clear_user);
11535 /* Atomic counter implementation. */
11536 #define ATOMIC_OP(op) \
11537 EXPORT_SYMBOL(atomic_##op); \
11538-EXPORT_SYMBOL(atomic64_##op);
11539+EXPORT_SYMBOL(atomic_##op##_unchecked); \
11540+EXPORT_SYMBOL(atomic64_##op); \
11541+EXPORT_SYMBOL(atomic64_##op##_unchecked);
11542
11543 #define ATOMIC_OP_RETURN(op) \
11544 EXPORT_SYMBOL(atomic_##op##_return); \
11545@@ -110,6 +112,8 @@ EXPORT_SYMBOL(atomic64_##op##_return);
11546 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_OP_RETURN(op)
11547
11548 ATOMIC_OPS(add)
11549+EXPORT_SYMBOL(atomic_add_ret_unchecked);
11550+EXPORT_SYMBOL(atomic64_add_ret_unchecked);
11551 ATOMIC_OPS(sub)
11552
11553 #undef ATOMIC_OPS
11554diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
11555index 30c3ecc..736f015 100644
11556--- a/arch/sparc/mm/Makefile
11557+++ b/arch/sparc/mm/Makefile
11558@@ -2,7 +2,7 @@
11559 #
11560
11561 asflags-y := -ansi
11562-ccflags-y := -Werror
11563+#ccflags-y := -Werror
11564
11565 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
11566 obj-y += fault_$(BITS).o
11567diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
11568index c399e7b..2387414 100644
11569--- a/arch/sparc/mm/fault_32.c
11570+++ b/arch/sparc/mm/fault_32.c
11571@@ -22,6 +22,9 @@
11572 #include <linux/interrupt.h>
11573 #include <linux/kdebug.h>
11574 #include <linux/uaccess.h>
11575+#include <linux/slab.h>
11576+#include <linux/pagemap.h>
11577+#include <linux/compiler.h>
11578
11579 #include <asm/page.h>
11580 #include <asm/pgtable.h>
11581@@ -156,6 +159,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
11582 return safe_compute_effective_address(regs, insn);
11583 }
11584
11585+#ifdef CONFIG_PAX_PAGEEXEC
11586+#ifdef CONFIG_PAX_DLRESOLVE
11587+static void pax_emuplt_close(struct vm_area_struct *vma)
11588+{
11589+ vma->vm_mm->call_dl_resolve = 0UL;
11590+}
11591+
11592+static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
11593+{
11594+ unsigned int *kaddr;
11595+
11596+ vmf->page = alloc_page(GFP_HIGHUSER);
11597+ if (!vmf->page)
11598+ return VM_FAULT_OOM;
11599+
11600+ kaddr = kmap(vmf->page);
11601+ memset(kaddr, 0, PAGE_SIZE);
11602+ kaddr[0] = 0x9DE3BFA8U; /* save */
11603+ flush_dcache_page(vmf->page);
11604+ kunmap(vmf->page);
11605+ return VM_FAULT_MAJOR;
11606+}
11607+
11608+static const struct vm_operations_struct pax_vm_ops = {
11609+ .close = pax_emuplt_close,
11610+ .fault = pax_emuplt_fault
11611+};
11612+
11613+static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
11614+{
11615+ int ret;
11616+
11617+ INIT_LIST_HEAD(&vma->anon_vma_chain);
11618+ vma->vm_mm = current->mm;
11619+ vma->vm_start = addr;
11620+ vma->vm_end = addr + PAGE_SIZE;
11621+ vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
11622+ vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
11623+ vma->vm_ops = &pax_vm_ops;
11624+
11625+ ret = insert_vm_struct(current->mm, vma);
11626+ if (ret)
11627+ return ret;
11628+
11629+ ++current->mm->total_vm;
11630+ return 0;
11631+}
11632+#endif
11633+
11634+/*
11635+ * PaX: decide what to do with offenders (regs->pc = fault address)
11636+ *
11637+ * returns 1 when task should be killed
11638+ * 2 when patched PLT trampoline was detected
11639+ * 3 when unpatched PLT trampoline was detected
11640+ */
11641+static int pax_handle_fetch_fault(struct pt_regs *regs)
11642+{
11643+
11644+#ifdef CONFIG_PAX_EMUPLT
11645+ int err;
11646+
11647+ do { /* PaX: patched PLT emulation #1 */
11648+ unsigned int sethi1, sethi2, jmpl;
11649+
11650+ err = get_user(sethi1, (unsigned int *)regs->pc);
11651+ err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
11652+ err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
11653+
11654+ if (err)
11655+ break;
11656+
11657+ if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
11658+ (sethi2 & 0xFFC00000U) == 0x03000000U &&
11659+ (jmpl & 0xFFFFE000U) == 0x81C06000U)
11660+ {
11661+ unsigned int addr;
11662+
11663+ regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
11664+ addr = regs->u_regs[UREG_G1];
11665+ addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11666+ regs->pc = addr;
11667+ regs->npc = addr+4;
11668+ return 2;
11669+ }
11670+ } while (0);
11671+
11672+ do { /* PaX: patched PLT emulation #2 */
11673+ unsigned int ba;
11674+
11675+ err = get_user(ba, (unsigned int *)regs->pc);
11676+
11677+ if (err)
11678+ break;
11679+
11680+ if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
11681+ unsigned int addr;
11682+
11683+ if ((ba & 0xFFC00000U) == 0x30800000U)
11684+ addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
11685+ else
11686+ addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11687+ regs->pc = addr;
11688+ regs->npc = addr+4;
11689+ return 2;
11690+ }
11691+ } while (0);
11692+
11693+ do { /* PaX: patched PLT emulation #3 */
11694+ unsigned int sethi, bajmpl, nop;
11695+
11696+ err = get_user(sethi, (unsigned int *)regs->pc);
11697+ err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
11698+ err |= get_user(nop, (unsigned int *)(regs->pc+8));
11699+
11700+ if (err)
11701+ break;
11702+
11703+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
11704+ ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
11705+ nop == 0x01000000U)
11706+ {
11707+ unsigned int addr;
11708+
11709+ addr = (sethi & 0x003FFFFFU) << 10;
11710+ regs->u_regs[UREG_G1] = addr;
11711+ if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
11712+ addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11713+ else
11714+ addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11715+ regs->pc = addr;
11716+ regs->npc = addr+4;
11717+ return 2;
11718+ }
11719+ } while (0);
11720+
11721+ do { /* PaX: unpatched PLT emulation step 1 */
11722+ unsigned int sethi, ba, nop;
11723+
11724+ err = get_user(sethi, (unsigned int *)regs->pc);
11725+ err |= get_user(ba, (unsigned int *)(regs->pc+4));
11726+ err |= get_user(nop, (unsigned int *)(regs->pc+8));
11727+
11728+ if (err)
11729+ break;
11730+
11731+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
11732+ ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
11733+ nop == 0x01000000U)
11734+ {
11735+ unsigned int addr, save, call;
11736+
11737+ if ((ba & 0xFFC00000U) == 0x30800000U)
11738+ addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
11739+ else
11740+ addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11741+
11742+ err = get_user(save, (unsigned int *)addr);
11743+ err |= get_user(call, (unsigned int *)(addr+4));
11744+ err |= get_user(nop, (unsigned int *)(addr+8));
11745+ if (err)
11746+ break;
11747+
11748+#ifdef CONFIG_PAX_DLRESOLVE
11749+ if (save == 0x9DE3BFA8U &&
11750+ (call & 0xC0000000U) == 0x40000000U &&
11751+ nop == 0x01000000U)
11752+ {
11753+ struct vm_area_struct *vma;
11754+ unsigned long call_dl_resolve;
11755+
11756+ down_read(&current->mm->mmap_sem);
11757+ call_dl_resolve = current->mm->call_dl_resolve;
11758+ up_read(&current->mm->mmap_sem);
11759+ if (likely(call_dl_resolve))
11760+ goto emulate;
11761+
11762+ vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11763+
11764+ down_write(&current->mm->mmap_sem);
11765+ if (current->mm->call_dl_resolve) {
11766+ call_dl_resolve = current->mm->call_dl_resolve;
11767+ up_write(&current->mm->mmap_sem);
11768+ if (vma)
11769+ kmem_cache_free(vm_area_cachep, vma);
11770+ goto emulate;
11771+ }
11772+
11773+ call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11774+ if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11775+ up_write(&current->mm->mmap_sem);
11776+ if (vma)
11777+ kmem_cache_free(vm_area_cachep, vma);
11778+ return 1;
11779+ }
11780+
11781+ if (pax_insert_vma(vma, call_dl_resolve)) {
11782+ up_write(&current->mm->mmap_sem);
11783+ kmem_cache_free(vm_area_cachep, vma);
11784+ return 1;
11785+ }
11786+
11787+ current->mm->call_dl_resolve = call_dl_resolve;
11788+ up_write(&current->mm->mmap_sem);
11789+
11790+emulate:
11791+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11792+ regs->pc = call_dl_resolve;
11793+ regs->npc = addr+4;
11794+ return 3;
11795+ }
11796+#endif
11797+
11798+ /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11799+ if ((save & 0xFFC00000U) == 0x05000000U &&
11800+ (call & 0xFFFFE000U) == 0x85C0A000U &&
11801+ nop == 0x01000000U)
11802+ {
11803+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11804+ regs->u_regs[UREG_G2] = addr + 4;
11805+ addr = (save & 0x003FFFFFU) << 10;
11806+ addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11807+ regs->pc = addr;
11808+ regs->npc = addr+4;
11809+ return 3;
11810+ }
11811+ }
11812+ } while (0);
11813+
11814+ do { /* PaX: unpatched PLT emulation step 2 */
11815+ unsigned int save, call, nop;
11816+
11817+ err = get_user(save, (unsigned int *)(regs->pc-4));
11818+ err |= get_user(call, (unsigned int *)regs->pc);
11819+ err |= get_user(nop, (unsigned int *)(regs->pc+4));
11820+ if (err)
11821+ break;
11822+
11823+ if (save == 0x9DE3BFA8U &&
11824+ (call & 0xC0000000U) == 0x40000000U &&
11825+ nop == 0x01000000U)
11826+ {
11827+ unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
11828+
11829+ regs->u_regs[UREG_RETPC] = regs->pc;
11830+ regs->pc = dl_resolve;
11831+ regs->npc = dl_resolve+4;
11832+ return 3;
11833+ }
11834+ } while (0);
11835+#endif
11836+
11837+ return 1;
11838+}
11839+
11840+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11841+{
11842+ unsigned long i;
11843+
11844+ printk(KERN_ERR "PAX: bytes at PC: ");
11845+ for (i = 0; i < 8; i++) {
11846+ unsigned int c;
11847+ if (get_user(c, (unsigned int *)pc+i))
11848+ printk(KERN_CONT "???????? ");
11849+ else
11850+ printk(KERN_CONT "%08x ", c);
11851+ }
11852+ printk("\n");
11853+}
11854+#endif
11855+
11856 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
11857 int text_fault)
11858 {
11859@@ -226,6 +500,24 @@ good_area:
11860 if (!(vma->vm_flags & VM_WRITE))
11861 goto bad_area;
11862 } else {
11863+
11864+#ifdef CONFIG_PAX_PAGEEXEC
11865+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
11866+ up_read(&mm->mmap_sem);
11867+ switch (pax_handle_fetch_fault(regs)) {
11868+
11869+#ifdef CONFIG_PAX_EMUPLT
11870+ case 2:
11871+ case 3:
11872+ return;
11873+#endif
11874+
11875+ }
11876+ pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
11877+ do_group_exit(SIGKILL);
11878+ }
11879+#endif
11880+
11881 /* Allow reads even for write-only mappings */
11882 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
11883 goto bad_area;
11884diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
11885index dbabe57..d34d315 100644
11886--- a/arch/sparc/mm/fault_64.c
11887+++ b/arch/sparc/mm/fault_64.c
11888@@ -23,6 +23,9 @@
11889 #include <linux/percpu.h>
11890 #include <linux/context_tracking.h>
11891 #include <linux/uaccess.h>
11892+#include <linux/slab.h>
11893+#include <linux/pagemap.h>
11894+#include <linux/compiler.h>
11895
11896 #include <asm/page.h>
11897 #include <asm/pgtable.h>
11898@@ -76,7 +79,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
11899 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
11900 regs->tpc);
11901 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
11902- printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
11903+ printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
11904 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
11905 dump_stack();
11906 unhandled_fault(regs->tpc, current, regs);
11907@@ -279,6 +282,466 @@ static void noinline __kprobes bogus_32bit_fault_tpc(struct pt_regs *regs)
11908 show_regs(regs);
11909 }
11910
11911+#ifdef CONFIG_PAX_PAGEEXEC
11912+#ifdef CONFIG_PAX_DLRESOLVE
11913+static void pax_emuplt_close(struct vm_area_struct *vma)
11914+{
11915+ vma->vm_mm->call_dl_resolve = 0UL;
11916+}
11917+
11918+static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
11919+{
11920+ unsigned int *kaddr;
11921+
11922+ vmf->page = alloc_page(GFP_HIGHUSER);
11923+ if (!vmf->page)
11924+ return VM_FAULT_OOM;
11925+
11926+ kaddr = kmap(vmf->page);
11927+ memset(kaddr, 0, PAGE_SIZE);
11928+ kaddr[0] = 0x9DE3BFA8U; /* save */
11929+ flush_dcache_page(vmf->page);
11930+ kunmap(vmf->page);
11931+ return VM_FAULT_MAJOR;
11932+}
11933+
11934+static const struct vm_operations_struct pax_vm_ops = {
11935+ .close = pax_emuplt_close,
11936+ .fault = pax_emuplt_fault
11937+};
11938+
11939+static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
11940+{
11941+ int ret;
11942+
11943+ INIT_LIST_HEAD(&vma->anon_vma_chain);
11944+ vma->vm_mm = current->mm;
11945+ vma->vm_start = addr;
11946+ vma->vm_end = addr + PAGE_SIZE;
11947+ vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
11948+ vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
11949+ vma->vm_ops = &pax_vm_ops;
11950+
11951+ ret = insert_vm_struct(current->mm, vma);
11952+ if (ret)
11953+ return ret;
11954+
11955+ ++current->mm->total_vm;
11956+ return 0;
11957+}
11958+#endif
11959+
11960+/*
11961+ * PaX: decide what to do with offenders (regs->tpc = fault address)
11962+ *
11963+ * returns 1 when task should be killed
11964+ * 2 when patched PLT trampoline was detected
11965+ * 3 when unpatched PLT trampoline was detected
11966+ */
11967+static int pax_handle_fetch_fault(struct pt_regs *regs)
11968+{
11969+
11970+#ifdef CONFIG_PAX_EMUPLT
11971+ int err;
11972+
11973+ do { /* PaX: patched PLT emulation #1 */
11974+ unsigned int sethi1, sethi2, jmpl;
11975+
11976+ err = get_user(sethi1, (unsigned int *)regs->tpc);
11977+ err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
11978+ err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
11979+
11980+ if (err)
11981+ break;
11982+
11983+ if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
11984+ (sethi2 & 0xFFC00000U) == 0x03000000U &&
11985+ (jmpl & 0xFFFFE000U) == 0x81C06000U)
11986+ {
11987+ unsigned long addr;
11988+
11989+ regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
11990+ addr = regs->u_regs[UREG_G1];
11991+ addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11992+
11993+ if (test_thread_flag(TIF_32BIT))
11994+ addr &= 0xFFFFFFFFUL;
11995+
11996+ regs->tpc = addr;
11997+ regs->tnpc = addr+4;
11998+ return 2;
11999+ }
12000+ } while (0);
12001+
12002+ do { /* PaX: patched PLT emulation #2 */
12003+ unsigned int ba;
12004+
12005+ err = get_user(ba, (unsigned int *)regs->tpc);
12006+
12007+ if (err)
12008+ break;
12009+
12010+ if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
12011+ unsigned long addr;
12012+
12013+ if ((ba & 0xFFC00000U) == 0x30800000U)
12014+ addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
12015+ else
12016+ addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
12017+
12018+ if (test_thread_flag(TIF_32BIT))
12019+ addr &= 0xFFFFFFFFUL;
12020+
12021+ regs->tpc = addr;
12022+ regs->tnpc = addr+4;
12023+ return 2;
12024+ }
12025+ } while (0);
12026+
12027+ do { /* PaX: patched PLT emulation #3 */
12028+ unsigned int sethi, bajmpl, nop;
12029+
12030+ err = get_user(sethi, (unsigned int *)regs->tpc);
12031+ err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
12032+ err |= get_user(nop, (unsigned int *)(regs->tpc+8));
12033+
12034+ if (err)
12035+ break;
12036+
12037+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12038+ ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
12039+ nop == 0x01000000U)
12040+ {
12041+ unsigned long addr;
12042+
12043+ addr = (sethi & 0x003FFFFFU) << 10;
12044+ regs->u_regs[UREG_G1] = addr;
12045+ if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
12046+ addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
12047+ else
12048+ addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
12049+
12050+ if (test_thread_flag(TIF_32BIT))
12051+ addr &= 0xFFFFFFFFUL;
12052+
12053+ regs->tpc = addr;
12054+ regs->tnpc = addr+4;
12055+ return 2;
12056+ }
12057+ } while (0);
12058+
12059+ do { /* PaX: patched PLT emulation #4 */
12060+ unsigned int sethi, mov1, call, mov2;
12061+
12062+ err = get_user(sethi, (unsigned int *)regs->tpc);
12063+ err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
12064+ err |= get_user(call, (unsigned int *)(regs->tpc+8));
12065+ err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
12066+
12067+ if (err)
12068+ break;
12069+
12070+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12071+ mov1 == 0x8210000FU &&
12072+ (call & 0xC0000000U) == 0x40000000U &&
12073+ mov2 == 0x9E100001U)
12074+ {
12075+ unsigned long addr;
12076+
12077+ regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
12078+ addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
12079+
12080+ if (test_thread_flag(TIF_32BIT))
12081+ addr &= 0xFFFFFFFFUL;
12082+
12083+ regs->tpc = addr;
12084+ regs->tnpc = addr+4;
12085+ return 2;
12086+ }
12087+ } while (0);
12088+
12089+ do { /* PaX: patched PLT emulation #5 */
12090+ unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
12091+
12092+ err = get_user(sethi, (unsigned int *)regs->tpc);
12093+ err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
12094+ err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
12095+ err |= get_user(or1, (unsigned int *)(regs->tpc+12));
12096+ err |= get_user(or2, (unsigned int *)(regs->tpc+16));
12097+ err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
12098+ err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
12099+ err |= get_user(nop, (unsigned int *)(regs->tpc+28));
12100+
12101+ if (err)
12102+ break;
12103+
12104+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12105+ (sethi1 & 0xFFC00000U) == 0x03000000U &&
12106+ (sethi2 & 0xFFC00000U) == 0x0B000000U &&
12107+ (or1 & 0xFFFFE000U) == 0x82106000U &&
12108+ (or2 & 0xFFFFE000U) == 0x8A116000U &&
12109+ sllx == 0x83287020U &&
12110+ jmpl == 0x81C04005U &&
12111+ nop == 0x01000000U)
12112+ {
12113+ unsigned long addr;
12114+
12115+ regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
12116+ regs->u_regs[UREG_G1] <<= 32;
12117+ regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
12118+ addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
12119+ regs->tpc = addr;
12120+ regs->tnpc = addr+4;
12121+ return 2;
12122+ }
12123+ } while (0);
12124+
12125+ do { /* PaX: patched PLT emulation #6 */
12126+ unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
12127+
12128+ err = get_user(sethi, (unsigned int *)regs->tpc);
12129+ err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
12130+ err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
12131+ err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
12132+ err |= get_user(or, (unsigned int *)(regs->tpc+16));
12133+ err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
12134+ err |= get_user(nop, (unsigned int *)(regs->tpc+24));
12135+
12136+ if (err)
12137+ break;
12138+
12139+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12140+ (sethi1 & 0xFFC00000U) == 0x03000000U &&
12141+ (sethi2 & 0xFFC00000U) == 0x0B000000U &&
12142+ sllx == 0x83287020U &&
12143+ (or & 0xFFFFE000U) == 0x8A116000U &&
12144+ jmpl == 0x81C04005U &&
12145+ nop == 0x01000000U)
12146+ {
12147+ unsigned long addr;
12148+
12149+ regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
12150+ regs->u_regs[UREG_G1] <<= 32;
12151+ regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
12152+ addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
12153+ regs->tpc = addr;
12154+ regs->tnpc = addr+4;
12155+ return 2;
12156+ }
12157+ } while (0);
12158+
12159+ do { /* PaX: unpatched PLT emulation step 1 */
12160+ unsigned int sethi, ba, nop;
12161+
12162+ err = get_user(sethi, (unsigned int *)regs->tpc);
12163+ err |= get_user(ba, (unsigned int *)(regs->tpc+4));
12164+ err |= get_user(nop, (unsigned int *)(regs->tpc+8));
12165+
12166+ if (err)
12167+ break;
12168+
12169+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12170+ ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
12171+ nop == 0x01000000U)
12172+ {
12173+ unsigned long addr;
12174+ unsigned int save, call;
12175+ unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
12176+
12177+ if ((ba & 0xFFC00000U) == 0x30800000U)
12178+ addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
12179+ else
12180+ addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
12181+
12182+ if (test_thread_flag(TIF_32BIT))
12183+ addr &= 0xFFFFFFFFUL;
12184+
12185+ err = get_user(save, (unsigned int *)addr);
12186+ err |= get_user(call, (unsigned int *)(addr+4));
12187+ err |= get_user(nop, (unsigned int *)(addr+8));
12188+ if (err)
12189+ break;
12190+
12191+#ifdef CONFIG_PAX_DLRESOLVE
12192+ if (save == 0x9DE3BFA8U &&
12193+ (call & 0xC0000000U) == 0x40000000U &&
12194+ nop == 0x01000000U)
12195+ {
12196+ struct vm_area_struct *vma;
12197+ unsigned long call_dl_resolve;
12198+
12199+ down_read(&current->mm->mmap_sem);
12200+ call_dl_resolve = current->mm->call_dl_resolve;
12201+ up_read(&current->mm->mmap_sem);
12202+ if (likely(call_dl_resolve))
12203+ goto emulate;
12204+
12205+ vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
12206+
12207+ down_write(&current->mm->mmap_sem);
12208+ if (current->mm->call_dl_resolve) {
12209+ call_dl_resolve = current->mm->call_dl_resolve;
12210+ up_write(&current->mm->mmap_sem);
12211+ if (vma)
12212+ kmem_cache_free(vm_area_cachep, vma);
12213+ goto emulate;
12214+ }
12215+
12216+ call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
12217+ if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
12218+ up_write(&current->mm->mmap_sem);
12219+ if (vma)
12220+ kmem_cache_free(vm_area_cachep, vma);
12221+ return 1;
12222+ }
12223+
12224+ if (pax_insert_vma(vma, call_dl_resolve)) {
12225+ up_write(&current->mm->mmap_sem);
12226+ kmem_cache_free(vm_area_cachep, vma);
12227+ return 1;
12228+ }
12229+
12230+ current->mm->call_dl_resolve = call_dl_resolve;
12231+ up_write(&current->mm->mmap_sem);
12232+
12233+emulate:
12234+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
12235+ regs->tpc = call_dl_resolve;
12236+ regs->tnpc = addr+4;
12237+ return 3;
12238+ }
12239+#endif
12240+
12241+ /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
12242+ if ((save & 0xFFC00000U) == 0x05000000U &&
12243+ (call & 0xFFFFE000U) == 0x85C0A000U &&
12244+ nop == 0x01000000U)
12245+ {
12246+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
12247+ regs->u_regs[UREG_G2] = addr + 4;
12248+ addr = (save & 0x003FFFFFU) << 10;
12249+ addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
12250+
12251+ if (test_thread_flag(TIF_32BIT))
12252+ addr &= 0xFFFFFFFFUL;
12253+
12254+ regs->tpc = addr;
12255+ regs->tnpc = addr+4;
12256+ return 3;
12257+ }
12258+
12259+ /* PaX: 64-bit PLT stub */
12260+ err = get_user(sethi1, (unsigned int *)addr);
12261+ err |= get_user(sethi2, (unsigned int *)(addr+4));
12262+ err |= get_user(or1, (unsigned int *)(addr+8));
12263+ err |= get_user(or2, (unsigned int *)(addr+12));
12264+ err |= get_user(sllx, (unsigned int *)(addr+16));
12265+ err |= get_user(add, (unsigned int *)(addr+20));
12266+ err |= get_user(jmpl, (unsigned int *)(addr+24));
12267+ err |= get_user(nop, (unsigned int *)(addr+28));
12268+ if (err)
12269+ break;
12270+
12271+ if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
12272+ (sethi2 & 0xFFC00000U) == 0x0B000000U &&
12273+ (or1 & 0xFFFFE000U) == 0x88112000U &&
12274+ (or2 & 0xFFFFE000U) == 0x8A116000U &&
12275+ sllx == 0x89293020U &&
12276+ add == 0x8A010005U &&
12277+ jmpl == 0x89C14000U &&
12278+ nop == 0x01000000U)
12279+ {
12280+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
12281+ regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
12282+ regs->u_regs[UREG_G4] <<= 32;
12283+ regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
12284+ regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
12285+ regs->u_regs[UREG_G4] = addr + 24;
12286+ addr = regs->u_regs[UREG_G5];
12287+ regs->tpc = addr;
12288+ regs->tnpc = addr+4;
12289+ return 3;
12290+ }
12291+ }
12292+ } while (0);
12293+
12294+#ifdef CONFIG_PAX_DLRESOLVE
12295+ do { /* PaX: unpatched PLT emulation step 2 */
12296+ unsigned int save, call, nop;
12297+
12298+ err = get_user(save, (unsigned int *)(regs->tpc-4));
12299+ err |= get_user(call, (unsigned int *)regs->tpc);
12300+ err |= get_user(nop, (unsigned int *)(regs->tpc+4));
12301+ if (err)
12302+ break;
12303+
12304+ if (save == 0x9DE3BFA8U &&
12305+ (call & 0xC0000000U) == 0x40000000U &&
12306+ nop == 0x01000000U)
12307+ {
12308+ unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
12309+
12310+ if (test_thread_flag(TIF_32BIT))
12311+ dl_resolve &= 0xFFFFFFFFUL;
12312+
12313+ regs->u_regs[UREG_RETPC] = regs->tpc;
12314+ regs->tpc = dl_resolve;
12315+ regs->tnpc = dl_resolve+4;
12316+ return 3;
12317+ }
12318+ } while (0);
12319+#endif
12320+
12321+ do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
12322+ unsigned int sethi, ba, nop;
12323+
12324+ err = get_user(sethi, (unsigned int *)regs->tpc);
12325+ err |= get_user(ba, (unsigned int *)(regs->tpc+4));
12326+ err |= get_user(nop, (unsigned int *)(regs->tpc+8));
12327+
12328+ if (err)
12329+ break;
12330+
12331+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12332+ (ba & 0xFFF00000U) == 0x30600000U &&
12333+ nop == 0x01000000U)
12334+ {
12335+ unsigned long addr;
12336+
12337+ addr = (sethi & 0x003FFFFFU) << 10;
12338+ regs->u_regs[UREG_G1] = addr;
12339+ addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
12340+
12341+ if (test_thread_flag(TIF_32BIT))
12342+ addr &= 0xFFFFFFFFUL;
12343+
12344+ regs->tpc = addr;
12345+ regs->tnpc = addr+4;
12346+ return 2;
12347+ }
12348+ } while (0);
12349+
12350+#endif
12351+
12352+ return 1;
12353+}
12354+
12355+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
12356+{
12357+ unsigned long i;
12358+
12359+ printk(KERN_ERR "PAX: bytes at PC: ");
12360+ for (i = 0; i < 8; i++) {
12361+ unsigned int c;
12362+ if (get_user(c, (unsigned int *)pc+i))
12363+ printk(KERN_CONT "???????? ");
12364+ else
12365+ printk(KERN_CONT "%08x ", c);
12366+ }
12367+ printk("\n");
12368+}
12369+#endif
12370+
12371 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
12372 {
12373 enum ctx_state prev_state = exception_enter();
12374@@ -353,6 +816,29 @@ retry:
12375 if (!vma)
12376 goto bad_area;
12377
12378+#ifdef CONFIG_PAX_PAGEEXEC
12379+ /* PaX: detect ITLB misses on non-exec pages */
12380+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
12381+ !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
12382+ {
12383+ if (address != regs->tpc)
12384+ goto good_area;
12385+
12386+ up_read(&mm->mmap_sem);
12387+ switch (pax_handle_fetch_fault(regs)) {
12388+
12389+#ifdef CONFIG_PAX_EMUPLT
12390+ case 2:
12391+ case 3:
12392+ return;
12393+#endif
12394+
12395+ }
12396+ pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
12397+ do_group_exit(SIGKILL);
12398+ }
12399+#endif
12400+
12401 /* Pure DTLB misses do not tell us whether the fault causing
12402 * load/store/atomic was a write or not, it only says that there
12403 * was no match. So in such a case we (carefully) read the
12404diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
12405index 131eaf4..285ea31 100644
12406--- a/arch/sparc/mm/hugetlbpage.c
12407+++ b/arch/sparc/mm/hugetlbpage.c
12408@@ -25,8 +25,10 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
12409 unsigned long addr,
12410 unsigned long len,
12411 unsigned long pgoff,
12412- unsigned long flags)
12413+ unsigned long flags,
12414+ unsigned long offset)
12415 {
12416+ struct mm_struct *mm = current->mm;
12417 unsigned long task_size = TASK_SIZE;
12418 struct vm_unmapped_area_info info;
12419
12420@@ -35,15 +37,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
12421
12422 info.flags = 0;
12423 info.length = len;
12424- info.low_limit = TASK_UNMAPPED_BASE;
12425+ info.low_limit = mm->mmap_base;
12426 info.high_limit = min(task_size, VA_EXCLUDE_START);
12427 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
12428 info.align_offset = 0;
12429+ info.threadstack_offset = offset;
12430 addr = vm_unmapped_area(&info);
12431
12432 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
12433 VM_BUG_ON(addr != -ENOMEM);
12434 info.low_limit = VA_EXCLUDE_END;
12435+
12436+#ifdef CONFIG_PAX_RANDMMAP
12437+ if (mm->pax_flags & MF_PAX_RANDMMAP)
12438+ info.low_limit += mm->delta_mmap;
12439+#endif
12440+
12441 info.high_limit = task_size;
12442 addr = vm_unmapped_area(&info);
12443 }
12444@@ -55,7 +64,8 @@ static unsigned long
12445 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
12446 const unsigned long len,
12447 const unsigned long pgoff,
12448- const unsigned long flags)
12449+ const unsigned long flags,
12450+ const unsigned long offset)
12451 {
12452 struct mm_struct *mm = current->mm;
12453 unsigned long addr = addr0;
12454@@ -70,6 +80,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
12455 info.high_limit = mm->mmap_base;
12456 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
12457 info.align_offset = 0;
12458+ info.threadstack_offset = offset;
12459 addr = vm_unmapped_area(&info);
12460
12461 /*
12462@@ -82,6 +93,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
12463 VM_BUG_ON(addr != -ENOMEM);
12464 info.flags = 0;
12465 info.low_limit = TASK_UNMAPPED_BASE;
12466+
12467+#ifdef CONFIG_PAX_RANDMMAP
12468+ if (mm->pax_flags & MF_PAX_RANDMMAP)
12469+ info.low_limit += mm->delta_mmap;
12470+#endif
12471+
12472 info.high_limit = STACK_TOP32;
12473 addr = vm_unmapped_area(&info);
12474 }
12475@@ -96,6 +113,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
12476 struct mm_struct *mm = current->mm;
12477 struct vm_area_struct *vma;
12478 unsigned long task_size = TASK_SIZE;
12479+ unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
12480
12481 if (test_thread_flag(TIF_32BIT))
12482 task_size = STACK_TOP32;
12483@@ -111,19 +129,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
12484 return addr;
12485 }
12486
12487+#ifdef CONFIG_PAX_RANDMMAP
12488+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
12489+#endif
12490+
12491 if (addr) {
12492 addr = ALIGN(addr, HPAGE_SIZE);
12493 vma = find_vma(mm, addr);
12494- if (task_size - len >= addr &&
12495- (!vma || addr + len <= vma->vm_start))
12496+ if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
12497 return addr;
12498 }
12499 if (mm->get_unmapped_area == arch_get_unmapped_area)
12500 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
12501- pgoff, flags);
12502+ pgoff, flags, offset);
12503 else
12504 return hugetlb_get_unmapped_area_topdown(file, addr, len,
12505- pgoff, flags);
12506+ pgoff, flags, offset);
12507 }
12508
12509 pte_t *huge_pte_alloc(struct mm_struct *mm,
12510diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
12511index 4ac88b7..bac6cb2 100644
12512--- a/arch/sparc/mm/init_64.c
12513+++ b/arch/sparc/mm/init_64.c
12514@@ -187,9 +187,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
12515 int num_kernel_image_mappings;
12516
12517 #ifdef CONFIG_DEBUG_DCFLUSH
12518-atomic_t dcpage_flushes = ATOMIC_INIT(0);
12519+atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
12520 #ifdef CONFIG_SMP
12521-atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
12522+atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
12523 #endif
12524 #endif
12525
12526@@ -197,7 +197,7 @@ inline void flush_dcache_page_impl(struct page *page)
12527 {
12528 BUG_ON(tlb_type == hypervisor);
12529 #ifdef CONFIG_DEBUG_DCFLUSH
12530- atomic_inc(&dcpage_flushes);
12531+ atomic_inc_unchecked(&dcpage_flushes);
12532 #endif
12533
12534 #ifdef DCACHE_ALIASING_POSSIBLE
12535@@ -469,10 +469,10 @@ void mmu_info(struct seq_file *m)
12536
12537 #ifdef CONFIG_DEBUG_DCFLUSH
12538 seq_printf(m, "DCPageFlushes\t: %d\n",
12539- atomic_read(&dcpage_flushes));
12540+ atomic_read_unchecked(&dcpage_flushes));
12541 #ifdef CONFIG_SMP
12542 seq_printf(m, "DCPageFlushesXC\t: %d\n",
12543- atomic_read(&dcpage_flushes_xcall));
12544+ atomic_read_unchecked(&dcpage_flushes_xcall));
12545 #endif /* CONFIG_SMP */
12546 #endif /* CONFIG_DEBUG_DCFLUSH */
12547 }
12548diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
12549index 9def1f5..cf0cabc 100644
12550--- a/arch/tile/Kconfig
12551+++ b/arch/tile/Kconfig
12552@@ -204,6 +204,7 @@ source "kernel/Kconfig.hz"
12553
12554 config KEXEC
12555 bool "kexec system call"
12556+ depends on !GRKERNSEC_KMEM
12557 ---help---
12558 kexec is a system call that implements the ability to shutdown your
12559 current kernel, and to start another kernel. It is like a reboot
12560diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
12561index 0496970..1a57e5f 100644
12562--- a/arch/tile/include/asm/atomic_64.h
12563+++ b/arch/tile/include/asm/atomic_64.h
12564@@ -105,6 +105,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
12565
12566 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12567
12568+#define atomic64_read_unchecked(v) atomic64_read(v)
12569+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
12570+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
12571+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
12572+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
12573+#define atomic64_inc_unchecked(v) atomic64_inc(v)
12574+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
12575+#define atomic64_dec_unchecked(v) atomic64_dec(v)
12576+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
12577+
12578 #endif /* !__ASSEMBLY__ */
12579
12580 #endif /* _ASM_TILE_ATOMIC_64_H */
12581diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
12582index 6160761..00cac88 100644
12583--- a/arch/tile/include/asm/cache.h
12584+++ b/arch/tile/include/asm/cache.h
12585@@ -15,11 +15,12 @@
12586 #ifndef _ASM_TILE_CACHE_H
12587 #define _ASM_TILE_CACHE_H
12588
12589+#include <linux/const.h>
12590 #include <arch/chip.h>
12591
12592 /* bytes per L1 data cache line */
12593 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
12594-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12595+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12596
12597 /* bytes per L2 cache line */
12598 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
12599diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
12600index 0a9c4265..bfb62d1 100644
12601--- a/arch/tile/include/asm/uaccess.h
12602+++ b/arch/tile/include/asm/uaccess.h
12603@@ -429,9 +429,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
12604 const void __user *from,
12605 unsigned long n)
12606 {
12607- int sz = __compiletime_object_size(to);
12608+ size_t sz = __compiletime_object_size(to);
12609
12610- if (likely(sz == -1 || sz >= n))
12611+ if (likely(sz == (size_t)-1 || sz >= n))
12612 n = _copy_from_user(to, from, n);
12613 else
12614 copy_from_user_overflow();
12615diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
12616index c034dc3..cf1cc96 100644
12617--- a/arch/tile/mm/hugetlbpage.c
12618+++ b/arch/tile/mm/hugetlbpage.c
12619@@ -174,6 +174,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
12620 info.high_limit = TASK_SIZE;
12621 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
12622 info.align_offset = 0;
12623+ info.threadstack_offset = 0;
12624 return vm_unmapped_area(&info);
12625 }
12626
12627@@ -191,6 +192,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
12628 info.high_limit = current->mm->mmap_base;
12629 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
12630 info.align_offset = 0;
12631+ info.threadstack_offset = 0;
12632 addr = vm_unmapped_area(&info);
12633
12634 /*
12635diff --git a/arch/um/Makefile b/arch/um/Makefile
12636index 098ab33..fc54a33 100644
12637--- a/arch/um/Makefile
12638+++ b/arch/um/Makefile
12639@@ -73,6 +73,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \
12640 -D_FILE_OFFSET_BITS=64 -idirafter include \
12641 -D__KERNEL__ -D__UM_HOST__
12642
12643+ifdef CONSTIFY_PLUGIN
12644+USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
12645+endif
12646+
12647 #This will adjust *FLAGS accordingly to the platform.
12648 include $(ARCH_DIR)/Makefile-os-$(OS)
12649
12650diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
12651index 19e1bdd..3665b77 100644
12652--- a/arch/um/include/asm/cache.h
12653+++ b/arch/um/include/asm/cache.h
12654@@ -1,6 +1,7 @@
12655 #ifndef __UM_CACHE_H
12656 #define __UM_CACHE_H
12657
12658+#include <linux/const.h>
12659
12660 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
12661 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12662@@ -12,6 +13,6 @@
12663 # define L1_CACHE_SHIFT 5
12664 #endif
12665
12666-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12667+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12668
12669 #endif
12670diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
12671index 2e0a6b1..a64d0f5 100644
12672--- a/arch/um/include/asm/kmap_types.h
12673+++ b/arch/um/include/asm/kmap_types.h
12674@@ -8,6 +8,6 @@
12675
12676 /* No more #include "asm/arch/kmap_types.h" ! */
12677
12678-#define KM_TYPE_NR 14
12679+#define KM_TYPE_NR 15
12680
12681 #endif
12682diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
12683index 71c5d13..4c7b9f1 100644
12684--- a/arch/um/include/asm/page.h
12685+++ b/arch/um/include/asm/page.h
12686@@ -14,6 +14,9 @@
12687 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
12688 #define PAGE_MASK (~(PAGE_SIZE-1))
12689
12690+#define ktla_ktva(addr) (addr)
12691+#define ktva_ktla(addr) (addr)
12692+
12693 #ifndef __ASSEMBLY__
12694
12695 struct page;
12696diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
12697index 2b4274e..754fe06 100644
12698--- a/arch/um/include/asm/pgtable-3level.h
12699+++ b/arch/um/include/asm/pgtable-3level.h
12700@@ -58,6 +58,7 @@
12701 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
12702 #define pud_populate(mm, pud, pmd) \
12703 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
12704+#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
12705
12706 #ifdef CONFIG_64BIT
12707 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
12708diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
12709index 68b9119..f72353c 100644
12710--- a/arch/um/kernel/process.c
12711+++ b/arch/um/kernel/process.c
12712@@ -345,22 +345,6 @@ int singlestepping(void * t)
12713 return 2;
12714 }
12715
12716-/*
12717- * Only x86 and x86_64 have an arch_align_stack().
12718- * All other arches have "#define arch_align_stack(x) (x)"
12719- * in their asm/exec.h
12720- * As this is included in UML from asm-um/system-generic.h,
12721- * we can use it to behave as the subarch does.
12722- */
12723-#ifndef arch_align_stack
12724-unsigned long arch_align_stack(unsigned long sp)
12725-{
12726- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
12727- sp -= get_random_int() % 8192;
12728- return sp & ~0xf;
12729-}
12730-#endif
12731-
12732 unsigned long get_wchan(struct task_struct *p)
12733 {
12734 unsigned long stack_page, sp, ip;
12735diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
12736index ad8f795..2c7eec6 100644
12737--- a/arch/unicore32/include/asm/cache.h
12738+++ b/arch/unicore32/include/asm/cache.h
12739@@ -12,8 +12,10 @@
12740 #ifndef __UNICORE_CACHE_H__
12741 #define __UNICORE_CACHE_H__
12742
12743-#define L1_CACHE_SHIFT (5)
12744-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12745+#include <linux/const.h>
12746+
12747+#define L1_CACHE_SHIFT 5
12748+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12749
12750 /*
12751 * Memory returned by kmalloc() may be used for DMA, so we must make
12752diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
12753index b3a1a5d..8dbc2d6 100644
12754--- a/arch/x86/Kconfig
12755+++ b/arch/x86/Kconfig
12756@@ -35,13 +35,12 @@ config X86
12757 select ARCH_MIGHT_HAVE_PC_SERIO
12758 select ARCH_SUPPORTS_ATOMIC_RMW
12759 select ARCH_SUPPORTS_DEFERRED_STRUCT_PAGE_INIT
12760- select ARCH_SUPPORTS_INT128 if X86_64
12761+ select ARCH_SUPPORTS_INT128 if X86_64 && !PAX_SIZE_OVERFLOW
12762 select ARCH_SUPPORTS_NUMA_BALANCING if X86_64
12763 select ARCH_USE_BUILTIN_BSWAP
12764 select ARCH_USE_CMPXCHG_LOCKREF if X86_64
12765 select ARCH_USE_QUEUED_RWLOCKS
12766 select ARCH_USE_QUEUED_SPINLOCKS
12767- select ARCH_WANTS_DYNAMIC_TASK_STRUCT
12768 select ARCH_WANT_FRAME_POINTERS
12769 select ARCH_WANT_IPC_PARSE_VERSION if X86_32
12770 select ARCH_WANT_OPTIONAL_GPIOLIB
12771@@ -85,7 +84,7 @@ config X86
12772 select HAVE_ARCH_TRACEHOOK
12773 select HAVE_ARCH_TRANSPARENT_HUGEPAGE
12774 select HAVE_BPF_JIT if X86_64
12775- select HAVE_CC_STACKPROTECTOR
12776+ select HAVE_CC_STACKPROTECTOR if X86_64 || !PAX_MEMORY_UDEREF
12777 select HAVE_CMPXCHG_DOUBLE
12778 select HAVE_CMPXCHG_LOCAL
12779 select HAVE_CONTEXT_TRACKING if X86_64
12780@@ -274,7 +273,7 @@ config X86_64_SMP
12781
12782 config X86_32_LAZY_GS
12783 def_bool y
12784- depends on X86_32 && !CC_STACKPROTECTOR
12785+ depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
12786
12787 config ARCH_HWEIGHT_CFLAGS
12788 string
12789@@ -646,6 +645,7 @@ config SCHED_OMIT_FRAME_POINTER
12790
12791 menuconfig HYPERVISOR_GUEST
12792 bool "Linux guest support"
12793+ depends on !GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_VIRT_GUEST || (GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_XEN)
12794 ---help---
12795 Say Y here to enable options for running Linux under various hyper-
12796 visors. This option enables basic hypervisor detection and platform
12797@@ -1014,6 +1014,7 @@ config VM86
12798
12799 config X86_16BIT
12800 bool "Enable support for 16-bit segments" if EXPERT
12801+ depends on !GRKERNSEC
12802 default y
12803 ---help---
12804 This option is required by programs like Wine to run 16-bit
12805@@ -1182,6 +1183,7 @@ choice
12806
12807 config NOHIGHMEM
12808 bool "off"
12809+ depends on !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
12810 ---help---
12811 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
12812 However, the address space of 32-bit x86 processors is only 4
12813@@ -1218,6 +1220,7 @@ config NOHIGHMEM
12814
12815 config HIGHMEM4G
12816 bool "4GB"
12817+ depends on !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
12818 ---help---
12819 Select this if you have a 32-bit processor and between 1 and 4
12820 gigabytes of physical RAM.
12821@@ -1270,7 +1273,7 @@ config PAGE_OFFSET
12822 hex
12823 default 0xB0000000 if VMSPLIT_3G_OPT
12824 default 0x80000000 if VMSPLIT_2G
12825- default 0x78000000 if VMSPLIT_2G_OPT
12826+ default 0x70000000 if VMSPLIT_2G_OPT
12827 default 0x40000000 if VMSPLIT_1G
12828 default 0xC0000000
12829 depends on X86_32
12830@@ -1290,7 +1293,6 @@ config X86_PAE
12831
12832 config ARCH_PHYS_ADDR_T_64BIT
12833 def_bool y
12834- depends on X86_64 || X86_PAE
12835
12836 config ARCH_DMA_ADDR_T_64BIT
12837 def_bool y
12838@@ -1724,6 +1726,7 @@ source kernel/Kconfig.hz
12839
12840 config KEXEC
12841 bool "kexec system call"
12842+ depends on !GRKERNSEC_KMEM
12843 ---help---
12844 kexec is a system call that implements the ability to shutdown your
12845 current kernel, and to start another kernel. It is like a reboot
12846@@ -1906,7 +1909,9 @@ config X86_NEED_RELOCS
12847
12848 config PHYSICAL_ALIGN
12849 hex "Alignment value to which kernel should be aligned"
12850- default "0x200000"
12851+ default "0x1000000"
12852+ range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
12853+ range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
12854 range 0x2000 0x1000000 if X86_32
12855 range 0x200000 0x1000000 if X86_64
12856 ---help---
12857@@ -1989,6 +1994,7 @@ config COMPAT_VDSO
12858 def_bool n
12859 prompt "Disable the 32-bit vDSO (needed for glibc 2.3.3)"
12860 depends on X86_32 || IA32_EMULATION
12861+ depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
12862 ---help---
12863 Certain buggy versions of glibc will crash if they are
12864 presented with a 32-bit vDSO that is not mapped at the address
12865@@ -2053,6 +2059,22 @@ config CMDLINE_OVERRIDE
12866 This is used to work around broken boot loaders. This should
12867 be set to 'N' under normal conditions.
12868
12869+config DEFAULT_MODIFY_LDT_SYSCALL
12870+ bool "Allow userspace to modify the LDT by default"
12871+ default y
12872+
12873+ ---help---
12874+ Modifying the LDT (Local Descriptor Table) may be needed to run a
12875+ 16-bit or segmented code such as Dosemu or Wine. This is done via
12876+ a system call which is not needed to run portable applications,
12877+ and which can sometimes be abused to exploit some weaknesses of
12878+ the architecture, opening new vulnerabilities.
12879+
12880+ For this reason this option allows one to enable or disable the
12881+ feature at runtime. It is recommended to say 'N' here to leave
12882+ the system protected, and to enable it at runtime only if needed
12883+ by setting the sys.kernel.modify_ldt sysctl.
12884+
12885 source "kernel/livepatch/Kconfig"
12886
12887 endmenu
12888diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
12889index 6983314..54ad7e8 100644
12890--- a/arch/x86/Kconfig.cpu
12891+++ b/arch/x86/Kconfig.cpu
12892@@ -319,7 +319,7 @@ config X86_PPRO_FENCE
12893
12894 config X86_F00F_BUG
12895 def_bool y
12896- depends on M586MMX || M586TSC || M586 || M486
12897+ depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
12898
12899 config X86_INVD_BUG
12900 def_bool y
12901@@ -327,7 +327,7 @@ config X86_INVD_BUG
12902
12903 config X86_ALIGNMENT_16
12904 def_bool y
12905- depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
12906+ depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
12907
12908 config X86_INTEL_USERCOPY
12909 def_bool y
12910@@ -369,7 +369,7 @@ config X86_CMPXCHG64
12911 # generates cmov.
12912 config X86_CMOV
12913 def_bool y
12914- depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
12915+ depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
12916
12917 config X86_MINIMUM_CPU_FAMILY
12918 int
12919diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
12920index d8c0d32..28e3117 100644
12921--- a/arch/x86/Kconfig.debug
12922+++ b/arch/x86/Kconfig.debug
12923@@ -69,6 +69,7 @@ config X86_PTDUMP
12924 bool "Export kernel pagetable layout to userspace via debugfs"
12925 depends on DEBUG_KERNEL
12926 select DEBUG_FS
12927+ depends on !GRKERNSEC_KMEM
12928 ---help---
12929 Say Y here if you want to show the kernel pagetable layout in a
12930 debugfs file. This information is only useful for kernel developers
12931@@ -89,7 +90,7 @@ config EFI_PGT_DUMP
12932 config DEBUG_RODATA
12933 bool "Write protect kernel read-only data structures"
12934 default y
12935- depends on DEBUG_KERNEL
12936+ depends on DEBUG_KERNEL && BROKEN
12937 ---help---
12938 Mark the kernel read-only data as write-protected in the pagetables,
12939 in order to catch accidental (and incorrect) writes to such const
12940@@ -107,7 +108,7 @@ config DEBUG_RODATA_TEST
12941
12942 config DEBUG_SET_MODULE_RONX
12943 bool "Set loadable kernel module data as NX and text as RO"
12944- depends on MODULES
12945+ depends on MODULES && BROKEN
12946 ---help---
12947 This option helps catch unintended modifications to loadable
12948 kernel module's text and read-only data. It also prevents execution
12949@@ -359,6 +360,7 @@ config X86_DEBUG_FPU
12950 config PUNIT_ATOM_DEBUG
12951 tristate "ATOM Punit debug driver"
12952 select DEBUG_FS
12953+ depends on !GRKERNSEC_KMEM
12954 select IOSF_MBI
12955 ---help---
12956 This is a debug driver, which gets the power states
12957diff --git a/arch/x86/Makefile b/arch/x86/Makefile
12958index 118e6de..e02efff 100644
12959--- a/arch/x86/Makefile
12960+++ b/arch/x86/Makefile
12961@@ -65,9 +65,6 @@ ifeq ($(CONFIG_X86_32),y)
12962 # CPU-specific tuning. Anything which can be shared with UML should go here.
12963 include arch/x86/Makefile_32.cpu
12964 KBUILD_CFLAGS += $(cflags-y)
12965-
12966- # temporary until string.h is fixed
12967- KBUILD_CFLAGS += -ffreestanding
12968 else
12969 BITS := 64
12970 UTS_MACHINE := x86_64
12971@@ -116,6 +113,9 @@ else
12972 KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args)
12973 endif
12974
12975+# temporary until string.h is fixed
12976+KBUILD_CFLAGS += -ffreestanding
12977+
12978 # Make sure compiler does not have buggy stack-protector support.
12979 ifdef CONFIG_CC_STACKPROTECTOR
12980 cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
12981@@ -184,6 +184,7 @@ archheaders:
12982 $(Q)$(MAKE) $(build)=arch/x86/entry/syscalls all
12983
12984 archprepare:
12985+ $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
12986 ifeq ($(CONFIG_KEXEC_FILE),y)
12987 $(Q)$(MAKE) $(build)=arch/x86/purgatory arch/x86/purgatory/kexec-purgatory.c
12988 endif
12989@@ -267,3 +268,9 @@ define archhelp
12990 echo ' FDARGS="..." arguments for the booted kernel'
12991 echo ' FDINITRD=file initrd for the booted kernel'
12992 endef
12993+
12994+define OLD_LD
12995+
12996+*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
12997+*** Please upgrade your binutils to 2.18 or newer
12998+endef
12999diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
13000index 57bbf2f..b100fce 100644
13001--- a/arch/x86/boot/Makefile
13002+++ b/arch/x86/boot/Makefile
13003@@ -58,6 +58,9 @@ clean-files += cpustr.h
13004 # ---------------------------------------------------------------------------
13005
13006 KBUILD_CFLAGS := $(USERINCLUDE) $(REALMODE_CFLAGS) -D_SETUP
13007+ifdef CONSTIFY_PLUGIN
13008+KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
13009+endif
13010 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
13011 GCOV_PROFILE := n
13012
13013diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
13014index 878e4b9..20537ab 100644
13015--- a/arch/x86/boot/bitops.h
13016+++ b/arch/x86/boot/bitops.h
13017@@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
13018 u8 v;
13019 const u32 *p = (const u32 *)addr;
13020
13021- asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
13022+ asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
13023 return v;
13024 }
13025
13026@@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
13027
13028 static inline void set_bit(int nr, void *addr)
13029 {
13030- asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
13031+ asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
13032 }
13033
13034 #endif /* BOOT_BITOPS_H */
13035diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
13036index bd49ec6..94c7f58 100644
13037--- a/arch/x86/boot/boot.h
13038+++ b/arch/x86/boot/boot.h
13039@@ -84,7 +84,7 @@ static inline void io_delay(void)
13040 static inline u16 ds(void)
13041 {
13042 u16 seg;
13043- asm("movw %%ds,%0" : "=rm" (seg));
13044+ asm volatile("movw %%ds,%0" : "=rm" (seg));
13045 return seg;
13046 }
13047
13048diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
13049index 0a291cd..9686efc 100644
13050--- a/arch/x86/boot/compressed/Makefile
13051+++ b/arch/x86/boot/compressed/Makefile
13052@@ -30,6 +30,9 @@ KBUILD_CFLAGS += $(cflags-y)
13053 KBUILD_CFLAGS += -mno-mmx -mno-sse
13054 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
13055 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
13056+ifdef CONSTIFY_PLUGIN
13057+KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
13058+endif
13059
13060 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
13061 GCOV_PROFILE := n
13062diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
13063index a53440e..c3dbf1e 100644
13064--- a/arch/x86/boot/compressed/efi_stub_32.S
13065+++ b/arch/x86/boot/compressed/efi_stub_32.S
13066@@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
13067 * parameter 2, ..., param n. To make things easy, we save the return
13068 * address of efi_call_phys in a global variable.
13069 */
13070- popl %ecx
13071- movl %ecx, saved_return_addr(%edx)
13072- /* get the function pointer into ECX*/
13073- popl %ecx
13074- movl %ecx, efi_rt_function_ptr(%edx)
13075+ popl saved_return_addr(%edx)
13076+ popl efi_rt_function_ptr(%edx)
13077
13078 /*
13079 * 3. Call the physical function.
13080 */
13081- call *%ecx
13082+ call *efi_rt_function_ptr(%edx)
13083
13084 /*
13085 * 4. Balance the stack. And because EAX contain the return value,
13086@@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
13087 1: popl %edx
13088 subl $1b, %edx
13089
13090- movl efi_rt_function_ptr(%edx), %ecx
13091- pushl %ecx
13092+ pushl efi_rt_function_ptr(%edx)
13093
13094 /*
13095 * 10. Push the saved return address onto the stack and return.
13096 */
13097- movl saved_return_addr(%edx), %ecx
13098- pushl %ecx
13099- ret
13100+ jmpl *saved_return_addr(%edx)
13101 ENDPROC(efi_call_phys)
13102 .previous
13103
13104diff --git a/arch/x86/boot/compressed/efi_thunk_64.S b/arch/x86/boot/compressed/efi_thunk_64.S
13105index 630384a..278e788 100644
13106--- a/arch/x86/boot/compressed/efi_thunk_64.S
13107+++ b/arch/x86/boot/compressed/efi_thunk_64.S
13108@@ -189,8 +189,8 @@ efi_gdt64:
13109 .long 0 /* Filled out by user */
13110 .word 0
13111 .quad 0x0000000000000000 /* NULL descriptor */
13112- .quad 0x00af9a000000ffff /* __KERNEL_CS */
13113- .quad 0x00cf92000000ffff /* __KERNEL_DS */
13114+ .quad 0x00af9b000000ffff /* __KERNEL_CS */
13115+ .quad 0x00cf93000000ffff /* __KERNEL_DS */
13116 .quad 0x0080890000000000 /* TS descriptor */
13117 .quad 0x0000000000000000 /* TS continued */
13118 efi_gdt64_end:
13119diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
13120index 8ef964d..fcfb8aa 100644
13121--- a/arch/x86/boot/compressed/head_32.S
13122+++ b/arch/x86/boot/compressed/head_32.S
13123@@ -141,10 +141,10 @@ preferred_addr:
13124 addl %eax, %ebx
13125 notl %eax
13126 andl %eax, %ebx
13127- cmpl $LOAD_PHYSICAL_ADDR, %ebx
13128+ cmpl $____LOAD_PHYSICAL_ADDR, %ebx
13129 jge 1f
13130 #endif
13131- movl $LOAD_PHYSICAL_ADDR, %ebx
13132+ movl $____LOAD_PHYSICAL_ADDR, %ebx
13133 1:
13134
13135 /* Target address to relocate to for decompression */
13136diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
13137index b0c0d16..3b44ff8 100644
13138--- a/arch/x86/boot/compressed/head_64.S
13139+++ b/arch/x86/boot/compressed/head_64.S
13140@@ -95,10 +95,10 @@ ENTRY(startup_32)
13141 addl %eax, %ebx
13142 notl %eax
13143 andl %eax, %ebx
13144- cmpl $LOAD_PHYSICAL_ADDR, %ebx
13145+ cmpl $____LOAD_PHYSICAL_ADDR, %ebx
13146 jge 1f
13147 #endif
13148- movl $LOAD_PHYSICAL_ADDR, %ebx
13149+ movl $____LOAD_PHYSICAL_ADDR, %ebx
13150 1:
13151
13152 /* Target address to relocate to for decompression */
13153@@ -323,10 +323,10 @@ preferred_addr:
13154 addq %rax, %rbp
13155 notq %rax
13156 andq %rax, %rbp
13157- cmpq $LOAD_PHYSICAL_ADDR, %rbp
13158+ cmpq $____LOAD_PHYSICAL_ADDR, %rbp
13159 jge 1f
13160 #endif
13161- movq $LOAD_PHYSICAL_ADDR, %rbp
13162+ movq $____LOAD_PHYSICAL_ADDR, %rbp
13163 1:
13164
13165 /* Target address to relocate to for decompression */
13166@@ -435,8 +435,8 @@ gdt:
13167 .long gdt
13168 .word 0
13169 .quad 0x0000000000000000 /* NULL descriptor */
13170- .quad 0x00af9a000000ffff /* __KERNEL_CS */
13171- .quad 0x00cf92000000ffff /* __KERNEL_DS */
13172+ .quad 0x00af9b000000ffff /* __KERNEL_CS */
13173+ .quad 0x00cf93000000ffff /* __KERNEL_DS */
13174 .quad 0x0080890000000000 /* TS descriptor */
13175 .quad 0x0000000000000000 /* TS continued */
13176 gdt_end:
13177diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
13178index e28437e..6a17460 100644
13179--- a/arch/x86/boot/compressed/misc.c
13180+++ b/arch/x86/boot/compressed/misc.c
13181@@ -242,7 +242,7 @@ static void handle_relocations(void *output, unsigned long output_len)
13182 * Calculate the delta between where vmlinux was linked to load
13183 * and where it was actually loaded.
13184 */
13185- delta = min_addr - LOAD_PHYSICAL_ADDR;
13186+ delta = min_addr - ____LOAD_PHYSICAL_ADDR;
13187 if (!delta) {
13188 debug_putstr("No relocation needed... ");
13189 return;
13190@@ -324,7 +324,7 @@ static void parse_elf(void *output)
13191 Elf32_Ehdr ehdr;
13192 Elf32_Phdr *phdrs, *phdr;
13193 #endif
13194- void *dest;
13195+ void *dest, *prev;
13196 int i;
13197
13198 memcpy(&ehdr, output, sizeof(ehdr));
13199@@ -351,13 +351,16 @@ static void parse_elf(void *output)
13200 case PT_LOAD:
13201 #ifdef CONFIG_RELOCATABLE
13202 dest = output;
13203- dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
13204+ dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
13205 #else
13206 dest = (void *)(phdr->p_paddr);
13207 #endif
13208 memcpy(dest,
13209 output + phdr->p_offset,
13210 phdr->p_filesz);
13211+ if (i)
13212+ memset(prev, 0xff, dest - prev);
13213+ prev = dest + phdr->p_filesz;
13214 break;
13215 default: /* Ignore other PT_* */ break;
13216 }
13217@@ -419,7 +422,7 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap,
13218 error("Destination address too large");
13219 #endif
13220 #ifndef CONFIG_RELOCATABLE
13221- if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
13222+ if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
13223 error("Wrong destination address");
13224 #endif
13225
13226diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
13227index 1fd7d57..0f7d096 100644
13228--- a/arch/x86/boot/cpucheck.c
13229+++ b/arch/x86/boot/cpucheck.c
13230@@ -125,9 +125,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
13231 u32 ecx = MSR_K7_HWCR;
13232 u32 eax, edx;
13233
13234- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13235+ asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13236 eax &= ~(1 << 15);
13237- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13238+ asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13239
13240 get_cpuflags(); /* Make sure it really did something */
13241 err = check_cpuflags();
13242@@ -140,9 +140,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
13243 u32 ecx = MSR_VIA_FCR;
13244 u32 eax, edx;
13245
13246- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13247+ asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13248 eax |= (1<<1)|(1<<7);
13249- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13250+ asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13251
13252 set_bit(X86_FEATURE_CX8, cpu.flags);
13253 err = check_cpuflags();
13254@@ -153,12 +153,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
13255 u32 eax, edx;
13256 u32 level = 1;
13257
13258- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13259- asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
13260- asm("cpuid"
13261+ asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13262+ asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
13263+ asm volatile("cpuid"
13264 : "+a" (level), "=d" (cpu.flags[0])
13265 : : "ecx", "ebx");
13266- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13267+ asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13268
13269 err = check_cpuflags();
13270 } else if (err == 0x01 &&
13271diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
13272index 16ef025..91e033b 100644
13273--- a/arch/x86/boot/header.S
13274+++ b/arch/x86/boot/header.S
13275@@ -438,10 +438,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
13276 # single linked list of
13277 # struct setup_data
13278
13279-pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
13280+pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
13281
13282 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
13283+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
13284+#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
13285+#else
13286 #define VO_INIT_SIZE (VO__end - VO__text)
13287+#endif
13288 #if ZO_INIT_SIZE > VO_INIT_SIZE
13289 #define INIT_SIZE ZO_INIT_SIZE
13290 #else
13291diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
13292index db75d07..8e6d0af 100644
13293--- a/arch/x86/boot/memory.c
13294+++ b/arch/x86/boot/memory.c
13295@@ -19,7 +19,7 @@
13296
13297 static int detect_memory_e820(void)
13298 {
13299- int count = 0;
13300+ unsigned int count = 0;
13301 struct biosregs ireg, oreg;
13302 struct e820entry *desc = boot_params.e820_map;
13303 static struct e820entry buf; /* static so it is zeroed */
13304diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
13305index ba3e100..6501b8f 100644
13306--- a/arch/x86/boot/video-vesa.c
13307+++ b/arch/x86/boot/video-vesa.c
13308@@ -201,6 +201,7 @@ static void vesa_store_pm_info(void)
13309
13310 boot_params.screen_info.vesapm_seg = oreg.es;
13311 boot_params.screen_info.vesapm_off = oreg.di;
13312+ boot_params.screen_info.vesapm_size = oreg.cx;
13313 }
13314
13315 /*
13316diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
13317index 05111bb..a1ae1f0 100644
13318--- a/arch/x86/boot/video.c
13319+++ b/arch/x86/boot/video.c
13320@@ -98,7 +98,7 @@ static void store_mode_params(void)
13321 static unsigned int get_entry(void)
13322 {
13323 char entry_buf[4];
13324- int i, len = 0;
13325+ unsigned int i, len = 0;
13326 int key;
13327 unsigned int v;
13328
13329diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
13330index 9105655..41779c1 100644
13331--- a/arch/x86/crypto/aes-x86_64-asm_64.S
13332+++ b/arch/x86/crypto/aes-x86_64-asm_64.S
13333@@ -8,6 +8,8 @@
13334 * including this sentence is retained in full.
13335 */
13336
13337+#include <asm/alternative-asm.h>
13338+
13339 .extern crypto_ft_tab
13340 .extern crypto_it_tab
13341 .extern crypto_fl_tab
13342@@ -70,6 +72,8 @@
13343 je B192; \
13344 leaq 32(r9),r9;
13345
13346+#define ret pax_force_retaddr; ret
13347+
13348 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
13349 movq r1,r2; \
13350 movq r3,r4; \
13351diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
13352index 6bd2c6c..368c93e 100644
13353--- a/arch/x86/crypto/aesni-intel_asm.S
13354+++ b/arch/x86/crypto/aesni-intel_asm.S
13355@@ -31,6 +31,7 @@
13356
13357 #include <linux/linkage.h>
13358 #include <asm/inst.h>
13359+#include <asm/alternative-asm.h>
13360
13361 /*
13362 * The following macros are used to move an (un)aligned 16 byte value to/from
13363@@ -217,7 +218,7 @@ enc: .octa 0x2
13364 * num_initial_blocks = b mod 4
13365 * encrypt the initial num_initial_blocks blocks and apply ghash on
13366 * the ciphertext
13367-* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13368+* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13369 * are clobbered
13370 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
13371 */
13372@@ -227,8 +228,8 @@ enc: .octa 0x2
13373 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
13374 MOVADQ SHUF_MASK(%rip), %xmm14
13375 mov arg7, %r10 # %r10 = AAD
13376- mov arg8, %r12 # %r12 = aadLen
13377- mov %r12, %r11
13378+ mov arg8, %r15 # %r15 = aadLen
13379+ mov %r15, %r11
13380 pxor %xmm\i, %xmm\i
13381
13382 _get_AAD_loop\num_initial_blocks\operation:
13383@@ -237,17 +238,17 @@ _get_AAD_loop\num_initial_blocks\operation:
13384 psrldq $4, %xmm\i
13385 pxor \TMP1, %xmm\i
13386 add $4, %r10
13387- sub $4, %r12
13388+ sub $4, %r15
13389 jne _get_AAD_loop\num_initial_blocks\operation
13390
13391 cmp $16, %r11
13392 je _get_AAD_loop2_done\num_initial_blocks\operation
13393
13394- mov $16, %r12
13395+ mov $16, %r15
13396 _get_AAD_loop2\num_initial_blocks\operation:
13397 psrldq $4, %xmm\i
13398- sub $4, %r12
13399- cmp %r11, %r12
13400+ sub $4, %r15
13401+ cmp %r11, %r15
13402 jne _get_AAD_loop2\num_initial_blocks\operation
13403
13404 _get_AAD_loop2_done\num_initial_blocks\operation:
13405@@ -442,7 +443,7 @@ _initial_blocks_done\num_initial_blocks\operation:
13406 * num_initial_blocks = b mod 4
13407 * encrypt the initial num_initial_blocks blocks and apply ghash on
13408 * the ciphertext
13409-* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13410+* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13411 * are clobbered
13412 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
13413 */
13414@@ -452,8 +453,8 @@ _initial_blocks_done\num_initial_blocks\operation:
13415 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
13416 MOVADQ SHUF_MASK(%rip), %xmm14
13417 mov arg7, %r10 # %r10 = AAD
13418- mov arg8, %r12 # %r12 = aadLen
13419- mov %r12, %r11
13420+ mov arg8, %r15 # %r15 = aadLen
13421+ mov %r15, %r11
13422 pxor %xmm\i, %xmm\i
13423 _get_AAD_loop\num_initial_blocks\operation:
13424 movd (%r10), \TMP1
13425@@ -461,15 +462,15 @@ _get_AAD_loop\num_initial_blocks\operation:
13426 psrldq $4, %xmm\i
13427 pxor \TMP1, %xmm\i
13428 add $4, %r10
13429- sub $4, %r12
13430+ sub $4, %r15
13431 jne _get_AAD_loop\num_initial_blocks\operation
13432 cmp $16, %r11
13433 je _get_AAD_loop2_done\num_initial_blocks\operation
13434- mov $16, %r12
13435+ mov $16, %r15
13436 _get_AAD_loop2\num_initial_blocks\operation:
13437 psrldq $4, %xmm\i
13438- sub $4, %r12
13439- cmp %r11, %r12
13440+ sub $4, %r15
13441+ cmp %r11, %r15
13442 jne _get_AAD_loop2\num_initial_blocks\operation
13443 _get_AAD_loop2_done\num_initial_blocks\operation:
13444 PSHUFB_XMM %xmm14, %xmm\i # byte-reflect the AAD data
13445@@ -1280,7 +1281,7 @@ _esb_loop_\@:
13446 *
13447 *****************************************************************************/
13448 ENTRY(aesni_gcm_dec)
13449- push %r12
13450+ push %r15
13451 push %r13
13452 push %r14
13453 mov %rsp, %r14
13454@@ -1290,8 +1291,8 @@ ENTRY(aesni_gcm_dec)
13455 */
13456 sub $VARIABLE_OFFSET, %rsp
13457 and $~63, %rsp # align rsp to 64 bytes
13458- mov %arg6, %r12
13459- movdqu (%r12), %xmm13 # %xmm13 = HashKey
13460+ mov %arg6, %r15
13461+ movdqu (%r15), %xmm13 # %xmm13 = HashKey
13462 movdqa SHUF_MASK(%rip), %xmm2
13463 PSHUFB_XMM %xmm2, %xmm13
13464
13465@@ -1319,10 +1320,10 @@ ENTRY(aesni_gcm_dec)
13466 movdqa %xmm13, HashKey(%rsp) # store HashKey<<1 (mod poly)
13467 mov %arg4, %r13 # save the number of bytes of plaintext/ciphertext
13468 and $-16, %r13 # %r13 = %r13 - (%r13 mod 16)
13469- mov %r13, %r12
13470- and $(3<<4), %r12
13471+ mov %r13, %r15
13472+ and $(3<<4), %r15
13473 jz _initial_num_blocks_is_0_decrypt
13474- cmp $(2<<4), %r12
13475+ cmp $(2<<4), %r15
13476 jb _initial_num_blocks_is_1_decrypt
13477 je _initial_num_blocks_is_2_decrypt
13478 _initial_num_blocks_is_3_decrypt:
13479@@ -1372,16 +1373,16 @@ _zero_cipher_left_decrypt:
13480 sub $16, %r11
13481 add %r13, %r11
13482 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte block
13483- lea SHIFT_MASK+16(%rip), %r12
13484- sub %r13, %r12
13485+ lea SHIFT_MASK+16(%rip), %r15
13486+ sub %r13, %r15
13487 # adjust the shuffle mask pointer to be able to shift 16-%r13 bytes
13488 # (%r13 is the number of bytes in plaintext mod 16)
13489- movdqu (%r12), %xmm2 # get the appropriate shuffle mask
13490+ movdqu (%r15), %xmm2 # get the appropriate shuffle mask
13491 PSHUFB_XMM %xmm2, %xmm1 # right shift 16-%r13 butes
13492
13493 movdqa %xmm1, %xmm2
13494 pxor %xmm1, %xmm0 # Ciphertext XOR E(K, Yn)
13495- movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
13496+ movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
13497 # get the appropriate mask to mask out top 16-%r13 bytes of %xmm0
13498 pand %xmm1, %xmm0 # mask out top 16-%r13 bytes of %xmm0
13499 pand %xmm1, %xmm2
13500@@ -1410,9 +1411,9 @@ _less_than_8_bytes_left_decrypt:
13501 sub $1, %r13
13502 jne _less_than_8_bytes_left_decrypt
13503 _multiple_of_16_bytes_decrypt:
13504- mov arg8, %r12 # %r13 = aadLen (number of bytes)
13505- shl $3, %r12 # convert into number of bits
13506- movd %r12d, %xmm15 # len(A) in %xmm15
13507+ mov arg8, %r15 # %r13 = aadLen (number of bytes)
13508+ shl $3, %r15 # convert into number of bits
13509+ movd %r15d, %xmm15 # len(A) in %xmm15
13510 shl $3, %arg4 # len(C) in bits (*128)
13511 MOVQ_R64_XMM %arg4, %xmm1
13512 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
13513@@ -1451,7 +1452,8 @@ _return_T_done_decrypt:
13514 mov %r14, %rsp
13515 pop %r14
13516 pop %r13
13517- pop %r12
13518+ pop %r15
13519+ pax_force_retaddr
13520 ret
13521 ENDPROC(aesni_gcm_dec)
13522
13523@@ -1540,7 +1542,7 @@ ENDPROC(aesni_gcm_dec)
13524 * poly = x^128 + x^127 + x^126 + x^121 + 1
13525 ***************************************************************************/
13526 ENTRY(aesni_gcm_enc)
13527- push %r12
13528+ push %r15
13529 push %r13
13530 push %r14
13531 mov %rsp, %r14
13532@@ -1550,8 +1552,8 @@ ENTRY(aesni_gcm_enc)
13533 #
13534 sub $VARIABLE_OFFSET, %rsp
13535 and $~63, %rsp
13536- mov %arg6, %r12
13537- movdqu (%r12), %xmm13
13538+ mov %arg6, %r15
13539+ movdqu (%r15), %xmm13
13540 movdqa SHUF_MASK(%rip), %xmm2
13541 PSHUFB_XMM %xmm2, %xmm13
13542
13543@@ -1575,13 +1577,13 @@ ENTRY(aesni_gcm_enc)
13544 movdqa %xmm13, HashKey(%rsp)
13545 mov %arg4, %r13 # %xmm13 holds HashKey<<1 (mod poly)
13546 and $-16, %r13
13547- mov %r13, %r12
13548+ mov %r13, %r15
13549
13550 # Encrypt first few blocks
13551
13552- and $(3<<4), %r12
13553+ and $(3<<4), %r15
13554 jz _initial_num_blocks_is_0_encrypt
13555- cmp $(2<<4), %r12
13556+ cmp $(2<<4), %r15
13557 jb _initial_num_blocks_is_1_encrypt
13558 je _initial_num_blocks_is_2_encrypt
13559 _initial_num_blocks_is_3_encrypt:
13560@@ -1634,14 +1636,14 @@ _zero_cipher_left_encrypt:
13561 sub $16, %r11
13562 add %r13, %r11
13563 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte blocks
13564- lea SHIFT_MASK+16(%rip), %r12
13565- sub %r13, %r12
13566+ lea SHIFT_MASK+16(%rip), %r15
13567+ sub %r13, %r15
13568 # adjust the shuffle mask pointer to be able to shift 16-r13 bytes
13569 # (%r13 is the number of bytes in plaintext mod 16)
13570- movdqu (%r12), %xmm2 # get the appropriate shuffle mask
13571+ movdqu (%r15), %xmm2 # get the appropriate shuffle mask
13572 PSHUFB_XMM %xmm2, %xmm1 # shift right 16-r13 byte
13573 pxor %xmm1, %xmm0 # Plaintext XOR Encrypt(K, Yn)
13574- movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
13575+ movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
13576 # get the appropriate mask to mask out top 16-r13 bytes of xmm0
13577 pand %xmm1, %xmm0 # mask out top 16-r13 bytes of xmm0
13578 movdqa SHUF_MASK(%rip), %xmm10
13579@@ -1674,9 +1676,9 @@ _less_than_8_bytes_left_encrypt:
13580 sub $1, %r13
13581 jne _less_than_8_bytes_left_encrypt
13582 _multiple_of_16_bytes_encrypt:
13583- mov arg8, %r12 # %r12 = addLen (number of bytes)
13584- shl $3, %r12
13585- movd %r12d, %xmm15 # len(A) in %xmm15
13586+ mov arg8, %r15 # %r15 = addLen (number of bytes)
13587+ shl $3, %r15
13588+ movd %r15d, %xmm15 # len(A) in %xmm15
13589 shl $3, %arg4 # len(C) in bits (*128)
13590 MOVQ_R64_XMM %arg4, %xmm1
13591 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
13592@@ -1715,7 +1717,8 @@ _return_T_done_encrypt:
13593 mov %r14, %rsp
13594 pop %r14
13595 pop %r13
13596- pop %r12
13597+ pop %r15
13598+ pax_force_retaddr
13599 ret
13600 ENDPROC(aesni_gcm_enc)
13601
13602@@ -1733,6 +1736,7 @@ _key_expansion_256a:
13603 pxor %xmm1, %xmm0
13604 movaps %xmm0, (TKEYP)
13605 add $0x10, TKEYP
13606+ pax_force_retaddr
13607 ret
13608 ENDPROC(_key_expansion_128)
13609 ENDPROC(_key_expansion_256a)
13610@@ -1759,6 +1763,7 @@ _key_expansion_192a:
13611 shufps $0b01001110, %xmm2, %xmm1
13612 movaps %xmm1, 0x10(TKEYP)
13613 add $0x20, TKEYP
13614+ pax_force_retaddr
13615 ret
13616 ENDPROC(_key_expansion_192a)
13617
13618@@ -1779,6 +1784,7 @@ _key_expansion_192b:
13619
13620 movaps %xmm0, (TKEYP)
13621 add $0x10, TKEYP
13622+ pax_force_retaddr
13623 ret
13624 ENDPROC(_key_expansion_192b)
13625
13626@@ -1792,6 +1798,7 @@ _key_expansion_256b:
13627 pxor %xmm1, %xmm2
13628 movaps %xmm2, (TKEYP)
13629 add $0x10, TKEYP
13630+ pax_force_retaddr
13631 ret
13632 ENDPROC(_key_expansion_256b)
13633
13634@@ -1905,6 +1912,7 @@ ENTRY(aesni_set_key)
13635 #ifndef __x86_64__
13636 popl KEYP
13637 #endif
13638+ pax_force_retaddr
13639 ret
13640 ENDPROC(aesni_set_key)
13641
13642@@ -1927,6 +1935,7 @@ ENTRY(aesni_enc)
13643 popl KLEN
13644 popl KEYP
13645 #endif
13646+ pax_force_retaddr
13647 ret
13648 ENDPROC(aesni_enc)
13649
13650@@ -1985,6 +1994,7 @@ _aesni_enc1:
13651 AESENC KEY STATE
13652 movaps 0x70(TKEYP), KEY
13653 AESENCLAST KEY STATE
13654+ pax_force_retaddr
13655 ret
13656 ENDPROC(_aesni_enc1)
13657
13658@@ -2094,6 +2104,7 @@ _aesni_enc4:
13659 AESENCLAST KEY STATE2
13660 AESENCLAST KEY STATE3
13661 AESENCLAST KEY STATE4
13662+ pax_force_retaddr
13663 ret
13664 ENDPROC(_aesni_enc4)
13665
13666@@ -2117,6 +2128,7 @@ ENTRY(aesni_dec)
13667 popl KLEN
13668 popl KEYP
13669 #endif
13670+ pax_force_retaddr
13671 ret
13672 ENDPROC(aesni_dec)
13673
13674@@ -2175,6 +2187,7 @@ _aesni_dec1:
13675 AESDEC KEY STATE
13676 movaps 0x70(TKEYP), KEY
13677 AESDECLAST KEY STATE
13678+ pax_force_retaddr
13679 ret
13680 ENDPROC(_aesni_dec1)
13681
13682@@ -2284,6 +2297,7 @@ _aesni_dec4:
13683 AESDECLAST KEY STATE2
13684 AESDECLAST KEY STATE3
13685 AESDECLAST KEY STATE4
13686+ pax_force_retaddr
13687 ret
13688 ENDPROC(_aesni_dec4)
13689
13690@@ -2342,6 +2356,7 @@ ENTRY(aesni_ecb_enc)
13691 popl KEYP
13692 popl LEN
13693 #endif
13694+ pax_force_retaddr
13695 ret
13696 ENDPROC(aesni_ecb_enc)
13697
13698@@ -2401,6 +2416,7 @@ ENTRY(aesni_ecb_dec)
13699 popl KEYP
13700 popl LEN
13701 #endif
13702+ pax_force_retaddr
13703 ret
13704 ENDPROC(aesni_ecb_dec)
13705
13706@@ -2443,6 +2459,7 @@ ENTRY(aesni_cbc_enc)
13707 popl LEN
13708 popl IVP
13709 #endif
13710+ pax_force_retaddr
13711 ret
13712 ENDPROC(aesni_cbc_enc)
13713
13714@@ -2534,6 +2551,7 @@ ENTRY(aesni_cbc_dec)
13715 popl LEN
13716 popl IVP
13717 #endif
13718+ pax_force_retaddr
13719 ret
13720 ENDPROC(aesni_cbc_dec)
13721
13722@@ -2561,6 +2579,7 @@ _aesni_inc_init:
13723 mov $1, TCTR_LOW
13724 MOVQ_R64_XMM TCTR_LOW INC
13725 MOVQ_R64_XMM CTR TCTR_LOW
13726+ pax_force_retaddr
13727 ret
13728 ENDPROC(_aesni_inc_init)
13729
13730@@ -2590,6 +2609,7 @@ _aesni_inc:
13731 .Linc_low:
13732 movaps CTR, IV
13733 PSHUFB_XMM BSWAP_MASK IV
13734+ pax_force_retaddr
13735 ret
13736 ENDPROC(_aesni_inc)
13737
13738@@ -2651,6 +2671,7 @@ ENTRY(aesni_ctr_enc)
13739 .Lctr_enc_ret:
13740 movups IV, (IVP)
13741 .Lctr_enc_just_ret:
13742+ pax_force_retaddr
13743 ret
13744 ENDPROC(aesni_ctr_enc)
13745
13746@@ -2777,6 +2798,7 @@ ENTRY(aesni_xts_crypt8)
13747 pxor INC, STATE4
13748 movdqu STATE4, 0x70(OUTP)
13749
13750+ pax_force_retaddr
13751 ret
13752 ENDPROC(aesni_xts_crypt8)
13753
13754diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
13755index 246c670..466e2d6 100644
13756--- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
13757+++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
13758@@ -21,6 +21,7 @@
13759 */
13760
13761 #include <linux/linkage.h>
13762+#include <asm/alternative-asm.h>
13763
13764 .file "blowfish-x86_64-asm.S"
13765 .text
13766@@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
13767 jnz .L__enc_xor;
13768
13769 write_block();
13770+ pax_force_retaddr
13771 ret;
13772 .L__enc_xor:
13773 xor_block();
13774+ pax_force_retaddr
13775 ret;
13776 ENDPROC(__blowfish_enc_blk)
13777
13778@@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
13779
13780 movq %r11, %rbp;
13781
13782+ pax_force_retaddr
13783 ret;
13784 ENDPROC(blowfish_dec_blk)
13785
13786@@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
13787
13788 popq %rbx;
13789 popq %rbp;
13790+ pax_force_retaddr
13791 ret;
13792
13793 .L__enc_xor4:
13794@@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
13795
13796 popq %rbx;
13797 popq %rbp;
13798+ pax_force_retaddr
13799 ret;
13800 ENDPROC(__blowfish_enc_blk_4way)
13801
13802@@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
13803 popq %rbx;
13804 popq %rbp;
13805
13806+ pax_force_retaddr
13807 ret;
13808 ENDPROC(blowfish_dec_blk_4way)
13809diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13810index ce71f92..1dce7ec 100644
13811--- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13812+++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13813@@ -16,6 +16,7 @@
13814 */
13815
13816 #include <linux/linkage.h>
13817+#include <asm/alternative-asm.h>
13818
13819 #define CAMELLIA_TABLE_BYTE_LEN 272
13820
13821@@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
13822 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
13823 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
13824 %rcx, (%r9));
13825+ pax_force_retaddr
13826 ret;
13827 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
13828
13829@@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
13830 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
13831 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
13832 %rax, (%r9));
13833+ pax_force_retaddr
13834 ret;
13835 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
13836
13837@@ -780,6 +783,7 @@ __camellia_enc_blk16:
13838 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
13839 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
13840
13841+ pax_force_retaddr
13842 ret;
13843
13844 .align 8
13845@@ -865,6 +869,7 @@ __camellia_dec_blk16:
13846 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
13847 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
13848
13849+ pax_force_retaddr
13850 ret;
13851
13852 .align 8
13853@@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
13854 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13855 %xmm8, %rsi);
13856
13857+ pax_force_retaddr
13858 ret;
13859 ENDPROC(camellia_ecb_enc_16way)
13860
13861@@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
13862 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13863 %xmm8, %rsi);
13864
13865+ pax_force_retaddr
13866 ret;
13867 ENDPROC(camellia_ecb_dec_16way)
13868
13869@@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
13870 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13871 %xmm8, %rsi);
13872
13873+ pax_force_retaddr
13874 ret;
13875 ENDPROC(camellia_cbc_dec_16way)
13876
13877@@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
13878 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13879 %xmm8, %rsi);
13880
13881+ pax_force_retaddr
13882 ret;
13883 ENDPROC(camellia_ctr_16way)
13884
13885@@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
13886 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13887 %xmm8, %rsi);
13888
13889+ pax_force_retaddr
13890 ret;
13891 ENDPROC(camellia_xts_crypt_16way)
13892
13893diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13894index 0e0b886..5a3123c 100644
13895--- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13896+++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13897@@ -11,6 +11,7 @@
13898 */
13899
13900 #include <linux/linkage.h>
13901+#include <asm/alternative-asm.h>
13902
13903 #define CAMELLIA_TABLE_BYTE_LEN 272
13904
13905@@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
13906 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
13907 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
13908 %rcx, (%r9));
13909+ pax_force_retaddr
13910 ret;
13911 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
13912
13913@@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
13914 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
13915 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
13916 %rax, (%r9));
13917+ pax_force_retaddr
13918 ret;
13919 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
13920
13921@@ -820,6 +823,7 @@ __camellia_enc_blk32:
13922 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
13923 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
13924
13925+ pax_force_retaddr
13926 ret;
13927
13928 .align 8
13929@@ -905,6 +909,7 @@ __camellia_dec_blk32:
13930 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
13931 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
13932
13933+ pax_force_retaddr
13934 ret;
13935
13936 .align 8
13937@@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
13938
13939 vzeroupper;
13940
13941+ pax_force_retaddr
13942 ret;
13943 ENDPROC(camellia_ecb_enc_32way)
13944
13945@@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
13946
13947 vzeroupper;
13948
13949+ pax_force_retaddr
13950 ret;
13951 ENDPROC(camellia_ecb_dec_32way)
13952
13953@@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
13954
13955 vzeroupper;
13956
13957+ pax_force_retaddr
13958 ret;
13959 ENDPROC(camellia_cbc_dec_32way)
13960
13961@@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
13962
13963 vzeroupper;
13964
13965+ pax_force_retaddr
13966 ret;
13967 ENDPROC(camellia_ctr_32way)
13968
13969@@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
13970
13971 vzeroupper;
13972
13973+ pax_force_retaddr
13974 ret;
13975 ENDPROC(camellia_xts_crypt_32way)
13976
13977diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
13978index 310319c..db3d7b5 100644
13979--- a/arch/x86/crypto/camellia-x86_64-asm_64.S
13980+++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
13981@@ -21,6 +21,7 @@
13982 */
13983
13984 #include <linux/linkage.h>
13985+#include <asm/alternative-asm.h>
13986
13987 .file "camellia-x86_64-asm_64.S"
13988 .text
13989@@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
13990 enc_outunpack(mov, RT1);
13991
13992 movq RRBP, %rbp;
13993+ pax_force_retaddr
13994 ret;
13995
13996 .L__enc_xor:
13997 enc_outunpack(xor, RT1);
13998
13999 movq RRBP, %rbp;
14000+ pax_force_retaddr
14001 ret;
14002 ENDPROC(__camellia_enc_blk)
14003
14004@@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
14005 dec_outunpack();
14006
14007 movq RRBP, %rbp;
14008+ pax_force_retaddr
14009 ret;
14010 ENDPROC(camellia_dec_blk)
14011
14012@@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
14013
14014 movq RRBP, %rbp;
14015 popq %rbx;
14016+ pax_force_retaddr
14017 ret;
14018
14019 .L__enc2_xor:
14020@@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
14021
14022 movq RRBP, %rbp;
14023 popq %rbx;
14024+ pax_force_retaddr
14025 ret;
14026 ENDPROC(__camellia_enc_blk_2way)
14027
14028@@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
14029
14030 movq RRBP, %rbp;
14031 movq RXOR, %rbx;
14032+ pax_force_retaddr
14033 ret;
14034 ENDPROC(camellia_dec_blk_2way)
14035diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
14036index c35fd5d..2d8c7db 100644
14037--- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
14038+++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
14039@@ -24,6 +24,7 @@
14040 */
14041
14042 #include <linux/linkage.h>
14043+#include <asm/alternative-asm.h>
14044
14045 .file "cast5-avx-x86_64-asm_64.S"
14046
14047@@ -281,6 +282,7 @@ __cast5_enc_blk16:
14048 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
14049 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
14050
14051+ pax_force_retaddr
14052 ret;
14053 ENDPROC(__cast5_enc_blk16)
14054
14055@@ -352,6 +354,7 @@ __cast5_dec_blk16:
14056 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
14057 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
14058
14059+ pax_force_retaddr
14060 ret;
14061
14062 .L__skip_dec:
14063@@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
14064 vmovdqu RR4, (6*4*4)(%r11);
14065 vmovdqu RL4, (7*4*4)(%r11);
14066
14067+ pax_force_retaddr
14068 ret;
14069 ENDPROC(cast5_ecb_enc_16way)
14070
14071@@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
14072 vmovdqu RR4, (6*4*4)(%r11);
14073 vmovdqu RL4, (7*4*4)(%r11);
14074
14075+ pax_force_retaddr
14076 ret;
14077 ENDPROC(cast5_ecb_dec_16way)
14078
14079@@ -430,10 +435,10 @@ ENTRY(cast5_cbc_dec_16way)
14080 * %rdx: src
14081 */
14082
14083- pushq %r12;
14084+ pushq %r14;
14085
14086 movq %rsi, %r11;
14087- movq %rdx, %r12;
14088+ movq %rdx, %r14;
14089
14090 vmovdqu (0*16)(%rdx), RL1;
14091 vmovdqu (1*16)(%rdx), RR1;
14092@@ -447,16 +452,16 @@ ENTRY(cast5_cbc_dec_16way)
14093 call __cast5_dec_blk16;
14094
14095 /* xor with src */
14096- vmovq (%r12), RX;
14097+ vmovq (%r14), RX;
14098 vpshufd $0x4f, RX, RX;
14099 vpxor RX, RR1, RR1;
14100- vpxor 0*16+8(%r12), RL1, RL1;
14101- vpxor 1*16+8(%r12), RR2, RR2;
14102- vpxor 2*16+8(%r12), RL2, RL2;
14103- vpxor 3*16+8(%r12), RR3, RR3;
14104- vpxor 4*16+8(%r12), RL3, RL3;
14105- vpxor 5*16+8(%r12), RR4, RR4;
14106- vpxor 6*16+8(%r12), RL4, RL4;
14107+ vpxor 0*16+8(%r14), RL1, RL1;
14108+ vpxor 1*16+8(%r14), RR2, RR2;
14109+ vpxor 2*16+8(%r14), RL2, RL2;
14110+ vpxor 3*16+8(%r14), RR3, RR3;
14111+ vpxor 4*16+8(%r14), RL3, RL3;
14112+ vpxor 5*16+8(%r14), RR4, RR4;
14113+ vpxor 6*16+8(%r14), RL4, RL4;
14114
14115 vmovdqu RR1, (0*16)(%r11);
14116 vmovdqu RL1, (1*16)(%r11);
14117@@ -467,8 +472,9 @@ ENTRY(cast5_cbc_dec_16way)
14118 vmovdqu RR4, (6*16)(%r11);
14119 vmovdqu RL4, (7*16)(%r11);
14120
14121- popq %r12;
14122+ popq %r14;
14123
14124+ pax_force_retaddr
14125 ret;
14126 ENDPROC(cast5_cbc_dec_16way)
14127
14128@@ -480,10 +486,10 @@ ENTRY(cast5_ctr_16way)
14129 * %rcx: iv (big endian, 64bit)
14130 */
14131
14132- pushq %r12;
14133+ pushq %r14;
14134
14135 movq %rsi, %r11;
14136- movq %rdx, %r12;
14137+ movq %rdx, %r14;
14138
14139 vpcmpeqd RTMP, RTMP, RTMP;
14140 vpsrldq $8, RTMP, RTMP; /* low: -1, high: 0 */
14141@@ -523,14 +529,14 @@ ENTRY(cast5_ctr_16way)
14142 call __cast5_enc_blk16;
14143
14144 /* dst = src ^ iv */
14145- vpxor (0*16)(%r12), RR1, RR1;
14146- vpxor (1*16)(%r12), RL1, RL1;
14147- vpxor (2*16)(%r12), RR2, RR2;
14148- vpxor (3*16)(%r12), RL2, RL2;
14149- vpxor (4*16)(%r12), RR3, RR3;
14150- vpxor (5*16)(%r12), RL3, RL3;
14151- vpxor (6*16)(%r12), RR4, RR4;
14152- vpxor (7*16)(%r12), RL4, RL4;
14153+ vpxor (0*16)(%r14), RR1, RR1;
14154+ vpxor (1*16)(%r14), RL1, RL1;
14155+ vpxor (2*16)(%r14), RR2, RR2;
14156+ vpxor (3*16)(%r14), RL2, RL2;
14157+ vpxor (4*16)(%r14), RR3, RR3;
14158+ vpxor (5*16)(%r14), RL3, RL3;
14159+ vpxor (6*16)(%r14), RR4, RR4;
14160+ vpxor (7*16)(%r14), RL4, RL4;
14161 vmovdqu RR1, (0*16)(%r11);
14162 vmovdqu RL1, (1*16)(%r11);
14163 vmovdqu RR2, (2*16)(%r11);
14164@@ -540,7 +546,8 @@ ENTRY(cast5_ctr_16way)
14165 vmovdqu RR4, (6*16)(%r11);
14166 vmovdqu RL4, (7*16)(%r11);
14167
14168- popq %r12;
14169+ popq %r14;
14170
14171+ pax_force_retaddr
14172 ret;
14173 ENDPROC(cast5_ctr_16way)
14174diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
14175index e3531f8..e123f35 100644
14176--- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
14177+++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
14178@@ -24,6 +24,7 @@
14179 */
14180
14181 #include <linux/linkage.h>
14182+#include <asm/alternative-asm.h>
14183 #include "glue_helper-asm-avx.S"
14184
14185 .file "cast6-avx-x86_64-asm_64.S"
14186@@ -295,6 +296,7 @@ __cast6_enc_blk8:
14187 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
14188 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
14189
14190+ pax_force_retaddr
14191 ret;
14192 ENDPROC(__cast6_enc_blk8)
14193
14194@@ -340,6 +342,7 @@ __cast6_dec_blk8:
14195 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
14196 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
14197
14198+ pax_force_retaddr
14199 ret;
14200 ENDPROC(__cast6_dec_blk8)
14201
14202@@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
14203
14204 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14205
14206+ pax_force_retaddr
14207 ret;
14208 ENDPROC(cast6_ecb_enc_8way)
14209
14210@@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
14211
14212 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14213
14214+ pax_force_retaddr
14215 ret;
14216 ENDPROC(cast6_ecb_dec_8way)
14217
14218@@ -386,19 +391,20 @@ ENTRY(cast6_cbc_dec_8way)
14219 * %rdx: src
14220 */
14221
14222- pushq %r12;
14223+ pushq %r14;
14224
14225 movq %rsi, %r11;
14226- movq %rdx, %r12;
14227+ movq %rdx, %r14;
14228
14229 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14230
14231 call __cast6_dec_blk8;
14232
14233- store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14234+ store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14235
14236- popq %r12;
14237+ popq %r14;
14238
14239+ pax_force_retaddr
14240 ret;
14241 ENDPROC(cast6_cbc_dec_8way)
14242
14243@@ -410,20 +416,21 @@ ENTRY(cast6_ctr_8way)
14244 * %rcx: iv (little endian, 128bit)
14245 */
14246
14247- pushq %r12;
14248+ pushq %r14;
14249
14250 movq %rsi, %r11;
14251- movq %rdx, %r12;
14252+ movq %rdx, %r14;
14253
14254 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
14255 RD2, RX, RKR, RKM);
14256
14257 call __cast6_enc_blk8;
14258
14259- store_ctr_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14260+ store_ctr_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14261
14262- popq %r12;
14263+ popq %r14;
14264
14265+ pax_force_retaddr
14266 ret;
14267 ENDPROC(cast6_ctr_8way)
14268
14269@@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
14270 /* dst <= regs xor IVs(in dst) */
14271 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14272
14273+ pax_force_retaddr
14274 ret;
14275 ENDPROC(cast6_xts_enc_8way)
14276
14277@@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
14278 /* dst <= regs xor IVs(in dst) */
14279 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14280
14281+ pax_force_retaddr
14282 ret;
14283 ENDPROC(cast6_xts_dec_8way)
14284diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
14285index 225be06..2885e731 100644
14286--- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
14287+++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
14288@@ -45,6 +45,7 @@
14289
14290 #include <asm/inst.h>
14291 #include <linux/linkage.h>
14292+#include <asm/alternative-asm.h>
14293
14294 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
14295
14296@@ -309,6 +310,7 @@ do_return:
14297 popq %rsi
14298 popq %rdi
14299 popq %rbx
14300+ pax_force_retaddr
14301 ret
14302
14303 ################################################################
14304@@ -330,7 +332,7 @@ ENDPROC(crc_pcl)
14305 ## PCLMULQDQ tables
14306 ## Table is 128 entries x 2 words (8 bytes) each
14307 ################################################################
14308-.section .rotata, "a", %progbits
14309+.section .rodata, "a", %progbits
14310 .align 8
14311 K_table:
14312 .long 0x493c7d27, 0x00000001
14313diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
14314index 5d1e007..098cb4f 100644
14315--- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
14316+++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
14317@@ -18,6 +18,7 @@
14318
14319 #include <linux/linkage.h>
14320 #include <asm/inst.h>
14321+#include <asm/alternative-asm.h>
14322
14323 .data
14324
14325@@ -89,6 +90,7 @@ __clmul_gf128mul_ble:
14326 psrlq $1, T2
14327 pxor T2, T1
14328 pxor T1, DATA
14329+ pax_force_retaddr
14330 ret
14331 ENDPROC(__clmul_gf128mul_ble)
14332
14333@@ -101,6 +103,7 @@ ENTRY(clmul_ghash_mul)
14334 call __clmul_gf128mul_ble
14335 PSHUFB_XMM BSWAP DATA
14336 movups DATA, (%rdi)
14337+ pax_force_retaddr
14338 ret
14339 ENDPROC(clmul_ghash_mul)
14340
14341@@ -128,5 +131,6 @@ ENTRY(clmul_ghash_update)
14342 PSHUFB_XMM BSWAP DATA
14343 movups DATA, (%rdi)
14344 .Lupdate_just_ret:
14345+ pax_force_retaddr
14346 ret
14347 ENDPROC(clmul_ghash_update)
14348diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
14349index 9279e0b..c4b3d2c 100644
14350--- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
14351+++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
14352@@ -1,4 +1,5 @@
14353 #include <linux/linkage.h>
14354+#include <asm/alternative-asm.h>
14355
14356 # enter salsa20_encrypt_bytes
14357 ENTRY(salsa20_encrypt_bytes)
14358@@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
14359 add %r11,%rsp
14360 mov %rdi,%rax
14361 mov %rsi,%rdx
14362+ pax_force_retaddr
14363 ret
14364 # bytesatleast65:
14365 ._bytesatleast65:
14366@@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
14367 add %r11,%rsp
14368 mov %rdi,%rax
14369 mov %rsi,%rdx
14370+ pax_force_retaddr
14371 ret
14372 ENDPROC(salsa20_keysetup)
14373
14374@@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
14375 add %r11,%rsp
14376 mov %rdi,%rax
14377 mov %rsi,%rdx
14378+ pax_force_retaddr
14379 ret
14380 ENDPROC(salsa20_ivsetup)
14381diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
14382index 2f202f4..d9164d6 100644
14383--- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
14384+++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
14385@@ -24,6 +24,7 @@
14386 */
14387
14388 #include <linux/linkage.h>
14389+#include <asm/alternative-asm.h>
14390 #include "glue_helper-asm-avx.S"
14391
14392 .file "serpent-avx-x86_64-asm_64.S"
14393@@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
14394 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14395 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14396
14397+ pax_force_retaddr
14398 ret;
14399 ENDPROC(__serpent_enc_blk8_avx)
14400
14401@@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
14402 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
14403 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
14404
14405+ pax_force_retaddr
14406 ret;
14407 ENDPROC(__serpent_dec_blk8_avx)
14408
14409@@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
14410
14411 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14412
14413+ pax_force_retaddr
14414 ret;
14415 ENDPROC(serpent_ecb_enc_8way_avx)
14416
14417@@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
14418
14419 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
14420
14421+ pax_force_retaddr
14422 ret;
14423 ENDPROC(serpent_ecb_dec_8way_avx)
14424
14425@@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
14426
14427 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
14428
14429+ pax_force_retaddr
14430 ret;
14431 ENDPROC(serpent_cbc_dec_8way_avx)
14432
14433@@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
14434
14435 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14436
14437+ pax_force_retaddr
14438 ret;
14439 ENDPROC(serpent_ctr_8way_avx)
14440
14441@@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
14442 /* dst <= regs xor IVs(in dst) */
14443 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14444
14445+ pax_force_retaddr
14446 ret;
14447 ENDPROC(serpent_xts_enc_8way_avx)
14448
14449@@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
14450 /* dst <= regs xor IVs(in dst) */
14451 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
14452
14453+ pax_force_retaddr
14454 ret;
14455 ENDPROC(serpent_xts_dec_8way_avx)
14456diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
14457index b222085..abd483c 100644
14458--- a/arch/x86/crypto/serpent-avx2-asm_64.S
14459+++ b/arch/x86/crypto/serpent-avx2-asm_64.S
14460@@ -15,6 +15,7 @@
14461 */
14462
14463 #include <linux/linkage.h>
14464+#include <asm/alternative-asm.h>
14465 #include "glue_helper-asm-avx2.S"
14466
14467 .file "serpent-avx2-asm_64.S"
14468@@ -610,6 +611,7 @@ __serpent_enc_blk16:
14469 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14470 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14471
14472+ pax_force_retaddr
14473 ret;
14474 ENDPROC(__serpent_enc_blk16)
14475
14476@@ -664,6 +666,7 @@ __serpent_dec_blk16:
14477 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
14478 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
14479
14480+ pax_force_retaddr
14481 ret;
14482 ENDPROC(__serpent_dec_blk16)
14483
14484@@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
14485
14486 vzeroupper;
14487
14488+ pax_force_retaddr
14489 ret;
14490 ENDPROC(serpent_ecb_enc_16way)
14491
14492@@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
14493
14494 vzeroupper;
14495
14496+ pax_force_retaddr
14497 ret;
14498 ENDPROC(serpent_ecb_dec_16way)
14499
14500@@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
14501
14502 vzeroupper;
14503
14504+ pax_force_retaddr
14505 ret;
14506 ENDPROC(serpent_cbc_dec_16way)
14507
14508@@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
14509
14510 vzeroupper;
14511
14512+ pax_force_retaddr
14513 ret;
14514 ENDPROC(serpent_ctr_16way)
14515
14516@@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
14517
14518 vzeroupper;
14519
14520+ pax_force_retaddr
14521 ret;
14522 ENDPROC(serpent_xts_enc_16way)
14523
14524@@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
14525
14526 vzeroupper;
14527
14528+ pax_force_retaddr
14529 ret;
14530 ENDPROC(serpent_xts_dec_16way)
14531diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
14532index acc066c..1559cc4 100644
14533--- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
14534+++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
14535@@ -25,6 +25,7 @@
14536 */
14537
14538 #include <linux/linkage.h>
14539+#include <asm/alternative-asm.h>
14540
14541 .file "serpent-sse2-x86_64-asm_64.S"
14542 .text
14543@@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
14544 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14545 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14546
14547+ pax_force_retaddr
14548 ret;
14549
14550 .L__enc_xor8:
14551 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14552 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14553
14554+ pax_force_retaddr
14555 ret;
14556 ENDPROC(__serpent_enc_blk_8way)
14557
14558@@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
14559 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
14560 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
14561
14562+ pax_force_retaddr
14563 ret;
14564 ENDPROC(serpent_dec_blk_8way)
14565diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
14566index a410950..9dfe7ad 100644
14567--- a/arch/x86/crypto/sha1_ssse3_asm.S
14568+++ b/arch/x86/crypto/sha1_ssse3_asm.S
14569@@ -29,6 +29,7 @@
14570 */
14571
14572 #include <linux/linkage.h>
14573+#include <asm/alternative-asm.h>
14574
14575 #define CTX %rdi // arg1
14576 #define BUF %rsi // arg2
14577@@ -75,9 +76,9 @@
14578
14579 push %rbx
14580 push %rbp
14581- push %r12
14582+ push %r14
14583
14584- mov %rsp, %r12
14585+ mov %rsp, %r14
14586 sub $64, %rsp # allocate workspace
14587 and $~15, %rsp # align stack
14588
14589@@ -99,11 +100,12 @@
14590 xor %rax, %rax
14591 rep stosq
14592
14593- mov %r12, %rsp # deallocate workspace
14594+ mov %r14, %rsp # deallocate workspace
14595
14596- pop %r12
14597+ pop %r14
14598 pop %rbp
14599 pop %rbx
14600+ pax_force_retaddr
14601 ret
14602
14603 ENDPROC(\name)
14604diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
14605index 92b3b5d..0dc1dcb 100644
14606--- a/arch/x86/crypto/sha256-avx-asm.S
14607+++ b/arch/x86/crypto/sha256-avx-asm.S
14608@@ -49,6 +49,7 @@
14609
14610 #ifdef CONFIG_AS_AVX
14611 #include <linux/linkage.h>
14612+#include <asm/alternative-asm.h>
14613
14614 ## assume buffers not aligned
14615 #define VMOVDQ vmovdqu
14616@@ -460,6 +461,7 @@ done_hash:
14617 popq %r13
14618 popq %rbp
14619 popq %rbx
14620+ pax_force_retaddr
14621 ret
14622 ENDPROC(sha256_transform_avx)
14623
14624diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
14625index 570ec5e..cf2b625 100644
14626--- a/arch/x86/crypto/sha256-avx2-asm.S
14627+++ b/arch/x86/crypto/sha256-avx2-asm.S
14628@@ -50,6 +50,7 @@
14629
14630 #ifdef CONFIG_AS_AVX2
14631 #include <linux/linkage.h>
14632+#include <asm/alternative-asm.h>
14633
14634 ## assume buffers not aligned
14635 #define VMOVDQ vmovdqu
14636@@ -720,6 +721,7 @@ done_hash:
14637 popq %r12
14638 popq %rbp
14639 popq %rbx
14640+ pax_force_retaddr
14641 ret
14642 ENDPROC(sha256_transform_rorx)
14643
14644diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
14645index 2cedc44..5144899 100644
14646--- a/arch/x86/crypto/sha256-ssse3-asm.S
14647+++ b/arch/x86/crypto/sha256-ssse3-asm.S
14648@@ -47,6 +47,7 @@
14649 ########################################################################
14650
14651 #include <linux/linkage.h>
14652+#include <asm/alternative-asm.h>
14653
14654 ## assume buffers not aligned
14655 #define MOVDQ movdqu
14656@@ -471,6 +472,7 @@ done_hash:
14657 popq %rbp
14658 popq %rbx
14659
14660+ pax_force_retaddr
14661 ret
14662 ENDPROC(sha256_transform_ssse3)
14663
14664diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
14665index 565274d..af6bc08 100644
14666--- a/arch/x86/crypto/sha512-avx-asm.S
14667+++ b/arch/x86/crypto/sha512-avx-asm.S
14668@@ -49,6 +49,7 @@
14669
14670 #ifdef CONFIG_AS_AVX
14671 #include <linux/linkage.h>
14672+#include <asm/alternative-asm.h>
14673
14674 .text
14675
14676@@ -364,6 +365,7 @@ updateblock:
14677 mov frame_RSPSAVE(%rsp), %rsp
14678
14679 nowork:
14680+ pax_force_retaddr
14681 ret
14682 ENDPROC(sha512_transform_avx)
14683
14684diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
14685index 1f20b35..f25c8c1 100644
14686--- a/arch/x86/crypto/sha512-avx2-asm.S
14687+++ b/arch/x86/crypto/sha512-avx2-asm.S
14688@@ -51,6 +51,7 @@
14689
14690 #ifdef CONFIG_AS_AVX2
14691 #include <linux/linkage.h>
14692+#include <asm/alternative-asm.h>
14693
14694 .text
14695
14696@@ -678,6 +679,7 @@ done_hash:
14697
14698 # Restore Stack Pointer
14699 mov frame_RSPSAVE(%rsp), %rsp
14700+ pax_force_retaddr
14701 ret
14702 ENDPROC(sha512_transform_rorx)
14703
14704diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
14705index e610e29..ffcb5ed 100644
14706--- a/arch/x86/crypto/sha512-ssse3-asm.S
14707+++ b/arch/x86/crypto/sha512-ssse3-asm.S
14708@@ -48,6 +48,7 @@
14709 ########################################################################
14710
14711 #include <linux/linkage.h>
14712+#include <asm/alternative-asm.h>
14713
14714 .text
14715
14716@@ -363,6 +364,7 @@ updateblock:
14717 mov frame_RSPSAVE(%rsp), %rsp
14718
14719 nowork:
14720+ pax_force_retaddr
14721 ret
14722 ENDPROC(sha512_transform_ssse3)
14723
14724diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14725index 0505813..b067311 100644
14726--- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14727+++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14728@@ -24,6 +24,7 @@
14729 */
14730
14731 #include <linux/linkage.h>
14732+#include <asm/alternative-asm.h>
14733 #include "glue_helper-asm-avx.S"
14734
14735 .file "twofish-avx-x86_64-asm_64.S"
14736@@ -284,6 +285,7 @@ __twofish_enc_blk8:
14737 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
14738 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
14739
14740+ pax_force_retaddr
14741 ret;
14742 ENDPROC(__twofish_enc_blk8)
14743
14744@@ -324,6 +326,7 @@ __twofish_dec_blk8:
14745 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
14746 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
14747
14748+ pax_force_retaddr
14749 ret;
14750 ENDPROC(__twofish_dec_blk8)
14751
14752@@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
14753
14754 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14755
14756+ pax_force_retaddr
14757 ret;
14758 ENDPROC(twofish_ecb_enc_8way)
14759
14760@@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
14761
14762 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14763
14764+ pax_force_retaddr
14765 ret;
14766 ENDPROC(twofish_ecb_dec_8way)
14767
14768@@ -370,19 +375,20 @@ ENTRY(twofish_cbc_dec_8way)
14769 * %rdx: src
14770 */
14771
14772- pushq %r12;
14773+ pushq %r14;
14774
14775 movq %rsi, %r11;
14776- movq %rdx, %r12;
14777+ movq %rdx, %r14;
14778
14779 load_8way(%rdx, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14780
14781 call __twofish_dec_blk8;
14782
14783- store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14784+ store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14785
14786- popq %r12;
14787+ popq %r14;
14788
14789+ pax_force_retaddr
14790 ret;
14791 ENDPROC(twofish_cbc_dec_8way)
14792
14793@@ -394,20 +400,21 @@ ENTRY(twofish_ctr_8way)
14794 * %rcx: iv (little endian, 128bit)
14795 */
14796
14797- pushq %r12;
14798+ pushq %r14;
14799
14800 movq %rsi, %r11;
14801- movq %rdx, %r12;
14802+ movq %rdx, %r14;
14803
14804 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
14805 RD2, RX0, RX1, RY0);
14806
14807 call __twofish_enc_blk8;
14808
14809- store_ctr_8way(%r12, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14810+ store_ctr_8way(%r14, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14811
14812- popq %r12;
14813+ popq %r14;
14814
14815+ pax_force_retaddr
14816 ret;
14817 ENDPROC(twofish_ctr_8way)
14818
14819@@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
14820 /* dst <= regs xor IVs(in dst) */
14821 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14822
14823+ pax_force_retaddr
14824 ret;
14825 ENDPROC(twofish_xts_enc_8way)
14826
14827@@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
14828 /* dst <= regs xor IVs(in dst) */
14829 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14830
14831+ pax_force_retaddr
14832 ret;
14833 ENDPROC(twofish_xts_dec_8way)
14834diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14835index 1c3b7ce..02f578d 100644
14836--- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14837+++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14838@@ -21,6 +21,7 @@
14839 */
14840
14841 #include <linux/linkage.h>
14842+#include <asm/alternative-asm.h>
14843
14844 .file "twofish-x86_64-asm-3way.S"
14845 .text
14846@@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
14847 popq %r13;
14848 popq %r14;
14849 popq %r15;
14850+ pax_force_retaddr
14851 ret;
14852
14853 .L__enc_xor3:
14854@@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
14855 popq %r13;
14856 popq %r14;
14857 popq %r15;
14858+ pax_force_retaddr
14859 ret;
14860 ENDPROC(__twofish_enc_blk_3way)
14861
14862@@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
14863 popq %r13;
14864 popq %r14;
14865 popq %r15;
14866+ pax_force_retaddr
14867 ret;
14868 ENDPROC(twofish_dec_blk_3way)
14869diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
14870index a350c99..c1bac24 100644
14871--- a/arch/x86/crypto/twofish-x86_64-asm_64.S
14872+++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
14873@@ -22,6 +22,7 @@
14874
14875 #include <linux/linkage.h>
14876 #include <asm/asm-offsets.h>
14877+#include <asm/alternative-asm.h>
14878
14879 #define a_offset 0
14880 #define b_offset 4
14881@@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
14882
14883 popq R1
14884 movl $1,%eax
14885+ pax_force_retaddr
14886 ret
14887 ENDPROC(twofish_enc_blk)
14888
14889@@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
14890
14891 popq R1
14892 movl $1,%eax
14893+ pax_force_retaddr
14894 ret
14895 ENDPROC(twofish_dec_blk)
14896diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h
14897index f4e6308..7ba29a1 100644
14898--- a/arch/x86/entry/calling.h
14899+++ b/arch/x86/entry/calling.h
14900@@ -93,23 +93,26 @@ For 32-bit we have the following conventions - kernel is built with
14901 .endm
14902
14903 .macro SAVE_C_REGS_HELPER offset=0 rax=1 rcx=1 r8910=1 r11=1
14904+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14905+ movq %r12, R12+\offset(%rsp)
14906+#endif
14907 .if \r11
14908- movq %r11, 6*8+\offset(%rsp)
14909+ movq %r11, R11+\offset(%rsp)
14910 .endif
14911 .if \r8910
14912- movq %r10, 7*8+\offset(%rsp)
14913- movq %r9, 8*8+\offset(%rsp)
14914- movq %r8, 9*8+\offset(%rsp)
14915+ movq %r10, R10+\offset(%rsp)
14916+ movq %r9, R9+\offset(%rsp)
14917+ movq %r8, R8+\offset(%rsp)
14918 .endif
14919 .if \rax
14920- movq %rax, 10*8+\offset(%rsp)
14921+ movq %rax, RAX+\offset(%rsp)
14922 .endif
14923 .if \rcx
14924- movq %rcx, 11*8+\offset(%rsp)
14925+ movq %rcx, RCX+\offset(%rsp)
14926 .endif
14927- movq %rdx, 12*8+\offset(%rsp)
14928- movq %rsi, 13*8+\offset(%rsp)
14929- movq %rdi, 14*8+\offset(%rsp)
14930+ movq %rdx, RDX+\offset(%rsp)
14931+ movq %rsi, RSI+\offset(%rsp)
14932+ movq %rdi, RDI+\offset(%rsp)
14933 .endm
14934 .macro SAVE_C_REGS offset=0
14935 SAVE_C_REGS_HELPER \offset, 1, 1, 1, 1
14936@@ -128,76 +131,87 @@ For 32-bit we have the following conventions - kernel is built with
14937 .endm
14938
14939 .macro SAVE_EXTRA_REGS offset=0
14940- movq %r15, 0*8+\offset(%rsp)
14941- movq %r14, 1*8+\offset(%rsp)
14942- movq %r13, 2*8+\offset(%rsp)
14943- movq %r12, 3*8+\offset(%rsp)
14944- movq %rbp, 4*8+\offset(%rsp)
14945- movq %rbx, 5*8+\offset(%rsp)
14946+ movq %r15, R15+\offset(%rsp)
14947+ movq %r14, R14+\offset(%rsp)
14948+ movq %r13, R13+\offset(%rsp)
14949+#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14950+ movq %r12, R12+\offset(%rsp)
14951+#endif
14952+ movq %rbp, RBP+\offset(%rsp)
14953+ movq %rbx, RBX+\offset(%rsp)
14954 .endm
14955 .macro SAVE_EXTRA_REGS_RBP offset=0
14956- movq %rbp, 4*8+\offset(%rsp)
14957+ movq %rbp, RBP+\offset(%rsp)
14958 .endm
14959
14960 .macro RESTORE_EXTRA_REGS offset=0
14961- movq 0*8+\offset(%rsp), %r15
14962- movq 1*8+\offset(%rsp), %r14
14963- movq 2*8+\offset(%rsp), %r13
14964- movq 3*8+\offset(%rsp), %r12
14965- movq 4*8+\offset(%rsp), %rbp
14966- movq 5*8+\offset(%rsp), %rbx
14967+ movq R15+\offset(%rsp), %r15
14968+ movq R14+\offset(%rsp), %r14
14969+ movq R13+\offset(%rsp), %r13
14970+#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14971+ movq R12+\offset(%rsp), %r12
14972+#endif
14973+ movq RBP+\offset(%rsp), %rbp
14974+ movq RBX+\offset(%rsp), %rbx
14975 .endm
14976
14977 .macro ZERO_EXTRA_REGS
14978 xorl %r15d, %r15d
14979 xorl %r14d, %r14d
14980 xorl %r13d, %r13d
14981+#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14982 xorl %r12d, %r12d
14983+#endif
14984 xorl %ebp, %ebp
14985 xorl %ebx, %ebx
14986 .endm
14987
14988- .macro RESTORE_C_REGS_HELPER rstor_rax=1, rstor_rcx=1, rstor_r11=1, rstor_r8910=1, rstor_rdx=1
14989+ .macro RESTORE_C_REGS_HELPER rstor_rax=1, rstor_rcx=1, rstor_r11=1, rstor_r8910=1, rstor_rdx=1, rstor_r12=1
14990+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14991+ .if \rstor_r12
14992+ movq R12(%rsp), %r12
14993+ .endif
14994+#endif
14995 .if \rstor_r11
14996- movq 6*8(%rsp), %r11
14997+ movq R11(%rsp), %r11
14998 .endif
14999 .if \rstor_r8910
15000- movq 7*8(%rsp), %r10
15001- movq 8*8(%rsp), %r9
15002- movq 9*8(%rsp), %r8
15003+ movq R10(%rsp), %r10
15004+ movq R9(%rsp), %r9
15005+ movq R8(%rsp), %r8
15006 .endif
15007 .if \rstor_rax
15008- movq 10*8(%rsp), %rax
15009+ movq RAX(%rsp), %rax
15010 .endif
15011 .if \rstor_rcx
15012- movq 11*8(%rsp), %rcx
15013+ movq RCX(%rsp), %rcx
15014 .endif
15015 .if \rstor_rdx
15016- movq 12*8(%rsp), %rdx
15017+ movq RDX(%rsp), %rdx
15018 .endif
15019- movq 13*8(%rsp), %rsi
15020- movq 14*8(%rsp), %rdi
15021+ movq RSI(%rsp), %rsi
15022+ movq RDI(%rsp), %rdi
15023 .endm
15024 .macro RESTORE_C_REGS
15025- RESTORE_C_REGS_HELPER 1,1,1,1,1
15026+ RESTORE_C_REGS_HELPER 1,1,1,1,1,1
15027 .endm
15028 .macro RESTORE_C_REGS_EXCEPT_RAX
15029- RESTORE_C_REGS_HELPER 0,1,1,1,1
15030+ RESTORE_C_REGS_HELPER 0,1,1,1,1,0
15031 .endm
15032 .macro RESTORE_C_REGS_EXCEPT_RCX
15033- RESTORE_C_REGS_HELPER 1,0,1,1,1
15034+ RESTORE_C_REGS_HELPER 1,0,1,1,1,0
15035 .endm
15036 .macro RESTORE_C_REGS_EXCEPT_R11
15037- RESTORE_C_REGS_HELPER 1,1,0,1,1
15038+ RESTORE_C_REGS_HELPER 1,1,0,1,1,1
15039 .endm
15040 .macro RESTORE_C_REGS_EXCEPT_RCX_R11
15041- RESTORE_C_REGS_HELPER 1,0,0,1,1
15042+ RESTORE_C_REGS_HELPER 1,0,0,1,1,1
15043 .endm
15044 .macro RESTORE_RSI_RDI
15045- RESTORE_C_REGS_HELPER 0,0,0,0,0
15046+ RESTORE_C_REGS_HELPER 0,0,0,0,0,1
15047 .endm
15048 .macro RESTORE_RSI_RDI_RDX
15049- RESTORE_C_REGS_HELPER 0,0,0,0,1
15050+ RESTORE_C_REGS_HELPER 0,0,0,0,1,1
15051 .endm
15052
15053 .macro REMOVE_PT_GPREGS_FROM_STACK addskip=0
15054diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
15055index 21dc60a..844def1 100644
15056--- a/arch/x86/entry/entry_32.S
15057+++ b/arch/x86/entry/entry_32.S
15058@@ -157,13 +157,154 @@
15059 movl \reg, PT_GS(%esp)
15060 .endm
15061 .macro SET_KERNEL_GS reg
15062+
15063+#ifdef CONFIG_CC_STACKPROTECTOR
15064 movl $(__KERNEL_STACK_CANARY), \reg
15065+#elif defined(CONFIG_PAX_MEMORY_UDEREF)
15066+ movl $(__USER_DS), \reg
15067+#else
15068+ xorl \reg, \reg
15069+#endif
15070+
15071 movl \reg, %gs
15072 .endm
15073
15074 #endif /* CONFIG_X86_32_LAZY_GS */
15075
15076-.macro SAVE_ALL
15077+.macro pax_enter_kernel
15078+#ifdef CONFIG_PAX_KERNEXEC
15079+ call pax_enter_kernel
15080+#endif
15081+.endm
15082+
15083+.macro pax_exit_kernel
15084+#ifdef CONFIG_PAX_KERNEXEC
15085+ call pax_exit_kernel
15086+#endif
15087+.endm
15088+
15089+#ifdef CONFIG_PAX_KERNEXEC
15090+ENTRY(pax_enter_kernel)
15091+#ifdef CONFIG_PARAVIRT
15092+ pushl %eax
15093+ pushl %ecx
15094+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
15095+ mov %eax, %esi
15096+#else
15097+ mov %cr0, %esi
15098+#endif
15099+ bts $X86_CR0_WP_BIT, %esi
15100+ jnc 1f
15101+ mov %cs, %esi
15102+ cmp $__KERNEL_CS, %esi
15103+ jz 3f
15104+ ljmp $__KERNEL_CS, $3f
15105+1: ljmp $__KERNEXEC_KERNEL_CS, $2f
15106+2:
15107+#ifdef CONFIG_PARAVIRT
15108+ mov %esi, %eax
15109+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
15110+#else
15111+ mov %esi, %cr0
15112+#endif
15113+3:
15114+#ifdef CONFIG_PARAVIRT
15115+ popl %ecx
15116+ popl %eax
15117+#endif
15118+ ret
15119+ENDPROC(pax_enter_kernel)
15120+
15121+ENTRY(pax_exit_kernel)
15122+#ifdef CONFIG_PARAVIRT
15123+ pushl %eax
15124+ pushl %ecx
15125+#endif
15126+ mov %cs, %esi
15127+ cmp $__KERNEXEC_KERNEL_CS, %esi
15128+ jnz 2f
15129+#ifdef CONFIG_PARAVIRT
15130+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
15131+ mov %eax, %esi
15132+#else
15133+ mov %cr0, %esi
15134+#endif
15135+ btr $X86_CR0_WP_BIT, %esi
15136+ ljmp $__KERNEL_CS, $1f
15137+1:
15138+#ifdef CONFIG_PARAVIRT
15139+ mov %esi, %eax
15140+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
15141+#else
15142+ mov %esi, %cr0
15143+#endif
15144+2:
15145+#ifdef CONFIG_PARAVIRT
15146+ popl %ecx
15147+ popl %eax
15148+#endif
15149+ ret
15150+ENDPROC(pax_exit_kernel)
15151+#endif
15152+
15153+ .macro pax_erase_kstack
15154+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
15155+ call pax_erase_kstack
15156+#endif
15157+ .endm
15158+
15159+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
15160+/*
15161+ * ebp: thread_info
15162+ */
15163+ENTRY(pax_erase_kstack)
15164+ pushl %edi
15165+ pushl %ecx
15166+ pushl %eax
15167+
15168+ mov TI_lowest_stack(%ebp), %edi
15169+ mov $-0xBEEF, %eax
15170+ std
15171+
15172+1: mov %edi, %ecx
15173+ and $THREAD_SIZE_asm - 1, %ecx
15174+ shr $2, %ecx
15175+ repne scasl
15176+ jecxz 2f
15177+
15178+ cmp $2*16, %ecx
15179+ jc 2f
15180+
15181+ mov $2*16, %ecx
15182+ repe scasl
15183+ jecxz 2f
15184+ jne 1b
15185+
15186+2: cld
15187+ or $2*4, %edi
15188+ mov %esp, %ecx
15189+ sub %edi, %ecx
15190+
15191+ cmp $THREAD_SIZE_asm, %ecx
15192+ jb 3f
15193+ ud2
15194+3:
15195+
15196+ shr $2, %ecx
15197+ rep stosl
15198+
15199+ mov TI_task_thread_sp0(%ebp), %edi
15200+ sub $128, %edi
15201+ mov %edi, TI_lowest_stack(%ebp)
15202+
15203+ popl %eax
15204+ popl %ecx
15205+ popl %edi
15206+ ret
15207+ENDPROC(pax_erase_kstack)
15208+#endif
15209+
15210+.macro __SAVE_ALL _DS
15211 cld
15212 PUSH_GS
15213 pushl %fs
15214@@ -176,7 +317,7 @@
15215 pushl %edx
15216 pushl %ecx
15217 pushl %ebx
15218- movl $(__USER_DS), %edx
15219+ movl $\_DS, %edx
15220 movl %edx, %ds
15221 movl %edx, %es
15222 movl $(__KERNEL_PERCPU), %edx
15223@@ -184,6 +325,15 @@
15224 SET_KERNEL_GS %edx
15225 .endm
15226
15227+.macro SAVE_ALL
15228+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
15229+ __SAVE_ALL __KERNEL_DS
15230+ pax_enter_kernel
15231+#else
15232+ __SAVE_ALL __USER_DS
15233+#endif
15234+.endm
15235+
15236 .macro RESTORE_INT_REGS
15237 popl %ebx
15238 popl %ecx
15239@@ -222,7 +372,7 @@ ENTRY(ret_from_fork)
15240 pushl $0x0202 # Reset kernel eflags
15241 popfl
15242 jmp syscall_exit
15243-END(ret_from_fork)
15244+ENDPROC(ret_from_fork)
15245
15246 ENTRY(ret_from_kernel_thread)
15247 pushl %eax
15248@@ -262,7 +412,15 @@ ret_from_intr:
15249 andl $SEGMENT_RPL_MASK, %eax
15250 #endif
15251 cmpl $USER_RPL, %eax
15252+
15253+#ifdef CONFIG_PAX_KERNEXEC
15254+ jae resume_userspace
15255+
15256+ pax_exit_kernel
15257+ jmp resume_kernel
15258+#else
15259 jb resume_kernel # not returning to v8086 or userspace
15260+#endif
15261
15262 ENTRY(resume_userspace)
15263 LOCKDEP_SYS_EXIT
15264@@ -274,8 +432,8 @@ ENTRY(resume_userspace)
15265 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
15266 # int/exception return?
15267 jne work_pending
15268- jmp restore_all
15269-END(ret_from_exception)
15270+ jmp restore_all_pax
15271+ENDPROC(ret_from_exception)
15272
15273 #ifdef CONFIG_PREEMPT
15274 ENTRY(resume_kernel)
15275@@ -287,7 +445,7 @@ need_resched:
15276 jz restore_all
15277 call preempt_schedule_irq
15278 jmp need_resched
15279-END(resume_kernel)
15280+ENDPROC(resume_kernel)
15281 #endif
15282
15283 /*
15284@@ -312,32 +470,44 @@ sysenter_past_esp:
15285 pushl $__USER_CS
15286 /*
15287 * Push current_thread_info()->sysenter_return to the stack.
15288- * A tiny bit of offset fixup is necessary: TI_sysenter_return
15289- * is relative to thread_info, which is at the bottom of the
15290- * kernel stack page. 4*4 means the 4 words pushed above;
15291- * TOP_OF_KERNEL_STACK_PADDING takes us to the top of the stack;
15292- * and THREAD_SIZE takes us to the bottom.
15293 */
15294- pushl ((TI_sysenter_return) - THREAD_SIZE + TOP_OF_KERNEL_STACK_PADDING + 4*4)(%esp)
15295+ pushl $0
15296
15297 pushl %eax
15298 SAVE_ALL
15299+ GET_THREAD_INFO(%ebp)
15300+ movl TI_sysenter_return(%ebp), %ebp
15301+ movl %ebp, PT_EIP(%esp)
15302 ENABLE_INTERRUPTS(CLBR_NONE)
15303
15304 /*
15305 * Load the potential sixth argument from user stack.
15306 * Careful about security.
15307 */
15308+ movl PT_OLDESP(%esp),%ebp
15309+
15310+#ifdef CONFIG_PAX_MEMORY_UDEREF
15311+ mov PT_OLDSS(%esp), %ds
15312+1: movl %ds:(%ebp), %ebp
15313+ push %ss
15314+ pop %ds
15315+#else
15316 cmpl $__PAGE_OFFSET-3, %ebp
15317 jae syscall_fault
15318 ASM_STAC
15319 1: movl (%ebp), %ebp
15320 ASM_CLAC
15321+#endif
15322+
15323 movl %ebp, PT_EBP(%esp)
15324 _ASM_EXTABLE(1b, syscall_fault)
15325
15326 GET_THREAD_INFO(%ebp)
15327
15328+#ifdef CONFIG_PAX_RANDKSTACK
15329+ pax_erase_kstack
15330+#endif
15331+
15332 testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%ebp)
15333 jnz sysenter_audit
15334 sysenter_do_call:
15335@@ -353,12 +523,24 @@ sysenter_after_call:
15336 testl $_TIF_ALLWORK_MASK, %ecx
15337 jnz sysexit_audit
15338 sysenter_exit:
15339+
15340+#ifdef CONFIG_PAX_RANDKSTACK
15341+ pushl %eax
15342+ movl %esp, %eax
15343+ call pax_randomize_kstack
15344+ popl %eax
15345+#endif
15346+
15347+ pax_erase_kstack
15348+
15349 /* if something modifies registers it must also disable sysexit */
15350 movl PT_EIP(%esp), %edx
15351 movl PT_OLDESP(%esp), %ecx
15352 xorl %ebp, %ebp
15353 TRACE_IRQS_ON
15354 1: mov PT_FS(%esp), %fs
15355+2: mov PT_DS(%esp), %ds
15356+3: mov PT_ES(%esp), %es
15357 PTGS_TO_GS
15358 ENABLE_INTERRUPTS_SYSEXIT
15359
15360@@ -372,6 +554,9 @@ sysenter_audit:
15361 pushl PT_ESI(%esp) /* a3: 5th arg */
15362 pushl PT_EDX+4(%esp) /* a2: 4th arg */
15363 call __audit_syscall_entry
15364+
15365+ pax_erase_kstack
15366+
15367 popl %ecx /* get that remapped edx off the stack */
15368 popl %ecx /* get that remapped esi off the stack */
15369 movl PT_EAX(%esp), %eax /* reload syscall number */
15370@@ -397,10 +582,16 @@ sysexit_audit:
15371 #endif
15372
15373 .pushsection .fixup, "ax"
15374-2: movl $0, PT_FS(%esp)
15375+4: movl $0, PT_FS(%esp)
15376+ jmp 1b
15377+5: movl $0, PT_DS(%esp)
15378+ jmp 1b
15379+6: movl $0, PT_ES(%esp)
15380 jmp 1b
15381 .popsection
15382- _ASM_EXTABLE(1b, 2b)
15383+ _ASM_EXTABLE(1b, 4b)
15384+ _ASM_EXTABLE(2b, 5b)
15385+ _ASM_EXTABLE(3b, 6b)
15386 PTGS_TO_GS_EX
15387 ENDPROC(entry_SYSENTER_32)
15388
15389@@ -410,6 +601,11 @@ ENTRY(entry_INT80_32)
15390 pushl %eax # save orig_eax
15391 SAVE_ALL
15392 GET_THREAD_INFO(%ebp)
15393+
15394+#ifdef CONFIG_PAX_RANDKSTACK
15395+ pax_erase_kstack
15396+#endif
15397+
15398 # system call tracing in operation / emulation
15399 testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%ebp)
15400 jnz syscall_trace_entry
15401@@ -429,6 +625,15 @@ syscall_exit:
15402 testl $_TIF_ALLWORK_MASK, %ecx # current->work
15403 jnz syscall_exit_work
15404
15405+restore_all_pax:
15406+
15407+#ifdef CONFIG_PAX_RANDKSTACK
15408+ movl %esp, %eax
15409+ call pax_randomize_kstack
15410+#endif
15411+
15412+ pax_erase_kstack
15413+
15414 restore_all:
15415 TRACE_IRQS_IRET
15416 restore_all_notrace:
15417@@ -483,14 +688,34 @@ ldt_ss:
15418 * compensating for the offset by changing to the ESPFIX segment with
15419 * a base address that matches for the difference.
15420 */
15421-#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
15422+#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
15423 mov %esp, %edx /* load kernel esp */
15424 mov PT_OLDESP(%esp), %eax /* load userspace esp */
15425 mov %dx, %ax /* eax: new kernel esp */
15426 sub %eax, %edx /* offset (low word is 0) */
15427+#ifdef CONFIG_SMP
15428+ movl PER_CPU_VAR(cpu_number), %ebx
15429+ shll $PAGE_SHIFT_asm, %ebx
15430+ addl $cpu_gdt_table, %ebx
15431+#else
15432+ movl $cpu_gdt_table, %ebx
15433+#endif
15434 shr $16, %edx
15435- mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
15436- mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
15437+
15438+#ifdef CONFIG_PAX_KERNEXEC
15439+ mov %cr0, %esi
15440+ btr $X86_CR0_WP_BIT, %esi
15441+ mov %esi, %cr0
15442+#endif
15443+
15444+ mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
15445+ mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
15446+
15447+#ifdef CONFIG_PAX_KERNEXEC
15448+ bts $X86_CR0_WP_BIT, %esi
15449+ mov %esi, %cr0
15450+#endif
15451+
15452 pushl $__ESPFIX_SS
15453 pushl %eax /* new kernel esp */
15454 /*
15455@@ -519,20 +744,18 @@ work_resched:
15456 movl TI_flags(%ebp), %ecx
15457 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
15458 # than syscall tracing?
15459- jz restore_all
15460+ jz restore_all_pax
15461 testb $_TIF_NEED_RESCHED, %cl
15462 jnz work_resched
15463
15464 work_notifysig: # deal with pending signals and
15465 # notify-resume requests
15466+ movl %esp, %eax
15467 #ifdef CONFIG_VM86
15468 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
15469- movl %esp, %eax
15470 jnz work_notifysig_v86 # returning to kernel-space or
15471 # vm86-space
15472 1:
15473-#else
15474- movl %esp, %eax
15475 #endif
15476 TRACE_IRQS_ON
15477 ENABLE_INTERRUPTS(CLBR_NONE)
15478@@ -553,7 +776,7 @@ work_notifysig_v86:
15479 movl %eax, %esp
15480 jmp 1b
15481 #endif
15482-END(work_pending)
15483+ENDPROC(work_pending)
15484
15485 # perform syscall exit tracing
15486 ALIGN
15487@@ -561,11 +784,14 @@ syscall_trace_entry:
15488 movl $-ENOSYS, PT_EAX(%esp)
15489 movl %esp, %eax
15490 call syscall_trace_enter
15491+
15492+ pax_erase_kstack
15493+
15494 /* What it returned is what we'll actually use. */
15495 cmpl $(NR_syscalls), %eax
15496 jnae syscall_call
15497 jmp syscall_exit
15498-END(syscall_trace_entry)
15499+ENDPROC(syscall_trace_entry)
15500
15501 # perform syscall exit tracing
15502 ALIGN
15503@@ -578,24 +804,28 @@ syscall_exit_work:
15504 movl %esp, %eax
15505 call syscall_trace_leave
15506 jmp resume_userspace
15507-END(syscall_exit_work)
15508+ENDPROC(syscall_exit_work)
15509
15510 syscall_fault:
15511+#ifdef CONFIG_PAX_MEMORY_UDEREF
15512+ push %ss
15513+ pop %ds
15514+#endif
15515 ASM_CLAC
15516 GET_THREAD_INFO(%ebp)
15517 movl $-EFAULT, PT_EAX(%esp)
15518 jmp resume_userspace
15519-END(syscall_fault)
15520+ENDPROC(syscall_fault)
15521
15522 syscall_badsys:
15523 movl $-ENOSYS, %eax
15524 jmp syscall_after_call
15525-END(syscall_badsys)
15526+ENDPROC(syscall_badsys)
15527
15528 sysenter_badsys:
15529 movl $-ENOSYS, %eax
15530 jmp sysenter_after_call
15531-END(sysenter_badsys)
15532+ENDPROC(sysenter_badsys)
15533
15534 .macro FIXUP_ESPFIX_STACK
15535 /*
15536@@ -607,8 +837,15 @@ END(sysenter_badsys)
15537 */
15538 #ifdef CONFIG_X86_ESPFIX32
15539 /* fixup the stack */
15540- mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
15541- mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
15542+#ifdef CONFIG_SMP
15543+ movl PER_CPU_VAR(cpu_number), %ebx
15544+ shll $PAGE_SHIFT_asm, %ebx
15545+ addl $cpu_gdt_table, %ebx
15546+#else
15547+ movl $cpu_gdt_table, %ebx
15548+#endif
15549+ mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
15550+ mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
15551 shl $16, %eax
15552 addl %esp, %eax /* the adjusted stack pointer */
15553 pushl $__KERNEL_DS
15554@@ -644,7 +881,7 @@ ENTRY(irq_entries_start)
15555 jmp common_interrupt
15556 .align 8
15557 .endr
15558-END(irq_entries_start)
15559+ENDPROC(irq_entries_start)
15560
15561 /*
15562 * the CPU automatically disables interrupts when executing an IRQ vector,
15563@@ -691,7 +928,7 @@ ENTRY(coprocessor_error)
15564 pushl $0
15565 pushl $do_coprocessor_error
15566 jmp error_code
15567-END(coprocessor_error)
15568+ENDPROC(coprocessor_error)
15569
15570 ENTRY(simd_coprocessor_error)
15571 ASM_CLAC
15572@@ -705,25 +942,25 @@ ENTRY(simd_coprocessor_error)
15573 pushl $do_simd_coprocessor_error
15574 #endif
15575 jmp error_code
15576-END(simd_coprocessor_error)
15577+ENDPROC(simd_coprocessor_error)
15578
15579 ENTRY(device_not_available)
15580 ASM_CLAC
15581 pushl $-1 # mark this as an int
15582 pushl $do_device_not_available
15583 jmp error_code
15584-END(device_not_available)
15585+ENDPROC(device_not_available)
15586
15587 #ifdef CONFIG_PARAVIRT
15588 ENTRY(native_iret)
15589 iret
15590 _ASM_EXTABLE(native_iret, iret_exc)
15591-END(native_iret)
15592+ENDPROC(native_iret)
15593
15594 ENTRY(native_irq_enable_sysexit)
15595 sti
15596 sysexit
15597-END(native_irq_enable_sysexit)
15598+ENDPROC(native_irq_enable_sysexit)
15599 #endif
15600
15601 ENTRY(overflow)
15602@@ -731,59 +968,59 @@ ENTRY(overflow)
15603 pushl $0
15604 pushl $do_overflow
15605 jmp error_code
15606-END(overflow)
15607+ENDPROC(overflow)
15608
15609 ENTRY(bounds)
15610 ASM_CLAC
15611 pushl $0
15612 pushl $do_bounds
15613 jmp error_code
15614-END(bounds)
15615+ENDPROC(bounds)
15616
15617 ENTRY(invalid_op)
15618 ASM_CLAC
15619 pushl $0
15620 pushl $do_invalid_op
15621 jmp error_code
15622-END(invalid_op)
15623+ENDPROC(invalid_op)
15624
15625 ENTRY(coprocessor_segment_overrun)
15626 ASM_CLAC
15627 pushl $0
15628 pushl $do_coprocessor_segment_overrun
15629 jmp error_code
15630-END(coprocessor_segment_overrun)
15631+ENDPROC(coprocessor_segment_overrun)
15632
15633 ENTRY(invalid_TSS)
15634 ASM_CLAC
15635 pushl $do_invalid_TSS
15636 jmp error_code
15637-END(invalid_TSS)
15638+ENDPROC(invalid_TSS)
15639
15640 ENTRY(segment_not_present)
15641 ASM_CLAC
15642 pushl $do_segment_not_present
15643 jmp error_code
15644-END(segment_not_present)
15645+ENDPROC(segment_not_present)
15646
15647 ENTRY(stack_segment)
15648 ASM_CLAC
15649 pushl $do_stack_segment
15650 jmp error_code
15651-END(stack_segment)
15652+ENDPROC(stack_segment)
15653
15654 ENTRY(alignment_check)
15655 ASM_CLAC
15656 pushl $do_alignment_check
15657 jmp error_code
15658-END(alignment_check)
15659+ENDPROC(alignment_check)
15660
15661 ENTRY(divide_error)
15662 ASM_CLAC
15663 pushl $0 # no error code
15664 pushl $do_divide_error
15665 jmp error_code
15666-END(divide_error)
15667+ENDPROC(divide_error)
15668
15669 #ifdef CONFIG_X86_MCE
15670 ENTRY(machine_check)
15671@@ -791,7 +1028,7 @@ ENTRY(machine_check)
15672 pushl $0
15673 pushl machine_check_vector
15674 jmp error_code
15675-END(machine_check)
15676+ENDPROC(machine_check)
15677 #endif
15678
15679 ENTRY(spurious_interrupt_bug)
15680@@ -799,7 +1036,7 @@ ENTRY(spurious_interrupt_bug)
15681 pushl $0
15682 pushl $do_spurious_interrupt_bug
15683 jmp error_code
15684-END(spurious_interrupt_bug)
15685+ENDPROC(spurious_interrupt_bug)
15686
15687 #ifdef CONFIG_XEN
15688 /*
15689@@ -906,7 +1143,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
15690
15691 ENTRY(mcount)
15692 ret
15693-END(mcount)
15694+ENDPROC(mcount)
15695
15696 ENTRY(ftrace_caller)
15697 pushl %eax
15698@@ -936,7 +1173,7 @@ ftrace_graph_call:
15699 .globl ftrace_stub
15700 ftrace_stub:
15701 ret
15702-END(ftrace_caller)
15703+ENDPROC(ftrace_caller)
15704
15705 ENTRY(ftrace_regs_caller)
15706 pushf /* push flags before compare (in cs location) */
15707@@ -1034,7 +1271,7 @@ trace:
15708 popl %ecx
15709 popl %eax
15710 jmp ftrace_stub
15711-END(mcount)
15712+ENDPROC(mcount)
15713 #endif /* CONFIG_DYNAMIC_FTRACE */
15714 #endif /* CONFIG_FUNCTION_TRACER */
15715
15716@@ -1052,7 +1289,7 @@ ENTRY(ftrace_graph_caller)
15717 popl %ecx
15718 popl %eax
15719 ret
15720-END(ftrace_graph_caller)
15721+ENDPROC(ftrace_graph_caller)
15722
15723 .globl return_to_handler
15724 return_to_handler:
15725@@ -1100,14 +1337,17 @@ error_code:
15726 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
15727 REG_TO_PTGS %ecx
15728 SET_KERNEL_GS %ecx
15729- movl $(__USER_DS), %ecx
15730+ movl $(__KERNEL_DS), %ecx
15731 movl %ecx, %ds
15732 movl %ecx, %es
15733+
15734+ pax_enter_kernel
15735+
15736 TRACE_IRQS_OFF
15737 movl %esp, %eax # pt_regs pointer
15738 call *%edi
15739 jmp ret_from_exception
15740-END(page_fault)
15741+ENDPROC(page_fault)
15742
15743 /*
15744 * Debug traps and NMI can happen at the one SYSENTER instruction
15745@@ -1145,7 +1385,7 @@ debug_stack_correct:
15746 movl %esp, %eax # pt_regs pointer
15747 call do_debug
15748 jmp ret_from_exception
15749-END(debug)
15750+ENDPROC(debug)
15751
15752 /*
15753 * NMI is doubly nasty. It can happen _while_ we're handling
15754@@ -1184,6 +1424,9 @@ nmi_stack_correct:
15755 xorl %edx, %edx # zero error code
15756 movl %esp, %eax # pt_regs pointer
15757 call do_nmi
15758+
15759+ pax_exit_kernel
15760+
15761 jmp restore_all_notrace
15762
15763 nmi_stack_fixup:
15764@@ -1217,11 +1460,14 @@ nmi_espfix_stack:
15765 FIXUP_ESPFIX_STACK # %eax == %esp
15766 xorl %edx, %edx # zero error code
15767 call do_nmi
15768+
15769+ pax_exit_kernel
15770+
15771 RESTORE_REGS
15772 lss 12+4(%esp), %esp # back to espfix stack
15773 jmp irq_return
15774 #endif
15775-END(nmi)
15776+ENDPROC(nmi)
15777
15778 ENTRY(int3)
15779 ASM_CLAC
15780@@ -1232,17 +1478,17 @@ ENTRY(int3)
15781 movl %esp, %eax # pt_regs pointer
15782 call do_int3
15783 jmp ret_from_exception
15784-END(int3)
15785+ENDPROC(int3)
15786
15787 ENTRY(general_protection)
15788 pushl $do_general_protection
15789 jmp error_code
15790-END(general_protection)
15791+ENDPROC(general_protection)
15792
15793 #ifdef CONFIG_KVM_GUEST
15794 ENTRY(async_page_fault)
15795 ASM_CLAC
15796 pushl $do_async_page_fault
15797 jmp error_code
15798-END(async_page_fault)
15799+ENDPROC(async_page_fault)
15800 #endif
15801diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
15802index d330840..4f1925e 100644
15803--- a/arch/x86/entry/entry_64.S
15804+++ b/arch/x86/entry/entry_64.S
15805@@ -37,6 +37,8 @@
15806 #include <asm/smap.h>
15807 #include <asm/pgtable_types.h>
15808 #include <linux/err.h>
15809+#include <asm/pgtable.h>
15810+#include <asm/alternative-asm.h>
15811
15812 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
15813 #include <linux/elf-em.h>
15814@@ -54,6 +56,402 @@ ENTRY(native_usergs_sysret64)
15815 ENDPROC(native_usergs_sysret64)
15816 #endif /* CONFIG_PARAVIRT */
15817
15818+ .macro ljmpq sel, off
15819+#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
15820+ .byte 0x48; ljmp *1234f(%rip)
15821+ .pushsection .rodata
15822+ .align 16
15823+ 1234: .quad \off; .word \sel
15824+ .popsection
15825+#else
15826+ pushq $\sel
15827+ pushq $\off
15828+ lretq
15829+#endif
15830+ .endm
15831+
15832+ .macro pax_enter_kernel
15833+ pax_set_fptr_mask
15834+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
15835+ call pax_enter_kernel
15836+#endif
15837+ .endm
15838+
15839+ .macro pax_exit_kernel
15840+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
15841+ call pax_exit_kernel
15842+#endif
15843+ .endm
15844+
15845+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
15846+ENTRY(pax_enter_kernel)
15847+ pushq %rdi
15848+
15849+#ifdef CONFIG_PARAVIRT
15850+ PV_SAVE_REGS(CLBR_RDI)
15851+#endif
15852+
15853+#ifdef CONFIG_PAX_KERNEXEC
15854+ GET_CR0_INTO_RDI
15855+ bts $X86_CR0_WP_BIT,%rdi
15856+ jnc 3f
15857+ mov %cs,%edi
15858+ cmp $__KERNEL_CS,%edi
15859+ jnz 2f
15860+1:
15861+#endif
15862+
15863+#ifdef CONFIG_PAX_MEMORY_UDEREF
15864+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
15865+ GET_CR3_INTO_RDI
15866+ cmp $0,%dil
15867+ jnz 112f
15868+ mov $__KERNEL_DS,%edi
15869+ mov %edi,%ss
15870+ jmp 111f
15871+112: cmp $1,%dil
15872+ jz 113f
15873+ ud2
15874+113: sub $4097,%rdi
15875+ bts $63,%rdi
15876+ SET_RDI_INTO_CR3
15877+ mov $__UDEREF_KERNEL_DS,%edi
15878+ mov %edi,%ss
15879+111:
15880+#endif
15881+
15882+#ifdef CONFIG_PARAVIRT
15883+ PV_RESTORE_REGS(CLBR_RDI)
15884+#endif
15885+
15886+ popq %rdi
15887+ pax_force_retaddr
15888+ retq
15889+
15890+#ifdef CONFIG_PAX_KERNEXEC
15891+2: ljmpq __KERNEL_CS,1b
15892+3: ljmpq __KERNEXEC_KERNEL_CS,4f
15893+4: SET_RDI_INTO_CR0
15894+ jmp 1b
15895+#endif
15896+ENDPROC(pax_enter_kernel)
15897+
15898+ENTRY(pax_exit_kernel)
15899+ pushq %rdi
15900+
15901+#ifdef CONFIG_PARAVIRT
15902+ PV_SAVE_REGS(CLBR_RDI)
15903+#endif
15904+
15905+#ifdef CONFIG_PAX_KERNEXEC
15906+ mov %cs,%rdi
15907+ cmp $__KERNEXEC_KERNEL_CS,%edi
15908+ jz 2f
15909+ GET_CR0_INTO_RDI
15910+ bts $X86_CR0_WP_BIT,%rdi
15911+ jnc 4f
15912+1:
15913+#endif
15914+
15915+#ifdef CONFIG_PAX_MEMORY_UDEREF
15916+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
15917+ mov %ss,%edi
15918+ cmp $__UDEREF_KERNEL_DS,%edi
15919+ jnz 111f
15920+ GET_CR3_INTO_RDI
15921+ cmp $0,%dil
15922+ jz 112f
15923+ ud2
15924+112: add $4097,%rdi
15925+ bts $63,%rdi
15926+ SET_RDI_INTO_CR3
15927+ mov $__KERNEL_DS,%edi
15928+ mov %edi,%ss
15929+111:
15930+#endif
15931+
15932+#ifdef CONFIG_PARAVIRT
15933+ PV_RESTORE_REGS(CLBR_RDI);
15934+#endif
15935+
15936+ popq %rdi
15937+ pax_force_retaddr
15938+ retq
15939+
15940+#ifdef CONFIG_PAX_KERNEXEC
15941+2: GET_CR0_INTO_RDI
15942+ btr $X86_CR0_WP_BIT,%rdi
15943+ jnc 4f
15944+ ljmpq __KERNEL_CS,3f
15945+3: SET_RDI_INTO_CR0
15946+ jmp 1b
15947+4: ud2
15948+ jmp 4b
15949+#endif
15950+ENDPROC(pax_exit_kernel)
15951+#endif
15952+
15953+ .macro pax_enter_kernel_user
15954+ pax_set_fptr_mask
15955+#ifdef CONFIG_PAX_MEMORY_UDEREF
15956+ call pax_enter_kernel_user
15957+#endif
15958+ .endm
15959+
15960+ .macro pax_exit_kernel_user
15961+#ifdef CONFIG_PAX_MEMORY_UDEREF
15962+ call pax_exit_kernel_user
15963+#endif
15964+#ifdef CONFIG_PAX_RANDKSTACK
15965+ pushq %rax
15966+ pushq %r11
15967+ call pax_randomize_kstack
15968+ popq %r11
15969+ popq %rax
15970+#endif
15971+ .endm
15972+
15973+#ifdef CONFIG_PAX_MEMORY_UDEREF
15974+ENTRY(pax_enter_kernel_user)
15975+ pushq %rdi
15976+ pushq %rbx
15977+
15978+#ifdef CONFIG_PARAVIRT
15979+ PV_SAVE_REGS(CLBR_RDI)
15980+#endif
15981+
15982+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
15983+ GET_CR3_INTO_RDI
15984+ cmp $1,%dil
15985+ jnz 4f
15986+ sub $4097,%rdi
15987+ bts $63,%rdi
15988+ SET_RDI_INTO_CR3
15989+ jmp 3f
15990+111:
15991+
15992+ GET_CR3_INTO_RDI
15993+ mov %rdi,%rbx
15994+ add $__START_KERNEL_map,%rbx
15995+ sub phys_base(%rip),%rbx
15996+
15997+#ifdef CONFIG_PARAVIRT
15998+ cmpl $0, pv_info+PARAVIRT_enabled
15999+ jz 1f
16000+ pushq %rdi
16001+ i = 0
16002+ .rept USER_PGD_PTRS
16003+ mov i*8(%rbx),%rsi
16004+ mov $0,%sil
16005+ lea i*8(%rbx),%rdi
16006+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
16007+ i = i + 1
16008+ .endr
16009+ popq %rdi
16010+ jmp 2f
16011+1:
16012+#endif
16013+
16014+ i = 0
16015+ .rept USER_PGD_PTRS
16016+ movb $0,i*8(%rbx)
16017+ i = i + 1
16018+ .endr
16019+
16020+2: SET_RDI_INTO_CR3
16021+
16022+#ifdef CONFIG_PAX_KERNEXEC
16023+ GET_CR0_INTO_RDI
16024+ bts $X86_CR0_WP_BIT,%rdi
16025+ SET_RDI_INTO_CR0
16026+#endif
16027+
16028+3:
16029+
16030+#ifdef CONFIG_PARAVIRT
16031+ PV_RESTORE_REGS(CLBR_RDI)
16032+#endif
16033+
16034+ popq %rbx
16035+ popq %rdi
16036+ pax_force_retaddr
16037+ retq
16038+4: ud2
16039+ENDPROC(pax_enter_kernel_user)
16040+
16041+ENTRY(pax_exit_kernel_user)
16042+ pushq %rdi
16043+ pushq %rbx
16044+
16045+#ifdef CONFIG_PARAVIRT
16046+ PV_SAVE_REGS(CLBR_RDI)
16047+#endif
16048+
16049+ GET_CR3_INTO_RDI
16050+ ALTERNATIVE "jmp 1f", "", X86_FEATURE_PCID
16051+ cmp $0,%dil
16052+ jnz 3f
16053+ add $4097,%rdi
16054+ bts $63,%rdi
16055+ SET_RDI_INTO_CR3
16056+ jmp 2f
16057+1:
16058+
16059+ mov %rdi,%rbx
16060+
16061+#ifdef CONFIG_PAX_KERNEXEC
16062+ GET_CR0_INTO_RDI
16063+ btr $X86_CR0_WP_BIT,%rdi
16064+ jnc 3f
16065+ SET_RDI_INTO_CR0
16066+#endif
16067+
16068+ add $__START_KERNEL_map,%rbx
16069+ sub phys_base(%rip),%rbx
16070+
16071+#ifdef CONFIG_PARAVIRT
16072+ cmpl $0, pv_info+PARAVIRT_enabled
16073+ jz 1f
16074+ i = 0
16075+ .rept USER_PGD_PTRS
16076+ mov i*8(%rbx),%rsi
16077+ mov $0x67,%sil
16078+ lea i*8(%rbx),%rdi
16079+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
16080+ i = i + 1
16081+ .endr
16082+ jmp 2f
16083+1:
16084+#endif
16085+
16086+ i = 0
16087+ .rept USER_PGD_PTRS
16088+ movb $0x67,i*8(%rbx)
16089+ i = i + 1
16090+ .endr
16091+2:
16092+
16093+#ifdef CONFIG_PARAVIRT
16094+ PV_RESTORE_REGS(CLBR_RDI)
16095+#endif
16096+
16097+ popq %rbx
16098+ popq %rdi
16099+ pax_force_retaddr
16100+ retq
16101+3: ud2
16102+ENDPROC(pax_exit_kernel_user)
16103+#endif
16104+
16105+ .macro pax_enter_kernel_nmi
16106+ pax_set_fptr_mask
16107+
16108+#ifdef CONFIG_PAX_KERNEXEC
16109+ GET_CR0_INTO_RDI
16110+ bts $X86_CR0_WP_BIT,%rdi
16111+ jc 110f
16112+ SET_RDI_INTO_CR0
16113+ or $2,%ebx
16114+110:
16115+#endif
16116+
16117+#ifdef CONFIG_PAX_MEMORY_UDEREF
16118+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
16119+ GET_CR3_INTO_RDI
16120+ cmp $0,%dil
16121+ jz 111f
16122+ sub $4097,%rdi
16123+ or $4,%ebx
16124+ bts $63,%rdi
16125+ SET_RDI_INTO_CR3
16126+ mov $__UDEREF_KERNEL_DS,%edi
16127+ mov %edi,%ss
16128+111:
16129+#endif
16130+ .endm
16131+
16132+ .macro pax_exit_kernel_nmi
16133+#ifdef CONFIG_PAX_KERNEXEC
16134+ btr $1,%ebx
16135+ jnc 110f
16136+ GET_CR0_INTO_RDI
16137+ btr $X86_CR0_WP_BIT,%rdi
16138+ SET_RDI_INTO_CR0
16139+110:
16140+#endif
16141+
16142+#ifdef CONFIG_PAX_MEMORY_UDEREF
16143+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
16144+ btr $2,%ebx
16145+ jnc 111f
16146+ GET_CR3_INTO_RDI
16147+ add $4097,%rdi
16148+ bts $63,%rdi
16149+ SET_RDI_INTO_CR3
16150+ mov $__KERNEL_DS,%edi
16151+ mov %edi,%ss
16152+111:
16153+#endif
16154+ .endm
16155+
16156+ .macro pax_erase_kstack
16157+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
16158+ call pax_erase_kstack
16159+#endif
16160+ .endm
16161+
16162+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
16163+ENTRY(pax_erase_kstack)
16164+ pushq %rdi
16165+ pushq %rcx
16166+ pushq %rax
16167+ pushq %r11
16168+
16169+ GET_THREAD_INFO(%r11)
16170+ mov TI_lowest_stack(%r11), %rdi
16171+ mov $-0xBEEF, %rax
16172+ std
16173+
16174+1: mov %edi, %ecx
16175+ and $THREAD_SIZE_asm - 1, %ecx
16176+ shr $3, %ecx
16177+ repne scasq
16178+ jecxz 2f
16179+
16180+ cmp $2*8, %ecx
16181+ jc 2f
16182+
16183+ mov $2*8, %ecx
16184+ repe scasq
16185+ jecxz 2f
16186+ jne 1b
16187+
16188+2: cld
16189+ or $2*8, %rdi
16190+ mov %esp, %ecx
16191+ sub %edi, %ecx
16192+
16193+ cmp $THREAD_SIZE_asm, %rcx
16194+ jb 3f
16195+ ud2
16196+3:
16197+
16198+ shr $3, %ecx
16199+ rep stosq
16200+
16201+ mov TI_task_thread_sp0(%r11), %rdi
16202+ sub $256, %rdi
16203+ mov %rdi, TI_lowest_stack(%r11)
16204+
16205+ popq %r11
16206+ popq %rax
16207+ popq %rcx
16208+ popq %rdi
16209+ pax_force_retaddr
16210+ ret
16211+ENDPROC(pax_erase_kstack)
16212+#endif
16213+
16214 .macro TRACE_IRQS_IRETQ
16215 #ifdef CONFIG_TRACE_IRQFLAGS
16216 bt $9, EFLAGS(%rsp) /* interrupts off? */
16217@@ -89,7 +487,7 @@ ENDPROC(native_usergs_sysret64)
16218 .endm
16219
16220 .macro TRACE_IRQS_IRETQ_DEBUG
16221- bt $9, EFLAGS(%rsp) /* interrupts off? */
16222+ bt $X86_EFLAGS_IF_BIT, EFLAGS(%rsp) /* interrupts off? */
16223 jnc 1f
16224 TRACE_IRQS_ON_DEBUG
16225 1:
16226@@ -149,14 +547,6 @@ GLOBAL(entry_SYSCALL_64_after_swapgs)
16227 /* Construct struct pt_regs on stack */
16228 pushq $__USER_DS /* pt_regs->ss */
16229 pushq PER_CPU_VAR(rsp_scratch) /* pt_regs->sp */
16230- /*
16231- * Re-enable interrupts.
16232- * We use 'rsp_scratch' as a scratch space, hence irq-off block above
16233- * must execute atomically in the face of possible interrupt-driven
16234- * task preemption. We must enable interrupts only after we're done
16235- * with using rsp_scratch:
16236- */
16237- ENABLE_INTERRUPTS(CLBR_NONE)
16238 pushq %r11 /* pt_regs->flags */
16239 pushq $__USER_CS /* pt_regs->cs */
16240 pushq %rcx /* pt_regs->ip */
16241@@ -172,7 +562,27 @@ GLOBAL(entry_SYSCALL_64_after_swapgs)
16242 pushq %r11 /* pt_regs->r11 */
16243 sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not saved */
16244
16245- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16246+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
16247+ movq %r12, R12(%rsp)
16248+#endif
16249+
16250+ pax_enter_kernel_user
16251+
16252+#ifdef CONFIG_PAX_RANDKSTACK
16253+ pax_erase_kstack
16254+#endif
16255+
16256+ /*
16257+ * Re-enable interrupts.
16258+ * We use 'rsp_scratch' as a scratch space, hence irq-off block above
16259+ * must execute atomically in the face of possible interrupt-driven
16260+ * task preemption. We must enable interrupts only after we're done
16261+ * with using rsp_scratch:
16262+ */
16263+ ENABLE_INTERRUPTS(CLBR_NONE)
16264+
16265+ GET_THREAD_INFO(%rcx)
16266+ testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%rcx)
16267 jnz tracesys
16268 entry_SYSCALL_64_fastpath:
16269 #if __SYSCALL_MASK == ~0
16270@@ -205,9 +615,13 @@ entry_SYSCALL_64_fastpath:
16271 * flags (TIF_NOTIFY_RESUME, TIF_USER_RETURN_NOTIFY, etc) set is
16272 * very bad.
16273 */
16274- testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16275+ GET_THREAD_INFO(%rcx)
16276+ testl $_TIF_ALLWORK_MASK, TI_flags(%rcx)
16277 jnz int_ret_from_sys_call_irqs_off /* Go to the slow path */
16278
16279+ pax_exit_kernel_user
16280+ pax_erase_kstack
16281+
16282 RESTORE_C_REGS_EXCEPT_RCX_R11
16283 movq RIP(%rsp), %rcx
16284 movq EFLAGS(%rsp), %r11
16285@@ -236,6 +650,9 @@ tracesys:
16286 call syscall_trace_enter_phase1
16287 test %rax, %rax
16288 jnz tracesys_phase2 /* if needed, run the slow path */
16289+
16290+ pax_erase_kstack
16291+
16292 RESTORE_C_REGS_EXCEPT_RAX /* else restore clobbered regs */
16293 movq ORIG_RAX(%rsp), %rax
16294 jmp entry_SYSCALL_64_fastpath /* and return to the fast path */
16295@@ -247,6 +664,8 @@ tracesys_phase2:
16296 movq %rax, %rdx
16297 call syscall_trace_enter_phase2
16298
16299+ pax_erase_kstack
16300+
16301 /*
16302 * Reload registers from stack in case ptrace changed them.
16303 * We don't reload %rax because syscall_trace_entry_phase2() returned
16304@@ -284,6 +703,8 @@ GLOBAL(int_with_check)
16305 andl %edi, %edx
16306 jnz int_careful
16307 andl $~TS_COMPAT, TI_status(%rcx)
16308+ pax_exit_kernel_user
16309+ pax_erase_kstack
16310 jmp syscall_return
16311
16312 /*
16313@@ -407,14 +828,14 @@ syscall_return_via_sysret:
16314 opportunistic_sysret_failed:
16315 SWAPGS
16316 jmp restore_c_regs_and_iret
16317-END(entry_SYSCALL_64)
16318+ENDPROC(entry_SYSCALL_64)
16319
16320
16321 .macro FORK_LIKE func
16322 ENTRY(stub_\func)
16323 SAVE_EXTRA_REGS 8
16324 jmp sys_\func
16325-END(stub_\func)
16326+ENDPROC(stub_\func)
16327 .endm
16328
16329 FORK_LIKE clone
16330@@ -434,7 +855,7 @@ return_from_execve:
16331 ZERO_EXTRA_REGS
16332 movq %rax, RAX(%rsp)
16333 jmp int_ret_from_sys_call
16334-END(stub_execve)
16335+ENDPROC(stub_execve)
16336 /*
16337 * Remaining execve stubs are only 7 bytes long.
16338 * ENTRY() often aligns to 16 bytes, which in this case has no benefits.
16339@@ -443,7 +864,7 @@ END(stub_execve)
16340 GLOBAL(stub_execveat)
16341 call sys_execveat
16342 jmp return_from_execve
16343-END(stub_execveat)
16344+ENDPROC(stub_execveat)
16345
16346 #if defined(CONFIG_X86_X32_ABI) || defined(CONFIG_IA32_EMULATION)
16347 .align 8
16348@@ -451,15 +872,15 @@ GLOBAL(stub_x32_execve)
16349 GLOBAL(stub32_execve)
16350 call compat_sys_execve
16351 jmp return_from_execve
16352-END(stub32_execve)
16353-END(stub_x32_execve)
16354+ENDPROC(stub32_execve)
16355+ENDPROC(stub_x32_execve)
16356 .align 8
16357 GLOBAL(stub_x32_execveat)
16358 GLOBAL(stub32_execveat)
16359 call compat_sys_execveat
16360 jmp return_from_execve
16361-END(stub32_execveat)
16362-END(stub_x32_execveat)
16363+ENDPROC(stub32_execveat)
16364+ENDPROC(stub_x32_execveat)
16365 #endif
16366
16367 /*
16368@@ -488,7 +909,7 @@ ENTRY(stub_x32_rt_sigreturn)
16369 SAVE_EXTRA_REGS 8
16370 call sys32_x32_rt_sigreturn
16371 jmp return_from_stub
16372-END(stub_x32_rt_sigreturn)
16373+ENDPROC(stub_x32_rt_sigreturn)
16374 #endif
16375
16376 /*
16377@@ -527,7 +948,7 @@ ENTRY(ret_from_fork)
16378 movl $0, RAX(%rsp)
16379 RESTORE_EXTRA_REGS
16380 jmp int_ret_from_sys_call
16381-END(ret_from_fork)
16382+ENDPROC(ret_from_fork)
16383
16384 /*
16385 * Build the entry stubs with some assembler magic.
16386@@ -542,7 +963,7 @@ ENTRY(irq_entries_start)
16387 jmp common_interrupt
16388 .align 8
16389 .endr
16390-END(irq_entries_start)
16391+ENDPROC(irq_entries_start)
16392
16393 /*
16394 * Interrupt entry/exit.
16395@@ -555,21 +976,13 @@ END(irq_entries_start)
16396 /* 0(%rsp): ~(interrupt number) */
16397 .macro interrupt func
16398 cld
16399- /*
16400- * Since nothing in interrupt handling code touches r12...r15 members
16401- * of "struct pt_regs", and since interrupts can nest, we can save
16402- * four stack slots and simultaneously provide
16403- * an unwind-friendly stack layout by saving "truncated" pt_regs
16404- * exactly up to rbp slot, without these members.
16405- */
16406- ALLOC_PT_GPREGS_ON_STACK -RBP
16407- SAVE_C_REGS -RBP
16408- /* this goes to 0(%rsp) for unwinder, not for saving the value: */
16409- SAVE_EXTRA_REGS_RBP -RBP
16410+ ALLOC_PT_GPREGS_ON_STACK
16411+ SAVE_C_REGS
16412+ SAVE_EXTRA_REGS
16413
16414- leaq -RBP(%rsp), %rdi /* arg1 for \func (pointer to pt_regs) */
16415+ movq %rsp, %rdi /* arg1 for \func (pointer to pt_regs) */
16416
16417- testb $3, CS-RBP(%rsp)
16418+ testb $3, CS(%rsp)
16419 jz 1f
16420 SWAPGS
16421 1:
16422@@ -584,6 +997,18 @@ END(irq_entries_start)
16423 incl PER_CPU_VAR(irq_count)
16424 cmovzq PER_CPU_VAR(irq_stack_ptr), %rsp
16425 pushq %rsi
16426+
16427+#ifdef CONFIG_PAX_MEMORY_UDEREF
16428+ testb $3, CS(%rdi)
16429+ jnz 1f
16430+ pax_enter_kernel
16431+ jmp 2f
16432+1: pax_enter_kernel_user
16433+2:
16434+#else
16435+ pax_enter_kernel
16436+#endif
16437+
16438 /* We entered an interrupt context - irqs are off: */
16439 TRACE_IRQS_OFF
16440
16441@@ -608,7 +1033,7 @@ ret_from_intr:
16442 /* Restore saved previous stack */
16443 popq %rsi
16444 /* return code expects complete pt_regs - adjust rsp accordingly: */
16445- leaq -RBP(%rsi), %rsp
16446+ movq %rsi, %rsp
16447
16448 testb $3, CS(%rsp)
16449 jz retint_kernel
16450@@ -630,6 +1055,8 @@ retint_swapgs: /* return to user-space */
16451 * The iretq could re-enable interrupts:
16452 */
16453 DISABLE_INTERRUPTS(CLBR_ANY)
16454+ pax_exit_kernel_user
16455+# pax_erase_kstack
16456 TRACE_IRQS_IRETQ
16457
16458 SWAPGS
16459@@ -648,6 +1075,21 @@ retint_kernel:
16460 jmp 0b
16461 1:
16462 #endif
16463+
16464+ pax_exit_kernel
16465+
16466+#if defined(CONFIG_EFI) && defined(CONFIG_PAX_KERNEXEC)
16467+ /* This is a quirk to allow IRQs/NMIs/MCEs during early EFI setup,
16468+ * namely calling EFI runtime services with a phys mapping. We're
16469+ * starting off with NOPs and patch in the real instrumentation
16470+ * (BTS/OR) before starting any userland process; even before starting
16471+ * up the APs.
16472+ */
16473+ ALTERNATIVE "", "pax_force_retaddr 16*8", X86_FEATURE_ALWAYS
16474+#else
16475+ pax_force_retaddr RIP
16476+#endif
16477+
16478 /*
16479 * The iretq could re-enable interrupts:
16480 */
16481@@ -689,15 +1131,15 @@ native_irq_return_ldt:
16482 SWAPGS
16483 movq PER_CPU_VAR(espfix_waddr), %rdi
16484 movq %rax, (0*8)(%rdi) /* RAX */
16485- movq (2*8)(%rsp), %rax /* RIP */
16486+ movq (2*8 + RIP-RIP)(%rsp), %rax /* RIP */
16487 movq %rax, (1*8)(%rdi)
16488- movq (3*8)(%rsp), %rax /* CS */
16489+ movq (2*8 + CS-RIP)(%rsp), %rax /* CS */
16490 movq %rax, (2*8)(%rdi)
16491- movq (4*8)(%rsp), %rax /* RFLAGS */
16492+ movq (2*8 + EFLAGS-RIP)(%rsp), %rax /* RFLAGS */
16493 movq %rax, (3*8)(%rdi)
16494- movq (6*8)(%rsp), %rax /* SS */
16495+ movq (2*8 + SS-RIP)(%rsp), %rax /* SS */
16496 movq %rax, (5*8)(%rdi)
16497- movq (5*8)(%rsp), %rax /* RSP */
16498+ movq (2*8 + RSP-RIP)(%rsp), %rax /* RSP */
16499 movq %rax, (4*8)(%rdi)
16500 andl $0xffff0000, %eax
16501 popq %rdi
16502@@ -738,7 +1180,7 @@ retint_signal:
16503 GET_THREAD_INFO(%rcx)
16504 jmp retint_with_reschedule
16505
16506-END(common_interrupt)
16507+ENDPROC(common_interrupt)
16508
16509 /*
16510 * APIC interrupts.
16511@@ -750,7 +1192,7 @@ ENTRY(\sym)
16512 .Lcommon_\sym:
16513 interrupt \do_sym
16514 jmp ret_from_intr
16515-END(\sym)
16516+ENDPROC(\sym)
16517 .endm
16518
16519 #ifdef CONFIG_TRACING
16520@@ -815,7 +1257,7 @@ apicinterrupt IRQ_WORK_VECTOR irq_work_interrupt smp_irq_work_interrupt
16521 /*
16522 * Exception entry points.
16523 */
16524-#define CPU_TSS_IST(x) PER_CPU_VAR(cpu_tss) + (TSS_ist + ((x) - 1) * 8)
16525+#define CPU_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r13)
16526
16527 .macro idtentry sym do_sym has_error_code:req paranoid=0 shift_ist=-1
16528 ENTRY(\sym)
16529@@ -862,6 +1304,12 @@ ENTRY(\sym)
16530 .endif
16531
16532 .if \shift_ist != -1
16533+#ifdef CONFIG_SMP
16534+ imul $TSS_size, PER_CPU_VAR(cpu_number), %r13d
16535+ lea cpu_tss(%r13), %r13
16536+#else
16537+ lea cpu_tss(%rip), %r13
16538+#endif
16539 subq $EXCEPTION_STKSZ, CPU_TSS_IST(\shift_ist)
16540 .endif
16541
16542@@ -905,7 +1353,7 @@ ENTRY(\sym)
16543
16544 jmp error_exit /* %ebx: no swapgs flag */
16545 .endif
16546-END(\sym)
16547+ENDPROC(\sym)
16548 .endm
16549
16550 #ifdef CONFIG_TRACING
16551@@ -947,8 +1395,9 @@ gs_change:
16552 2: mfence /* workaround */
16553 SWAPGS
16554 popfq
16555+ pax_force_retaddr
16556 ret
16557-END(native_load_gs_index)
16558+ENDPROC(native_load_gs_index)
16559
16560 _ASM_EXTABLE(gs_change, bad_gs)
16561 .section .fixup, "ax"
16562@@ -970,8 +1419,9 @@ ENTRY(do_softirq_own_stack)
16563 call __do_softirq
16564 leaveq
16565 decl PER_CPU_VAR(irq_count)
16566+ pax_force_retaddr
16567 ret
16568-END(do_softirq_own_stack)
16569+ENDPROC(do_softirq_own_stack)
16570
16571 #ifdef CONFIG_XEN
16572 idtentry xen_hypervisor_callback xen_do_hypervisor_callback has_error_code=0
16573@@ -1007,7 +1457,7 @@ ENTRY(xen_do_hypervisor_callback) /* do_hypervisor_callback(struct *pt_regs) */
16574 call xen_maybe_preempt_hcall
16575 #endif
16576 jmp error_exit
16577-END(xen_do_hypervisor_callback)
16578+ENDPROC(xen_do_hypervisor_callback)
16579
16580 /*
16581 * Hypervisor uses this for application faults while it executes.
16582@@ -1052,7 +1502,7 @@ ENTRY(xen_failsafe_callback)
16583 SAVE_C_REGS
16584 SAVE_EXTRA_REGS
16585 jmp error_exit
16586-END(xen_failsafe_callback)
16587+ENDPROC(xen_failsafe_callback)
16588
16589 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
16590 xen_hvm_callback_vector xen_evtchn_do_upcall
16591@@ -1101,8 +1551,36 @@ ENTRY(paranoid_entry)
16592 js 1f /* negative -> in kernel */
16593 SWAPGS
16594 xorl %ebx, %ebx
16595-1: ret
16596-END(paranoid_entry)
16597+1:
16598+#ifdef CONFIG_PAX_MEMORY_UDEREF
16599+ testb $3, CS+8(%rsp)
16600+ jnz 1f
16601+ pax_enter_kernel
16602+ jmp 2f
16603+1: pax_enter_kernel_user
16604+2:
16605+#else
16606+ pax_enter_kernel
16607+#endif
16608+ pax_force_retaddr
16609+ ret
16610+ENDPROC(paranoid_entry)
16611+
16612+ENTRY(paranoid_entry_nmi)
16613+ cld
16614+ SAVE_C_REGS 8
16615+ SAVE_EXTRA_REGS 8
16616+ movl $1, %ebx
16617+ movl $MSR_GS_BASE, %ecx
16618+ rdmsr
16619+ testl %edx, %edx
16620+ js 1f /* negative -> in kernel */
16621+ SWAPGS
16622+ xorl %ebx, %ebx
16623+1: pax_enter_kernel_nmi
16624+ pax_force_retaddr
16625+ ret
16626+ENDPROC(paranoid_entry_nmi)
16627
16628 /*
16629 * "Paranoid" exit path from exception stack. This is invoked
16630@@ -1119,19 +1597,26 @@ END(paranoid_entry)
16631 ENTRY(paranoid_exit)
16632 DISABLE_INTERRUPTS(CLBR_NONE)
16633 TRACE_IRQS_OFF_DEBUG
16634- testl %ebx, %ebx /* swapgs needed? */
16635+ testl $1, %ebx /* swapgs needed? */
16636 jnz paranoid_exit_no_swapgs
16637+#ifdef CONFIG_PAX_MEMORY_UDEREF
16638+ pax_exit_kernel_user
16639+#else
16640+ pax_exit_kernel
16641+#endif
16642 TRACE_IRQS_IRETQ
16643 SWAPGS_UNSAFE_STACK
16644 jmp paranoid_exit_restore
16645 paranoid_exit_no_swapgs:
16646+ pax_exit_kernel
16647 TRACE_IRQS_IRETQ_DEBUG
16648 paranoid_exit_restore:
16649 RESTORE_EXTRA_REGS
16650 RESTORE_C_REGS
16651 REMOVE_PT_GPREGS_FROM_STACK 8
16652+ pax_force_retaddr_bts
16653 INTERRUPT_RETURN
16654-END(paranoid_exit)
16655+ENDPROC(paranoid_exit)
16656
16657 /*
16658 * Save all registers in pt_regs, and switch gs if needed.
16659@@ -1149,7 +1634,18 @@ ENTRY(error_entry)
16660 SWAPGS
16661
16662 error_entry_done:
16663+#ifdef CONFIG_PAX_MEMORY_UDEREF
16664+ testb $3, CS+8(%rsp)
16665+ jnz 1f
16666+ pax_enter_kernel
16667+ jmp 2f
16668+1: pax_enter_kernel_user
16669+2:
16670+#else
16671+ pax_enter_kernel
16672+#endif
16673 TRACE_IRQS_OFF
16674+ pax_force_retaddr
16675 ret
16676
16677 /*
16678@@ -1199,7 +1695,7 @@ error_bad_iret:
16679 mov %rax, %rsp
16680 decl %ebx
16681 jmp error_entry_done
16682-END(error_entry)
16683+ENDPROC(error_entry)
16684
16685
16686 /*
16687@@ -1212,10 +1708,10 @@ ENTRY(error_exit)
16688 RESTORE_EXTRA_REGS
16689 DISABLE_INTERRUPTS(CLBR_NONE)
16690 TRACE_IRQS_OFF
16691- testl %eax, %eax
16692+ testl $1, %eax
16693 jnz retint_kernel
16694 jmp retint_user
16695-END(error_exit)
16696+ENDPROC(error_exit)
16697
16698 /* Runs on exception stack */
16699 ENTRY(nmi)
16700@@ -1269,6 +1765,8 @@ ENTRY(nmi)
16701 * other IST entries.
16702 */
16703
16704+ ASM_CLAC
16705+
16706 /* Use %rdx as our temp variable throughout */
16707 pushq %rdx
16708
16709@@ -1312,6 +1810,12 @@ ENTRY(nmi)
16710 pushq %r14 /* pt_regs->r14 */
16711 pushq %r15 /* pt_regs->r15 */
16712
16713+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
16714+ xorl %ebx, %ebx
16715+#endif
16716+
16717+ pax_enter_kernel_nmi
16718+
16719 /*
16720 * At this point we no longer need to worry about stack damage
16721 * due to nesting -- we're on the normal thread stack and we're
16722@@ -1322,12 +1826,19 @@ ENTRY(nmi)
16723 movq $-1, %rsi
16724 call do_nmi
16725
16726+ pax_exit_kernel_nmi
16727+
16728 /*
16729 * Return back to user mode. We must *not* do the normal exit
16730 * work, because we don't want to enable interrupts. Fortunately,
16731 * do_nmi doesn't modify pt_regs.
16732 */
16733 SWAPGS
16734+
16735+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
16736+ movq RBX(%rsp), %rbx
16737+#endif
16738+
16739 jmp restore_c_regs_and_iret
16740
16741 .Lnmi_from_kernel:
16742@@ -1449,6 +1960,7 @@ nested_nmi_out:
16743 popq %rdx
16744
16745 /* We are returning to kernel mode, so this cannot result in a fault. */
16746+# pax_force_retaddr_bts
16747 INTERRUPT_RETURN
16748
16749 first_nmi:
16750@@ -1522,20 +2034,22 @@ end_repeat_nmi:
16751 ALLOC_PT_GPREGS_ON_STACK
16752
16753 /*
16754- * Use paranoid_entry to handle SWAPGS, but no need to use paranoid_exit
16755+ * Use paranoid_entry_nmi to handle SWAPGS, but no need to use paranoid_exit
16756 * as we should not be calling schedule in NMI context.
16757 * Even with normal interrupts enabled. An NMI should not be
16758 * setting NEED_RESCHED or anything that normal interrupts and
16759 * exceptions might do.
16760 */
16761- call paranoid_entry
16762+ call paranoid_entry_nmi
16763
16764 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
16765 movq %rsp, %rdi
16766 movq $-1, %rsi
16767 call do_nmi
16768
16769- testl %ebx, %ebx /* swapgs needed? */
16770+ pax_exit_kernel_nmi
16771+
16772+ testl $1, %ebx /* swapgs needed? */
16773 jnz nmi_restore
16774 nmi_swapgs:
16775 SWAPGS_UNSAFE_STACK
16776@@ -1546,6 +2060,8 @@ nmi_restore:
16777 /* Point RSP at the "iret" frame. */
16778 REMOVE_PT_GPREGS_FROM_STACK 6*8
16779
16780+ pax_force_retaddr_bts
16781+
16782 /*
16783 * Clear "NMI executing". Set DF first so that we can easily
16784 * distinguish the remaining code between here and IRET from
16785@@ -1563,9 +2079,9 @@ nmi_restore:
16786 * mode, so this cannot result in a fault.
16787 */
16788 INTERRUPT_RETURN
16789-END(nmi)
16790+ENDPROC(nmi)
16791
16792 ENTRY(ignore_sysret)
16793 mov $-ENOSYS, %eax
16794 sysret
16795-END(ignore_sysret)
16796+ENDPROC(ignore_sysret)
16797diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
16798index a7e257d..3a6ad23 100644
16799--- a/arch/x86/entry/entry_64_compat.S
16800+++ b/arch/x86/entry/entry_64_compat.S
16801@@ -13,8 +13,10 @@
16802 #include <asm/irqflags.h>
16803 #include <asm/asm.h>
16804 #include <asm/smap.h>
16805+#include <asm/pgtable.h>
16806 #include <linux/linkage.h>
16807 #include <linux/err.h>
16808+#include <asm/alternative-asm.h>
16809
16810 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
16811 #include <linux/elf-em.h>
16812@@ -35,6 +37,32 @@ ENTRY(native_usergs_sysret32)
16813 ENDPROC(native_usergs_sysret32)
16814 #endif
16815
16816+ .macro pax_enter_kernel_user
16817+ pax_set_fptr_mask
16818+#ifdef CONFIG_PAX_MEMORY_UDEREF
16819+ call pax_enter_kernel_user
16820+#endif
16821+ .endm
16822+
16823+ .macro pax_exit_kernel_user
16824+#ifdef CONFIG_PAX_MEMORY_UDEREF
16825+ call pax_exit_kernel_user
16826+#endif
16827+#ifdef CONFIG_PAX_RANDKSTACK
16828+ pushq %rax
16829+ pushq %r11
16830+ call pax_randomize_kstack
16831+ popq %r11
16832+ popq %rax
16833+#endif
16834+ .endm
16835+
16836+ .macro pax_erase_kstack
16837+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
16838+ call pax_erase_kstack
16839+#endif
16840+ .endm
16841+
16842 /*
16843 * 32-bit SYSENTER instruction entry.
16844 *
16845@@ -65,20 +93,21 @@ ENTRY(entry_SYSENTER_compat)
16846 */
16847 SWAPGS_UNSAFE_STACK
16848 movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
16849- ENABLE_INTERRUPTS(CLBR_NONE)
16850
16851 /* Zero-extending 32-bit regs, do not remove */
16852 movl %ebp, %ebp
16853 movl %eax, %eax
16854
16855- movl ASM_THREAD_INFO(TI_sysenter_return, %rsp, 0), %r10d
16856+ GET_THREAD_INFO(%r11)
16857+ movl TI_sysenter_return(%r11), %r11d
16858
16859 /* Construct struct pt_regs on stack */
16860 pushq $__USER32_DS /* pt_regs->ss */
16861 pushq %rbp /* pt_regs->sp */
16862 pushfq /* pt_regs->flags */
16863+ orl $X86_EFLAGS_IF,(%rsp)
16864 pushq $__USER32_CS /* pt_regs->cs */
16865- pushq %r10 /* pt_regs->ip = thread_info->sysenter_return */
16866+ pushq %r11 /* pt_regs->ip = thread_info->sysenter_return */
16867 pushq %rax /* pt_regs->orig_ax */
16868 pushq %rdi /* pt_regs->di */
16869 pushq %rsi /* pt_regs->si */
16870@@ -88,15 +117,37 @@ ENTRY(entry_SYSENTER_compat)
16871 cld
16872 sub $(10*8), %rsp /* pt_regs->r8-11, bp, bx, r12-15 not saved */
16873
16874+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
16875+ movq %r12, R12(%rsp)
16876+#endif
16877+
16878+ pax_enter_kernel_user
16879+
16880+#ifdef CONFIG_PAX_RANDKSTACK
16881+ pax_erase_kstack
16882+#endif
16883+
16884+ ENABLE_INTERRUPTS(CLBR_NONE)
16885+
16886 /*
16887 * no need to do an access_ok check here because rbp has been
16888 * 32-bit zero extended
16889 */
16890+
16891+#ifdef CONFIG_PAX_MEMORY_UDEREF
16892+ addq pax_user_shadow_base, %rbp
16893+ ASM_PAX_OPEN_USERLAND
16894+#endif
16895+
16896 ASM_STAC
16897 1: movl (%rbp), %ebp
16898 _ASM_EXTABLE(1b, ia32_badarg)
16899 ASM_CLAC
16900
16901+#ifdef CONFIG_PAX_MEMORY_UDEREF
16902+ ASM_PAX_CLOSE_USERLAND
16903+#endif
16904+
16905 /*
16906 * Sysenter doesn't filter flags, so we need to clear NT
16907 * ourselves. To save a few cycles, we can check whether
16908@@ -106,8 +157,9 @@ ENTRY(entry_SYSENTER_compat)
16909 jnz sysenter_fix_flags
16910 sysenter_flags_fixed:
16911
16912- orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
16913- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16914+ GET_THREAD_INFO(%r11)
16915+ orl $TS_COMPAT, TI_status(%r11)
16916+ testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%r11)
16917 jnz sysenter_tracesys
16918
16919 sysenter_do_call:
16920@@ -123,9 +175,10 @@ sysenter_dispatch:
16921 call *ia32_sys_call_table(, %rax, 8)
16922 movq %rax, RAX(%rsp)
16923 1:
16924+ GET_THREAD_INFO(%r11)
16925 DISABLE_INTERRUPTS(CLBR_NONE)
16926 TRACE_IRQS_OFF
16927- testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16928+ testl $_TIF_ALLWORK_MASK, TI_flags(%r11)
16929 jnz sysexit_audit
16930 sysexit_from_sys_call:
16931 /*
16932@@ -138,7 +191,9 @@ sysexit_from_sys_call:
16933 * This code path is still called 'sysexit' because it pairs
16934 * with 'sysenter' and it uses the SYSENTER calling convention.
16935 */
16936- andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
16937+ pax_exit_kernel_user
16938+ pax_erase_kstack
16939+ andl $~TS_COMPAT, TI_status(%r11)
16940 movl RIP(%rsp), %ecx /* User %eip */
16941 movq RAX(%rsp), %rax
16942 RESTORE_RSI_RDI
16943@@ -194,6 +249,8 @@ sysexit_from_sys_call:
16944 movl %eax, %edi /* arg1 (RDI) <= syscall number (EAX) */
16945 call __audit_syscall_entry
16946
16947+ pax_erase_kstack
16948+
16949 /*
16950 * We are going to jump back to the syscall dispatch code.
16951 * Prepare syscall args as required by the 64-bit C ABI.
16952@@ -209,7 +266,7 @@ sysexit_from_sys_call:
16953 .endm
16954
16955 .macro auditsys_exit exit
16956- testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16957+ testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), TI_flags(%r11)
16958 jnz ia32_ret_from_sys_call
16959 TRACE_IRQS_ON
16960 ENABLE_INTERRUPTS(CLBR_NONE)
16961@@ -220,10 +277,11 @@ sysexit_from_sys_call:
16962 1: setbe %al /* 1 if error, 0 if not */
16963 movzbl %al, %edi /* zero-extend that into %edi */
16964 call __audit_syscall_exit
16965+ GET_THREAD_INFO(%r11)
16966 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), %edi
16967 DISABLE_INTERRUPTS(CLBR_NONE)
16968 TRACE_IRQS_OFF
16969- testl %edi, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16970+ testl %edi, TI_flags(%r11)
16971 jz \exit
16972 xorl %eax, %eax /* Do not leak kernel information */
16973 movq %rax, R11(%rsp)
16974@@ -249,7 +307,7 @@ sysenter_fix_flags:
16975
16976 sysenter_tracesys:
16977 #ifdef CONFIG_AUDITSYSCALL
16978- testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16979+ testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), TI_flags(%r11)
16980 jz sysenter_auditsys
16981 #endif
16982 SAVE_EXTRA_REGS
16983@@ -269,6 +327,9 @@ sysenter_tracesys:
16984 movl %eax, %eax /* zero extension */
16985
16986 RESTORE_EXTRA_REGS
16987+
16988+ pax_erase_kstack
16989+
16990 jmp sysenter_do_call
16991 ENDPROC(entry_SYSENTER_compat)
16992
16993@@ -311,7 +372,6 @@ ENTRY(entry_SYSCALL_compat)
16994 SWAPGS_UNSAFE_STACK
16995 movl %esp, %r8d
16996 movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
16997- ENABLE_INTERRUPTS(CLBR_NONE)
16998
16999 /* Zero-extending 32-bit regs, do not remove */
17000 movl %eax, %eax
17001@@ -331,16 +391,41 @@ ENTRY(entry_SYSCALL_compat)
17002 pushq $-ENOSYS /* pt_regs->ax */
17003 sub $(10*8), %rsp /* pt_regs->r8-11, bp, bx, r12-15 not saved */
17004
17005+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
17006+ movq %r12, R12(%rsp)
17007+#endif
17008+
17009+ pax_enter_kernel_user
17010+
17011+#ifdef CONFIG_PAX_RANDKSTACK
17012+ pax_erase_kstack
17013+#endif
17014+
17015+ ENABLE_INTERRUPTS(CLBR_NONE)
17016+
17017 /*
17018 * No need to do an access_ok check here because r8 has been
17019 * 32-bit zero extended:
17020 */
17021+
17022+#ifdef CONFIG_PAX_MEMORY_UDEREF
17023+ ASM_PAX_OPEN_USERLAND
17024+ movq pax_user_shadow_base, %r8
17025+ addq RSP(%rsp), %r8
17026+#endif
17027+
17028 ASM_STAC
17029 1: movl (%r8), %r9d
17030 _ASM_EXTABLE(1b, ia32_badarg)
17031 ASM_CLAC
17032- orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
17033- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
17034+
17035+#ifdef CONFIG_PAX_MEMORY_UDEREF
17036+ ASM_PAX_CLOSE_USERLAND
17037+#endif
17038+
17039+ GET_THREAD_INFO(%r11)
17040+ orl $TS_COMPAT,TI_status(%r11)
17041+ testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
17042 jnz cstar_tracesys
17043
17044 cstar_do_call:
17045@@ -358,13 +443,16 @@ cstar_dispatch:
17046 call *ia32_sys_call_table(, %rax, 8)
17047 movq %rax, RAX(%rsp)
17048 1:
17049+ GET_THREAD_INFO(%r11)
17050 DISABLE_INTERRUPTS(CLBR_NONE)
17051 TRACE_IRQS_OFF
17052- testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
17053+ testl $_TIF_ALLWORK_MASK, TI_flags(%r11)
17054 jnz sysretl_audit
17055
17056 sysretl_from_sys_call:
17057- andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
17058+ pax_exit_kernel_user
17059+ pax_erase_kstack
17060+ andl $~TS_COMPAT, TI_status(%r11)
17061 RESTORE_RSI_RDI_RDX
17062 movl RIP(%rsp), %ecx
17063 movl EFLAGS(%rsp), %r11d
17064@@ -403,7 +491,7 @@ sysretl_audit:
17065
17066 cstar_tracesys:
17067 #ifdef CONFIG_AUDITSYSCALL
17068- testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
17069+ testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), TI_flags(%r11)
17070 jz cstar_auditsys
17071 #endif
17072 xchgl %r9d, %ebp
17073@@ -426,11 +514,19 @@ cstar_tracesys:
17074
17075 RESTORE_EXTRA_REGS
17076 xchgl %ebp, %r9d
17077+
17078+ pax_erase_kstack
17079+
17080 jmp cstar_do_call
17081 END(entry_SYSCALL_compat)
17082
17083 ia32_badarg:
17084 ASM_CLAC
17085+
17086+#ifdef CONFIG_PAX_MEMORY_UDEREF
17087+ ASM_PAX_CLOSE_USERLAND
17088+#endif
17089+
17090 movq $-EFAULT, RAX(%rsp)
17091 ia32_ret_from_sys_call:
17092 xorl %eax, %eax /* Do not leak kernel information */
17093@@ -462,14 +558,8 @@ ia32_ret_from_sys_call:
17094 */
17095
17096 ENTRY(entry_INT80_compat)
17097- /*
17098- * Interrupts are off on entry.
17099- * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
17100- * it is too small to ever cause noticeable irq latency.
17101- */
17102 PARAVIRT_ADJUST_EXCEPTION_FRAME
17103 SWAPGS
17104- ENABLE_INTERRUPTS(CLBR_NONE)
17105
17106 /* Zero-extending 32-bit regs, do not remove */
17107 movl %eax, %eax
17108@@ -488,8 +578,26 @@ ENTRY(entry_INT80_compat)
17109 cld
17110 sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not saved */
17111
17112- orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
17113- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
17114+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
17115+ movq %r12, R12(%rsp)
17116+#endif
17117+
17118+ pax_enter_kernel_user
17119+
17120+#ifdef CONFIG_PAX_RANDKSTACK
17121+ pax_erase_kstack
17122+#endif
17123+
17124+ /*
17125+ * Interrupts are off on entry.
17126+ * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
17127+ * it is too small to ever cause noticeable irq latency.
17128+ */
17129+ ENABLE_INTERRUPTS(CLBR_NONE)
17130+
17131+ GET_THREAD_INFO(%r11)
17132+ orl $TS_COMPAT, TI_status(%r11)
17133+ testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%r11)
17134 jnz ia32_tracesys
17135
17136 ia32_do_call:
17137@@ -524,6 +632,9 @@ ia32_tracesys:
17138 movl RDI(%rsp), %edi
17139 movl %eax, %eax /* zero extension */
17140 RESTORE_EXTRA_REGS
17141+
17142+ pax_erase_kstack
17143+
17144 jmp ia32_do_call
17145 END(entry_INT80_compat)
17146
17147diff --git a/arch/x86/entry/thunk_64.S b/arch/x86/entry/thunk_64.S
17148index efb2b93..8a9cb8e 100644
17149--- a/arch/x86/entry/thunk_64.S
17150+++ b/arch/x86/entry/thunk_64.S
17151@@ -8,6 +8,7 @@
17152 #include <linux/linkage.h>
17153 #include "calling.h"
17154 #include <asm/asm.h>
17155+#include <asm/alternative-asm.h>
17156
17157 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
17158 .macro THUNK name, func, put_ret_addr_in_rdi=0
17159@@ -62,6 +63,7 @@ restore:
17160 popq %rdx
17161 popq %rsi
17162 popq %rdi
17163+ pax_force_retaddr
17164 ret
17165 _ASM_NOKPROBE(restore)
17166 #endif
17167diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
17168index e970320..c006fea 100644
17169--- a/arch/x86/entry/vdso/Makefile
17170+++ b/arch/x86/entry/vdso/Makefile
17171@@ -175,7 +175,7 @@ quiet_cmd_vdso = VDSO $@
17172 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
17173 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
17174
17175-VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
17176+VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
17177 $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS)
17178 GCOV_PROFILE := n
17179
17180diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/entry/vdso/vdso2c.h
17181index 0224987..8deb742 100644
17182--- a/arch/x86/entry/vdso/vdso2c.h
17183+++ b/arch/x86/entry/vdso/vdso2c.h
17184@@ -12,7 +12,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
17185 unsigned long load_size = -1; /* Work around bogus warning */
17186 unsigned long mapping_size;
17187 ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr;
17188- int i;
17189+ unsigned int i;
17190 unsigned long j;
17191 ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr,
17192 *alt_sec = NULL;
17193@@ -83,7 +83,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
17194 for (i = 0;
17195 i < GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize);
17196 i++) {
17197- int k;
17198+ unsigned int k;
17199 ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) +
17200 GET_LE(&symtab_hdr->sh_entsize) * i;
17201 const char *name = raw_addr + GET_LE(&strtab_hdr->sh_offset) +
17202diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
17203index 1c9f750..cfddb1a 100644
17204--- a/arch/x86/entry/vdso/vma.c
17205+++ b/arch/x86/entry/vdso/vma.c
17206@@ -19,10 +19,7 @@
17207 #include <asm/page.h>
17208 #include <asm/hpet.h>
17209 #include <asm/desc.h>
17210-
17211-#if defined(CONFIG_X86_64)
17212-unsigned int __read_mostly vdso64_enabled = 1;
17213-#endif
17214+#include <asm/mman.h>
17215
17216 void __init init_vdso_image(const struct vdso_image *image)
17217 {
17218@@ -101,6 +98,11 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
17219 .pages = no_pages,
17220 };
17221
17222+#ifdef CONFIG_PAX_RANDMMAP
17223+ if (mm->pax_flags & MF_PAX_RANDMMAP)
17224+ calculate_addr = false;
17225+#endif
17226+
17227 if (calculate_addr) {
17228 addr = vdso_addr(current->mm->start_stack,
17229 image->size - image->sym_vvar_start);
17230@@ -111,14 +113,14 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
17231 down_write(&mm->mmap_sem);
17232
17233 addr = get_unmapped_area(NULL, addr,
17234- image->size - image->sym_vvar_start, 0, 0);
17235+ image->size - image->sym_vvar_start, 0, MAP_EXECUTABLE);
17236 if (IS_ERR_VALUE(addr)) {
17237 ret = addr;
17238 goto up_fail;
17239 }
17240
17241 text_start = addr - image->sym_vvar_start;
17242- current->mm->context.vdso = (void __user *)text_start;
17243+ mm->context.vdso = text_start;
17244
17245 /*
17246 * MAYWRITE to allow gdb to COW and set breakpoints
17247@@ -163,15 +165,12 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
17248 hpet_address >> PAGE_SHIFT,
17249 PAGE_SIZE,
17250 pgprot_noncached(PAGE_READONLY));
17251-
17252- if (ret)
17253- goto up_fail;
17254 }
17255 #endif
17256
17257 up_fail:
17258 if (ret)
17259- current->mm->context.vdso = NULL;
17260+ current->mm->context.vdso = 0;
17261
17262 up_write(&mm->mmap_sem);
17263 return ret;
17264@@ -191,8 +190,8 @@ static int load_vdso32(void)
17265
17266 if (selected_vdso32->sym_VDSO32_SYSENTER_RETURN)
17267 current_thread_info()->sysenter_return =
17268- current->mm->context.vdso +
17269- selected_vdso32->sym_VDSO32_SYSENTER_RETURN;
17270+ (void __force_user *)(current->mm->context.vdso +
17271+ selected_vdso32->sym_VDSO32_SYSENTER_RETURN);
17272
17273 return 0;
17274 }
17275@@ -201,9 +200,6 @@ static int load_vdso32(void)
17276 #ifdef CONFIG_X86_64
17277 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
17278 {
17279- if (!vdso64_enabled)
17280- return 0;
17281-
17282 return map_vdso(&vdso_image_64, true);
17283 }
17284
17285@@ -212,12 +208,8 @@ int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
17286 int uses_interp)
17287 {
17288 #ifdef CONFIG_X86_X32_ABI
17289- if (test_thread_flag(TIF_X32)) {
17290- if (!vdso64_enabled)
17291- return 0;
17292-
17293+ if (test_thread_flag(TIF_X32))
17294 return map_vdso(&vdso_image_x32, true);
17295- }
17296 #endif
17297
17298 return load_vdso32();
17299@@ -231,15 +223,6 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
17300 #endif
17301
17302 #ifdef CONFIG_X86_64
17303-static __init int vdso_setup(char *s)
17304-{
17305- vdso64_enabled = simple_strtoul(s, NULL, 0);
17306- return 0;
17307-}
17308-__setup("vdso=", vdso_setup);
17309-#endif
17310-
17311-#ifdef CONFIG_X86_64
17312 static void vgetcpu_cpu_init(void *arg)
17313 {
17314 int cpu = smp_processor_id();
17315diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c
17316index 2dcc6ff..082dc7a 100644
17317--- a/arch/x86/entry/vsyscall/vsyscall_64.c
17318+++ b/arch/x86/entry/vsyscall/vsyscall_64.c
17319@@ -38,15 +38,13 @@
17320 #define CREATE_TRACE_POINTS
17321 #include "vsyscall_trace.h"
17322
17323-static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
17324+static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
17325
17326 static int __init vsyscall_setup(char *str)
17327 {
17328 if (str) {
17329 if (!strcmp("emulate", str))
17330 vsyscall_mode = EMULATE;
17331- else if (!strcmp("native", str))
17332- vsyscall_mode = NATIVE;
17333 else if (!strcmp("none", str))
17334 vsyscall_mode = NONE;
17335 else
17336@@ -264,8 +262,7 @@ do_ret:
17337 return true;
17338
17339 sigsegv:
17340- force_sig(SIGSEGV, current);
17341- return true;
17342+ do_group_exit(SIGKILL);
17343 }
17344
17345 /*
17346@@ -283,8 +280,8 @@ static struct vm_operations_struct gate_vma_ops = {
17347 static struct vm_area_struct gate_vma = {
17348 .vm_start = VSYSCALL_ADDR,
17349 .vm_end = VSYSCALL_ADDR + PAGE_SIZE,
17350- .vm_page_prot = PAGE_READONLY_EXEC,
17351- .vm_flags = VM_READ | VM_EXEC,
17352+ .vm_page_prot = PAGE_READONLY,
17353+ .vm_flags = VM_READ,
17354 .vm_ops = &gate_vma_ops,
17355 };
17356
17357@@ -325,10 +322,7 @@ void __init map_vsyscall(void)
17358 unsigned long physaddr_vsyscall = __pa_symbol(&__vsyscall_page);
17359
17360 if (vsyscall_mode != NONE)
17361- __set_fixmap(VSYSCALL_PAGE, physaddr_vsyscall,
17362- vsyscall_mode == NATIVE
17363- ? PAGE_KERNEL_VSYSCALL
17364- : PAGE_KERNEL_VVAR);
17365+ __set_fixmap(VSYSCALL_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
17366
17367 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_PAGE) !=
17368 (unsigned long)VSYSCALL_ADDR);
17369diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
17370index ae6aad1..719d6d9 100644
17371--- a/arch/x86/ia32/ia32_aout.c
17372+++ b/arch/x86/ia32/ia32_aout.c
17373@@ -153,6 +153,8 @@ static int aout_core_dump(struct coredump_params *cprm)
17374 unsigned long dump_start, dump_size;
17375 struct user32 dump;
17376
17377+ memset(&dump, 0, sizeof(dump));
17378+
17379 fs = get_fs();
17380 set_fs(KERNEL_DS);
17381 has_dumped = 1;
17382diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
17383index ae3a29a..cea65e9 100644
17384--- a/arch/x86/ia32/ia32_signal.c
17385+++ b/arch/x86/ia32/ia32_signal.c
17386@@ -216,7 +216,7 @@ asmlinkage long sys32_sigreturn(void)
17387 if (__get_user(set.sig[0], &frame->sc.oldmask)
17388 || (_COMPAT_NSIG_WORDS > 1
17389 && __copy_from_user((((char *) &set.sig) + 4),
17390- &frame->extramask,
17391+ frame->extramask,
17392 sizeof(frame->extramask))))
17393 goto badframe;
17394
17395@@ -336,7 +336,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
17396 sp -= frame_size;
17397 /* Align the stack pointer according to the i386 ABI,
17398 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
17399- sp = ((sp + 4) & -16ul) - 4;
17400+ sp = ((sp - 12) & -16ul) - 4;
17401 return (void __user *) sp;
17402 }
17403
17404@@ -381,10 +381,10 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
17405 } else {
17406 /* Return stub is in 32bit vsyscall page */
17407 if (current->mm->context.vdso)
17408- restorer = current->mm->context.vdso +
17409- selected_vdso32->sym___kernel_sigreturn;
17410+ restorer = (void __force_user *)(current->mm->context.vdso +
17411+ selected_vdso32->sym___kernel_sigreturn);
17412 else
17413- restorer = &frame->retcode;
17414+ restorer = frame->retcode;
17415 }
17416
17417 put_user_try {
17418@@ -394,7 +394,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
17419 * These are actually not used anymore, but left because some
17420 * gdb versions depend on them as a marker.
17421 */
17422- put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
17423+ put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
17424 } put_user_catch(err);
17425
17426 if (err)
17427@@ -436,7 +436,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
17428 0xb8,
17429 __NR_ia32_rt_sigreturn,
17430 0x80cd,
17431- 0,
17432+ 0
17433 };
17434
17435 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
17436@@ -459,16 +459,19 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
17437
17438 if (ksig->ka.sa.sa_flags & SA_RESTORER)
17439 restorer = ksig->ka.sa.sa_restorer;
17440+ else if (current->mm->context.vdso)
17441+ /* Return stub is in 32bit vsyscall page */
17442+ restorer = (void __force_user *)(current->mm->context.vdso +
17443+ selected_vdso32->sym___kernel_rt_sigreturn);
17444 else
17445- restorer = current->mm->context.vdso +
17446- selected_vdso32->sym___kernel_rt_sigreturn;
17447+ restorer = frame->retcode;
17448 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
17449
17450 /*
17451 * Not actually used anymore, but left because some gdb
17452 * versions need it.
17453 */
17454- put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
17455+ put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
17456 } put_user_catch(err);
17457
17458 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
17459diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
17460index 719cd70..72af944 100644
17461--- a/arch/x86/ia32/sys_ia32.c
17462+++ b/arch/x86/ia32/sys_ia32.c
17463@@ -49,18 +49,26 @@
17464
17465 #define AA(__x) ((unsigned long)(__x))
17466
17467+static inline loff_t compose_loff(unsigned int high, unsigned int low)
17468+{
17469+ loff_t retval = low;
17470+
17471+ BUILD_BUG_ON(sizeof retval != sizeof low + sizeof high);
17472+ __builtin_memcpy((unsigned char *)&retval + sizeof low, &high, sizeof high);
17473+ return retval;
17474+}
17475
17476 asmlinkage long sys32_truncate64(const char __user *filename,
17477- unsigned long offset_low,
17478- unsigned long offset_high)
17479+ unsigned int offset_low,
17480+ unsigned int offset_high)
17481 {
17482- return sys_truncate(filename, ((loff_t) offset_high << 32) | offset_low);
17483+ return sys_truncate(filename, compose_loff(offset_high, offset_low));
17484 }
17485
17486-asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
17487- unsigned long offset_high)
17488+asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned int offset_low,
17489+ unsigned int offset_high)
17490 {
17491- return sys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low);
17492+ return sys_ftruncate(fd, ((unsigned long) offset_high << 32) | offset_low);
17493 }
17494
17495 /*
17496@@ -69,8 +77,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
17497 */
17498 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
17499 {
17500- typeof(ubuf->st_uid) uid = 0;
17501- typeof(ubuf->st_gid) gid = 0;
17502+ typeof(((struct stat64 *)0)->st_uid) uid = 0;
17503+ typeof(((struct stat64 *)0)->st_gid) gid = 0;
17504 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
17505 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
17506 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
17507@@ -196,29 +204,29 @@ long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
17508 __u32 len_low, __u32 len_high, int advice)
17509 {
17510 return sys_fadvise64_64(fd,
17511- (((u64)offset_high)<<32) | offset_low,
17512- (((u64)len_high)<<32) | len_low,
17513+ compose_loff(offset_high, offset_low),
17514+ compose_loff(len_high, len_low),
17515 advice);
17516 }
17517
17518 asmlinkage ssize_t sys32_readahead(int fd, unsigned off_lo, unsigned off_hi,
17519 size_t count)
17520 {
17521- return sys_readahead(fd, ((u64)off_hi << 32) | off_lo, count);
17522+ return sys_readahead(fd, compose_loff(off_hi, off_lo), count);
17523 }
17524
17525 asmlinkage long sys32_sync_file_range(int fd, unsigned off_low, unsigned off_hi,
17526 unsigned n_low, unsigned n_hi, int flags)
17527 {
17528 return sys_sync_file_range(fd,
17529- ((u64)off_hi << 32) | off_low,
17530- ((u64)n_hi << 32) | n_low, flags);
17531+ compose_loff(off_hi, off_low),
17532+ compose_loff(n_hi, n_low), flags);
17533 }
17534
17535 asmlinkage long sys32_fadvise64(int fd, unsigned offset_lo, unsigned offset_hi,
17536- size_t len, int advice)
17537+ int len, int advice)
17538 {
17539- return sys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo,
17540+ return sys_fadvise64_64(fd, compose_loff(offset_hi, offset_lo),
17541 len, advice);
17542 }
17543
17544@@ -226,6 +234,6 @@ asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_lo,
17545 unsigned offset_hi, unsigned len_lo,
17546 unsigned len_hi)
17547 {
17548- return sys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo,
17549- ((u64)len_hi << 32) | len_lo);
17550+ return sys_fallocate(fd, mode, compose_loff(offset_hi, offset_lo),
17551+ compose_loff(len_hi, len_lo));
17552 }
17553diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
17554index e7636ba..e1fb78a 100644
17555--- a/arch/x86/include/asm/alternative-asm.h
17556+++ b/arch/x86/include/asm/alternative-asm.h
17557@@ -18,6 +18,45 @@
17558 .endm
17559 #endif
17560
17561+#ifdef KERNEXEC_PLUGIN
17562+ .macro pax_force_retaddr_bts rip=0
17563+ btsq $63,\rip(%rsp)
17564+ .endm
17565+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
17566+ .macro pax_force_retaddr rip=0, reload=0
17567+ btsq $63,\rip(%rsp)
17568+ .endm
17569+ .macro pax_force_fptr ptr
17570+ btsq $63,\ptr
17571+ .endm
17572+ .macro pax_set_fptr_mask
17573+ .endm
17574+#endif
17575+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
17576+ .macro pax_force_retaddr rip=0, reload=0
17577+ .if \reload
17578+ pax_set_fptr_mask
17579+ .endif
17580+ orq %r12,\rip(%rsp)
17581+ .endm
17582+ .macro pax_force_fptr ptr
17583+ orq %r12,\ptr
17584+ .endm
17585+ .macro pax_set_fptr_mask
17586+ movabs $0x8000000000000000,%r12
17587+ .endm
17588+#endif
17589+#else
17590+ .macro pax_force_retaddr rip=0, reload=0
17591+ .endm
17592+ .macro pax_force_fptr ptr
17593+ .endm
17594+ .macro pax_force_retaddr_bts rip=0
17595+ .endm
17596+ .macro pax_set_fptr_mask
17597+ .endm
17598+#endif
17599+
17600 /*
17601 * Issue one struct alt_instr descriptor entry (need to put it into
17602 * the section .altinstructions, see below). This entry contains
17603@@ -50,7 +89,7 @@
17604 altinstruction_entry 140b,143f,\feature,142b-140b,144f-143f,142b-141b
17605 .popsection
17606
17607- .pushsection .altinstr_replacement,"ax"
17608+ .pushsection .altinstr_replacement,"a"
17609 143:
17610 \newinstr
17611 144:
17612@@ -86,7 +125,7 @@
17613 altinstruction_entry 140b,144f,\feature2,142b-140b,145f-144f,142b-141b
17614 .popsection
17615
17616- .pushsection .altinstr_replacement,"ax"
17617+ .pushsection .altinstr_replacement,"a"
17618 143:
17619 \newinstr1
17620 144:
17621diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
17622index 7bfc85b..65d1ec4 100644
17623--- a/arch/x86/include/asm/alternative.h
17624+++ b/arch/x86/include/asm/alternative.h
17625@@ -136,7 +136,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
17626 ".pushsection .altinstructions,\"a\"\n" \
17627 ALTINSTR_ENTRY(feature, 1) \
17628 ".popsection\n" \
17629- ".pushsection .altinstr_replacement, \"ax\"\n" \
17630+ ".pushsection .altinstr_replacement, \"a\"\n" \
17631 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
17632 ".popsection"
17633
17634@@ -146,7 +146,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
17635 ALTINSTR_ENTRY(feature1, 1) \
17636 ALTINSTR_ENTRY(feature2, 2) \
17637 ".popsection\n" \
17638- ".pushsection .altinstr_replacement, \"ax\"\n" \
17639+ ".pushsection .altinstr_replacement, \"a\"\n" \
17640 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
17641 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
17642 ".popsection"
17643diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
17644index c839363..b9a8c43 100644
17645--- a/arch/x86/include/asm/apic.h
17646+++ b/arch/x86/include/asm/apic.h
17647@@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
17648
17649 #ifdef CONFIG_X86_LOCAL_APIC
17650
17651-extern unsigned int apic_verbosity;
17652+extern int apic_verbosity;
17653 extern int local_apic_timer_c2_ok;
17654
17655 extern int disable_apic;
17656diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
17657index 20370c6..a2eb9b0 100644
17658--- a/arch/x86/include/asm/apm.h
17659+++ b/arch/x86/include/asm/apm.h
17660@@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
17661 __asm__ __volatile__(APM_DO_ZERO_SEGS
17662 "pushl %%edi\n\t"
17663 "pushl %%ebp\n\t"
17664- "lcall *%%cs:apm_bios_entry\n\t"
17665+ "lcall *%%ss:apm_bios_entry\n\t"
17666 "setc %%al\n\t"
17667 "popl %%ebp\n\t"
17668 "popl %%edi\n\t"
17669@@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
17670 __asm__ __volatile__(APM_DO_ZERO_SEGS
17671 "pushl %%edi\n\t"
17672 "pushl %%ebp\n\t"
17673- "lcall *%%cs:apm_bios_entry\n\t"
17674+ "lcall *%%ss:apm_bios_entry\n\t"
17675 "setc %%bl\n\t"
17676 "popl %%ebp\n\t"
17677 "popl %%edi\n\t"
17678diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
17679index e916895..42d729d 100644
17680--- a/arch/x86/include/asm/atomic.h
17681+++ b/arch/x86/include/asm/atomic.h
17682@@ -28,6 +28,17 @@ static __always_inline int atomic_read(const atomic_t *v)
17683 }
17684
17685 /**
17686+ * atomic_read_unchecked - read atomic variable
17687+ * @v: pointer of type atomic_unchecked_t
17688+ *
17689+ * Atomically reads the value of @v.
17690+ */
17691+static __always_inline int __intentional_overflow(-1) atomic_read_unchecked(const atomic_unchecked_t *v)
17692+{
17693+ return ACCESS_ONCE((v)->counter);
17694+}
17695+
17696+/**
17697 * atomic_set - set atomic variable
17698 * @v: pointer of type atomic_t
17699 * @i: required value
17700@@ -40,6 +51,18 @@ static __always_inline void atomic_set(atomic_t *v, int i)
17701 }
17702
17703 /**
17704+ * atomic_set_unchecked - set atomic variable
17705+ * @v: pointer of type atomic_unchecked_t
17706+ * @i: required value
17707+ *
17708+ * Atomically sets the value of @v to @i.
17709+ */
17710+static __always_inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
17711+{
17712+ v->counter = i;
17713+}
17714+
17715+/**
17716 * atomic_add - add integer to atomic variable
17717 * @i: integer value to add
17718 * @v: pointer of type atomic_t
17719@@ -48,7 +71,29 @@ static __always_inline void atomic_set(atomic_t *v, int i)
17720 */
17721 static __always_inline void atomic_add(int i, atomic_t *v)
17722 {
17723- asm volatile(LOCK_PREFIX "addl %1,%0"
17724+ asm volatile(LOCK_PREFIX "addl %1,%0\n"
17725+
17726+#ifdef CONFIG_PAX_REFCOUNT
17727+ "jno 0f\n"
17728+ LOCK_PREFIX "subl %1,%0\n"
17729+ "int $4\n0:\n"
17730+ _ASM_EXTABLE(0b, 0b)
17731+#endif
17732+
17733+ : "+m" (v->counter)
17734+ : "ir" (i));
17735+}
17736+
17737+/**
17738+ * atomic_add_unchecked - add integer to atomic variable
17739+ * @i: integer value to add
17740+ * @v: pointer of type atomic_unchecked_t
17741+ *
17742+ * Atomically adds @i to @v.
17743+ */
17744+static __always_inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
17745+{
17746+ asm volatile(LOCK_PREFIX "addl %1,%0\n"
17747 : "+m" (v->counter)
17748 : "ir" (i));
17749 }
17750@@ -62,7 +107,29 @@ static __always_inline void atomic_add(int i, atomic_t *v)
17751 */
17752 static __always_inline void atomic_sub(int i, atomic_t *v)
17753 {
17754- asm volatile(LOCK_PREFIX "subl %1,%0"
17755+ asm volatile(LOCK_PREFIX "subl %1,%0\n"
17756+
17757+#ifdef CONFIG_PAX_REFCOUNT
17758+ "jno 0f\n"
17759+ LOCK_PREFIX "addl %1,%0\n"
17760+ "int $4\n0:\n"
17761+ _ASM_EXTABLE(0b, 0b)
17762+#endif
17763+
17764+ : "+m" (v->counter)
17765+ : "ir" (i));
17766+}
17767+
17768+/**
17769+ * atomic_sub_unchecked - subtract integer from atomic variable
17770+ * @i: integer value to subtract
17771+ * @v: pointer of type atomic_unchecked_t
17772+ *
17773+ * Atomically subtracts @i from @v.
17774+ */
17775+static __always_inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
17776+{
17777+ asm volatile(LOCK_PREFIX "subl %1,%0\n"
17778 : "+m" (v->counter)
17779 : "ir" (i));
17780 }
17781@@ -78,7 +145,7 @@ static __always_inline void atomic_sub(int i, atomic_t *v)
17782 */
17783 static __always_inline int atomic_sub_and_test(int i, atomic_t *v)
17784 {
17785- GEN_BINARY_RMWcc(LOCK_PREFIX "subl", v->counter, "er", i, "%0", "e");
17786+ GEN_BINARY_RMWcc(LOCK_PREFIX "subl", LOCK_PREFIX "addl", v->counter, "er", i, "%0", "e");
17787 }
17788
17789 /**
17790@@ -89,7 +156,27 @@ static __always_inline int atomic_sub_and_test(int i, atomic_t *v)
17791 */
17792 static __always_inline void atomic_inc(atomic_t *v)
17793 {
17794- asm volatile(LOCK_PREFIX "incl %0"
17795+ asm volatile(LOCK_PREFIX "incl %0\n"
17796+
17797+#ifdef CONFIG_PAX_REFCOUNT
17798+ "jno 0f\n"
17799+ LOCK_PREFIX "decl %0\n"
17800+ "int $4\n0:\n"
17801+ _ASM_EXTABLE(0b, 0b)
17802+#endif
17803+
17804+ : "+m" (v->counter));
17805+}
17806+
17807+/**
17808+ * atomic_inc_unchecked - increment atomic variable
17809+ * @v: pointer of type atomic_unchecked_t
17810+ *
17811+ * Atomically increments @v by 1.
17812+ */
17813+static __always_inline void atomic_inc_unchecked(atomic_unchecked_t *v)
17814+{
17815+ asm volatile(LOCK_PREFIX "incl %0\n"
17816 : "+m" (v->counter));
17817 }
17818
17819@@ -101,7 +188,27 @@ static __always_inline void atomic_inc(atomic_t *v)
17820 */
17821 static __always_inline void atomic_dec(atomic_t *v)
17822 {
17823- asm volatile(LOCK_PREFIX "decl %0"
17824+ asm volatile(LOCK_PREFIX "decl %0\n"
17825+
17826+#ifdef CONFIG_PAX_REFCOUNT
17827+ "jno 0f\n"
17828+ LOCK_PREFIX "incl %0\n"
17829+ "int $4\n0:\n"
17830+ _ASM_EXTABLE(0b, 0b)
17831+#endif
17832+
17833+ : "+m" (v->counter));
17834+}
17835+
17836+/**
17837+ * atomic_dec_unchecked - decrement atomic variable
17838+ * @v: pointer of type atomic_unchecked_t
17839+ *
17840+ * Atomically decrements @v by 1.
17841+ */
17842+static __always_inline void atomic_dec_unchecked(atomic_unchecked_t *v)
17843+{
17844+ asm volatile(LOCK_PREFIX "decl %0\n"
17845 : "+m" (v->counter));
17846 }
17847
17848@@ -115,7 +222,7 @@ static __always_inline void atomic_dec(atomic_t *v)
17849 */
17850 static __always_inline int atomic_dec_and_test(atomic_t *v)
17851 {
17852- GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, "%0", "e");
17853+ GEN_UNARY_RMWcc(LOCK_PREFIX "decl", LOCK_PREFIX "incl", v->counter, "%0", "e");
17854 }
17855
17856 /**
17857@@ -128,7 +235,20 @@ static __always_inline int atomic_dec_and_test(atomic_t *v)
17858 */
17859 static __always_inline int atomic_inc_and_test(atomic_t *v)
17860 {
17861- GEN_UNARY_RMWcc(LOCK_PREFIX "incl", v->counter, "%0", "e");
17862+ GEN_UNARY_RMWcc(LOCK_PREFIX "incl", LOCK_PREFIX "decl", v->counter, "%0", "e");
17863+}
17864+
17865+/**
17866+ * atomic_inc_and_test_unchecked - increment and test
17867+ * @v: pointer of type atomic_unchecked_t
17868+ *
17869+ * Atomically increments @v by 1
17870+ * and returns true if the result is zero, or false for all
17871+ * other cases.
17872+ */
17873+static __always_inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
17874+{
17875+ GEN_UNARY_RMWcc_unchecked(LOCK_PREFIX "incl", v->counter, "%0", "e");
17876 }
17877
17878 /**
17879@@ -142,7 +262,7 @@ static __always_inline int atomic_inc_and_test(atomic_t *v)
17880 */
17881 static __always_inline int atomic_add_negative(int i, atomic_t *v)
17882 {
17883- GEN_BINARY_RMWcc(LOCK_PREFIX "addl", v->counter, "er", i, "%0", "s");
17884+ GEN_BINARY_RMWcc(LOCK_PREFIX "addl", LOCK_PREFIX "subl", v->counter, "er", i, "%0", "s");
17885 }
17886
17887 /**
17888@@ -152,7 +272,19 @@ static __always_inline int atomic_add_negative(int i, atomic_t *v)
17889 *
17890 * Atomically adds @i to @v and returns @i + @v
17891 */
17892-static __always_inline int atomic_add_return(int i, atomic_t *v)
17893+static __always_inline int __intentional_overflow(-1) atomic_add_return(int i, atomic_t *v)
17894+{
17895+ return i + xadd_check_overflow(&v->counter, i);
17896+}
17897+
17898+/**
17899+ * atomic_add_return_unchecked - add integer and return
17900+ * @i: integer value to add
17901+ * @v: pointer of type atomi_uncheckedc_t
17902+ *
17903+ * Atomically adds @i to @v and returns @i + @v
17904+ */
17905+static __always_inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
17906 {
17907 return i + xadd(&v->counter, i);
17908 }
17909@@ -164,15 +296,24 @@ static __always_inline int atomic_add_return(int i, atomic_t *v)
17910 *
17911 * Atomically subtracts @i from @v and returns @v - @i
17912 */
17913-static __always_inline int atomic_sub_return(int i, atomic_t *v)
17914+static __always_inline int __intentional_overflow(-1) atomic_sub_return(int i, atomic_t *v)
17915 {
17916 return atomic_add_return(-i, v);
17917 }
17918
17919 #define atomic_inc_return(v) (atomic_add_return(1, v))
17920+static __always_inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
17921+{
17922+ return atomic_add_return_unchecked(1, v);
17923+}
17924 #define atomic_dec_return(v) (atomic_sub_return(1, v))
17925
17926-static __always_inline int atomic_cmpxchg(atomic_t *v, int old, int new)
17927+static __always_inline int __intentional_overflow(-1) atomic_cmpxchg(atomic_t *v, int old, int new)
17928+{
17929+ return cmpxchg(&v->counter, old, new);
17930+}
17931+
17932+static __always_inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
17933 {
17934 return cmpxchg(&v->counter, old, new);
17935 }
17936@@ -182,6 +323,11 @@ static inline int atomic_xchg(atomic_t *v, int new)
17937 return xchg(&v->counter, new);
17938 }
17939
17940+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
17941+{
17942+ return xchg(&v->counter, new);
17943+}
17944+
17945 /**
17946 * __atomic_add_unless - add unless the number is already a given value
17947 * @v: pointer of type atomic_t
17948@@ -193,12 +339,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
17949 */
17950 static __always_inline int __atomic_add_unless(atomic_t *v, int a, int u)
17951 {
17952- int c, old;
17953+ int c, old, new;
17954 c = atomic_read(v);
17955 for (;;) {
17956- if (unlikely(c == (u)))
17957+ if (unlikely(c == u))
17958 break;
17959- old = atomic_cmpxchg((v), c, c + (a));
17960+
17961+ asm volatile("addl %2,%0\n"
17962+
17963+#ifdef CONFIG_PAX_REFCOUNT
17964+ "jno 0f\n"
17965+ "subl %2,%0\n"
17966+ "int $4\n0:\n"
17967+ _ASM_EXTABLE(0b, 0b)
17968+#endif
17969+
17970+ : "=r" (new)
17971+ : "0" (c), "ir" (a));
17972+
17973+ old = atomic_cmpxchg(v, c, new);
17974 if (likely(old == c))
17975 break;
17976 c = old;
17977@@ -207,6 +366,49 @@ static __always_inline int __atomic_add_unless(atomic_t *v, int a, int u)
17978 }
17979
17980 /**
17981+ * atomic_inc_not_zero_hint - increment if not null
17982+ * @v: pointer of type atomic_t
17983+ * @hint: probable value of the atomic before the increment
17984+ *
17985+ * This version of atomic_inc_not_zero() gives a hint of probable
17986+ * value of the atomic. This helps processor to not read the memory
17987+ * before doing the atomic read/modify/write cycle, lowering
17988+ * number of bus transactions on some arches.
17989+ *
17990+ * Returns: 0 if increment was not done, 1 otherwise.
17991+ */
17992+#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
17993+static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
17994+{
17995+ int val, c = hint, new;
17996+
17997+ /* sanity test, should be removed by compiler if hint is a constant */
17998+ if (!hint)
17999+ return __atomic_add_unless(v, 1, 0);
18000+
18001+ do {
18002+ asm volatile("incl %0\n"
18003+
18004+#ifdef CONFIG_PAX_REFCOUNT
18005+ "jno 0f\n"
18006+ "decl %0\n"
18007+ "int $4\n0:\n"
18008+ _ASM_EXTABLE(0b, 0b)
18009+#endif
18010+
18011+ : "=r" (new)
18012+ : "0" (c));
18013+
18014+ val = atomic_cmpxchg(v, c, new);
18015+ if (val == c)
18016+ return 1;
18017+ c = val;
18018+ } while (c);
18019+
18020+ return 0;
18021+}
18022+
18023+/**
18024 * atomic_inc_short - increment of a short integer
18025 * @v: pointer to type int
18026 *
18027@@ -220,14 +422,37 @@ static __always_inline short int atomic_inc_short(short int *v)
18028 }
18029
18030 /* These are x86-specific, used by some header files */
18031-#define atomic_clear_mask(mask, addr) \
18032- asm volatile(LOCK_PREFIX "andl %0,%1" \
18033- : : "r" (~(mask)), "m" (*(addr)) : "memory")
18034+static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
18035+{
18036+ asm volatile(LOCK_PREFIX "andl %1,%0"
18037+ : "+m" (v->counter)
18038+ : "r" (~(mask))
18039+ : "memory");
18040+}
18041
18042-#define atomic_set_mask(mask, addr) \
18043- asm volatile(LOCK_PREFIX "orl %0,%1" \
18044- : : "r" ((unsigned)(mask)), "m" (*(addr)) \
18045- : "memory")
18046+static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
18047+{
18048+ asm volatile(LOCK_PREFIX "andl %1,%0"
18049+ : "+m" (v->counter)
18050+ : "r" (~(mask))
18051+ : "memory");
18052+}
18053+
18054+static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
18055+{
18056+ asm volatile(LOCK_PREFIX "orl %1,%0"
18057+ : "+m" (v->counter)
18058+ : "r" (mask)
18059+ : "memory");
18060+}
18061+
18062+static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
18063+{
18064+ asm volatile(LOCK_PREFIX "orl %1,%0"
18065+ : "+m" (v->counter)
18066+ : "r" (mask)
18067+ : "memory");
18068+}
18069
18070 #ifdef CONFIG_X86_32
18071 # include <asm/atomic64_32.h>
18072diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
18073index b154de7..3dc335d 100644
18074--- a/arch/x86/include/asm/atomic64_32.h
18075+++ b/arch/x86/include/asm/atomic64_32.h
18076@@ -12,6 +12,14 @@ typedef struct {
18077 u64 __aligned(8) counter;
18078 } atomic64_t;
18079
18080+#ifdef CONFIG_PAX_REFCOUNT
18081+typedef struct {
18082+ u64 __aligned(8) counter;
18083+} atomic64_unchecked_t;
18084+#else
18085+typedef atomic64_t atomic64_unchecked_t;
18086+#endif
18087+
18088 #define ATOMIC64_INIT(val) { (val) }
18089
18090 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
18091@@ -37,21 +45,31 @@ typedef struct {
18092 ATOMIC64_DECL_ONE(sym##_386)
18093
18094 ATOMIC64_DECL_ONE(add_386);
18095+ATOMIC64_DECL_ONE(add_unchecked_386);
18096 ATOMIC64_DECL_ONE(sub_386);
18097+ATOMIC64_DECL_ONE(sub_unchecked_386);
18098 ATOMIC64_DECL_ONE(inc_386);
18099+ATOMIC64_DECL_ONE(inc_unchecked_386);
18100 ATOMIC64_DECL_ONE(dec_386);
18101+ATOMIC64_DECL_ONE(dec_unchecked_386);
18102 #endif
18103
18104 #define alternative_atomic64(f, out, in...) \
18105 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
18106
18107 ATOMIC64_DECL(read);
18108+ATOMIC64_DECL(read_unchecked);
18109 ATOMIC64_DECL(set);
18110+ATOMIC64_DECL(set_unchecked);
18111 ATOMIC64_DECL(xchg);
18112 ATOMIC64_DECL(add_return);
18113+ATOMIC64_DECL(add_return_unchecked);
18114 ATOMIC64_DECL(sub_return);
18115+ATOMIC64_DECL(sub_return_unchecked);
18116 ATOMIC64_DECL(inc_return);
18117+ATOMIC64_DECL(inc_return_unchecked);
18118 ATOMIC64_DECL(dec_return);
18119+ATOMIC64_DECL(dec_return_unchecked);
18120 ATOMIC64_DECL(dec_if_positive);
18121 ATOMIC64_DECL(inc_not_zero);
18122 ATOMIC64_DECL(add_unless);
18123@@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
18124 }
18125
18126 /**
18127+ * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
18128+ * @p: pointer to type atomic64_unchecked_t
18129+ * @o: expected value
18130+ * @n: new value
18131+ *
18132+ * Atomically sets @v to @n if it was equal to @o and returns
18133+ * the old value.
18134+ */
18135+
18136+static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
18137+{
18138+ return cmpxchg64(&v->counter, o, n);
18139+}
18140+
18141+/**
18142 * atomic64_xchg - xchg atomic64 variable
18143 * @v: pointer to type atomic64_t
18144 * @n: value to assign
18145@@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
18146 }
18147
18148 /**
18149+ * atomic64_set_unchecked - set atomic64 variable
18150+ * @v: pointer to type atomic64_unchecked_t
18151+ * @n: value to assign
18152+ *
18153+ * Atomically sets the value of @v to @n.
18154+ */
18155+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
18156+{
18157+ unsigned high = (unsigned)(i >> 32);
18158+ unsigned low = (unsigned)i;
18159+ alternative_atomic64(set, /* no output */,
18160+ "S" (v), "b" (low), "c" (high)
18161+ : "eax", "edx", "memory");
18162+}
18163+
18164+/**
18165 * atomic64_read - read atomic64 variable
18166 * @v: pointer to type atomic64_t
18167 *
18168@@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
18169 }
18170
18171 /**
18172+ * atomic64_read_unchecked - read atomic64 variable
18173+ * @v: pointer to type atomic64_unchecked_t
18174+ *
18175+ * Atomically reads the value of @v and returns it.
18176+ */
18177+static inline long long __intentional_overflow(-1) atomic64_read_unchecked(const atomic64_unchecked_t *v)
18178+{
18179+ long long r;
18180+ alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
18181+ return r;
18182+ }
18183+
18184+/**
18185 * atomic64_add_return - add and return
18186 * @i: integer value to add
18187 * @v: pointer to type atomic64_t
18188@@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
18189 return i;
18190 }
18191
18192+/**
18193+ * atomic64_add_return_unchecked - add and return
18194+ * @i: integer value to add
18195+ * @v: pointer to type atomic64_unchecked_t
18196+ *
18197+ * Atomically adds @i to @v and returns @i + *@v
18198+ */
18199+static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
18200+{
18201+ alternative_atomic64(add_return_unchecked,
18202+ ASM_OUTPUT2("+A" (i), "+c" (v)),
18203+ ASM_NO_INPUT_CLOBBER("memory"));
18204+ return i;
18205+}
18206+
18207 /*
18208 * Other variants with different arithmetic operators:
18209 */
18210@@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
18211 return a;
18212 }
18213
18214+static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
18215+{
18216+ long long a;
18217+ alternative_atomic64(inc_return_unchecked, "=&A" (a),
18218+ "S" (v) : "memory", "ecx");
18219+ return a;
18220+}
18221+
18222 static inline long long atomic64_dec_return(atomic64_t *v)
18223 {
18224 long long a;
18225@@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
18226 }
18227
18228 /**
18229+ * atomic64_add_unchecked - add integer to atomic64 variable
18230+ * @i: integer value to add
18231+ * @v: pointer to type atomic64_unchecked_t
18232+ *
18233+ * Atomically adds @i to @v.
18234+ */
18235+static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
18236+{
18237+ __alternative_atomic64(add_unchecked, add_return_unchecked,
18238+ ASM_OUTPUT2("+A" (i), "+c" (v)),
18239+ ASM_NO_INPUT_CLOBBER("memory"));
18240+ return i;
18241+}
18242+
18243+/**
18244 * atomic64_sub - subtract the atomic64 variable
18245 * @i: integer value to subtract
18246 * @v: pointer to type atomic64_t
18247diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
18248index b965f9e..8e22dd3 100644
18249--- a/arch/x86/include/asm/atomic64_64.h
18250+++ b/arch/x86/include/asm/atomic64_64.h
18251@@ -22,6 +22,18 @@ static inline long atomic64_read(const atomic64_t *v)
18252 }
18253
18254 /**
18255+ * atomic64_read_unchecked - read atomic64 variable
18256+ * @v: pointer of type atomic64_unchecked_t
18257+ *
18258+ * Atomically reads the value of @v.
18259+ * Doesn't imply a read memory barrier.
18260+ */
18261+static inline long __intentional_overflow(-1) atomic64_read_unchecked(const atomic64_unchecked_t *v)
18262+{
18263+ return ACCESS_ONCE((v)->counter);
18264+}
18265+
18266+/**
18267 * atomic64_set - set atomic64 variable
18268 * @v: pointer to type atomic64_t
18269 * @i: required value
18270@@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
18271 }
18272
18273 /**
18274+ * atomic64_set_unchecked - set atomic64 variable
18275+ * @v: pointer to type atomic64_unchecked_t
18276+ * @i: required value
18277+ *
18278+ * Atomically sets the value of @v to @i.
18279+ */
18280+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
18281+{
18282+ v->counter = i;
18283+}
18284+
18285+/**
18286 * atomic64_add - add integer to atomic64 variable
18287 * @i: integer value to add
18288 * @v: pointer to type atomic64_t
18289@@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
18290 */
18291 static __always_inline void atomic64_add(long i, atomic64_t *v)
18292 {
18293+ asm volatile(LOCK_PREFIX "addq %1,%0\n"
18294+
18295+#ifdef CONFIG_PAX_REFCOUNT
18296+ "jno 0f\n"
18297+ LOCK_PREFIX "subq %1,%0\n"
18298+ "int $4\n0:\n"
18299+ _ASM_EXTABLE(0b, 0b)
18300+#endif
18301+
18302+ : "=m" (v->counter)
18303+ : "er" (i), "m" (v->counter));
18304+}
18305+
18306+/**
18307+ * atomic64_add_unchecked - add integer to atomic64 variable
18308+ * @i: integer value to add
18309+ * @v: pointer to type atomic64_unchecked_t
18310+ *
18311+ * Atomically adds @i to @v.
18312+ */
18313+static __always_inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
18314+{
18315 asm volatile(LOCK_PREFIX "addq %1,%0"
18316 : "=m" (v->counter)
18317 : "er" (i), "m" (v->counter));
18318@@ -56,7 +102,29 @@ static __always_inline void atomic64_add(long i, atomic64_t *v)
18319 */
18320 static inline void atomic64_sub(long i, atomic64_t *v)
18321 {
18322- asm volatile(LOCK_PREFIX "subq %1,%0"
18323+ asm volatile(LOCK_PREFIX "subq %1,%0\n"
18324+
18325+#ifdef CONFIG_PAX_REFCOUNT
18326+ "jno 0f\n"
18327+ LOCK_PREFIX "addq %1,%0\n"
18328+ "int $4\n0:\n"
18329+ _ASM_EXTABLE(0b, 0b)
18330+#endif
18331+
18332+ : "=m" (v->counter)
18333+ : "er" (i), "m" (v->counter));
18334+}
18335+
18336+/**
18337+ * atomic64_sub_unchecked - subtract the atomic64 variable
18338+ * @i: integer value to subtract
18339+ * @v: pointer to type atomic64_unchecked_t
18340+ *
18341+ * Atomically subtracts @i from @v.
18342+ */
18343+static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
18344+{
18345+ asm volatile(LOCK_PREFIX "subq %1,%0\n"
18346 : "=m" (v->counter)
18347 : "er" (i), "m" (v->counter));
18348 }
18349@@ -72,7 +140,7 @@ static inline void atomic64_sub(long i, atomic64_t *v)
18350 */
18351 static inline int atomic64_sub_and_test(long i, atomic64_t *v)
18352 {
18353- GEN_BINARY_RMWcc(LOCK_PREFIX "subq", v->counter, "er", i, "%0", "e");
18354+ GEN_BINARY_RMWcc(LOCK_PREFIX "subq", LOCK_PREFIX "addq", v->counter, "er", i, "%0", "e");
18355 }
18356
18357 /**
18358@@ -83,6 +151,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
18359 */
18360 static __always_inline void atomic64_inc(atomic64_t *v)
18361 {
18362+ asm volatile(LOCK_PREFIX "incq %0\n"
18363+
18364+#ifdef CONFIG_PAX_REFCOUNT
18365+ "jno 0f\n"
18366+ LOCK_PREFIX "decq %0\n"
18367+ "int $4\n0:\n"
18368+ _ASM_EXTABLE(0b, 0b)
18369+#endif
18370+
18371+ : "=m" (v->counter)
18372+ : "m" (v->counter));
18373+}
18374+
18375+/**
18376+ * atomic64_inc_unchecked - increment atomic64 variable
18377+ * @v: pointer to type atomic64_unchecked_t
18378+ *
18379+ * Atomically increments @v by 1.
18380+ */
18381+static __always_inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
18382+{
18383 asm volatile(LOCK_PREFIX "incq %0"
18384 : "=m" (v->counter)
18385 : "m" (v->counter));
18386@@ -96,7 +185,28 @@ static __always_inline void atomic64_inc(atomic64_t *v)
18387 */
18388 static __always_inline void atomic64_dec(atomic64_t *v)
18389 {
18390- asm volatile(LOCK_PREFIX "decq %0"
18391+ asm volatile(LOCK_PREFIX "decq %0\n"
18392+
18393+#ifdef CONFIG_PAX_REFCOUNT
18394+ "jno 0f\n"
18395+ LOCK_PREFIX "incq %0\n"
18396+ "int $4\n0:\n"
18397+ _ASM_EXTABLE(0b, 0b)
18398+#endif
18399+
18400+ : "=m" (v->counter)
18401+ : "m" (v->counter));
18402+}
18403+
18404+/**
18405+ * atomic64_dec_unchecked - decrement atomic64 variable
18406+ * @v: pointer to type atomic64_t
18407+ *
18408+ * Atomically decrements @v by 1.
18409+ */
18410+static __always_inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
18411+{
18412+ asm volatile(LOCK_PREFIX "decq %0\n"
18413 : "=m" (v->counter)
18414 : "m" (v->counter));
18415 }
18416@@ -111,7 +221,7 @@ static __always_inline void atomic64_dec(atomic64_t *v)
18417 */
18418 static inline int atomic64_dec_and_test(atomic64_t *v)
18419 {
18420- GEN_UNARY_RMWcc(LOCK_PREFIX "decq", v->counter, "%0", "e");
18421+ GEN_UNARY_RMWcc(LOCK_PREFIX "decq", LOCK_PREFIX "incq", v->counter, "%0", "e");
18422 }
18423
18424 /**
18425@@ -124,7 +234,7 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
18426 */
18427 static inline int atomic64_inc_and_test(atomic64_t *v)
18428 {
18429- GEN_UNARY_RMWcc(LOCK_PREFIX "incq", v->counter, "%0", "e");
18430+ GEN_UNARY_RMWcc(LOCK_PREFIX "incq", LOCK_PREFIX "decq", v->counter, "%0", "e");
18431 }
18432
18433 /**
18434@@ -138,7 +248,7 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
18435 */
18436 static inline int atomic64_add_negative(long i, atomic64_t *v)
18437 {
18438- GEN_BINARY_RMWcc(LOCK_PREFIX "addq", v->counter, "er", i, "%0", "s");
18439+ GEN_BINARY_RMWcc(LOCK_PREFIX "addq", LOCK_PREFIX "subq", v->counter, "er", i, "%0", "s");
18440 }
18441
18442 /**
18443@@ -150,6 +260,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
18444 */
18445 static __always_inline long atomic64_add_return(long i, atomic64_t *v)
18446 {
18447+ return i + xadd_check_overflow(&v->counter, i);
18448+}
18449+
18450+/**
18451+ * atomic64_add_return_unchecked - add and return
18452+ * @i: integer value to add
18453+ * @v: pointer to type atomic64_unchecked_t
18454+ *
18455+ * Atomically adds @i to @v and returns @i + @v
18456+ */
18457+static __always_inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
18458+{
18459 return i + xadd(&v->counter, i);
18460 }
18461
18462@@ -159,6 +281,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
18463 }
18464
18465 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
18466+static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
18467+{
18468+ return atomic64_add_return_unchecked(1, v);
18469+}
18470 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
18471
18472 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
18473@@ -166,6 +292,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
18474 return cmpxchg(&v->counter, old, new);
18475 }
18476
18477+static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
18478+{
18479+ return cmpxchg(&v->counter, old, new);
18480+}
18481+
18482 static inline long atomic64_xchg(atomic64_t *v, long new)
18483 {
18484 return xchg(&v->counter, new);
18485@@ -182,17 +313,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
18486 */
18487 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
18488 {
18489- long c, old;
18490+ long c, old, new;
18491 c = atomic64_read(v);
18492 for (;;) {
18493- if (unlikely(c == (u)))
18494+ if (unlikely(c == u))
18495 break;
18496- old = atomic64_cmpxchg((v), c, c + (a));
18497+
18498+ asm volatile("add %2,%0\n"
18499+
18500+#ifdef CONFIG_PAX_REFCOUNT
18501+ "jno 0f\n"
18502+ "sub %2,%0\n"
18503+ "int $4\n0:\n"
18504+ _ASM_EXTABLE(0b, 0b)
18505+#endif
18506+
18507+ : "=r" (new)
18508+ : "0" (c), "ir" (a));
18509+
18510+ old = atomic64_cmpxchg(v, c, new);
18511 if (likely(old == c))
18512 break;
18513 c = old;
18514 }
18515- return c != (u);
18516+ return c != u;
18517 }
18518
18519 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
18520diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
18521index e51a8f8..ee075df 100644
18522--- a/arch/x86/include/asm/barrier.h
18523+++ b/arch/x86/include/asm/barrier.h
18524@@ -57,7 +57,7 @@
18525 do { \
18526 compiletime_assert_atomic_type(*p); \
18527 smp_mb(); \
18528- ACCESS_ONCE(*p) = (v); \
18529+ ACCESS_ONCE_RW(*p) = (v); \
18530 } while (0)
18531
18532 #define smp_load_acquire(p) \
18533@@ -74,7 +74,7 @@ do { \
18534 do { \
18535 compiletime_assert_atomic_type(*p); \
18536 barrier(); \
18537- ACCESS_ONCE(*p) = (v); \
18538+ ACCESS_ONCE_RW(*p) = (v); \
18539 } while (0)
18540
18541 #define smp_load_acquire(p) \
18542diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
18543index cfe3b95..d01b118 100644
18544--- a/arch/x86/include/asm/bitops.h
18545+++ b/arch/x86/include/asm/bitops.h
18546@@ -50,7 +50,7 @@
18547 * a mask operation on a byte.
18548 */
18549 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
18550-#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
18551+#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
18552 #define CONST_MASK(nr) (1 << ((nr) & 7))
18553
18554 /**
18555@@ -203,7 +203,7 @@ static inline void change_bit(long nr, volatile unsigned long *addr)
18556 */
18557 static inline int test_and_set_bit(long nr, volatile unsigned long *addr)
18558 {
18559- GEN_BINARY_RMWcc(LOCK_PREFIX "bts", *addr, "Ir", nr, "%0", "c");
18560+ GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "bts", *addr, "Ir", nr, "%0", "c");
18561 }
18562
18563 /**
18564@@ -249,7 +249,7 @@ static inline int __test_and_set_bit(long nr, volatile unsigned long *addr)
18565 */
18566 static inline int test_and_clear_bit(long nr, volatile unsigned long *addr)
18567 {
18568- GEN_BINARY_RMWcc(LOCK_PREFIX "btr", *addr, "Ir", nr, "%0", "c");
18569+ GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "btr", *addr, "Ir", nr, "%0", "c");
18570 }
18571
18572 /**
18573@@ -302,7 +302,7 @@ static inline int __test_and_change_bit(long nr, volatile unsigned long *addr)
18574 */
18575 static inline int test_and_change_bit(long nr, volatile unsigned long *addr)
18576 {
18577- GEN_BINARY_RMWcc(LOCK_PREFIX "btc", *addr, "Ir", nr, "%0", "c");
18578+ GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "btc", *addr, "Ir", nr, "%0", "c");
18579 }
18580
18581 static __always_inline int constant_test_bit(long nr, const volatile unsigned long *addr)
18582@@ -343,7 +343,7 @@ static int test_bit(int nr, const volatile unsigned long *addr);
18583 *
18584 * Undefined if no bit exists, so code should check against 0 first.
18585 */
18586-static inline unsigned long __ffs(unsigned long word)
18587+static inline unsigned long __intentional_overflow(-1) __ffs(unsigned long word)
18588 {
18589 asm("rep; bsf %1,%0"
18590 : "=r" (word)
18591@@ -357,7 +357,7 @@ static inline unsigned long __ffs(unsigned long word)
18592 *
18593 * Undefined if no zero exists, so code should check against ~0UL first.
18594 */
18595-static inline unsigned long ffz(unsigned long word)
18596+static inline unsigned long __intentional_overflow(-1) ffz(unsigned long word)
18597 {
18598 asm("rep; bsf %1,%0"
18599 : "=r" (word)
18600@@ -371,7 +371,7 @@ static inline unsigned long ffz(unsigned long word)
18601 *
18602 * Undefined if no set bit exists, so code should check against 0 first.
18603 */
18604-static inline unsigned long __fls(unsigned long word)
18605+static inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
18606 {
18607 asm("bsr %1,%0"
18608 : "=r" (word)
18609@@ -434,7 +434,7 @@ static inline int ffs(int x)
18610 * set bit if value is nonzero. The last (most significant) bit is
18611 * at position 32.
18612 */
18613-static inline int fls(int x)
18614+static inline int __intentional_overflow(-1) fls(int x)
18615 {
18616 int r;
18617
18618@@ -476,7 +476,7 @@ static inline int fls(int x)
18619 * at position 64.
18620 */
18621 #ifdef CONFIG_X86_64
18622-static __always_inline int fls64(__u64 x)
18623+static __always_inline __intentional_overflow(-1) int fls64(__u64 x)
18624 {
18625 int bitpos = -1;
18626 /*
18627diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
18628index 4fa687a..4ca636f 100644
18629--- a/arch/x86/include/asm/boot.h
18630+++ b/arch/x86/include/asm/boot.h
18631@@ -6,7 +6,7 @@
18632 #include <uapi/asm/boot.h>
18633
18634 /* Physical address where kernel should be loaded. */
18635-#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
18636+#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
18637 + (CONFIG_PHYSICAL_ALIGN - 1)) \
18638 & ~(CONFIG_PHYSICAL_ALIGN - 1))
18639
18640diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
18641index 48f99f1..d78ebf9 100644
18642--- a/arch/x86/include/asm/cache.h
18643+++ b/arch/x86/include/asm/cache.h
18644@@ -5,12 +5,13 @@
18645
18646 /* L1 cache line size */
18647 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
18648-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
18649+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
18650
18651 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
18652+#define __read_only __attribute__((__section__(".data..read_only")))
18653
18654 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
18655-#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
18656+#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
18657
18658 #ifdef CONFIG_X86_VSMP
18659 #ifdef CONFIG_SMP
18660diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
18661index f50de69..2b0a458 100644
18662--- a/arch/x86/include/asm/checksum_32.h
18663+++ b/arch/x86/include/asm/checksum_32.h
18664@@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
18665 int len, __wsum sum,
18666 int *src_err_ptr, int *dst_err_ptr);
18667
18668+asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
18669+ int len, __wsum sum,
18670+ int *src_err_ptr, int *dst_err_ptr);
18671+
18672+asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
18673+ int len, __wsum sum,
18674+ int *src_err_ptr, int *dst_err_ptr);
18675+
18676 /*
18677 * Note: when you get a NULL pointer exception here this means someone
18678 * passed in an incorrect kernel address to one of these functions.
18679@@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
18680
18681 might_sleep();
18682 stac();
18683- ret = csum_partial_copy_generic((__force void *)src, dst,
18684+ ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
18685 len, sum, err_ptr, NULL);
18686 clac();
18687
18688@@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
18689 might_sleep();
18690 if (access_ok(VERIFY_WRITE, dst, len)) {
18691 stac();
18692- ret = csum_partial_copy_generic(src, (__force void *)dst,
18693+ ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
18694 len, sum, NULL, err_ptr);
18695 clac();
18696 return ret;
18697diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
18698index ad19841..0784041 100644
18699--- a/arch/x86/include/asm/cmpxchg.h
18700+++ b/arch/x86/include/asm/cmpxchg.h
18701@@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
18702 __compiletime_error("Bad argument size for cmpxchg");
18703 extern void __xadd_wrong_size(void)
18704 __compiletime_error("Bad argument size for xadd");
18705+extern void __xadd_check_overflow_wrong_size(void)
18706+ __compiletime_error("Bad argument size for xadd_check_overflow");
18707 extern void __add_wrong_size(void)
18708 __compiletime_error("Bad argument size for add");
18709+extern void __add_check_overflow_wrong_size(void)
18710+ __compiletime_error("Bad argument size for add_check_overflow");
18711
18712 /*
18713 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
18714@@ -67,6 +71,38 @@ extern void __add_wrong_size(void)
18715 __ret; \
18716 })
18717
18718+#ifdef CONFIG_PAX_REFCOUNT
18719+#define __xchg_op_check_overflow(ptr, arg, op, lock) \
18720+ ({ \
18721+ __typeof__ (*(ptr)) __ret = (arg); \
18722+ switch (sizeof(*(ptr))) { \
18723+ case __X86_CASE_L: \
18724+ asm volatile (lock #op "l %0, %1\n" \
18725+ "jno 0f\n" \
18726+ "mov %0,%1\n" \
18727+ "int $4\n0:\n" \
18728+ _ASM_EXTABLE(0b, 0b) \
18729+ : "+r" (__ret), "+m" (*(ptr)) \
18730+ : : "memory", "cc"); \
18731+ break; \
18732+ case __X86_CASE_Q: \
18733+ asm volatile (lock #op "q %q0, %1\n" \
18734+ "jno 0f\n" \
18735+ "mov %0,%1\n" \
18736+ "int $4\n0:\n" \
18737+ _ASM_EXTABLE(0b, 0b) \
18738+ : "+r" (__ret), "+m" (*(ptr)) \
18739+ : : "memory", "cc"); \
18740+ break; \
18741+ default: \
18742+ __ ## op ## _check_overflow_wrong_size(); \
18743+ } \
18744+ __ret; \
18745+ })
18746+#else
18747+#define __xchg_op_check_overflow(ptr, arg, op, lock) __xchg_op(ptr, arg, op, lock)
18748+#endif
18749+
18750 /*
18751 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
18752 * Since this is generally used to protect other memory information, we
18753@@ -165,6 +201,9 @@ extern void __add_wrong_size(void)
18754 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
18755 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
18756
18757+#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
18758+#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
18759+
18760 #define __add(ptr, inc, lock) \
18761 ({ \
18762 __typeof__ (*(ptr)) __ret = (inc); \
18763diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
18764index acdee09..a553db3 100644
18765--- a/arch/x86/include/asm/compat.h
18766+++ b/arch/x86/include/asm/compat.h
18767@@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
18768 typedef u32 compat_uint_t;
18769 typedef u32 compat_ulong_t;
18770 typedef u64 __attribute__((aligned(4))) compat_u64;
18771-typedef u32 compat_uptr_t;
18772+typedef u32 __user compat_uptr_t;
18773
18774 struct compat_timespec {
18775 compat_time_t tv_sec;
18776diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
18777index 3d6606f..300641d 100644
18778--- a/arch/x86/include/asm/cpufeature.h
18779+++ b/arch/x86/include/asm/cpufeature.h
18780@@ -214,7 +214,8 @@
18781 #define X86_FEATURE_PAUSEFILTER ( 8*32+13) /* AMD filtered pause intercept */
18782 #define X86_FEATURE_PFTHRESHOLD ( 8*32+14) /* AMD pause filter threshold */
18783 #define X86_FEATURE_VMMCALL ( 8*32+15) /* Prefer vmmcall to vmcall */
18784-
18785+#define X86_FEATURE_PCIDUDEREF ( 8*32+30) /* PaX PCID based UDEREF */
18786+#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
18787
18788 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
18789 #define X86_FEATURE_FSGSBASE ( 9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
18790@@ -222,7 +223,7 @@
18791 #define X86_FEATURE_BMI1 ( 9*32+ 3) /* 1st group bit manipulation extensions */
18792 #define X86_FEATURE_HLE ( 9*32+ 4) /* Hardware Lock Elision */
18793 #define X86_FEATURE_AVX2 ( 9*32+ 5) /* AVX2 instructions */
18794-#define X86_FEATURE_SMEP ( 9*32+ 7) /* Supervisor Mode Execution Protection */
18795+#define X86_FEATURE_SMEP ( 9*32+ 7) /* Supervisor Mode Execution Prevention */
18796 #define X86_FEATURE_BMI2 ( 9*32+ 8) /* 2nd group bit manipulation extensions */
18797 #define X86_FEATURE_ERMS ( 9*32+ 9) /* Enhanced REP MOVSB/STOSB */
18798 #define X86_FEATURE_INVPCID ( 9*32+10) /* Invalidate Processor Context ID */
18799@@ -401,6 +402,7 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
18800 #define cpu_has_eager_fpu boot_cpu_has(X86_FEATURE_EAGER_FPU)
18801 #define cpu_has_topoext boot_cpu_has(X86_FEATURE_TOPOEXT)
18802 #define cpu_has_bpext boot_cpu_has(X86_FEATURE_BPEXT)
18803+#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
18804
18805 #if __GNUC__ >= 4
18806 extern void warn_pre_alternatives(void);
18807@@ -454,7 +456,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
18808
18809 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
18810 t_warn:
18811- warn_pre_alternatives();
18812+ if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID && bit != X86_FEATURE_PCIDUDEREF)
18813+ warn_pre_alternatives();
18814 return false;
18815 #endif
18816
18817@@ -475,7 +478,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
18818 ".section .discard,\"aw\",@progbits\n"
18819 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
18820 ".previous\n"
18821- ".section .altinstr_replacement,\"ax\"\n"
18822+ ".section .altinstr_replacement,\"a\"\n"
18823 "3: movb $1,%0\n"
18824 "4:\n"
18825 ".previous\n"
18826@@ -510,7 +513,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
18827 " .byte 5f - 4f\n" /* repl len */
18828 " .byte 3b - 2b\n" /* pad len */
18829 ".previous\n"
18830- ".section .altinstr_replacement,\"ax\"\n"
18831+ ".section .altinstr_replacement,\"a\"\n"
18832 "4: jmp %l[t_no]\n"
18833 "5:\n"
18834 ".previous\n"
18835@@ -545,7 +548,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
18836 ".section .discard,\"aw\",@progbits\n"
18837 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
18838 ".previous\n"
18839- ".section .altinstr_replacement,\"ax\"\n"
18840+ ".section .altinstr_replacement,\"a\"\n"
18841 "3: movb $0,%0\n"
18842 "4:\n"
18843 ".previous\n"
18844@@ -560,7 +563,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
18845 ".section .discard,\"aw\",@progbits\n"
18846 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
18847 ".previous\n"
18848- ".section .altinstr_replacement,\"ax\"\n"
18849+ ".section .altinstr_replacement,\"a\"\n"
18850 "5: movb $1,%0\n"
18851 "6:\n"
18852 ".previous\n"
18853diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
18854index 4e10d73..7319a47 100644
18855--- a/arch/x86/include/asm/desc.h
18856+++ b/arch/x86/include/asm/desc.h
18857@@ -4,6 +4,7 @@
18858 #include <asm/desc_defs.h>
18859 #include <asm/ldt.h>
18860 #include <asm/mmu.h>
18861+#include <asm/pgtable.h>
18862
18863 #include <linux/smp.h>
18864 #include <linux/percpu.h>
18865@@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
18866
18867 desc->type = (info->read_exec_only ^ 1) << 1;
18868 desc->type |= info->contents << 2;
18869+ desc->type |= info->seg_not_present ^ 1;
18870
18871 desc->s = 1;
18872 desc->dpl = 0x3;
18873@@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
18874 }
18875
18876 extern struct desc_ptr idt_descr;
18877-extern gate_desc idt_table[];
18878-extern struct desc_ptr debug_idt_descr;
18879-extern gate_desc debug_idt_table[];
18880-
18881-struct gdt_page {
18882- struct desc_struct gdt[GDT_ENTRIES];
18883-} __attribute__((aligned(PAGE_SIZE)));
18884-
18885-DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
18886+extern gate_desc idt_table[IDT_ENTRIES];
18887+extern const struct desc_ptr debug_idt_descr;
18888+extern gate_desc debug_idt_table[IDT_ENTRIES];
18889
18890+extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
18891 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
18892 {
18893- return per_cpu(gdt_page, cpu).gdt;
18894+ return cpu_gdt_table[cpu];
18895 }
18896
18897 #ifdef CONFIG_X86_64
18898@@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
18899 unsigned long base, unsigned dpl, unsigned flags,
18900 unsigned short seg)
18901 {
18902- gate->a = (seg << 16) | (base & 0xffff);
18903- gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
18904+ gate->gate.offset_low = base;
18905+ gate->gate.seg = seg;
18906+ gate->gate.reserved = 0;
18907+ gate->gate.type = type;
18908+ gate->gate.s = 0;
18909+ gate->gate.dpl = dpl;
18910+ gate->gate.p = 1;
18911+ gate->gate.offset_high = base >> 16;
18912 }
18913
18914 #endif
18915@@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
18916
18917 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
18918 {
18919+ pax_open_kernel();
18920 memcpy(&idt[entry], gate, sizeof(*gate));
18921+ pax_close_kernel();
18922 }
18923
18924 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
18925 {
18926+ pax_open_kernel();
18927 memcpy(&ldt[entry], desc, 8);
18928+ pax_close_kernel();
18929 }
18930
18931 static inline void
18932@@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
18933 default: size = sizeof(*gdt); break;
18934 }
18935
18936+ pax_open_kernel();
18937 memcpy(&gdt[entry], desc, size);
18938+ pax_close_kernel();
18939 }
18940
18941 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
18942@@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
18943
18944 static inline void native_load_tr_desc(void)
18945 {
18946+ pax_open_kernel();
18947 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
18948+ pax_close_kernel();
18949 }
18950
18951 static inline void native_load_gdt(const struct desc_ptr *dtr)
18952@@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
18953 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
18954 unsigned int i;
18955
18956+ pax_open_kernel();
18957 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
18958 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
18959+ pax_close_kernel();
18960 }
18961
18962 /* This intentionally ignores lm, since 32-bit apps don't have that field. */
18963@@ -280,7 +293,7 @@ static inline void clear_LDT(void)
18964 set_ldt(NULL, 0);
18965 }
18966
18967-static inline unsigned long get_desc_base(const struct desc_struct *desc)
18968+static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
18969 {
18970 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
18971 }
18972@@ -304,7 +317,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
18973 }
18974
18975 #ifdef CONFIG_X86_64
18976-static inline void set_nmi_gate(int gate, void *addr)
18977+static inline void set_nmi_gate(int gate, const void *addr)
18978 {
18979 gate_desc s;
18980
18981@@ -314,14 +327,14 @@ static inline void set_nmi_gate(int gate, void *addr)
18982 #endif
18983
18984 #ifdef CONFIG_TRACING
18985-extern struct desc_ptr trace_idt_descr;
18986-extern gate_desc trace_idt_table[];
18987+extern const struct desc_ptr trace_idt_descr;
18988+extern gate_desc trace_idt_table[IDT_ENTRIES];
18989 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
18990 {
18991 write_idt_entry(trace_idt_table, entry, gate);
18992 }
18993
18994-static inline void _trace_set_gate(int gate, unsigned type, void *addr,
18995+static inline void _trace_set_gate(int gate, unsigned type, const void *addr,
18996 unsigned dpl, unsigned ist, unsigned seg)
18997 {
18998 gate_desc s;
18999@@ -341,7 +354,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
19000 #define _trace_set_gate(gate, type, addr, dpl, ist, seg)
19001 #endif
19002
19003-static inline void _set_gate(int gate, unsigned type, void *addr,
19004+static inline void _set_gate(int gate, unsigned type, const void *addr,
19005 unsigned dpl, unsigned ist, unsigned seg)
19006 {
19007 gate_desc s;
19008@@ -364,14 +377,14 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
19009 #define set_intr_gate_notrace(n, addr) \
19010 do { \
19011 BUG_ON((unsigned)n > 0xFF); \
19012- _set_gate(n, GATE_INTERRUPT, (void *)addr, 0, 0, \
19013+ _set_gate(n, GATE_INTERRUPT, (const void *)addr, 0, 0, \
19014 __KERNEL_CS); \
19015 } while (0)
19016
19017 #define set_intr_gate(n, addr) \
19018 do { \
19019 set_intr_gate_notrace(n, addr); \
19020- _trace_set_gate(n, GATE_INTERRUPT, (void *)trace_##addr,\
19021+ _trace_set_gate(n, GATE_INTERRUPT, (const void *)trace_##addr,\
19022 0, 0, __KERNEL_CS); \
19023 } while (0)
19024
19025@@ -399,19 +412,19 @@ static inline void alloc_system_vector(int vector)
19026 /*
19027 * This routine sets up an interrupt gate at directory privilege level 3.
19028 */
19029-static inline void set_system_intr_gate(unsigned int n, void *addr)
19030+static inline void set_system_intr_gate(unsigned int n, const void *addr)
19031 {
19032 BUG_ON((unsigned)n > 0xFF);
19033 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
19034 }
19035
19036-static inline void set_system_trap_gate(unsigned int n, void *addr)
19037+static inline void set_system_trap_gate(unsigned int n, const void *addr)
19038 {
19039 BUG_ON((unsigned)n > 0xFF);
19040 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
19041 }
19042
19043-static inline void set_trap_gate(unsigned int n, void *addr)
19044+static inline void set_trap_gate(unsigned int n, const void *addr)
19045 {
19046 BUG_ON((unsigned)n > 0xFF);
19047 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
19048@@ -420,16 +433,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
19049 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
19050 {
19051 BUG_ON((unsigned)n > 0xFF);
19052- _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
19053+ _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
19054 }
19055
19056-static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
19057+static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
19058 {
19059 BUG_ON((unsigned)n > 0xFF);
19060 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
19061 }
19062
19063-static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
19064+static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
19065 {
19066 BUG_ON((unsigned)n > 0xFF);
19067 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
19068@@ -501,4 +514,17 @@ static inline void load_current_idt(void)
19069 else
19070 load_idt((const struct desc_ptr *)&idt_descr);
19071 }
19072+
19073+#ifdef CONFIG_X86_32
19074+static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
19075+{
19076+ struct desc_struct d;
19077+
19078+ if (likely(limit))
19079+ limit = (limit - 1UL) >> PAGE_SHIFT;
19080+ pack_descriptor(&d, base, limit, 0xFB, 0xC);
19081+ write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
19082+}
19083+#endif
19084+
19085 #endif /* _ASM_X86_DESC_H */
19086diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
19087index 278441f..b95a174 100644
19088--- a/arch/x86/include/asm/desc_defs.h
19089+++ b/arch/x86/include/asm/desc_defs.h
19090@@ -31,6 +31,12 @@ struct desc_struct {
19091 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
19092 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
19093 };
19094+ struct {
19095+ u16 offset_low;
19096+ u16 seg;
19097+ unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
19098+ unsigned offset_high: 16;
19099+ } gate;
19100 };
19101 } __attribute__((packed));
19102
19103diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
19104index ced283a..ffe04cc 100644
19105--- a/arch/x86/include/asm/div64.h
19106+++ b/arch/x86/include/asm/div64.h
19107@@ -39,7 +39,7 @@
19108 __mod; \
19109 })
19110
19111-static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
19112+static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
19113 {
19114 union {
19115 u64 v64;
19116diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
19117index f161c18..97d43e8 100644
19118--- a/arch/x86/include/asm/elf.h
19119+++ b/arch/x86/include/asm/elf.h
19120@@ -75,9 +75,6 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
19121
19122 #include <asm/vdso.h>
19123
19124-#ifdef CONFIG_X86_64
19125-extern unsigned int vdso64_enabled;
19126-#endif
19127 #if defined(CONFIG_X86_32) || defined(CONFIG_COMPAT)
19128 extern unsigned int vdso32_enabled;
19129 #endif
19130@@ -250,7 +247,25 @@ extern int force_personality32;
19131 the loader. We need to make sure that it is out of the way of the program
19132 that it will "exec", and that there is sufficient room for the brk. */
19133
19134+#ifdef CONFIG_PAX_SEGMEXEC
19135+#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
19136+#else
19137 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
19138+#endif
19139+
19140+#ifdef CONFIG_PAX_ASLR
19141+#ifdef CONFIG_X86_32
19142+#define PAX_ELF_ET_DYN_BASE 0x10000000UL
19143+
19144+#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
19145+#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
19146+#else
19147+#define PAX_ELF_ET_DYN_BASE 0x400000UL
19148+
19149+#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
19150+#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
19151+#endif
19152+#endif
19153
19154 /* This yields a mask that user programs can use to figure out what
19155 instruction set this CPU supports. This could be done in user space,
19156@@ -299,17 +314,13 @@ do { \
19157
19158 #define ARCH_DLINFO \
19159 do { \
19160- if (vdso64_enabled) \
19161- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
19162- (unsigned long __force)current->mm->context.vdso); \
19163+ NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
19164 } while (0)
19165
19166 /* As a historical oddity, the x32 and x86_64 vDSOs are controlled together. */
19167 #define ARCH_DLINFO_X32 \
19168 do { \
19169- if (vdso64_enabled) \
19170- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
19171- (unsigned long __force)current->mm->context.vdso); \
19172+ NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
19173 } while (0)
19174
19175 #define AT_SYSINFO 32
19176@@ -324,10 +335,10 @@ else \
19177
19178 #endif /* !CONFIG_X86_32 */
19179
19180-#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
19181+#define VDSO_CURRENT_BASE (current->mm->context.vdso)
19182
19183 #define VDSO_ENTRY \
19184- ((unsigned long)current->mm->context.vdso + \
19185+ (current->mm->context.vdso + \
19186 selected_vdso32->sym___kernel_vsyscall)
19187
19188 struct linux_binprm;
19189diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
19190index 77a99ac..39ff7f5 100644
19191--- a/arch/x86/include/asm/emergency-restart.h
19192+++ b/arch/x86/include/asm/emergency-restart.h
19193@@ -1,6 +1,6 @@
19194 #ifndef _ASM_X86_EMERGENCY_RESTART_H
19195 #define _ASM_X86_EMERGENCY_RESTART_H
19196
19197-extern void machine_emergency_restart(void);
19198+extern void machine_emergency_restart(void) __noreturn;
19199
19200 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
19201diff --git a/arch/x86/include/asm/floppy.h b/arch/x86/include/asm/floppy.h
19202index 1c7eefe..d0e4702 100644
19203--- a/arch/x86/include/asm/floppy.h
19204+++ b/arch/x86/include/asm/floppy.h
19205@@ -229,18 +229,18 @@ static struct fd_routine_l {
19206 int (*_dma_setup)(char *addr, unsigned long size, int mode, int io);
19207 } fd_routine[] = {
19208 {
19209- request_dma,
19210- free_dma,
19211- get_dma_residue,
19212- dma_mem_alloc,
19213- hard_dma_setup
19214+ ._request_dma = request_dma,
19215+ ._free_dma = free_dma,
19216+ ._get_dma_residue = get_dma_residue,
19217+ ._dma_mem_alloc = dma_mem_alloc,
19218+ ._dma_setup = hard_dma_setup
19219 },
19220 {
19221- vdma_request_dma,
19222- vdma_nop,
19223- vdma_get_dma_residue,
19224- vdma_mem_alloc,
19225- vdma_dma_setup
19226+ ._request_dma = vdma_request_dma,
19227+ ._free_dma = vdma_nop,
19228+ ._get_dma_residue = vdma_get_dma_residue,
19229+ ._dma_mem_alloc = vdma_mem_alloc,
19230+ ._dma_setup = vdma_dma_setup
19231 }
19232 };
19233
19234diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
19235index 3c3550c..995858d 100644
19236--- a/arch/x86/include/asm/fpu/internal.h
19237+++ b/arch/x86/include/asm/fpu/internal.h
19238@@ -97,8 +97,11 @@ extern void fpstate_sanitize_xstate(struct fpu *fpu);
19239 #define user_insn(insn, output, input...) \
19240 ({ \
19241 int err; \
19242+ pax_open_userland(); \
19243 asm volatile(ASM_STAC "\n" \
19244- "1:" #insn "\n\t" \
19245+ "1:" \
19246+ __copyuser_seg \
19247+ #insn "\n\t" \
19248 "2: " ASM_CLAC "\n" \
19249 ".section .fixup,\"ax\"\n" \
19250 "3: movl $-1,%[err]\n" \
19251@@ -107,6 +110,7 @@ extern void fpstate_sanitize_xstate(struct fpu *fpu);
19252 _ASM_EXTABLE(1b, 3b) \
19253 : [err] "=r" (err), output \
19254 : "0"(0), input); \
19255+ pax_close_userland(); \
19256 err; \
19257 })
19258
19259@@ -186,9 +190,9 @@ static inline int copy_user_to_fregs(struct fregs_state __user *fx)
19260 static inline void copy_fxregs_to_kernel(struct fpu *fpu)
19261 {
19262 if (config_enabled(CONFIG_X86_32))
19263- asm volatile( "fxsave %[fx]" : [fx] "=m" (fpu->state.fxsave));
19264+ asm volatile( "fxsave %[fx]" : [fx] "=m" (fpu->state->fxsave));
19265 else if (config_enabled(CONFIG_AS_FXSAVEQ))
19266- asm volatile("fxsaveq %[fx]" : [fx] "=m" (fpu->state.fxsave));
19267+ asm volatile("fxsaveq %[fx]" : [fx] "=m" (fpu->state->fxsave));
19268 else {
19269 /* Using "rex64; fxsave %0" is broken because, if the memory
19270 * operand uses any extended registers for addressing, a second
19271@@ -212,8 +216,8 @@ static inline void copy_fxregs_to_kernel(struct fpu *fpu)
19272 * registers.
19273 */
19274 asm volatile( "rex64/fxsave (%[fx])"
19275- : "=m" (fpu->state.fxsave)
19276- : [fx] "R" (&fpu->state.fxsave));
19277+ : "=m" (fpu->state->fxsave)
19278+ : [fx] "R" (&fpu->state->fxsave));
19279 }
19280 }
19281
19282@@ -388,12 +392,16 @@ static inline int copy_xregs_to_user(struct xregs_state __user *buf)
19283 if (unlikely(err))
19284 return -EFAULT;
19285
19286+ pax_open_userland();
19287 __asm__ __volatile__(ASM_STAC "\n"
19288- "1:"XSAVE"\n"
19289+ "1:"
19290+ __copyuser_seg
19291+ XSAVE"\n"
19292 "2: " ASM_CLAC "\n"
19293 xstate_fault(err)
19294 : "D" (buf), "a" (-1), "d" (-1), "0" (err)
19295 : "memory");
19296+ pax_close_userland();
19297 return err;
19298 }
19299
19300@@ -402,17 +410,21 @@ static inline int copy_xregs_to_user(struct xregs_state __user *buf)
19301 */
19302 static inline int copy_user_to_xregs(struct xregs_state __user *buf, u64 mask)
19303 {
19304- struct xregs_state *xstate = ((__force struct xregs_state *)buf);
19305+ struct xregs_state *xstate = ((__force_kernel struct xregs_state *)buf);
19306 u32 lmask = mask;
19307 u32 hmask = mask >> 32;
19308 int err = 0;
19309
19310+ pax_open_userland();
19311 __asm__ __volatile__(ASM_STAC "\n"
19312- "1:"XRSTOR"\n"
19313+ "1:"
19314+ __copyuser_seg
19315+ XRSTOR"\n"
19316 "2: " ASM_CLAC "\n"
19317 xstate_fault(err)
19318 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (err)
19319 : "memory"); /* memory required? */
19320+ pax_close_userland();
19321 return err;
19322 }
19323
19324@@ -429,7 +441,7 @@ static inline int copy_user_to_xregs(struct xregs_state __user *buf, u64 mask)
19325 static inline int copy_fpregs_to_fpstate(struct fpu *fpu)
19326 {
19327 if (likely(use_xsave())) {
19328- copy_xregs_to_kernel(&fpu->state.xsave);
19329+ copy_xregs_to_kernel(&fpu->state->xsave);
19330 return 1;
19331 }
19332
19333@@ -442,7 +454,7 @@ static inline int copy_fpregs_to_fpstate(struct fpu *fpu)
19334 * Legacy FPU register saving, FNSAVE always clears FPU registers,
19335 * so we have to mark them inactive:
19336 */
19337- asm volatile("fnsave %[fp]; fwait" : [fp] "=m" (fpu->state.fsave));
19338+ asm volatile("fnsave %[fp]; fwait" : [fp] "=m" (fpu->state->fsave));
19339
19340 return 0;
19341 }
19342@@ -471,7 +483,7 @@ static inline void copy_kernel_to_fpregs(union fpregs_state *fpstate)
19343 "fnclex\n\t"
19344 "emms\n\t"
19345 "fildl %P[addr]" /* set F?P to defined value */
19346- : : [addr] "m" (fpstate));
19347+ : : [addr] "m" (cpu_tss[raw_smp_processor_id()].x86_tss.sp0));
19348 }
19349
19350 __copy_kernel_to_fpregs(fpstate);
19351@@ -643,7 +655,7 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu *new_fpu, int cpu)
19352 static inline void switch_fpu_finish(struct fpu *new_fpu, fpu_switch_t fpu_switch)
19353 {
19354 if (fpu_switch.preload)
19355- copy_kernel_to_fpregs(&new_fpu->state);
19356+ copy_kernel_to_fpregs(new_fpu->state);
19357 }
19358
19359 /*
19360diff --git a/arch/x86/include/asm/fpu/types.h b/arch/x86/include/asm/fpu/types.h
19361index c49c517..55ff1d0 100644
19362--- a/arch/x86/include/asm/fpu/types.h
19363+++ b/arch/x86/include/asm/fpu/types.h
19364@@ -287,10 +287,9 @@ struct fpu {
19365 * logic, which unconditionally saves/restores all FPU state
19366 * across context switches. (if FPU state exists.)
19367 */
19368- union fpregs_state state;
19369+ union fpregs_state *state;
19370 /*
19371- * WARNING: 'state' is dynamically-sized. Do not put
19372- * anything after it here.
19373+ * WARNING: 'state' is dynamically-sized.
19374 */
19375 };
19376
19377diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
19378index b4c1f54..e290c08 100644
19379--- a/arch/x86/include/asm/futex.h
19380+++ b/arch/x86/include/asm/futex.h
19381@@ -12,6 +12,7 @@
19382 #include <asm/smap.h>
19383
19384 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
19385+ typecheck(u32 __user *, uaddr); \
19386 asm volatile("\t" ASM_STAC "\n" \
19387 "1:\t" insn "\n" \
19388 "2:\t" ASM_CLAC "\n" \
19389@@ -20,15 +21,16 @@
19390 "\tjmp\t2b\n" \
19391 "\t.previous\n" \
19392 _ASM_EXTABLE(1b, 3b) \
19393- : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
19394+ : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
19395 : "i" (-EFAULT), "0" (oparg), "1" (0))
19396
19397 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
19398+ typecheck(u32 __user *, uaddr); \
19399 asm volatile("\t" ASM_STAC "\n" \
19400 "1:\tmovl %2, %0\n" \
19401 "\tmovl\t%0, %3\n" \
19402 "\t" insn "\n" \
19403- "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
19404+ "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
19405 "\tjnz\t1b\n" \
19406 "3:\t" ASM_CLAC "\n" \
19407 "\t.section .fixup,\"ax\"\n" \
19408@@ -38,7 +40,7 @@
19409 _ASM_EXTABLE(1b, 4b) \
19410 _ASM_EXTABLE(2b, 4b) \
19411 : "=&a" (oldval), "=&r" (ret), \
19412- "+m" (*uaddr), "=&r" (tem) \
19413+ "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
19414 : "r" (oparg), "i" (-EFAULT), "1" (0))
19415
19416 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
19417@@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
19418
19419 pagefault_disable();
19420
19421+ pax_open_userland();
19422 switch (op) {
19423 case FUTEX_OP_SET:
19424- __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
19425+ __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
19426 break;
19427 case FUTEX_OP_ADD:
19428- __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
19429+ __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
19430 uaddr, oparg);
19431 break;
19432 case FUTEX_OP_OR:
19433@@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
19434 default:
19435 ret = -ENOSYS;
19436 }
19437+ pax_close_userland();
19438
19439 pagefault_enable();
19440
19441diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
19442index 6615032..9c233be 100644
19443--- a/arch/x86/include/asm/hw_irq.h
19444+++ b/arch/x86/include/asm/hw_irq.h
19445@@ -158,8 +158,8 @@ static inline void unlock_vector_lock(void) {}
19446 #endif /* CONFIG_X86_LOCAL_APIC */
19447
19448 /* Statistics */
19449-extern atomic_t irq_err_count;
19450-extern atomic_t irq_mis_count;
19451+extern atomic_unchecked_t irq_err_count;
19452+extern atomic_unchecked_t irq_mis_count;
19453
19454 extern void elcr_set_level_irq(unsigned int irq);
19455
19456diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
19457index ccffa53..3c90c87 100644
19458--- a/arch/x86/include/asm/i8259.h
19459+++ b/arch/x86/include/asm/i8259.h
19460@@ -62,7 +62,7 @@ struct legacy_pic {
19461 void (*init)(int auto_eoi);
19462 int (*irq_pending)(unsigned int irq);
19463 void (*make_irq)(unsigned int irq);
19464-};
19465+} __do_const;
19466
19467 extern struct legacy_pic *legacy_pic;
19468 extern struct legacy_pic null_legacy_pic;
19469diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
19470index cc9c61b..7b17f40 100644
19471--- a/arch/x86/include/asm/io.h
19472+++ b/arch/x86/include/asm/io.h
19473@@ -42,6 +42,7 @@
19474 #include <asm/page.h>
19475 #include <asm/early_ioremap.h>
19476 #include <asm/pgtable_types.h>
19477+#include <asm/processor.h>
19478
19479 #define build_mmio_read(name, size, type, reg, barrier) \
19480 static inline type name(const volatile void __iomem *addr) \
19481@@ -54,12 +55,12 @@ static inline void name(type val, volatile void __iomem *addr) \
19482 "m" (*(volatile type __force *)addr) barrier); }
19483
19484 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
19485-build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
19486-build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
19487+build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
19488+build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
19489
19490 build_mmio_read(__readb, "b", unsigned char, "=q", )
19491-build_mmio_read(__readw, "w", unsigned short, "=r", )
19492-build_mmio_read(__readl, "l", unsigned int, "=r", )
19493+build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
19494+build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
19495
19496 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
19497 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
19498@@ -115,7 +116,7 @@ build_mmio_write(writeq, "q", unsigned long, "r", :"memory")
19499 * this function
19500 */
19501
19502-static inline phys_addr_t virt_to_phys(volatile void *address)
19503+static inline phys_addr_t __intentional_overflow(-1) virt_to_phys(volatile void *address)
19504 {
19505 return __pa(address);
19506 }
19507@@ -192,7 +193,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
19508 return ioremap_nocache(offset, size);
19509 }
19510
19511-extern void iounmap(volatile void __iomem *addr);
19512+extern void iounmap(const volatile void __iomem *addr);
19513
19514 extern void set_iounmap_nonlazy(void);
19515
19516@@ -200,6 +201,17 @@ extern void set_iounmap_nonlazy(void);
19517
19518 #include <asm-generic/iomap.h>
19519
19520+#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
19521+static inline int valid_phys_addr_range(unsigned long addr, size_t count)
19522+{
19523+ return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
19524+}
19525+
19526+static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
19527+{
19528+ return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
19529+}
19530+
19531 /*
19532 * Convert a virtual cached pointer to an uncached pointer
19533 */
19534diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
19535index b77f5ed..a2f791e 100644
19536--- a/arch/x86/include/asm/irqflags.h
19537+++ b/arch/x86/include/asm/irqflags.h
19538@@ -137,6 +137,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
19539 swapgs; \
19540 sysretl
19541
19542+#define GET_CR0_INTO_RDI mov %cr0, %rdi
19543+#define SET_RDI_INTO_CR0 mov %rdi, %cr0
19544+#define GET_CR3_INTO_RDI mov %cr3, %rdi
19545+#define SET_RDI_INTO_CR3 mov %rdi, %cr3
19546+
19547 #else
19548 #define INTERRUPT_RETURN iret
19549 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
19550diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
19551index 4421b5d..8543006 100644
19552--- a/arch/x86/include/asm/kprobes.h
19553+++ b/arch/x86/include/asm/kprobes.h
19554@@ -37,13 +37,8 @@ typedef u8 kprobe_opcode_t;
19555 #define RELATIVEJUMP_SIZE 5
19556 #define RELATIVECALL_OPCODE 0xe8
19557 #define RELATIVE_ADDR_SIZE 4
19558-#define MAX_STACK_SIZE 64
19559-#define MIN_STACK_SIZE(ADDR) \
19560- (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
19561- THREAD_SIZE - (unsigned long)(ADDR))) \
19562- ? (MAX_STACK_SIZE) \
19563- : (((unsigned long)current_thread_info()) + \
19564- THREAD_SIZE - (unsigned long)(ADDR)))
19565+#define MAX_STACK_SIZE 64UL
19566+#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
19567
19568 #define flush_insn_slot(p) do { } while (0)
19569
19570diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
19571index 4ad6560..75c7bdd 100644
19572--- a/arch/x86/include/asm/local.h
19573+++ b/arch/x86/include/asm/local.h
19574@@ -10,33 +10,97 @@ typedef struct {
19575 atomic_long_t a;
19576 } local_t;
19577
19578+typedef struct {
19579+ atomic_long_unchecked_t a;
19580+} local_unchecked_t;
19581+
19582 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
19583
19584 #define local_read(l) atomic_long_read(&(l)->a)
19585+#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
19586 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
19587+#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
19588
19589 static inline void local_inc(local_t *l)
19590 {
19591- asm volatile(_ASM_INC "%0"
19592+ asm volatile(_ASM_INC "%0\n"
19593+
19594+#ifdef CONFIG_PAX_REFCOUNT
19595+ "jno 0f\n"
19596+ _ASM_DEC "%0\n"
19597+ "int $4\n0:\n"
19598+ _ASM_EXTABLE(0b, 0b)
19599+#endif
19600+
19601+ : "+m" (l->a.counter));
19602+}
19603+
19604+static inline void local_inc_unchecked(local_unchecked_t *l)
19605+{
19606+ asm volatile(_ASM_INC "%0\n"
19607 : "+m" (l->a.counter));
19608 }
19609
19610 static inline void local_dec(local_t *l)
19611 {
19612- asm volatile(_ASM_DEC "%0"
19613+ asm volatile(_ASM_DEC "%0\n"
19614+
19615+#ifdef CONFIG_PAX_REFCOUNT
19616+ "jno 0f\n"
19617+ _ASM_INC "%0\n"
19618+ "int $4\n0:\n"
19619+ _ASM_EXTABLE(0b, 0b)
19620+#endif
19621+
19622+ : "+m" (l->a.counter));
19623+}
19624+
19625+static inline void local_dec_unchecked(local_unchecked_t *l)
19626+{
19627+ asm volatile(_ASM_DEC "%0\n"
19628 : "+m" (l->a.counter));
19629 }
19630
19631 static inline void local_add(long i, local_t *l)
19632 {
19633- asm volatile(_ASM_ADD "%1,%0"
19634+ asm volatile(_ASM_ADD "%1,%0\n"
19635+
19636+#ifdef CONFIG_PAX_REFCOUNT
19637+ "jno 0f\n"
19638+ _ASM_SUB "%1,%0\n"
19639+ "int $4\n0:\n"
19640+ _ASM_EXTABLE(0b, 0b)
19641+#endif
19642+
19643+ : "+m" (l->a.counter)
19644+ : "ir" (i));
19645+}
19646+
19647+static inline void local_add_unchecked(long i, local_unchecked_t *l)
19648+{
19649+ asm volatile(_ASM_ADD "%1,%0\n"
19650 : "+m" (l->a.counter)
19651 : "ir" (i));
19652 }
19653
19654 static inline void local_sub(long i, local_t *l)
19655 {
19656- asm volatile(_ASM_SUB "%1,%0"
19657+ asm volatile(_ASM_SUB "%1,%0\n"
19658+
19659+#ifdef CONFIG_PAX_REFCOUNT
19660+ "jno 0f\n"
19661+ _ASM_ADD "%1,%0\n"
19662+ "int $4\n0:\n"
19663+ _ASM_EXTABLE(0b, 0b)
19664+#endif
19665+
19666+ : "+m" (l->a.counter)
19667+ : "ir" (i));
19668+}
19669+
19670+static inline void local_sub_unchecked(long i, local_unchecked_t *l)
19671+{
19672+ asm volatile(_ASM_SUB "%1,%0\n"
19673 : "+m" (l->a.counter)
19674 : "ir" (i));
19675 }
19676@@ -52,7 +116,7 @@ static inline void local_sub(long i, local_t *l)
19677 */
19678 static inline int local_sub_and_test(long i, local_t *l)
19679 {
19680- GEN_BINARY_RMWcc(_ASM_SUB, l->a.counter, "er", i, "%0", "e");
19681+ GEN_BINARY_RMWcc(_ASM_SUB, _ASM_ADD, l->a.counter, "er", i, "%0", "e");
19682 }
19683
19684 /**
19685@@ -65,7 +129,7 @@ static inline int local_sub_and_test(long i, local_t *l)
19686 */
19687 static inline int local_dec_and_test(local_t *l)
19688 {
19689- GEN_UNARY_RMWcc(_ASM_DEC, l->a.counter, "%0", "e");
19690+ GEN_UNARY_RMWcc(_ASM_DEC, _ASM_INC, l->a.counter, "%0", "e");
19691 }
19692
19693 /**
19694@@ -78,7 +142,7 @@ static inline int local_dec_and_test(local_t *l)
19695 */
19696 static inline int local_inc_and_test(local_t *l)
19697 {
19698- GEN_UNARY_RMWcc(_ASM_INC, l->a.counter, "%0", "e");
19699+ GEN_UNARY_RMWcc(_ASM_INC, _ASM_DEC, l->a.counter, "%0", "e");
19700 }
19701
19702 /**
19703@@ -92,7 +156,7 @@ static inline int local_inc_and_test(local_t *l)
19704 */
19705 static inline int local_add_negative(long i, local_t *l)
19706 {
19707- GEN_BINARY_RMWcc(_ASM_ADD, l->a.counter, "er", i, "%0", "s");
19708+ GEN_BINARY_RMWcc(_ASM_ADD, _ASM_SUB, l->a.counter, "er", i, "%0", "s");
19709 }
19710
19711 /**
19712@@ -105,6 +169,30 @@ static inline int local_add_negative(long i, local_t *l)
19713 static inline long local_add_return(long i, local_t *l)
19714 {
19715 long __i = i;
19716+ asm volatile(_ASM_XADD "%0, %1\n"
19717+
19718+#ifdef CONFIG_PAX_REFCOUNT
19719+ "jno 0f\n"
19720+ _ASM_MOV "%0,%1\n"
19721+ "int $4\n0:\n"
19722+ _ASM_EXTABLE(0b, 0b)
19723+#endif
19724+
19725+ : "+r" (i), "+m" (l->a.counter)
19726+ : : "memory");
19727+ return i + __i;
19728+}
19729+
19730+/**
19731+ * local_add_return_unchecked - add and return
19732+ * @i: integer value to add
19733+ * @l: pointer to type local_unchecked_t
19734+ *
19735+ * Atomically adds @i to @l and returns @i + @l
19736+ */
19737+static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
19738+{
19739+ long __i = i;
19740 asm volatile(_ASM_XADD "%0, %1;"
19741 : "+r" (i), "+m" (l->a.counter)
19742 : : "memory");
19743@@ -121,6 +209,8 @@ static inline long local_sub_return(long i, local_t *l)
19744
19745 #define local_cmpxchg(l, o, n) \
19746 (cmpxchg_local(&((l)->a.counter), (o), (n)))
19747+#define local_cmpxchg_unchecked(l, o, n) \
19748+ (cmpxchg_local(&((l)->a.counter), (o), (n)))
19749 /* Always has a lock prefix */
19750 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
19751
19752diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
19753new file mode 100644
19754index 0000000..2bfd3ba
19755--- /dev/null
19756+++ b/arch/x86/include/asm/mman.h
19757@@ -0,0 +1,15 @@
19758+#ifndef _X86_MMAN_H
19759+#define _X86_MMAN_H
19760+
19761+#include <uapi/asm/mman.h>
19762+
19763+#ifdef __KERNEL__
19764+#ifndef __ASSEMBLY__
19765+#ifdef CONFIG_X86_32
19766+#define arch_mmap_check i386_mmap_check
19767+int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
19768+#endif
19769+#endif
19770+#endif
19771+
19772+#endif /* X86_MMAN_H */
19773diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
19774index 364d274..e51b4bc 100644
19775--- a/arch/x86/include/asm/mmu.h
19776+++ b/arch/x86/include/asm/mmu.h
19777@@ -17,7 +17,19 @@ typedef struct {
19778 #endif
19779
19780 struct mutex lock;
19781- void __user *vdso;
19782+ unsigned long vdso;
19783+
19784+#ifdef CONFIG_X86_32
19785+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
19786+ unsigned long user_cs_base;
19787+ unsigned long user_cs_limit;
19788+
19789+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
19790+ cpumask_t cpu_user_cs_mask;
19791+#endif
19792+
19793+#endif
19794+#endif
19795
19796 atomic_t perf_rdpmc_allowed; /* nonzero if rdpmc is allowed */
19797 } mm_context_t;
19798diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
19799index 984abfe..9996c62 100644
19800--- a/arch/x86/include/asm/mmu_context.h
19801+++ b/arch/x86/include/asm/mmu_context.h
19802@@ -45,7 +45,7 @@ struct ldt_struct {
19803 * allocations, but it's not worth trying to optimize.
19804 */
19805 struct desc_struct *entries;
19806- int size;
19807+ unsigned int size;
19808 };
19809
19810 static inline void load_mm_ldt(struct mm_struct *mm)
19811@@ -86,26 +86,95 @@ void destroy_context(struct mm_struct *mm);
19812
19813 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
19814 {
19815+
19816+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19817+ if (!(static_cpu_has(X86_FEATURE_PCIDUDEREF))) {
19818+ unsigned int i;
19819+ pgd_t *pgd;
19820+
19821+ pax_open_kernel();
19822+ pgd = get_cpu_pgd(smp_processor_id(), kernel);
19823+ for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
19824+ set_pgd_batched(pgd+i, native_make_pgd(0));
19825+ pax_close_kernel();
19826+ }
19827+#endif
19828+
19829 #ifdef CONFIG_SMP
19830 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
19831 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
19832 #endif
19833 }
19834
19835+static inline void pax_switch_mm(struct mm_struct *next, unsigned int cpu)
19836+{
19837+
19838+#ifdef CONFIG_PAX_PER_CPU_PGD
19839+ pax_open_kernel();
19840+
19841+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19842+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF))
19843+ __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
19844+ else
19845+#endif
19846+
19847+ __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
19848+
19849+ __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
19850+
19851+ pax_close_kernel();
19852+
19853+ BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
19854+
19855+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19856+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF)) {
19857+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
19858+ u64 descriptor[2];
19859+ descriptor[0] = PCID_USER;
19860+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
19861+ if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
19862+ descriptor[0] = PCID_KERNEL;
19863+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
19864+ }
19865+ } else {
19866+ write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
19867+ if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
19868+ write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
19869+ else
19870+ write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
19871+ }
19872+ } else
19873+#endif
19874+
19875+ load_cr3(get_cpu_pgd(cpu, kernel));
19876+#endif
19877+
19878+}
19879+
19880 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
19881 struct task_struct *tsk)
19882 {
19883 unsigned cpu = smp_processor_id();
19884+#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
19885+ int tlbstate = TLBSTATE_OK;
19886+#endif
19887
19888 if (likely(prev != next)) {
19889 #ifdef CONFIG_SMP
19890+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
19891+ tlbstate = this_cpu_read(cpu_tlbstate.state);
19892+#endif
19893 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
19894 this_cpu_write(cpu_tlbstate.active_mm, next);
19895 #endif
19896 cpumask_set_cpu(cpu, mm_cpumask(next));
19897
19898 /* Re-load page tables */
19899+#ifdef CONFIG_PAX_PER_CPU_PGD
19900+ pax_switch_mm(next, cpu);
19901+#else
19902 load_cr3(next->pgd);
19903+#endif
19904 trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL);
19905
19906 /* Stop flush ipis for the previous mm */
19907@@ -128,9 +197,31 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
19908 */
19909 if (unlikely(prev->context.ldt != next->context.ldt))
19910 load_mm_ldt(next);
19911+
19912+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
19913+ if (!(__supported_pte_mask & _PAGE_NX)) {
19914+ smp_mb__before_atomic();
19915+ cpumask_clear_cpu(cpu, &prev->context.cpu_user_cs_mask);
19916+ smp_mb__after_atomic();
19917+ cpumask_set_cpu(cpu, &next->context.cpu_user_cs_mask);
19918+ }
19919+#endif
19920+
19921+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
19922+ if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
19923+ prev->context.user_cs_limit != next->context.user_cs_limit))
19924+ set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
19925+#ifdef CONFIG_SMP
19926+ else if (unlikely(tlbstate != TLBSTATE_OK))
19927+ set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
19928+#endif
19929+#endif
19930+
19931 }
19932+ else {
19933+ pax_switch_mm(next, cpu);
19934+
19935 #ifdef CONFIG_SMP
19936- else {
19937 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
19938 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
19939
19940@@ -147,13 +238,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
19941 * tlb flush IPI delivery. We must reload CR3
19942 * to make sure to use no freed page tables.
19943 */
19944+
19945+#ifndef CONFIG_PAX_PER_CPU_PGD
19946 load_cr3(next->pgd);
19947 trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL);
19948+#endif
19949+
19950 load_mm_cr4(next);
19951 load_mm_ldt(next);
19952+
19953+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
19954+ if (!(__supported_pte_mask & _PAGE_NX))
19955+ cpumask_set_cpu(cpu, &next->context.cpu_user_cs_mask);
19956+#endif
19957+
19958+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
19959+#ifdef CONFIG_PAX_PAGEEXEC
19960+ if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
19961+#endif
19962+ set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
19963+#endif
19964+
19965 }
19966+#endif
19967 }
19968-#endif
19969 }
19970
19971 #define activate_mm(prev, next) \
19972diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
19973index e3b7819..b257c64 100644
19974--- a/arch/x86/include/asm/module.h
19975+++ b/arch/x86/include/asm/module.h
19976@@ -5,6 +5,7 @@
19977
19978 #ifdef CONFIG_X86_64
19979 /* X86_64 does not define MODULE_PROC_FAMILY */
19980+#define MODULE_PROC_FAMILY ""
19981 #elif defined CONFIG_M486
19982 #define MODULE_PROC_FAMILY "486 "
19983 #elif defined CONFIG_M586
19984@@ -57,8 +58,20 @@
19985 #error unknown processor family
19986 #endif
19987
19988-#ifdef CONFIG_X86_32
19989-# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
19990+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
19991+#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
19992+#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
19993+#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
19994+#else
19995+#define MODULE_PAX_KERNEXEC ""
19996 #endif
19997
19998+#ifdef CONFIG_PAX_MEMORY_UDEREF
19999+#define MODULE_PAX_UDEREF "UDEREF "
20000+#else
20001+#define MODULE_PAX_UDEREF ""
20002+#endif
20003+
20004+#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
20005+
20006 #endif /* _ASM_X86_MODULE_H */
20007diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
20008index 5f2fc44..106caa6 100644
20009--- a/arch/x86/include/asm/nmi.h
20010+++ b/arch/x86/include/asm/nmi.h
20011@@ -36,26 +36,35 @@ enum {
20012
20013 typedef int (*nmi_handler_t)(unsigned int, struct pt_regs *);
20014
20015+struct nmiaction;
20016+
20017+struct nmiwork {
20018+ const struct nmiaction *action;
20019+ u64 max_duration;
20020+ struct irq_work irq_work;
20021+};
20022+
20023 struct nmiaction {
20024 struct list_head list;
20025 nmi_handler_t handler;
20026- u64 max_duration;
20027- struct irq_work irq_work;
20028 unsigned long flags;
20029 const char *name;
20030-};
20031+ struct nmiwork *work;
20032+} __do_const;
20033
20034 #define register_nmi_handler(t, fn, fg, n, init...) \
20035 ({ \
20036- static struct nmiaction init fn##_na = { \
20037+ static struct nmiwork fn##_nw; \
20038+ static const struct nmiaction init fn##_na = { \
20039 .handler = (fn), \
20040 .name = (n), \
20041 .flags = (fg), \
20042+ .work = &fn##_nw, \
20043 }; \
20044 __register_nmi_handler((t), &fn##_na); \
20045 })
20046
20047-int __register_nmi_handler(unsigned int, struct nmiaction *);
20048+int __register_nmi_handler(unsigned int, const struct nmiaction *);
20049
20050 void unregister_nmi_handler(unsigned int, const char *);
20051
20052diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
20053index 802dde3..9183e68 100644
20054--- a/arch/x86/include/asm/page.h
20055+++ b/arch/x86/include/asm/page.h
20056@@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
20057 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
20058
20059 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
20060+#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
20061
20062 #define __boot_va(x) __va(x)
20063 #define __boot_pa(x) __pa(x)
20064@@ -60,11 +61,21 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
20065 * virt_to_page(kaddr) returns a valid pointer if and only if
20066 * virt_addr_valid(kaddr) returns true.
20067 */
20068-#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
20069 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
20070 extern bool __virt_addr_valid(unsigned long kaddr);
20071 #define virt_addr_valid(kaddr) __virt_addr_valid((unsigned long) (kaddr))
20072
20073+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
20074+#define virt_to_page(kaddr) \
20075+ ({ \
20076+ const void *__kaddr = (const void *)(kaddr); \
20077+ BUG_ON(!virt_addr_valid(__kaddr)); \
20078+ pfn_to_page(__pa(__kaddr) >> PAGE_SHIFT); \
20079+ })
20080+#else
20081+#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
20082+#endif
20083+
20084 #endif /* __ASSEMBLY__ */
20085
20086 #include <asm-generic/memory_model.h>
20087diff --git a/arch/x86/include/asm/page_32.h b/arch/x86/include/asm/page_32.h
20088index 904f528..b4d0d24 100644
20089--- a/arch/x86/include/asm/page_32.h
20090+++ b/arch/x86/include/asm/page_32.h
20091@@ -7,11 +7,17 @@
20092
20093 #define __phys_addr_nodebug(x) ((x) - PAGE_OFFSET)
20094 #ifdef CONFIG_DEBUG_VIRTUAL
20095-extern unsigned long __phys_addr(unsigned long);
20096+extern unsigned long __intentional_overflow(-1) __phys_addr(unsigned long);
20097 #else
20098-#define __phys_addr(x) __phys_addr_nodebug(x)
20099+static inline unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
20100+{
20101+ return __phys_addr_nodebug(x);
20102+}
20103 #endif
20104-#define __phys_addr_symbol(x) __phys_addr(x)
20105+static inline unsigned long __intentional_overflow(-1) __phys_addr_symbol(unsigned long x)
20106+{
20107+ return __phys_addr(x);
20108+}
20109 #define __phys_reloc_hide(x) RELOC_HIDE((x), 0)
20110
20111 #ifdef CONFIG_FLATMEM
20112diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
20113index b3bebf9..cb419e7 100644
20114--- a/arch/x86/include/asm/page_64.h
20115+++ b/arch/x86/include/asm/page_64.h
20116@@ -7,9 +7,9 @@
20117
20118 /* duplicated to the one in bootmem.h */
20119 extern unsigned long max_pfn;
20120-extern unsigned long phys_base;
20121+extern const unsigned long phys_base;
20122
20123-static inline unsigned long __phys_addr_nodebug(unsigned long x)
20124+static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
20125 {
20126 unsigned long y = x - __START_KERNEL_map;
20127
20128@@ -20,12 +20,14 @@ static inline unsigned long __phys_addr_nodebug(unsigned long x)
20129 }
20130
20131 #ifdef CONFIG_DEBUG_VIRTUAL
20132-extern unsigned long __phys_addr(unsigned long);
20133-extern unsigned long __phys_addr_symbol(unsigned long);
20134+extern unsigned long __intentional_overflow(-1) __phys_addr(unsigned long);
20135+extern unsigned long __intentional_overflow(-1) __phys_addr_symbol(unsigned long);
20136 #else
20137 #define __phys_addr(x) __phys_addr_nodebug(x)
20138-#define __phys_addr_symbol(x) \
20139- ((unsigned long)(x) - __START_KERNEL_map + phys_base)
20140+static inline unsigned long __intentional_overflow(-1) __phys_addr_symbol(unsigned long x)
20141+{
20142+ return x - __START_KERNEL_map + phys_base;
20143+}
20144 #endif
20145
20146 #define __phys_reloc_hide(x) (x)
20147diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
20148index d143bfa..30d1f41 100644
20149--- a/arch/x86/include/asm/paravirt.h
20150+++ b/arch/x86/include/asm/paravirt.h
20151@@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
20152 return (pmd_t) { ret };
20153 }
20154
20155-static inline pmdval_t pmd_val(pmd_t pmd)
20156+static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
20157 {
20158 pmdval_t ret;
20159
20160@@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
20161 val);
20162 }
20163
20164+static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
20165+{
20166+ pgdval_t val = native_pgd_val(pgd);
20167+
20168+ if (sizeof(pgdval_t) > sizeof(long))
20169+ PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
20170+ val, (u64)val >> 32);
20171+ else
20172+ PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
20173+ val);
20174+}
20175+
20176 static inline void pgd_clear(pgd_t *pgdp)
20177 {
20178 set_pgd(pgdp, __pgd(0));
20179@@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
20180 pv_mmu_ops.set_fixmap(idx, phys, flags);
20181 }
20182
20183+#ifdef CONFIG_PAX_KERNEXEC
20184+static inline unsigned long pax_open_kernel(void)
20185+{
20186+ return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
20187+}
20188+
20189+static inline unsigned long pax_close_kernel(void)
20190+{
20191+ return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
20192+}
20193+#else
20194+static inline unsigned long pax_open_kernel(void) { return 0; }
20195+static inline unsigned long pax_close_kernel(void) { return 0; }
20196+#endif
20197+
20198 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
20199
20200 #ifdef CONFIG_QUEUED_SPINLOCKS
20201@@ -933,7 +960,7 @@ extern void default_banner(void);
20202
20203 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
20204 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
20205-#define PARA_INDIRECT(addr) *%cs:addr
20206+#define PARA_INDIRECT(addr) *%ss:addr
20207 #endif
20208
20209 #define INTERRUPT_RETURN \
20210@@ -1003,6 +1030,21 @@ extern void default_banner(void);
20211 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_usergs_sysret64), \
20212 CLBR_NONE, \
20213 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_usergs_sysret64))
20214+
20215+#define GET_CR0_INTO_RDI \
20216+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
20217+ mov %rax,%rdi
20218+
20219+#define SET_RDI_INTO_CR0 \
20220+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20221+
20222+#define GET_CR3_INTO_RDI \
20223+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
20224+ mov %rax,%rdi
20225+
20226+#define SET_RDI_INTO_CR3 \
20227+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
20228+
20229 #endif /* CONFIG_X86_32 */
20230
20231 #endif /* __ASSEMBLY__ */
20232diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
20233index a6b8f9f..fd61ef7 100644
20234--- a/arch/x86/include/asm/paravirt_types.h
20235+++ b/arch/x86/include/asm/paravirt_types.h
20236@@ -84,7 +84,7 @@ struct pv_init_ops {
20237 */
20238 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
20239 unsigned long addr, unsigned len);
20240-};
20241+} __no_const __no_randomize_layout;
20242
20243
20244 struct pv_lazy_ops {
20245@@ -92,13 +92,13 @@ struct pv_lazy_ops {
20246 void (*enter)(void);
20247 void (*leave)(void);
20248 void (*flush)(void);
20249-};
20250+} __no_randomize_layout;
20251
20252 struct pv_time_ops {
20253 unsigned long long (*sched_clock)(void);
20254 unsigned long long (*steal_clock)(int cpu);
20255 unsigned long (*get_tsc_khz)(void);
20256-};
20257+} __no_const __no_randomize_layout;
20258
20259 struct pv_cpu_ops {
20260 /* hooks for various privileged instructions */
20261@@ -193,7 +193,7 @@ struct pv_cpu_ops {
20262
20263 void (*start_context_switch)(struct task_struct *prev);
20264 void (*end_context_switch)(struct task_struct *next);
20265-};
20266+} __no_const __no_randomize_layout;
20267
20268 struct pv_irq_ops {
20269 /*
20270@@ -216,7 +216,7 @@ struct pv_irq_ops {
20271 #ifdef CONFIG_X86_64
20272 void (*adjust_exception_frame)(void);
20273 #endif
20274-};
20275+} __no_randomize_layout;
20276
20277 struct pv_apic_ops {
20278 #ifdef CONFIG_X86_LOCAL_APIC
20279@@ -224,7 +224,7 @@ struct pv_apic_ops {
20280 unsigned long start_eip,
20281 unsigned long start_esp);
20282 #endif
20283-};
20284+} __no_const __no_randomize_layout;
20285
20286 struct pv_mmu_ops {
20287 unsigned long (*read_cr2)(void);
20288@@ -314,6 +314,7 @@ struct pv_mmu_ops {
20289 struct paravirt_callee_save make_pud;
20290
20291 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
20292+ void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
20293 #endif /* CONFIG_PGTABLE_LEVELS == 4 */
20294 #endif /* CONFIG_PGTABLE_LEVELS >= 3 */
20295
20296@@ -325,7 +326,13 @@ struct pv_mmu_ops {
20297 an mfn. We can tell which is which from the index. */
20298 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
20299 phys_addr_t phys, pgprot_t flags);
20300-};
20301+
20302+#ifdef CONFIG_PAX_KERNEXEC
20303+ unsigned long (*pax_open_kernel)(void);
20304+ unsigned long (*pax_close_kernel)(void);
20305+#endif
20306+
20307+} __no_randomize_layout;
20308
20309 struct arch_spinlock;
20310 #ifdef CONFIG_SMP
20311@@ -347,11 +354,14 @@ struct pv_lock_ops {
20312 struct paravirt_callee_save lock_spinning;
20313 void (*unlock_kick)(struct arch_spinlock *lock, __ticket_t ticket);
20314 #endif /* !CONFIG_QUEUED_SPINLOCKS */
20315-};
20316+} __no_randomize_layout;
20317
20318 /* This contains all the paravirt structures: we get a convenient
20319 * number for each function using the offset which we use to indicate
20320- * what to patch. */
20321+ * what to patch.
20322+ * shouldn't be randomized due to the "NEAT TRICK" in paravirt.c
20323+ */
20324+
20325 struct paravirt_patch_template {
20326 struct pv_init_ops pv_init_ops;
20327 struct pv_time_ops pv_time_ops;
20328@@ -360,7 +370,7 @@ struct paravirt_patch_template {
20329 struct pv_apic_ops pv_apic_ops;
20330 struct pv_mmu_ops pv_mmu_ops;
20331 struct pv_lock_ops pv_lock_ops;
20332-};
20333+} __no_randomize_layout;
20334
20335 extern struct pv_info pv_info;
20336 extern struct pv_init_ops pv_init_ops;
20337diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
20338index bf7f8b5..ca5799d 100644
20339--- a/arch/x86/include/asm/pgalloc.h
20340+++ b/arch/x86/include/asm/pgalloc.h
20341@@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
20342 pmd_t *pmd, pte_t *pte)
20343 {
20344 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
20345+ set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
20346+}
20347+
20348+static inline void pmd_populate_user(struct mm_struct *mm,
20349+ pmd_t *pmd, pte_t *pte)
20350+{
20351+ paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
20352 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
20353 }
20354
20355@@ -108,12 +115,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
20356
20357 #ifdef CONFIG_X86_PAE
20358 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
20359+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
20360+{
20361+ pud_populate(mm, pudp, pmd);
20362+}
20363 #else /* !CONFIG_X86_PAE */
20364 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
20365 {
20366 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
20367 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
20368 }
20369+
20370+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
20371+{
20372+ paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
20373+ set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
20374+}
20375 #endif /* CONFIG_X86_PAE */
20376
20377 #if CONFIG_PGTABLE_LEVELS > 3
20378@@ -123,6 +140,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
20379 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
20380 }
20381
20382+static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
20383+{
20384+ paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
20385+ set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
20386+}
20387+
20388 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
20389 {
20390 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
20391diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
20392index fd74a11..35fd5af 100644
20393--- a/arch/x86/include/asm/pgtable-2level.h
20394+++ b/arch/x86/include/asm/pgtable-2level.h
20395@@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
20396
20397 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
20398 {
20399+ pax_open_kernel();
20400 *pmdp = pmd;
20401+ pax_close_kernel();
20402 }
20403
20404 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
20405diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
20406index cdaa58c..ae30f0d 100644
20407--- a/arch/x86/include/asm/pgtable-3level.h
20408+++ b/arch/x86/include/asm/pgtable-3level.h
20409@@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
20410
20411 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
20412 {
20413+ pax_open_kernel();
20414 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
20415+ pax_close_kernel();
20416 }
20417
20418 static inline void native_set_pud(pud_t *pudp, pud_t pud)
20419 {
20420+ pax_open_kernel();
20421 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
20422+ pax_close_kernel();
20423 }
20424
20425 /*
20426@@ -116,9 +120,12 @@ static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr,
20427 static inline void native_pmd_clear(pmd_t *pmd)
20428 {
20429 u32 *tmp = (u32 *)pmd;
20430+
20431+ pax_open_kernel();
20432 *tmp = 0;
20433 smp_wmb();
20434 *(tmp + 1) = 0;
20435+ pax_close_kernel();
20436 }
20437
20438 static inline void pud_clear(pud_t *pudp)
20439diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
20440index 867da5b..7ec083d 100644
20441--- a/arch/x86/include/asm/pgtable.h
20442+++ b/arch/x86/include/asm/pgtable.h
20443@@ -47,6 +47,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
20444
20445 #ifndef __PAGETABLE_PUD_FOLDED
20446 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
20447+#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
20448 #define pgd_clear(pgd) native_pgd_clear(pgd)
20449 #endif
20450
20451@@ -84,12 +85,53 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
20452
20453 #define arch_end_context_switch(prev) do {} while(0)
20454
20455+#define pax_open_kernel() native_pax_open_kernel()
20456+#define pax_close_kernel() native_pax_close_kernel()
20457 #endif /* CONFIG_PARAVIRT */
20458
20459+#define __HAVE_ARCH_PAX_OPEN_KERNEL
20460+#define __HAVE_ARCH_PAX_CLOSE_KERNEL
20461+
20462+#ifdef CONFIG_PAX_KERNEXEC
20463+static inline unsigned long native_pax_open_kernel(void)
20464+{
20465+ unsigned long cr0;
20466+
20467+ preempt_disable();
20468+ barrier();
20469+ cr0 = read_cr0() ^ X86_CR0_WP;
20470+ BUG_ON(cr0 & X86_CR0_WP);
20471+ write_cr0(cr0);
20472+ barrier();
20473+ return cr0 ^ X86_CR0_WP;
20474+}
20475+
20476+static inline unsigned long native_pax_close_kernel(void)
20477+{
20478+ unsigned long cr0;
20479+
20480+ barrier();
20481+ cr0 = read_cr0() ^ X86_CR0_WP;
20482+ BUG_ON(!(cr0 & X86_CR0_WP));
20483+ write_cr0(cr0);
20484+ barrier();
20485+ preempt_enable_no_resched();
20486+ return cr0 ^ X86_CR0_WP;
20487+}
20488+#else
20489+static inline unsigned long native_pax_open_kernel(void) { return 0; }
20490+static inline unsigned long native_pax_close_kernel(void) { return 0; }
20491+#endif
20492+
20493 /*
20494 * The following only work if pte_present() is true.
20495 * Undefined behaviour if not..
20496 */
20497+static inline int pte_user(pte_t pte)
20498+{
20499+ return pte_val(pte) & _PAGE_USER;
20500+}
20501+
20502 static inline int pte_dirty(pte_t pte)
20503 {
20504 return pte_flags(pte) & _PAGE_DIRTY;
20505@@ -150,6 +192,11 @@ static inline unsigned long pud_pfn(pud_t pud)
20506 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
20507 }
20508
20509+static inline unsigned long pgd_pfn(pgd_t pgd)
20510+{
20511+ return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
20512+}
20513+
20514 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
20515
20516 static inline int pmd_large(pmd_t pte)
20517@@ -203,9 +250,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
20518 return pte_clear_flags(pte, _PAGE_RW);
20519 }
20520
20521+static inline pte_t pte_mkread(pte_t pte)
20522+{
20523+ return __pte(pte_val(pte) | _PAGE_USER);
20524+}
20525+
20526 static inline pte_t pte_mkexec(pte_t pte)
20527 {
20528- return pte_clear_flags(pte, _PAGE_NX);
20529+#ifdef CONFIG_X86_PAE
20530+ if (__supported_pte_mask & _PAGE_NX)
20531+ return pte_clear_flags(pte, _PAGE_NX);
20532+ else
20533+#endif
20534+ return pte_set_flags(pte, _PAGE_USER);
20535+}
20536+
20537+static inline pte_t pte_exprotect(pte_t pte)
20538+{
20539+#ifdef CONFIG_X86_PAE
20540+ if (__supported_pte_mask & _PAGE_NX)
20541+ return pte_set_flags(pte, _PAGE_NX);
20542+ else
20543+#endif
20544+ return pte_clear_flags(pte, _PAGE_USER);
20545 }
20546
20547 static inline pte_t pte_mkdirty(pte_t pte)
20548@@ -426,6 +493,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
20549 #endif
20550
20551 #ifndef __ASSEMBLY__
20552+
20553+#ifdef CONFIG_PAX_PER_CPU_PGD
20554+extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
20555+enum cpu_pgd_type {kernel = 0, user = 1};
20556+static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
20557+{
20558+ return cpu_pgd[cpu][type];
20559+}
20560+#endif
20561+
20562 #include <linux/mm_types.h>
20563 #include <linux/mmdebug.h>
20564 #include <linux/log2.h>
20565@@ -577,7 +654,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
20566 * Currently stuck as a macro due to indirect forward reference to
20567 * linux/mmzone.h's __section_mem_map_addr() definition:
20568 */
20569-#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
20570+#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
20571
20572 /* Find an entry in the second-level page table.. */
20573 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
20574@@ -617,7 +694,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
20575 * Currently stuck as a macro due to indirect forward reference to
20576 * linux/mmzone.h's __section_mem_map_addr() definition:
20577 */
20578-#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
20579+#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
20580
20581 /* to find an entry in a page-table-directory. */
20582 static inline unsigned long pud_index(unsigned long address)
20583@@ -632,7 +709,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
20584
20585 static inline int pgd_bad(pgd_t pgd)
20586 {
20587- return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
20588+ return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
20589 }
20590
20591 static inline int pgd_none(pgd_t pgd)
20592@@ -655,7 +732,12 @@ static inline int pgd_none(pgd_t pgd)
20593 * pgd_offset() returns a (pgd_t *)
20594 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
20595 */
20596-#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
20597+#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
20598+
20599+#ifdef CONFIG_PAX_PER_CPU_PGD
20600+#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
20601+#endif
20602+
20603 /*
20604 * a shortcut which implies the use of the kernel's pgd, instead
20605 * of a process's
20606@@ -666,6 +748,25 @@ static inline int pgd_none(pgd_t pgd)
20607 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
20608 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
20609
20610+#ifdef CONFIG_X86_32
20611+#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
20612+#else
20613+#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
20614+#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
20615+
20616+#ifdef CONFIG_PAX_MEMORY_UDEREF
20617+#ifdef __ASSEMBLY__
20618+#define pax_user_shadow_base pax_user_shadow_base(%rip)
20619+#else
20620+extern unsigned long pax_user_shadow_base;
20621+extern pgdval_t clone_pgd_mask;
20622+#endif
20623+#else
20624+#define pax_user_shadow_base (0UL)
20625+#endif
20626+
20627+#endif
20628+
20629 #ifndef __ASSEMBLY__
20630
20631 extern int direct_gbpages;
20632@@ -832,11 +933,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
20633 * dst and src can be on the same page, but the range must not overlap,
20634 * and must not cross a page boundary.
20635 */
20636-static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
20637+static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
20638 {
20639- memcpy(dst, src, count * sizeof(pgd_t));
20640+ pax_open_kernel();
20641+ while (count--)
20642+ *dst++ = *src++;
20643+ pax_close_kernel();
20644 }
20645
20646+#ifdef CONFIG_PAX_PER_CPU_PGD
20647+extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
20648+#endif
20649+
20650+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
20651+extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
20652+#else
20653+static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
20654+#endif
20655+
20656 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
20657 static inline int page_level_shift(enum pg_level level)
20658 {
20659diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
20660index b6c0b40..3535d47 100644
20661--- a/arch/x86/include/asm/pgtable_32.h
20662+++ b/arch/x86/include/asm/pgtable_32.h
20663@@ -25,9 +25,6 @@
20664 struct mm_struct;
20665 struct vm_area_struct;
20666
20667-extern pgd_t swapper_pg_dir[1024];
20668-extern pgd_t initial_page_table[1024];
20669-
20670 static inline void pgtable_cache_init(void) { }
20671 static inline void check_pgt_cache(void) { }
20672 void paging_init(void);
20673@@ -45,6 +42,12 @@ void paging_init(void);
20674 # include <asm/pgtable-2level.h>
20675 #endif
20676
20677+extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
20678+extern pgd_t initial_page_table[PTRS_PER_PGD];
20679+#ifdef CONFIG_X86_PAE
20680+extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
20681+#endif
20682+
20683 #if defined(CONFIG_HIGHPTE)
20684 #define pte_offset_map(dir, address) \
20685 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
20686@@ -59,12 +62,17 @@ void paging_init(void);
20687 /* Clear a kernel PTE and flush it from the TLB */
20688 #define kpte_clear_flush(ptep, vaddr) \
20689 do { \
20690+ pax_open_kernel(); \
20691 pte_clear(&init_mm, (vaddr), (ptep)); \
20692+ pax_close_kernel(); \
20693 __flush_tlb_one((vaddr)); \
20694 } while (0)
20695
20696 #endif /* !__ASSEMBLY__ */
20697
20698+#define HAVE_ARCH_UNMAPPED_AREA
20699+#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
20700+
20701 /*
20702 * kern_addr_valid() is (1) for FLATMEM and (0) for
20703 * SPARSEMEM and DISCONTIGMEM
20704diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
20705index 9fb2f2b..8e18c70 100644
20706--- a/arch/x86/include/asm/pgtable_32_types.h
20707+++ b/arch/x86/include/asm/pgtable_32_types.h
20708@@ -8,7 +8,7 @@
20709 */
20710 #ifdef CONFIG_X86_PAE
20711 # include <asm/pgtable-3level_types.h>
20712-# define PMD_SIZE (1UL << PMD_SHIFT)
20713+# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
20714 # define PMD_MASK (~(PMD_SIZE - 1))
20715 #else
20716 # include <asm/pgtable-2level_types.h>
20717@@ -46,6 +46,28 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
20718 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
20719 #endif
20720
20721+#ifdef CONFIG_PAX_KERNEXEC
20722+#ifndef __ASSEMBLY__
20723+extern unsigned char MODULES_EXEC_VADDR[];
20724+extern unsigned char MODULES_EXEC_END[];
20725+
20726+extern unsigned char __LOAD_PHYSICAL_ADDR[];
20727+#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
20728+static inline unsigned long __intentional_overflow(-1) ktla_ktva(unsigned long addr)
20729+{
20730+ return addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET;
20731+
20732+}
20733+static inline unsigned long __intentional_overflow(-1) ktva_ktla(unsigned long addr)
20734+{
20735+ return addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET;
20736+}
20737+#endif
20738+#else
20739+#define ktla_ktva(addr) (addr)
20740+#define ktva_ktla(addr) (addr)
20741+#endif
20742+
20743 #define MODULES_VADDR VMALLOC_START
20744 #define MODULES_END VMALLOC_END
20745 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
20746diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
20747index 2ee7811..afd76c0 100644
20748--- a/arch/x86/include/asm/pgtable_64.h
20749+++ b/arch/x86/include/asm/pgtable_64.h
20750@@ -16,11 +16,17 @@
20751
20752 extern pud_t level3_kernel_pgt[512];
20753 extern pud_t level3_ident_pgt[512];
20754+extern pud_t level3_vmalloc_start_pgt[512];
20755+extern pud_t level3_vmalloc_end_pgt[512];
20756+extern pud_t level3_vmemmap_pgt[512];
20757+extern pud_t level2_vmemmap_pgt[512];
20758 extern pmd_t level2_kernel_pgt[512];
20759 extern pmd_t level2_fixmap_pgt[512];
20760-extern pmd_t level2_ident_pgt[512];
20761-extern pte_t level1_fixmap_pgt[512];
20762-extern pgd_t init_level4_pgt[];
20763+extern pmd_t level2_ident_pgt[2][512];
20764+extern pte_t level1_modules_pgt[4][512];
20765+extern pte_t level1_fixmap_pgt[3][512];
20766+extern pte_t level1_vsyscall_pgt[512];
20767+extern pgd_t init_level4_pgt[512];
20768
20769 #define swapper_pg_dir init_level4_pgt
20770
20771@@ -62,7 +68,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
20772
20773 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
20774 {
20775+ pax_open_kernel();
20776 *pmdp = pmd;
20777+ pax_close_kernel();
20778 }
20779
20780 static inline void native_pmd_clear(pmd_t *pmd)
20781@@ -98,7 +106,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
20782
20783 static inline void native_set_pud(pud_t *pudp, pud_t pud)
20784 {
20785+ pax_open_kernel();
20786 *pudp = pud;
20787+ pax_close_kernel();
20788 }
20789
20790 static inline void native_pud_clear(pud_t *pud)
20791@@ -108,6 +118,13 @@ static inline void native_pud_clear(pud_t *pud)
20792
20793 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
20794 {
20795+ pax_open_kernel();
20796+ *pgdp = pgd;
20797+ pax_close_kernel();
20798+}
20799+
20800+static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
20801+{
20802 *pgdp = pgd;
20803 }
20804
20805diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
20806index e6844df..432b56e 100644
20807--- a/arch/x86/include/asm/pgtable_64_types.h
20808+++ b/arch/x86/include/asm/pgtable_64_types.h
20809@@ -60,11 +60,16 @@ typedef struct { pteval_t pte; } pte_t;
20810 #define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
20811 #define MODULES_END _AC(0xffffffffff000000, UL)
20812 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
20813+#define MODULES_EXEC_VADDR MODULES_VADDR
20814+#define MODULES_EXEC_END MODULES_END
20815 #define ESPFIX_PGD_ENTRY _AC(-2, UL)
20816 #define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
20817 #define EFI_VA_START ( -4 * (_AC(1, UL) << 30))
20818 #define EFI_VA_END (-68 * (_AC(1, UL) << 30))
20819
20820+#define ktla_ktva(addr) (addr)
20821+#define ktva_ktla(addr) (addr)
20822+
20823 #define EARLY_DYNAMIC_PAGE_TABLES 64
20824
20825 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
20826diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
20827index 13f310b..f0ef42e 100644
20828--- a/arch/x86/include/asm/pgtable_types.h
20829+++ b/arch/x86/include/asm/pgtable_types.h
20830@@ -85,8 +85,10 @@
20831
20832 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
20833 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
20834-#else
20835+#elif defined(CONFIG_KMEMCHECK) || defined(CONFIG_MEM_SOFT_DIRTY)
20836 #define _PAGE_NX (_AT(pteval_t, 0))
20837+#else
20838+#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
20839 #endif
20840
20841 #define _PAGE_PROTNONE (_AT(pteval_t, 1) << _PAGE_BIT_PROTNONE)
20842@@ -141,6 +143,9 @@ enum page_cache_mode {
20843 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
20844 _PAGE_ACCESSED)
20845
20846+#define PAGE_READONLY_NOEXEC PAGE_READONLY
20847+#define PAGE_SHARED_NOEXEC PAGE_SHARED
20848+
20849 #define __PAGE_KERNEL_EXEC \
20850 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
20851 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
20852@@ -148,7 +153,7 @@ enum page_cache_mode {
20853 #define __PAGE_KERNEL_RO (__PAGE_KERNEL & ~_PAGE_RW)
20854 #define __PAGE_KERNEL_RX (__PAGE_KERNEL_EXEC & ~_PAGE_RW)
20855 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_NOCACHE)
20856-#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
20857+#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
20858 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
20859 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
20860 #define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE)
20861@@ -194,7 +199,7 @@ enum page_cache_mode {
20862 #ifdef CONFIG_X86_64
20863 #define __PAGE_KERNEL_IDENT_LARGE_EXEC __PAGE_KERNEL_LARGE_EXEC
20864 #else
20865-#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
20866+#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
20867 #define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
20868 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
20869 #endif
20870@@ -233,7 +238,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
20871 {
20872 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
20873 }
20874+#endif
20875
20876+#if CONFIG_PGTABLE_LEVELS == 3
20877+#include <asm-generic/pgtable-nopud.h>
20878+#endif
20879+
20880+#if CONFIG_PGTABLE_LEVELS == 2
20881+#include <asm-generic/pgtable-nopmd.h>
20882+#endif
20883+
20884+#ifndef __ASSEMBLY__
20885 #if CONFIG_PGTABLE_LEVELS > 3
20886 typedef struct { pudval_t pud; } pud_t;
20887
20888@@ -247,8 +262,6 @@ static inline pudval_t native_pud_val(pud_t pud)
20889 return pud.pud;
20890 }
20891 #else
20892-#include <asm-generic/pgtable-nopud.h>
20893-
20894 static inline pudval_t native_pud_val(pud_t pud)
20895 {
20896 return native_pgd_val(pud.pgd);
20897@@ -268,8 +281,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
20898 return pmd.pmd;
20899 }
20900 #else
20901-#include <asm-generic/pgtable-nopmd.h>
20902-
20903 static inline pmdval_t native_pmd_val(pmd_t pmd)
20904 {
20905 return native_pgd_val(pmd.pud.pgd);
20906@@ -362,7 +373,6 @@ typedef struct page *pgtable_t;
20907
20908 extern pteval_t __supported_pte_mask;
20909 extern void set_nx(void);
20910-extern int nx_enabled;
20911
20912 #define pgprot_writecombine pgprot_writecombine
20913 extern pgprot_t pgprot_writecombine(pgprot_t prot);
20914diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h
20915index b12f810..aedcc13 100644
20916--- a/arch/x86/include/asm/preempt.h
20917+++ b/arch/x86/include/asm/preempt.h
20918@@ -84,7 +84,7 @@ static __always_inline void __preempt_count_sub(int val)
20919 */
20920 static __always_inline bool __preempt_count_dec_and_test(void)
20921 {
20922- GEN_UNARY_RMWcc("decl", __preempt_count, __percpu_arg(0), "e");
20923+ GEN_UNARY_RMWcc("decl", "incl", __preempt_count, __percpu_arg(0), "e");
20924 }
20925
20926 /*
20927diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
20928index 944f178..12f1c25 100644
20929--- a/arch/x86/include/asm/processor.h
20930+++ b/arch/x86/include/asm/processor.h
20931@@ -136,7 +136,7 @@ struct cpuinfo_x86 {
20932 /* Index into per_cpu list: */
20933 u16 cpu_index;
20934 u32 microcode;
20935-};
20936+} __randomize_layout;
20937
20938 #define X86_VENDOR_INTEL 0
20939 #define X86_VENDOR_CYRIX 1
20940@@ -206,9 +206,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
20941 : "memory");
20942 }
20943
20944+/* invpcid (%rdx),%rax */
20945+#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
20946+
20947+#define INVPCID_SINGLE_ADDRESS 0UL
20948+#define INVPCID_SINGLE_CONTEXT 1UL
20949+#define INVPCID_ALL_GLOBAL 2UL
20950+#define INVPCID_ALL_NONGLOBAL 3UL
20951+
20952+#define PCID_KERNEL 0UL
20953+#define PCID_USER 1UL
20954+#define PCID_NOFLUSH (1UL << 63)
20955+
20956 static inline void load_cr3(pgd_t *pgdir)
20957 {
20958- write_cr3(__pa(pgdir));
20959+ write_cr3(__pa(pgdir) | PCID_KERNEL);
20960 }
20961
20962 #ifdef CONFIG_X86_32
20963@@ -305,11 +317,9 @@ struct tss_struct {
20964
20965 } ____cacheline_aligned;
20966
20967-DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss);
20968+extern struct tss_struct cpu_tss[NR_CPUS];
20969
20970-#ifdef CONFIG_X86_32
20971 DECLARE_PER_CPU(unsigned long, cpu_current_top_of_stack);
20972-#endif
20973
20974 /*
20975 * Save the original ist values for checking stack pointers during debugging
20976@@ -381,6 +391,7 @@ struct thread_struct {
20977 unsigned short ds;
20978 unsigned short fsindex;
20979 unsigned short gsindex;
20980+ unsigned short ss;
20981 #endif
20982 #ifdef CONFIG_X86_32
20983 unsigned long ip;
20984@@ -463,10 +474,10 @@ static inline void native_swapgs(void)
20985 #endif
20986 }
20987
20988-static inline unsigned long current_top_of_stack(void)
20989+static inline unsigned long current_top_of_stack(unsigned int cpu)
20990 {
20991 #ifdef CONFIG_X86_64
20992- return this_cpu_read_stable(cpu_tss.x86_tss.sp0);
20993+ return cpu_tss[cpu].x86_tss.sp0;
20994 #else
20995 /* sp0 on x86_32 is special in and around vm86 mode. */
20996 return this_cpu_read_stable(cpu_current_top_of_stack);
20997@@ -709,20 +720,30 @@ static inline void spin_lock_prefetch(const void *x)
20998 #define TOP_OF_INIT_STACK ((unsigned long)&init_stack + sizeof(init_stack) - \
20999 TOP_OF_KERNEL_STACK_PADDING)
21000
21001+extern union fpregs_state init_fpregs_state;
21002+
21003 #ifdef CONFIG_X86_32
21004 /*
21005 * User space process size: 3GB (default).
21006 */
21007 #define TASK_SIZE PAGE_OFFSET
21008 #define TASK_SIZE_MAX TASK_SIZE
21009+
21010+#ifdef CONFIG_PAX_SEGMEXEC
21011+#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
21012+#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
21013+#else
21014 #define STACK_TOP TASK_SIZE
21015-#define STACK_TOP_MAX STACK_TOP
21016+#endif
21017+
21018+#define STACK_TOP_MAX TASK_SIZE
21019
21020 #define INIT_THREAD { \
21021 .sp0 = TOP_OF_INIT_STACK, \
21022 .vm86_info = NULL, \
21023 .sysenter_cs = __KERNEL_CS, \
21024 .io_bitmap_ptr = NULL, \
21025+ .fpu.state = &init_fpregs_state, \
21026 }
21027
21028 extern unsigned long thread_saved_pc(struct task_struct *tsk);
21029@@ -737,12 +758,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
21030 * "struct pt_regs" is possible, but they may contain the
21031 * completely wrong values.
21032 */
21033-#define task_pt_regs(task) \
21034-({ \
21035- unsigned long __ptr = (unsigned long)task_stack_page(task); \
21036- __ptr += THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING; \
21037- ((struct pt_regs *)__ptr) - 1; \
21038-})
21039+#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.sp0 - 1)
21040
21041 #define KSTK_ESP(task) (task_pt_regs(task)->sp)
21042
21043@@ -756,13 +772,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
21044 * particular problem by preventing anything from being mapped
21045 * at the maximum canonical address.
21046 */
21047-#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
21048+#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
21049
21050 /* This decides where the kernel will search for a free chunk of vm
21051 * space during mmap's.
21052 */
21053 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
21054- 0xc0000000 : 0xFFFFe000)
21055+ 0xc0000000 : 0xFFFFf000)
21056
21057 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
21058 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
21059@@ -773,7 +789,8 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
21060 #define STACK_TOP_MAX TASK_SIZE_MAX
21061
21062 #define INIT_THREAD { \
21063- .sp0 = TOP_OF_INIT_STACK \
21064+ .sp0 = TOP_OF_INIT_STACK, \
21065+ .fpu.state = &init_fpregs_state, \
21066 }
21067
21068 /*
21069@@ -796,6 +813,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
21070 */
21071 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
21072
21073+#ifdef CONFIG_PAX_SEGMEXEC
21074+#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
21075+#endif
21076+
21077 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
21078
21079 /* Get/set a process' ability to use the timestamp counter instruction */
21080@@ -841,7 +862,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
21081 return 0;
21082 }
21083
21084-extern unsigned long arch_align_stack(unsigned long sp);
21085+#define arch_align_stack(x) ((x) & ~0xfUL)
21086 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
21087
21088 void default_idle(void);
21089@@ -851,6 +872,6 @@ bool xen_set_default_idle(void);
21090 #define xen_set_default_idle 0
21091 #endif
21092
21093-void stop_this_cpu(void *dummy);
21094+void stop_this_cpu(void *dummy) __noreturn;
21095 void df_debug(struct pt_regs *regs, long error_code);
21096 #endif /* _ASM_X86_PROCESSOR_H */
21097diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
21098index 5fabf13..7388158 100644
21099--- a/arch/x86/include/asm/ptrace.h
21100+++ b/arch/x86/include/asm/ptrace.h
21101@@ -125,15 +125,16 @@ static inline int v8086_mode(struct pt_regs *regs)
21102 #ifdef CONFIG_X86_64
21103 static inline bool user_64bit_mode(struct pt_regs *regs)
21104 {
21105+ unsigned long cs = regs->cs & 0xffff;
21106 #ifndef CONFIG_PARAVIRT
21107 /*
21108 * On non-paravirt systems, this is the only long mode CPL 3
21109 * selector. We do not allow long mode selectors in the LDT.
21110 */
21111- return regs->cs == __USER_CS;
21112+ return cs == __USER_CS;
21113 #else
21114 /* Headers are too twisted for this to go in paravirt.h. */
21115- return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
21116+ return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
21117 #endif
21118 }
21119
21120@@ -180,9 +181,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
21121 * Traps from the kernel do not save sp and ss.
21122 * Use the helper function to retrieve sp.
21123 */
21124- if (offset == offsetof(struct pt_regs, sp) &&
21125- regs->cs == __KERNEL_CS)
21126- return kernel_stack_pointer(regs);
21127+ if (offset == offsetof(struct pt_regs, sp)) {
21128+ unsigned long cs = regs->cs & 0xffff;
21129+ if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
21130+ return kernel_stack_pointer(regs);
21131+ }
21132 #endif
21133 return *(unsigned long *)((unsigned long)regs + offset);
21134 }
21135diff --git a/arch/x86/include/asm/qrwlock.h b/arch/x86/include/asm/qrwlock.h
21136index ae0e241..e80b10b 100644
21137--- a/arch/x86/include/asm/qrwlock.h
21138+++ b/arch/x86/include/asm/qrwlock.h
21139@@ -7,8 +7,8 @@
21140 #define queue_write_unlock queue_write_unlock
21141 static inline void queue_write_unlock(struct qrwlock *lock)
21142 {
21143- barrier();
21144- ACCESS_ONCE(*(u8 *)&lock->cnts) = 0;
21145+ barrier();
21146+ ACCESS_ONCE_RW(*(u8 *)&lock->cnts) = 0;
21147 }
21148 #endif
21149
21150diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
21151index 9c6b890..5305f53 100644
21152--- a/arch/x86/include/asm/realmode.h
21153+++ b/arch/x86/include/asm/realmode.h
21154@@ -22,16 +22,14 @@ struct real_mode_header {
21155 #endif
21156 /* APM/BIOS reboot */
21157 u32 machine_real_restart_asm;
21158-#ifdef CONFIG_X86_64
21159 u32 machine_real_restart_seg;
21160-#endif
21161 };
21162
21163 /* This must match data at trampoline_32/64.S */
21164 struct trampoline_header {
21165 #ifdef CONFIG_X86_32
21166 u32 start;
21167- u16 gdt_pad;
21168+ u16 boot_cs;
21169 u16 gdt_limit;
21170 u32 gdt_base;
21171 #else
21172diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
21173index a82c4f1..ac45053 100644
21174--- a/arch/x86/include/asm/reboot.h
21175+++ b/arch/x86/include/asm/reboot.h
21176@@ -6,13 +6,13 @@
21177 struct pt_regs;
21178
21179 struct machine_ops {
21180- void (*restart)(char *cmd);
21181- void (*halt)(void);
21182- void (*power_off)(void);
21183+ void (* __noreturn restart)(char *cmd);
21184+ void (* __noreturn halt)(void);
21185+ void (* __noreturn power_off)(void);
21186 void (*shutdown)(void);
21187 void (*crash_shutdown)(struct pt_regs *);
21188- void (*emergency_restart)(void);
21189-};
21190+ void (* __noreturn emergency_restart)(void);
21191+} __no_const;
21192
21193 extern struct machine_ops machine_ops;
21194
21195diff --git a/arch/x86/include/asm/rmwcc.h b/arch/x86/include/asm/rmwcc.h
21196index 8f7866a..e442f20 100644
21197--- a/arch/x86/include/asm/rmwcc.h
21198+++ b/arch/x86/include/asm/rmwcc.h
21199@@ -3,7 +3,34 @@
21200
21201 #ifdef CC_HAVE_ASM_GOTO
21202
21203-#define __GEN_RMWcc(fullop, var, cc, ...) \
21204+#ifdef CONFIG_PAX_REFCOUNT
21205+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
21206+do { \
21207+ asm_volatile_goto (fullop \
21208+ ";jno 0f\n" \
21209+ fullantiop \
21210+ ";int $4\n0:\n" \
21211+ _ASM_EXTABLE(0b, 0b) \
21212+ ";j" cc " %l[cc_label]" \
21213+ : : "m" (var), ## __VA_ARGS__ \
21214+ : "memory" : cc_label); \
21215+ return 0; \
21216+cc_label: \
21217+ return 1; \
21218+} while (0)
21219+#else
21220+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
21221+do { \
21222+ asm_volatile_goto (fullop ";j" cc " %l[cc_label]" \
21223+ : : "m" (var), ## __VA_ARGS__ \
21224+ : "memory" : cc_label); \
21225+ return 0; \
21226+cc_label: \
21227+ return 1; \
21228+} while (0)
21229+#endif
21230+
21231+#define __GEN_RMWcc_unchecked(fullop, var, cc, ...) \
21232 do { \
21233 asm_volatile_goto (fullop "; j" cc " %l[cc_label]" \
21234 : : "m" (var), ## __VA_ARGS__ \
21235@@ -13,15 +40,46 @@ cc_label: \
21236 return 1; \
21237 } while (0)
21238
21239-#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
21240- __GEN_RMWcc(op " " arg0, var, cc)
21241+#define GEN_UNARY_RMWcc(op, antiop, var, arg0, cc) \
21242+ __GEN_RMWcc(op " " arg0, antiop " " arg0, var, cc)
21243
21244-#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
21245- __GEN_RMWcc(op " %1, " arg0, var, cc, vcon (val))
21246+#define GEN_UNARY_RMWcc_unchecked(op, var, arg0, cc) \
21247+ __GEN_RMWcc_unchecked(op " " arg0, var, cc)
21248+
21249+#define GEN_BINARY_RMWcc(op, antiop, var, vcon, val, arg0, cc) \
21250+ __GEN_RMWcc(op " %1, " arg0, antiop " %1, " arg0, var, cc, vcon (val))
21251+
21252+#define GEN_BINARY_RMWcc_unchecked(op, var, vcon, val, arg0, cc) \
21253+ __GEN_RMWcc_unchecked(op " %1, " arg0, var, cc, vcon (val))
21254
21255 #else /* !CC_HAVE_ASM_GOTO */
21256
21257-#define __GEN_RMWcc(fullop, var, cc, ...) \
21258+#ifdef CONFIG_PAX_REFCOUNT
21259+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
21260+do { \
21261+ char c; \
21262+ asm volatile (fullop \
21263+ ";jno 0f\n" \
21264+ fullantiop \
21265+ ";int $4\n0:\n" \
21266+ _ASM_EXTABLE(0b, 0b) \
21267+ "; set" cc " %1" \
21268+ : "+m" (var), "=qm" (c) \
21269+ : __VA_ARGS__ : "memory"); \
21270+ return c != 0; \
21271+} while (0)
21272+#else
21273+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
21274+do { \
21275+ char c; \
21276+ asm volatile (fullop "; set" cc " %1" \
21277+ : "+m" (var), "=qm" (c) \
21278+ : __VA_ARGS__ : "memory"); \
21279+ return c != 0; \
21280+} while (0)
21281+#endif
21282+
21283+#define __GEN_RMWcc_unchecked(fullop, var, cc, ...) \
21284 do { \
21285 char c; \
21286 asm volatile (fullop "; set" cc " %1" \
21287@@ -30,11 +88,17 @@ do { \
21288 return c != 0; \
21289 } while (0)
21290
21291-#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
21292- __GEN_RMWcc(op " " arg0, var, cc)
21293+#define GEN_UNARY_RMWcc(op, antiop, var, arg0, cc) \
21294+ __GEN_RMWcc(op " " arg0, antiop " " arg0, var, cc)
21295+
21296+#define GEN_UNARY_RMWcc_unchecked(op, var, arg0, cc) \
21297+ __GEN_RMWcc_unchecked(op " " arg0, var, cc)
21298+
21299+#define GEN_BINARY_RMWcc(op, antiop, var, vcon, val, arg0, cc) \
21300+ __GEN_RMWcc(op " %2, " arg0, antiop " %2, " arg0, var, cc, vcon (val))
21301
21302-#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
21303- __GEN_RMWcc(op " %2, " arg0, var, cc, vcon (val))
21304+#define GEN_BINARY_RMWcc_unchecked(op, var, vcon, val, arg0, cc) \
21305+ __GEN_RMWcc_unchecked(op " %2, " arg0, var, cc, vcon (val))
21306
21307 #endif /* CC_HAVE_ASM_GOTO */
21308
21309diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
21310index cad82c9..2e5c5c1 100644
21311--- a/arch/x86/include/asm/rwsem.h
21312+++ b/arch/x86/include/asm/rwsem.h
21313@@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
21314 {
21315 asm volatile("# beginning down_read\n\t"
21316 LOCK_PREFIX _ASM_INC "(%1)\n\t"
21317+
21318+#ifdef CONFIG_PAX_REFCOUNT
21319+ "jno 0f\n"
21320+ LOCK_PREFIX _ASM_DEC "(%1)\n"
21321+ "int $4\n0:\n"
21322+ _ASM_EXTABLE(0b, 0b)
21323+#endif
21324+
21325 /* adds 0x00000001 */
21326 " jns 1f\n"
21327 " call call_rwsem_down_read_failed\n"
21328@@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
21329 "1:\n\t"
21330 " mov %1,%2\n\t"
21331 " add %3,%2\n\t"
21332+
21333+#ifdef CONFIG_PAX_REFCOUNT
21334+ "jno 0f\n"
21335+ "sub %3,%2\n"
21336+ "int $4\n0:\n"
21337+ _ASM_EXTABLE(0b, 0b)
21338+#endif
21339+
21340 " jle 2f\n\t"
21341 LOCK_PREFIX " cmpxchg %2,%0\n\t"
21342 " jnz 1b\n\t"
21343@@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
21344 long tmp;
21345 asm volatile("# beginning down_write\n\t"
21346 LOCK_PREFIX " xadd %1,(%2)\n\t"
21347+
21348+#ifdef CONFIG_PAX_REFCOUNT
21349+ "jno 0f\n"
21350+ "mov %1,(%2)\n"
21351+ "int $4\n0:\n"
21352+ _ASM_EXTABLE(0b, 0b)
21353+#endif
21354+
21355 /* adds 0xffff0001, returns the old value */
21356 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
21357 /* was the active mask 0 before? */
21358@@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
21359 long tmp;
21360 asm volatile("# beginning __up_read\n\t"
21361 LOCK_PREFIX " xadd %1,(%2)\n\t"
21362+
21363+#ifdef CONFIG_PAX_REFCOUNT
21364+ "jno 0f\n"
21365+ "mov %1,(%2)\n"
21366+ "int $4\n0:\n"
21367+ _ASM_EXTABLE(0b, 0b)
21368+#endif
21369+
21370 /* subtracts 1, returns the old value */
21371 " jns 1f\n\t"
21372 " call call_rwsem_wake\n" /* expects old value in %edx */
21373@@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
21374 long tmp;
21375 asm volatile("# beginning __up_write\n\t"
21376 LOCK_PREFIX " xadd %1,(%2)\n\t"
21377+
21378+#ifdef CONFIG_PAX_REFCOUNT
21379+ "jno 0f\n"
21380+ "mov %1,(%2)\n"
21381+ "int $4\n0:\n"
21382+ _ASM_EXTABLE(0b, 0b)
21383+#endif
21384+
21385 /* subtracts 0xffff0001, returns the old value */
21386 " jns 1f\n\t"
21387 " call call_rwsem_wake\n" /* expects old value in %edx */
21388@@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
21389 {
21390 asm volatile("# beginning __downgrade_write\n\t"
21391 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
21392+
21393+#ifdef CONFIG_PAX_REFCOUNT
21394+ "jno 0f\n"
21395+ LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
21396+ "int $4\n0:\n"
21397+ _ASM_EXTABLE(0b, 0b)
21398+#endif
21399+
21400 /*
21401 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
21402 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
21403@@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
21404 */
21405 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
21406 {
21407- asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
21408+ asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
21409+
21410+#ifdef CONFIG_PAX_REFCOUNT
21411+ "jno 0f\n"
21412+ LOCK_PREFIX _ASM_SUB "%1,%0\n"
21413+ "int $4\n0:\n"
21414+ _ASM_EXTABLE(0b, 0b)
21415+#endif
21416+
21417 : "+m" (sem->count)
21418 : "er" (delta));
21419 }
21420@@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
21421 */
21422 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
21423 {
21424- return delta + xadd(&sem->count, delta);
21425+ return delta + xadd_check_overflow(&sem->count, delta);
21426 }
21427
21428 #endif /* __KERNEL__ */
21429diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
21430index 7d5a192..23ef1aa 100644
21431--- a/arch/x86/include/asm/segment.h
21432+++ b/arch/x86/include/asm/segment.h
21433@@ -82,14 +82,20 @@
21434 * 26 - ESPFIX small SS
21435 * 27 - per-cpu [ offset to per-cpu data area ]
21436 * 28 - stack_canary-20 [ for stack protector ] <=== cacheline #8
21437- * 29 - unused
21438- * 30 - unused
21439+ * 29 - PCI BIOS CS
21440+ * 30 - PCI BIOS DS
21441 * 31 - TSS for double fault handler
21442 */
21443+#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
21444+#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
21445+#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
21446+#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
21447+
21448 #define GDT_ENTRY_TLS_MIN 6
21449 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
21450
21451 #define GDT_ENTRY_KERNEL_CS 12
21452+#define GDT_ENTRY_KERNEXEC_KERNEL_CS 4
21453 #define GDT_ENTRY_KERNEL_DS 13
21454 #define GDT_ENTRY_DEFAULT_USER_CS 14
21455 #define GDT_ENTRY_DEFAULT_USER_DS 15
21456@@ -106,6 +112,12 @@
21457 #define GDT_ENTRY_PERCPU 27
21458 #define GDT_ENTRY_STACK_CANARY 28
21459
21460+#define GDT_ENTRY_PCIBIOS_CS 29
21461+#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
21462+
21463+#define GDT_ENTRY_PCIBIOS_DS 30
21464+#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
21465+
21466 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
21467
21468 /*
21469@@ -118,6 +130,7 @@
21470 */
21471
21472 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
21473+#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
21474 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
21475 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8 + 3)
21476 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8 + 3)
21477@@ -129,7 +142,7 @@
21478 #define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16*8)
21479
21480 /* "Is this PNP code selector (PNP_CS32 or PNP_CS16)?" */
21481-#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == PNP_CS32)
21482+#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
21483
21484 /* data segment for BIOS: */
21485 #define PNP_DS (GDT_ENTRY_PNPBIOS_DS*8)
21486@@ -176,6 +189,8 @@
21487 #define GDT_ENTRY_DEFAULT_USER_DS 5
21488 #define GDT_ENTRY_DEFAULT_USER_CS 6
21489
21490+#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
21491+
21492 /* Needs two entries */
21493 #define GDT_ENTRY_TSS 8
21494 /* Needs two entries */
21495@@ -187,10 +202,12 @@
21496 /* Abused to load per CPU data from limit */
21497 #define GDT_ENTRY_PER_CPU 15
21498
21499+#define GDT_ENTRY_UDEREF_KERNEL_DS 16
21500+
21501 /*
21502 * Number of entries in the GDT table:
21503 */
21504-#define GDT_ENTRIES 16
21505+#define GDT_ENTRIES 17
21506
21507 /*
21508 * Segment selector values corresponding to the above entries:
21509@@ -200,7 +217,9 @@
21510 */
21511 #define __KERNEL32_CS (GDT_ENTRY_KERNEL32_CS*8)
21512 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
21513+#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
21514 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
21515+#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
21516 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8 + 3)
21517 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8 + 3)
21518 #define __USER32_DS __USER_DS
21519diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
21520index ba665eb..0f72938 100644
21521--- a/arch/x86/include/asm/smap.h
21522+++ b/arch/x86/include/asm/smap.h
21523@@ -25,6 +25,18 @@
21524
21525 #include <asm/alternative-asm.h>
21526
21527+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21528+#define ASM_PAX_OPEN_USERLAND \
21529+ ALTERNATIVE "", "call __pax_open_userland", X86_FEATURE_STRONGUDEREF
21530+
21531+#define ASM_PAX_CLOSE_USERLAND \
21532+ ALTERNATIVE "", "call __pax_close_userland", X86_FEATURE_STRONGUDEREF
21533+
21534+#else
21535+#define ASM_PAX_OPEN_USERLAND
21536+#define ASM_PAX_CLOSE_USERLAND
21537+#endif
21538+
21539 #ifdef CONFIG_X86_SMAP
21540
21541 #define ASM_CLAC \
21542@@ -44,6 +56,37 @@
21543
21544 #include <asm/alternative.h>
21545
21546+#define __HAVE_ARCH_PAX_OPEN_USERLAND
21547+#define __HAVE_ARCH_PAX_CLOSE_USERLAND
21548+
21549+extern void __pax_open_userland(void);
21550+static __always_inline unsigned long pax_open_userland(void)
21551+{
21552+
21553+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21554+ asm volatile(ALTERNATIVE("", "call %P[open]", X86_FEATURE_STRONGUDEREF)
21555+ :
21556+ : [open] "i" (__pax_open_userland)
21557+ : "memory", "rax");
21558+#endif
21559+
21560+ return 0;
21561+}
21562+
21563+extern void __pax_close_userland(void);
21564+static __always_inline unsigned long pax_close_userland(void)
21565+{
21566+
21567+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21568+ asm volatile(ALTERNATIVE("", "call %P[close]", X86_FEATURE_STRONGUDEREF)
21569+ :
21570+ : [close] "i" (__pax_close_userland)
21571+ : "memory", "rax");
21572+#endif
21573+
21574+ return 0;
21575+}
21576+
21577 #ifdef CONFIG_X86_SMAP
21578
21579 static __always_inline void clac(void)
21580diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
21581index 222a6a3..839da8d 100644
21582--- a/arch/x86/include/asm/smp.h
21583+++ b/arch/x86/include/asm/smp.h
21584@@ -35,7 +35,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
21585 /* cpus sharing the last level cache: */
21586 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
21587 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
21588-DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
21589+DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
21590
21591 static inline struct cpumask *cpu_llc_shared_mask(int cpu)
21592 {
21593@@ -68,7 +68,7 @@ struct smp_ops {
21594
21595 void (*send_call_func_ipi)(const struct cpumask *mask);
21596 void (*send_call_func_single_ipi)(int cpu);
21597-};
21598+} __no_const;
21599
21600 /* Globals due to paravirt */
21601 extern void set_cpu_sibling_map(int cpu);
21602@@ -182,14 +182,8 @@ extern unsigned disabled_cpus;
21603 extern int safe_smp_processor_id(void);
21604
21605 #elif defined(CONFIG_X86_64_SMP)
21606-#define raw_smp_processor_id() (this_cpu_read(cpu_number))
21607-
21608-#define stack_smp_processor_id() \
21609-({ \
21610- struct thread_info *ti; \
21611- __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
21612- ti->cpu; \
21613-})
21614+#define raw_smp_processor_id() (this_cpu_read(cpu_number))
21615+#define stack_smp_processor_id() raw_smp_processor_id()
21616 #define safe_smp_processor_id() smp_processor_id()
21617
21618 #endif
21619diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
21620index c2e00bb..a10266e 100644
21621--- a/arch/x86/include/asm/stackprotector.h
21622+++ b/arch/x86/include/asm/stackprotector.h
21623@@ -49,7 +49,7 @@
21624 * head_32 for boot CPU and setup_per_cpu_areas() for others.
21625 */
21626 #define GDT_STACK_CANARY_INIT \
21627- [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
21628+ [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
21629
21630 /*
21631 * Initialize the stackprotector canary value.
21632@@ -114,7 +114,7 @@ static inline void setup_stack_canary_segment(int cpu)
21633
21634 static inline void load_stack_canary_segment(void)
21635 {
21636-#ifdef CONFIG_X86_32
21637+#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
21638 asm volatile ("mov %0, %%gs" : : "r" (0));
21639 #endif
21640 }
21641diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
21642index 70bbe39..4ae2bd4 100644
21643--- a/arch/x86/include/asm/stacktrace.h
21644+++ b/arch/x86/include/asm/stacktrace.h
21645@@ -11,28 +11,20 @@
21646
21647 extern int kstack_depth_to_print;
21648
21649-struct thread_info;
21650+struct task_struct;
21651 struct stacktrace_ops;
21652
21653-typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
21654- unsigned long *stack,
21655- unsigned long bp,
21656- const struct stacktrace_ops *ops,
21657- void *data,
21658- unsigned long *end,
21659- int *graph);
21660+typedef unsigned long walk_stack_t(struct task_struct *task,
21661+ void *stack_start,
21662+ unsigned long *stack,
21663+ unsigned long bp,
21664+ const struct stacktrace_ops *ops,
21665+ void *data,
21666+ unsigned long *end,
21667+ int *graph);
21668
21669-extern unsigned long
21670-print_context_stack(struct thread_info *tinfo,
21671- unsigned long *stack, unsigned long bp,
21672- const struct stacktrace_ops *ops, void *data,
21673- unsigned long *end, int *graph);
21674-
21675-extern unsigned long
21676-print_context_stack_bp(struct thread_info *tinfo,
21677- unsigned long *stack, unsigned long bp,
21678- const struct stacktrace_ops *ops, void *data,
21679- unsigned long *end, int *graph);
21680+extern walk_stack_t print_context_stack;
21681+extern walk_stack_t print_context_stack_bp;
21682
21683 /* Generic stack tracer with callbacks */
21684
21685@@ -40,7 +32,7 @@ struct stacktrace_ops {
21686 void (*address)(void *data, unsigned long address, int reliable);
21687 /* On negative return stop dumping */
21688 int (*stack)(void *data, char *name);
21689- walk_stack_t walk_stack;
21690+ walk_stack_t *walk_stack;
21691 };
21692
21693 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
21694diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
21695index d7f3b3b..3cc39f1 100644
21696--- a/arch/x86/include/asm/switch_to.h
21697+++ b/arch/x86/include/asm/switch_to.h
21698@@ -108,7 +108,7 @@ do { \
21699 "call __switch_to\n\t" \
21700 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
21701 __switch_canary \
21702- "movq %P[thread_info](%%rsi),%%r8\n\t" \
21703+ "movq "__percpu_arg([thread_info])",%%r8\n\t" \
21704 "movq %%rax,%%rdi\n\t" \
21705 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
21706 "jnz ret_from_fork\n\t" \
21707@@ -119,7 +119,7 @@ do { \
21708 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
21709 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
21710 [_tif_fork] "i" (_TIF_FORK), \
21711- [thread_info] "i" (offsetof(struct task_struct, stack)), \
21712+ [thread_info] "m" (current_tinfo), \
21713 [current_task] "m" (current_task) \
21714 __switch_canary_iparam \
21715 : "memory", "cc" __EXTRA_CLOBBER)
21716diff --git a/arch/x86/include/asm/sys_ia32.h b/arch/x86/include/asm/sys_ia32.h
21717index 82c34ee..940fa40 100644
21718--- a/arch/x86/include/asm/sys_ia32.h
21719+++ b/arch/x86/include/asm/sys_ia32.h
21720@@ -20,8 +20,8 @@
21721 #include <asm/ia32.h>
21722
21723 /* ia32/sys_ia32.c */
21724-asmlinkage long sys32_truncate64(const char __user *, unsigned long, unsigned long);
21725-asmlinkage long sys32_ftruncate64(unsigned int, unsigned long, unsigned long);
21726+asmlinkage long sys32_truncate64(const char __user *, unsigned int, unsigned int);
21727+asmlinkage long sys32_ftruncate64(unsigned int, unsigned int, unsigned int);
21728
21729 asmlinkage long sys32_stat64(const char __user *, struct stat64 __user *);
21730 asmlinkage long sys32_lstat64(const char __user *, struct stat64 __user *);
21731@@ -42,7 +42,7 @@ long sys32_vm86_warning(void);
21732 asmlinkage ssize_t sys32_readahead(int, unsigned, unsigned, size_t);
21733 asmlinkage long sys32_sync_file_range(int, unsigned, unsigned,
21734 unsigned, unsigned, int);
21735-asmlinkage long sys32_fadvise64(int, unsigned, unsigned, size_t, int);
21736+asmlinkage long sys32_fadvise64(int, unsigned, unsigned, int, int);
21737 asmlinkage long sys32_fallocate(int, int, unsigned,
21738 unsigned, unsigned, unsigned);
21739
21740diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
21741index 225ee54..fae4566 100644
21742--- a/arch/x86/include/asm/thread_info.h
21743+++ b/arch/x86/include/asm/thread_info.h
21744@@ -36,7 +36,7 @@
21745 #ifdef CONFIG_X86_32
21746 # define TOP_OF_KERNEL_STACK_PADDING 8
21747 #else
21748-# define TOP_OF_KERNEL_STACK_PADDING 0
21749+# define TOP_OF_KERNEL_STACK_PADDING 16
21750 #endif
21751
21752 /*
21753@@ -50,27 +50,26 @@ struct task_struct;
21754 #include <linux/atomic.h>
21755
21756 struct thread_info {
21757- struct task_struct *task; /* main task structure */
21758 __u32 flags; /* low level flags */
21759 __u32 status; /* thread synchronous flags */
21760 __u32 cpu; /* current CPU */
21761 int saved_preempt_count;
21762 mm_segment_t addr_limit;
21763 void __user *sysenter_return;
21764+ unsigned long lowest_stack;
21765 unsigned int sig_on_uaccess_error:1;
21766 unsigned int uaccess_err:1; /* uaccess failed */
21767 };
21768
21769-#define INIT_THREAD_INFO(tsk) \
21770+#define INIT_THREAD_INFO \
21771 { \
21772- .task = &tsk, \
21773 .flags = 0, \
21774 .cpu = 0, \
21775 .saved_preempt_count = INIT_PREEMPT_COUNT, \
21776 .addr_limit = KERNEL_DS, \
21777 }
21778
21779-#define init_thread_info (init_thread_union.thread_info)
21780+#define init_thread_info (init_thread_union.stack)
21781 #define init_stack (init_thread_union.stack)
21782
21783 #else /* !__ASSEMBLY__ */
21784@@ -110,6 +109,7 @@ struct thread_info {
21785 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
21786 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
21787 #define TIF_X32 30 /* 32-bit native x86-64 binary */
21788+#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
21789
21790 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
21791 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
21792@@ -133,17 +133,18 @@ struct thread_info {
21793 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
21794 #define _TIF_ADDR32 (1 << TIF_ADDR32)
21795 #define _TIF_X32 (1 << TIF_X32)
21796+#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
21797
21798 /* work to do in syscall_trace_enter() */
21799 #define _TIF_WORK_SYSCALL_ENTRY \
21800 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
21801 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
21802- _TIF_NOHZ)
21803+ _TIF_NOHZ | _TIF_GRSEC_SETXID)
21804
21805 /* work to do in syscall_trace_leave() */
21806 #define _TIF_WORK_SYSCALL_EXIT \
21807 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
21808- _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
21809+ _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
21810
21811 /* work to do on interrupt/exception return */
21812 #define _TIF_WORK_MASK \
21813@@ -154,7 +155,7 @@ struct thread_info {
21814 /* work to do on any return to user space */
21815 #define _TIF_ALLWORK_MASK \
21816 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
21817- _TIF_NOHZ)
21818+ _TIF_NOHZ | _TIF_GRSEC_SETXID)
21819
21820 /* Only used for 64 bit */
21821 #define _TIF_DO_NOTIFY_MASK \
21822@@ -177,9 +178,11 @@ struct thread_info {
21823 */
21824 #ifndef __ASSEMBLY__
21825
21826+DECLARE_PER_CPU(struct thread_info *, current_tinfo);
21827+
21828 static inline struct thread_info *current_thread_info(void)
21829 {
21830- return (struct thread_info *)(current_top_of_stack() - THREAD_SIZE);
21831+ return this_cpu_read_stable(current_tinfo);
21832 }
21833
21834 static inline unsigned long current_stack_pointer(void)
21835@@ -195,14 +198,9 @@ static inline unsigned long current_stack_pointer(void)
21836
21837 #else /* !__ASSEMBLY__ */
21838
21839-#ifdef CONFIG_X86_64
21840-# define cpu_current_top_of_stack (cpu_tss + TSS_sp0)
21841-#endif
21842-
21843 /* Load thread_info address into "reg" */
21844 #define GET_THREAD_INFO(reg) \
21845- _ASM_MOV PER_CPU_VAR(cpu_current_top_of_stack),reg ; \
21846- _ASM_SUB $(THREAD_SIZE),reg ;
21847+ _ASM_MOV PER_CPU_VAR(current_tinfo),reg ;
21848
21849 /*
21850 * ASM operand which evaluates to a 'thread_info' address of
21851@@ -295,5 +293,12 @@ static inline bool is_ia32_task(void)
21852 extern void arch_task_cache_init(void);
21853 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
21854 extern void arch_release_task_struct(struct task_struct *tsk);
21855+
21856+#define __HAVE_THREAD_FUNCTIONS
21857+#define task_thread_info(task) (&(task)->tinfo)
21858+#define task_stack_page(task) ((task)->stack)
21859+#define setup_thread_stack(p, org) do {} while (0)
21860+#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
21861+
21862 #endif
21863 #endif /* _ASM_X86_THREAD_INFO_H */
21864diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
21865index cd79194..6a9956f 100644
21866--- a/arch/x86/include/asm/tlbflush.h
21867+++ b/arch/x86/include/asm/tlbflush.h
21868@@ -86,18 +86,44 @@ static inline void cr4_set_bits_and_update_boot(unsigned long mask)
21869
21870 static inline void __native_flush_tlb(void)
21871 {
21872+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
21873+ u64 descriptor[2];
21874+
21875+ descriptor[0] = PCID_KERNEL;
21876+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_NONGLOBAL) : "memory");
21877+ return;
21878+ }
21879+
21880+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21881+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF)) {
21882+ unsigned int cpu = raw_get_cpu();
21883+
21884+ native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
21885+ native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
21886+ raw_put_cpu_no_resched();
21887+ return;
21888+ }
21889+#endif
21890+
21891 native_write_cr3(native_read_cr3());
21892 }
21893
21894 static inline void __native_flush_tlb_global_irq_disabled(void)
21895 {
21896- unsigned long cr4;
21897+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
21898+ u64 descriptor[2];
21899
21900- cr4 = this_cpu_read(cpu_tlbstate.cr4);
21901- /* clear PGE */
21902- native_write_cr4(cr4 & ~X86_CR4_PGE);
21903- /* write old PGE again and flush TLBs */
21904- native_write_cr4(cr4);
21905+ descriptor[0] = PCID_KERNEL;
21906+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
21907+ } else {
21908+ unsigned long cr4;
21909+
21910+ cr4 = this_cpu_read(cpu_tlbstate.cr4);
21911+ /* clear PGE */
21912+ native_write_cr4(cr4 & ~X86_CR4_PGE);
21913+ /* write old PGE again and flush TLBs */
21914+ native_write_cr4(cr4);
21915+ }
21916 }
21917
21918 static inline void __native_flush_tlb_global(void)
21919@@ -118,6 +144,43 @@ static inline void __native_flush_tlb_global(void)
21920
21921 static inline void __native_flush_tlb_single(unsigned long addr)
21922 {
21923+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
21924+ u64 descriptor[2];
21925+
21926+ descriptor[0] = PCID_KERNEL;
21927+ descriptor[1] = addr;
21928+
21929+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21930+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF)) {
21931+ if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
21932+ if (addr < TASK_SIZE_MAX)
21933+ descriptor[1] += pax_user_shadow_base;
21934+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
21935+ }
21936+
21937+ descriptor[0] = PCID_USER;
21938+ descriptor[1] = addr;
21939+ }
21940+#endif
21941+
21942+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
21943+ return;
21944+ }
21945+
21946+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21947+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF)) {
21948+ unsigned int cpu = raw_get_cpu();
21949+
21950+ native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
21951+ asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
21952+ native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
21953+ raw_put_cpu_no_resched();
21954+
21955+ if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
21956+ addr += pax_user_shadow_base;
21957+ }
21958+#endif
21959+
21960 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
21961 }
21962
21963diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
21964index a8df874..ef0e34f 100644
21965--- a/arch/x86/include/asm/uaccess.h
21966+++ b/arch/x86/include/asm/uaccess.h
21967@@ -7,6 +7,7 @@
21968 #include <linux/compiler.h>
21969 #include <linux/thread_info.h>
21970 #include <linux/string.h>
21971+#include <linux/spinlock.h>
21972 #include <asm/asm.h>
21973 #include <asm/page.h>
21974 #include <asm/smap.h>
21975@@ -29,7 +30,12 @@
21976
21977 #define get_ds() (KERNEL_DS)
21978 #define get_fs() (current_thread_info()->addr_limit)
21979+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
21980+void __set_fs(mm_segment_t x);
21981+void set_fs(mm_segment_t x);
21982+#else
21983 #define set_fs(x) (current_thread_info()->addr_limit = (x))
21984+#endif
21985
21986 #define segment_eq(a, b) ((a).seg == (b).seg)
21987
21988@@ -86,8 +92,36 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un
21989 * checks that the pointer is in the user space range - after calling
21990 * this function, memory access functions may still return -EFAULT.
21991 */
21992-#define access_ok(type, addr, size) \
21993- likely(!__range_not_ok(addr, size, user_addr_max()))
21994+extern int _cond_resched(void);
21995+#define access_ok_noprefault(type, addr, size) (likely(!__range_not_ok(addr, size, user_addr_max())))
21996+#define access_ok(type, addr, size) \
21997+({ \
21998+ unsigned long __size = size; \
21999+ unsigned long __addr = (unsigned long)addr; \
22000+ bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
22001+ if (__ret_ao && __size) { \
22002+ unsigned long __addr_ao = __addr & PAGE_MASK; \
22003+ unsigned long __end_ao = __addr + __size - 1; \
22004+ if (unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
22005+ while (__addr_ao <= __end_ao) { \
22006+ char __c_ao; \
22007+ __addr_ao += PAGE_SIZE; \
22008+ if (__size > PAGE_SIZE) \
22009+ _cond_resched(); \
22010+ if (__get_user(__c_ao, (char __user *)__addr)) \
22011+ break; \
22012+ if (type != VERIFY_WRITE) { \
22013+ __addr = __addr_ao; \
22014+ continue; \
22015+ } \
22016+ if (__put_user(__c_ao, (char __user *)__addr)) \
22017+ break; \
22018+ __addr = __addr_ao; \
22019+ } \
22020+ } \
22021+ } \
22022+ __ret_ao; \
22023+})
22024
22025 /*
22026 * The exception table consists of pairs of addresses relative to the
22027@@ -135,11 +169,13 @@ extern int __get_user_8(void);
22028 extern int __get_user_bad(void);
22029
22030 /*
22031- * This is a type: either unsigned long, if the argument fits into
22032- * that type, or otherwise unsigned long long.
22033+ * This is a type: either (un)signed int, if the argument fits into
22034+ * that type, or otherwise (un)signed long long.
22035 */
22036 #define __inttype(x) \
22037-__typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
22038+__typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0U), \
22039+ __builtin_choose_expr(__type_is_unsigned(__typeof__(x)), 0ULL, 0LL),\
22040+ __builtin_choose_expr(__type_is_unsigned(__typeof__(x)), 0U, 0)))
22041
22042 /**
22043 * get_user: - Get a simple variable from user space.
22044@@ -178,10 +214,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
22045 register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX); \
22046 __chk_user_ptr(ptr); \
22047 might_fault(); \
22048+ pax_open_userland(); \
22049 asm volatile("call __get_user_%P3" \
22050 : "=a" (__ret_gu), "=r" (__val_gu) \
22051 : "0" (ptr), "i" (sizeof(*(ptr)))); \
22052 (x) = (__force __typeof__(*(ptr))) __val_gu; \
22053+ pax_close_userland(); \
22054 __ret_gu; \
22055 })
22056
22057@@ -189,13 +227,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
22058 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
22059 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
22060
22061-
22062+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
22063+#define __copyuser_seg "gs;"
22064+#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
22065+#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
22066+#else
22067+#define __copyuser_seg
22068+#define __COPYUSER_SET_ES
22069+#define __COPYUSER_RESTORE_ES
22070+#endif
22071
22072 #ifdef CONFIG_X86_32
22073 #define __put_user_asm_u64(x, addr, err, errret) \
22074 asm volatile(ASM_STAC "\n" \
22075- "1: movl %%eax,0(%2)\n" \
22076- "2: movl %%edx,4(%2)\n" \
22077+ "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
22078+ "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
22079 "3: " ASM_CLAC "\n" \
22080 ".section .fixup,\"ax\"\n" \
22081 "4: movl %3,%0\n" \
22082@@ -208,8 +254,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
22083
22084 #define __put_user_asm_ex_u64(x, addr) \
22085 asm volatile(ASM_STAC "\n" \
22086- "1: movl %%eax,0(%1)\n" \
22087- "2: movl %%edx,4(%1)\n" \
22088+ "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
22089+ "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
22090 "3: " ASM_CLAC "\n" \
22091 _ASM_EXTABLE_EX(1b, 2b) \
22092 _ASM_EXTABLE_EX(2b, 3b) \
22093@@ -260,7 +306,8 @@ extern void __put_user_8(void);
22094 __typeof__(*(ptr)) __pu_val; \
22095 __chk_user_ptr(ptr); \
22096 might_fault(); \
22097- __pu_val = x; \
22098+ __pu_val = (x); \
22099+ pax_open_userland(); \
22100 switch (sizeof(*(ptr))) { \
22101 case 1: \
22102 __put_user_x(1, __pu_val, ptr, __ret_pu); \
22103@@ -278,6 +325,7 @@ extern void __put_user_8(void);
22104 __put_user_x(X, __pu_val, ptr, __ret_pu); \
22105 break; \
22106 } \
22107+ pax_close_userland(); \
22108 __ret_pu; \
22109 })
22110
22111@@ -358,8 +406,10 @@ do { \
22112 } while (0)
22113
22114 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
22115+do { \
22116+ pax_open_userland(); \
22117 asm volatile(ASM_STAC "\n" \
22118- "1: mov"itype" %2,%"rtype"1\n" \
22119+ "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
22120 "2: " ASM_CLAC "\n" \
22121 ".section .fixup,\"ax\"\n" \
22122 "3: mov %3,%0\n" \
22123@@ -367,8 +417,10 @@ do { \
22124 " jmp 2b\n" \
22125 ".previous\n" \
22126 _ASM_EXTABLE(1b, 3b) \
22127- : "=r" (err), ltype(x) \
22128- : "m" (__m(addr)), "i" (errret), "0" (err))
22129+ : "=r" (err), ltype (x) \
22130+ : "m" (__m(addr)), "i" (errret), "0" (err)); \
22131+ pax_close_userland(); \
22132+} while (0)
22133
22134 #define __get_user_size_ex(x, ptr, size) \
22135 do { \
22136@@ -392,7 +444,7 @@ do { \
22137 } while (0)
22138
22139 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
22140- asm volatile("1: mov"itype" %1,%"rtype"0\n" \
22141+ asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
22142 "2:\n" \
22143 _ASM_EXTABLE_EX(1b, 2b) \
22144 : ltype(x) : "m" (__m(addr)))
22145@@ -409,13 +461,24 @@ do { \
22146 int __gu_err; \
22147 unsigned long __gu_val; \
22148 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
22149- (x) = (__force __typeof__(*(ptr)))__gu_val; \
22150+ (x) = (__typeof__(*(ptr)))__gu_val; \
22151 __gu_err; \
22152 })
22153
22154 /* FIXME: this hack is definitely wrong -AK */
22155 struct __large_struct { unsigned long buf[100]; };
22156-#define __m(x) (*(struct __large_struct __user *)(x))
22157+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22158+#define ____m(x) \
22159+({ \
22160+ unsigned long ____x = (unsigned long)(x); \
22161+ if (____x < pax_user_shadow_base) \
22162+ ____x += pax_user_shadow_base; \
22163+ (typeof(x))____x; \
22164+})
22165+#else
22166+#define ____m(x) (x)
22167+#endif
22168+#define __m(x) (*(struct __large_struct __user *)____m(x))
22169
22170 /*
22171 * Tell gcc we read from memory instead of writing: this is because
22172@@ -423,8 +486,10 @@ struct __large_struct { unsigned long buf[100]; };
22173 * aliasing issues.
22174 */
22175 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
22176+do { \
22177+ pax_open_userland(); \
22178 asm volatile(ASM_STAC "\n" \
22179- "1: mov"itype" %"rtype"1,%2\n" \
22180+ "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
22181 "2: " ASM_CLAC "\n" \
22182 ".section .fixup,\"ax\"\n" \
22183 "3: mov %3,%0\n" \
22184@@ -432,10 +497,12 @@ struct __large_struct { unsigned long buf[100]; };
22185 ".previous\n" \
22186 _ASM_EXTABLE(1b, 3b) \
22187 : "=r"(err) \
22188- : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
22189+ : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
22190+ pax_close_userland(); \
22191+} while (0)
22192
22193 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
22194- asm volatile("1: mov"itype" %"rtype"0,%1\n" \
22195+ asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
22196 "2:\n" \
22197 _ASM_EXTABLE_EX(1b, 2b) \
22198 : : ltype(x), "m" (__m(addr)))
22199@@ -445,11 +512,13 @@ struct __large_struct { unsigned long buf[100]; };
22200 */
22201 #define uaccess_try do { \
22202 current_thread_info()->uaccess_err = 0; \
22203+ pax_open_userland(); \
22204 stac(); \
22205 barrier();
22206
22207 #define uaccess_catch(err) \
22208 clac(); \
22209+ pax_close_userland(); \
22210 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
22211 } while (0)
22212
22213@@ -475,8 +544,12 @@ struct __large_struct { unsigned long buf[100]; };
22214 * On error, the variable @x is set to zero.
22215 */
22216
22217+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22218+#define __get_user(x, ptr) get_user((x), (ptr))
22219+#else
22220 #define __get_user(x, ptr) \
22221 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
22222+#endif
22223
22224 /**
22225 * __put_user: - Write a simple value into user space, with less checking.
22226@@ -499,8 +572,12 @@ struct __large_struct { unsigned long buf[100]; };
22227 * Returns zero on success, or -EFAULT on error.
22228 */
22229
22230+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22231+#define __put_user(x, ptr) put_user((x), (ptr))
22232+#else
22233 #define __put_user(x, ptr) \
22234 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
22235+#endif
22236
22237 #define __get_user_unaligned __get_user
22238 #define __put_user_unaligned __put_user
22239@@ -518,7 +595,7 @@ struct __large_struct { unsigned long buf[100]; };
22240 #define get_user_ex(x, ptr) do { \
22241 unsigned long __gue_val; \
22242 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
22243- (x) = (__force __typeof__(*(ptr)))__gue_val; \
22244+ (x) = (__typeof__(*(ptr)))__gue_val; \
22245 } while (0)
22246
22247 #define put_user_try uaccess_try
22248@@ -536,7 +613,7 @@ extern __must_check long strlen_user(const char __user *str);
22249 extern __must_check long strnlen_user(const char __user *str, long n);
22250
22251 unsigned long __must_check clear_user(void __user *mem, unsigned long len);
22252-unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
22253+unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
22254
22255 extern void __cmpxchg_wrong_size(void)
22256 __compiletime_error("Bad argument size for cmpxchg");
22257@@ -547,18 +624,19 @@ extern void __cmpxchg_wrong_size(void)
22258 __typeof__(ptr) __uval = (uval); \
22259 __typeof__(*(ptr)) __old = (old); \
22260 __typeof__(*(ptr)) __new = (new); \
22261+ pax_open_userland(); \
22262 switch (size) { \
22263 case 1: \
22264 { \
22265 asm volatile("\t" ASM_STAC "\n" \
22266- "1:\t" LOCK_PREFIX "cmpxchgb %4, %2\n" \
22267+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgb %4, %2\n"\
22268 "2:\t" ASM_CLAC "\n" \
22269 "\t.section .fixup, \"ax\"\n" \
22270 "3:\tmov %3, %0\n" \
22271 "\tjmp 2b\n" \
22272 "\t.previous\n" \
22273 _ASM_EXTABLE(1b, 3b) \
22274- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
22275+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
22276 : "i" (-EFAULT), "q" (__new), "1" (__old) \
22277 : "memory" \
22278 ); \
22279@@ -567,14 +645,14 @@ extern void __cmpxchg_wrong_size(void)
22280 case 2: \
22281 { \
22282 asm volatile("\t" ASM_STAC "\n" \
22283- "1:\t" LOCK_PREFIX "cmpxchgw %4, %2\n" \
22284+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgw %4, %2\n"\
22285 "2:\t" ASM_CLAC "\n" \
22286 "\t.section .fixup, \"ax\"\n" \
22287 "3:\tmov %3, %0\n" \
22288 "\tjmp 2b\n" \
22289 "\t.previous\n" \
22290 _ASM_EXTABLE(1b, 3b) \
22291- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
22292+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
22293 : "i" (-EFAULT), "r" (__new), "1" (__old) \
22294 : "memory" \
22295 ); \
22296@@ -583,14 +661,14 @@ extern void __cmpxchg_wrong_size(void)
22297 case 4: \
22298 { \
22299 asm volatile("\t" ASM_STAC "\n" \
22300- "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n" \
22301+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"\
22302 "2:\t" ASM_CLAC "\n" \
22303 "\t.section .fixup, \"ax\"\n" \
22304 "3:\tmov %3, %0\n" \
22305 "\tjmp 2b\n" \
22306 "\t.previous\n" \
22307 _ASM_EXTABLE(1b, 3b) \
22308- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
22309+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
22310 : "i" (-EFAULT), "r" (__new), "1" (__old) \
22311 : "memory" \
22312 ); \
22313@@ -602,14 +680,14 @@ extern void __cmpxchg_wrong_size(void)
22314 __cmpxchg_wrong_size(); \
22315 \
22316 asm volatile("\t" ASM_STAC "\n" \
22317- "1:\t" LOCK_PREFIX "cmpxchgq %4, %2\n" \
22318+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgq %4, %2\n"\
22319 "2:\t" ASM_CLAC "\n" \
22320 "\t.section .fixup, \"ax\"\n" \
22321 "3:\tmov %3, %0\n" \
22322 "\tjmp 2b\n" \
22323 "\t.previous\n" \
22324 _ASM_EXTABLE(1b, 3b) \
22325- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
22326+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
22327 : "i" (-EFAULT), "r" (__new), "1" (__old) \
22328 : "memory" \
22329 ); \
22330@@ -618,6 +696,7 @@ extern void __cmpxchg_wrong_size(void)
22331 default: \
22332 __cmpxchg_wrong_size(); \
22333 } \
22334+ pax_close_userland(); \
22335 *__uval = __old; \
22336 __ret; \
22337 })
22338@@ -641,17 +720,6 @@ extern struct movsl_mask {
22339
22340 #define ARCH_HAS_NOCACHE_UACCESS 1
22341
22342-#ifdef CONFIG_X86_32
22343-# include <asm/uaccess_32.h>
22344-#else
22345-# include <asm/uaccess_64.h>
22346-#endif
22347-
22348-unsigned long __must_check _copy_from_user(void *to, const void __user *from,
22349- unsigned n);
22350-unsigned long __must_check _copy_to_user(void __user *to, const void *from,
22351- unsigned n);
22352-
22353 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
22354 # define copy_user_diag __compiletime_error
22355 #else
22356@@ -661,7 +729,7 @@ unsigned long __must_check _copy_to_user(void __user *to, const void *from,
22357 extern void copy_user_diag("copy_from_user() buffer size is too small")
22358 copy_from_user_overflow(void);
22359 extern void copy_user_diag("copy_to_user() buffer size is too small")
22360-copy_to_user_overflow(void) __asm__("copy_from_user_overflow");
22361+copy_to_user_overflow(void);
22362
22363 #undef copy_user_diag
22364
22365@@ -674,7 +742,7 @@ __copy_from_user_overflow(void) __asm__("copy_from_user_overflow");
22366
22367 extern void
22368 __compiletime_warning("copy_to_user() buffer size is not provably correct")
22369-__copy_to_user_overflow(void) __asm__("copy_from_user_overflow");
22370+__copy_to_user_overflow(void) __asm__("copy_to_user_overflow");
22371 #define __copy_to_user_overflow(size, count) __copy_to_user_overflow()
22372
22373 #else
22374@@ -689,10 +757,16 @@ __copy_from_user_overflow(int size, unsigned long count)
22375
22376 #endif
22377
22378+#ifdef CONFIG_X86_32
22379+# include <asm/uaccess_32.h>
22380+#else
22381+# include <asm/uaccess_64.h>
22382+#endif
22383+
22384 static inline unsigned long __must_check
22385 copy_from_user(void *to, const void __user *from, unsigned long n)
22386 {
22387- int sz = __compiletime_object_size(to);
22388+ size_t sz = __compiletime_object_size(to);
22389
22390 might_fault();
22391
22392@@ -714,12 +788,15 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
22393 * case, and do only runtime checking for non-constant sizes.
22394 */
22395
22396- if (likely(sz < 0 || sz >= n))
22397- n = _copy_from_user(to, from, n);
22398- else if(__builtin_constant_p(n))
22399- copy_from_user_overflow();
22400- else
22401- __copy_from_user_overflow(sz, n);
22402+ if (likely(sz != (size_t)-1 && sz < n)) {
22403+ if(__builtin_constant_p(n))
22404+ copy_from_user_overflow();
22405+ else
22406+ __copy_from_user_overflow(sz, n);
22407+ } else if (access_ok(VERIFY_READ, from, n))
22408+ n = __copy_from_user(to, from, n);
22409+ else if ((long)n > 0)
22410+ memset(to, 0, n);
22411
22412 return n;
22413 }
22414@@ -727,17 +804,18 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
22415 static inline unsigned long __must_check
22416 copy_to_user(void __user *to, const void *from, unsigned long n)
22417 {
22418- int sz = __compiletime_object_size(from);
22419+ size_t sz = __compiletime_object_size(from);
22420
22421 might_fault();
22422
22423 /* See the comment in copy_from_user() above. */
22424- if (likely(sz < 0 || sz >= n))
22425- n = _copy_to_user(to, from, n);
22426- else if(__builtin_constant_p(n))
22427- copy_to_user_overflow();
22428- else
22429- __copy_to_user_overflow(sz, n);
22430+ if (likely(sz != (size_t)-1 && sz < n)) {
22431+ if(__builtin_constant_p(n))
22432+ copy_to_user_overflow();
22433+ else
22434+ __copy_to_user_overflow(sz, n);
22435+ } else if (access_ok(VERIFY_WRITE, to, n))
22436+ n = __copy_to_user(to, from, n);
22437
22438 return n;
22439 }
22440diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
22441index f5dcb52..da2c15b 100644
22442--- a/arch/x86/include/asm/uaccess_32.h
22443+++ b/arch/x86/include/asm/uaccess_32.h
22444@@ -40,9 +40,14 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
22445 * anything, so this is accurate.
22446 */
22447
22448-static __always_inline unsigned long __must_check
22449+static __always_inline __size_overflow(3) unsigned long __must_check
22450 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
22451 {
22452+ if ((long)n < 0)
22453+ return n;
22454+
22455+ check_object_size(from, n, true);
22456+
22457 if (__builtin_constant_p(n)) {
22458 unsigned long ret;
22459
22460@@ -87,12 +92,16 @@ static __always_inline unsigned long __must_check
22461 __copy_to_user(void __user *to, const void *from, unsigned long n)
22462 {
22463 might_fault();
22464+
22465 return __copy_to_user_inatomic(to, from, n);
22466 }
22467
22468-static __always_inline unsigned long
22469+static __always_inline __size_overflow(3) unsigned long
22470 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
22471 {
22472+ if ((long)n < 0)
22473+ return n;
22474+
22475 /* Avoid zeroing the tail if the copy fails..
22476 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
22477 * but as the zeroing behaviour is only significant when n is not
22478@@ -143,6 +152,12 @@ static __always_inline unsigned long
22479 __copy_from_user(void *to, const void __user *from, unsigned long n)
22480 {
22481 might_fault();
22482+
22483+ if ((long)n < 0)
22484+ return n;
22485+
22486+ check_object_size(to, n, false);
22487+
22488 if (__builtin_constant_p(n)) {
22489 unsigned long ret;
22490
22491@@ -165,6 +180,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
22492 const void __user *from, unsigned long n)
22493 {
22494 might_fault();
22495+
22496+ if ((long)n < 0)
22497+ return n;
22498+
22499 if (__builtin_constant_p(n)) {
22500 unsigned long ret;
22501
22502@@ -187,7 +206,10 @@ static __always_inline unsigned long
22503 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
22504 unsigned long n)
22505 {
22506- return __copy_from_user_ll_nocache_nozero(to, from, n);
22507+ if ((long)n < 0)
22508+ return n;
22509+
22510+ return __copy_from_user_ll_nocache_nozero(to, from, n);
22511 }
22512
22513 #endif /* _ASM_X86_UACCESS_32_H */
22514diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
22515index f2f9b39..2ae1bf8 100644
22516--- a/arch/x86/include/asm/uaccess_64.h
22517+++ b/arch/x86/include/asm/uaccess_64.h
22518@@ -10,6 +10,9 @@
22519 #include <asm/alternative.h>
22520 #include <asm/cpufeature.h>
22521 #include <asm/page.h>
22522+#include <asm/pgtable.h>
22523+
22524+#define set_fs(x) (current_thread_info()->addr_limit = (x))
22525
22526 /*
22527 * Copy To/From Userspace
22528@@ -23,8 +26,8 @@ copy_user_generic_string(void *to, const void *from, unsigned len);
22529 __must_check unsigned long
22530 copy_user_generic_unrolled(void *to, const void *from, unsigned len);
22531
22532-static __always_inline __must_check unsigned long
22533-copy_user_generic(void *to, const void *from, unsigned len)
22534+static __always_inline __must_check __size_overflow(3) unsigned long
22535+copy_user_generic(void *to, const void *from, unsigned long len)
22536 {
22537 unsigned ret;
22538
22539@@ -46,121 +49,170 @@ copy_user_generic(void *to, const void *from, unsigned len)
22540 }
22541
22542 __must_check unsigned long
22543-copy_in_user(void __user *to, const void __user *from, unsigned len);
22544+copy_in_user(void __user *to, const void __user *from, unsigned long len);
22545
22546 static __always_inline __must_check
22547-int __copy_from_user_nocheck(void *dst, const void __user *src, unsigned size)
22548+unsigned long __copy_from_user_nocheck(void *dst, const void __user *src, unsigned long size)
22549 {
22550- int ret = 0;
22551+ size_t sz = __compiletime_object_size(dst);
22552+ unsigned ret = 0;
22553+
22554+ if (size > INT_MAX)
22555+ return size;
22556+
22557+ check_object_size(dst, size, false);
22558+
22559+#ifdef CONFIG_PAX_MEMORY_UDEREF
22560+ if (!access_ok_noprefault(VERIFY_READ, src, size))
22561+ return size;
22562+#endif
22563+
22564+ if (unlikely(sz != (size_t)-1 && sz < size)) {
22565+ if(__builtin_constant_p(size))
22566+ copy_from_user_overflow();
22567+ else
22568+ __copy_from_user_overflow(sz, size);
22569+ return size;
22570+ }
22571
22572 if (!__builtin_constant_p(size))
22573- return copy_user_generic(dst, (__force void *)src, size);
22574+ return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
22575 switch (size) {
22576- case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
22577+ case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
22578 ret, "b", "b", "=q", 1);
22579 return ret;
22580- case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
22581+ case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
22582 ret, "w", "w", "=r", 2);
22583 return ret;
22584- case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
22585+ case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
22586 ret, "l", "k", "=r", 4);
22587 return ret;
22588- case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
22589+ case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
22590 ret, "q", "", "=r", 8);
22591 return ret;
22592 case 10:
22593- __get_user_asm(*(u64 *)dst, (u64 __user *)src,
22594+ __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
22595 ret, "q", "", "=r", 10);
22596 if (unlikely(ret))
22597 return ret;
22598 __get_user_asm(*(u16 *)(8 + (char *)dst),
22599- (u16 __user *)(8 + (char __user *)src),
22600+ (const u16 __user *)(8 + (const char __user *)src),
22601 ret, "w", "w", "=r", 2);
22602 return ret;
22603 case 16:
22604- __get_user_asm(*(u64 *)dst, (u64 __user *)src,
22605+ __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
22606 ret, "q", "", "=r", 16);
22607 if (unlikely(ret))
22608 return ret;
22609 __get_user_asm(*(u64 *)(8 + (char *)dst),
22610- (u64 __user *)(8 + (char __user *)src),
22611+ (const u64 __user *)(8 + (const char __user *)src),
22612 ret, "q", "", "=r", 8);
22613 return ret;
22614 default:
22615- return copy_user_generic(dst, (__force void *)src, size);
22616+ return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
22617 }
22618 }
22619
22620 static __always_inline __must_check
22621-int __copy_from_user(void *dst, const void __user *src, unsigned size)
22622+unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
22623 {
22624 might_fault();
22625 return __copy_from_user_nocheck(dst, src, size);
22626 }
22627
22628 static __always_inline __must_check
22629-int __copy_to_user_nocheck(void __user *dst, const void *src, unsigned size)
22630+unsigned long __copy_to_user_nocheck(void __user *dst, const void *src, unsigned long size)
22631 {
22632- int ret = 0;
22633+ size_t sz = __compiletime_object_size(src);
22634+ unsigned ret = 0;
22635+
22636+ if (size > INT_MAX)
22637+ return size;
22638+
22639+ check_object_size(src, size, true);
22640+
22641+#ifdef CONFIG_PAX_MEMORY_UDEREF
22642+ if (!access_ok_noprefault(VERIFY_WRITE, dst, size))
22643+ return size;
22644+#endif
22645+
22646+ if (unlikely(sz != (size_t)-1 && sz < size)) {
22647+ if(__builtin_constant_p(size))
22648+ copy_to_user_overflow();
22649+ else
22650+ __copy_to_user_overflow(sz, size);
22651+ return size;
22652+ }
22653
22654 if (!__builtin_constant_p(size))
22655- return copy_user_generic((__force void *)dst, src, size);
22656+ return copy_user_generic((__force_kernel void *)____m(dst), src, size);
22657 switch (size) {
22658- case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
22659+ case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
22660 ret, "b", "b", "iq", 1);
22661 return ret;
22662- case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
22663+ case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
22664 ret, "w", "w", "ir", 2);
22665 return ret;
22666- case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
22667+ case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
22668 ret, "l", "k", "ir", 4);
22669 return ret;
22670- case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
22671+ case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
22672 ret, "q", "", "er", 8);
22673 return ret;
22674 case 10:
22675- __put_user_asm(*(u64 *)src, (u64 __user *)dst,
22676+ __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
22677 ret, "q", "", "er", 10);
22678 if (unlikely(ret))
22679 return ret;
22680 asm("":::"memory");
22681- __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
22682+ __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
22683 ret, "w", "w", "ir", 2);
22684 return ret;
22685 case 16:
22686- __put_user_asm(*(u64 *)src, (u64 __user *)dst,
22687+ __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
22688 ret, "q", "", "er", 16);
22689 if (unlikely(ret))
22690 return ret;
22691 asm("":::"memory");
22692- __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
22693+ __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
22694 ret, "q", "", "er", 8);
22695 return ret;
22696 default:
22697- return copy_user_generic((__force void *)dst, src, size);
22698+ return copy_user_generic((__force_kernel void *)____m(dst), src, size);
22699 }
22700 }
22701
22702 static __always_inline __must_check
22703-int __copy_to_user(void __user *dst, const void *src, unsigned size)
22704+unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
22705 {
22706 might_fault();
22707 return __copy_to_user_nocheck(dst, src, size);
22708 }
22709
22710 static __always_inline __must_check
22711-int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22712+unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22713 {
22714- int ret = 0;
22715+ unsigned ret = 0;
22716
22717 might_fault();
22718+
22719+ if (size > INT_MAX)
22720+ return size;
22721+
22722+#ifdef CONFIG_PAX_MEMORY_UDEREF
22723+ if (!access_ok_noprefault(VERIFY_READ, src, size))
22724+ return size;
22725+ if (!access_ok_noprefault(VERIFY_WRITE, dst, size))
22726+ return size;
22727+#endif
22728+
22729 if (!__builtin_constant_p(size))
22730- return copy_user_generic((__force void *)dst,
22731- (__force void *)src, size);
22732+ return copy_user_generic((__force_kernel void *)____m(dst),
22733+ (__force_kernel const void *)____m(src), size);
22734 switch (size) {
22735 case 1: {
22736 u8 tmp;
22737- __get_user_asm(tmp, (u8 __user *)src,
22738+ __get_user_asm(tmp, (const u8 __user *)src,
22739 ret, "b", "b", "=q", 1);
22740 if (likely(!ret))
22741 __put_user_asm(tmp, (u8 __user *)dst,
22742@@ -169,7 +221,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22743 }
22744 case 2: {
22745 u16 tmp;
22746- __get_user_asm(tmp, (u16 __user *)src,
22747+ __get_user_asm(tmp, (const u16 __user *)src,
22748 ret, "w", "w", "=r", 2);
22749 if (likely(!ret))
22750 __put_user_asm(tmp, (u16 __user *)dst,
22751@@ -179,7 +231,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22752
22753 case 4: {
22754 u32 tmp;
22755- __get_user_asm(tmp, (u32 __user *)src,
22756+ __get_user_asm(tmp, (const u32 __user *)src,
22757 ret, "l", "k", "=r", 4);
22758 if (likely(!ret))
22759 __put_user_asm(tmp, (u32 __user *)dst,
22760@@ -188,7 +240,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22761 }
22762 case 8: {
22763 u64 tmp;
22764- __get_user_asm(tmp, (u64 __user *)src,
22765+ __get_user_asm(tmp, (const u64 __user *)src,
22766 ret, "q", "", "=r", 8);
22767 if (likely(!ret))
22768 __put_user_asm(tmp, (u64 __user *)dst,
22769@@ -196,41 +248,58 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22770 return ret;
22771 }
22772 default:
22773- return copy_user_generic((__force void *)dst,
22774- (__force void *)src, size);
22775+ return copy_user_generic((__force_kernel void *)____m(dst),
22776+ (__force_kernel const void *)____m(src), size);
22777 }
22778 }
22779
22780-static __must_check __always_inline int
22781-__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
22782+static __must_check __always_inline unsigned long
22783+__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
22784 {
22785 return __copy_from_user_nocheck(dst, src, size);
22786 }
22787
22788-static __must_check __always_inline int
22789-__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
22790+static __must_check __always_inline unsigned long
22791+__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
22792 {
22793 return __copy_to_user_nocheck(dst, src, size);
22794 }
22795
22796-extern long __copy_user_nocache(void *dst, const void __user *src,
22797- unsigned size, int zerorest);
22798+extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
22799+ unsigned long size, int zerorest);
22800
22801-static inline int
22802-__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
22803+static inline unsigned long
22804+__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
22805 {
22806 might_fault();
22807+
22808+ if (size > INT_MAX)
22809+ return size;
22810+
22811+#ifdef CONFIG_PAX_MEMORY_UDEREF
22812+ if (!access_ok_noprefault(VERIFY_READ, src, size))
22813+ return size;
22814+#endif
22815+
22816 return __copy_user_nocache(dst, src, size, 1);
22817 }
22818
22819-static inline int
22820+static inline unsigned long
22821 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
22822- unsigned size)
22823+ unsigned long size)
22824 {
22825+ if (size > INT_MAX)
22826+ return size;
22827+
22828+#ifdef CONFIG_PAX_MEMORY_UDEREF
22829+ if (!access_ok_noprefault(VERIFY_READ, src, size))
22830+ return size;
22831+#endif
22832+
22833 return __copy_user_nocache(dst, src, size, 0);
22834 }
22835
22836 unsigned long
22837-copy_user_handle_tail(char *to, char *from, unsigned len);
22838+copy_user_handle_tail(char __user *to, char __user *from, unsigned long len) __size_overflow(3);
22839
22840 #endif /* _ASM_X86_UACCESS_64_H */
22841diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
22842index 5b238981..77fdd78 100644
22843--- a/arch/x86/include/asm/word-at-a-time.h
22844+++ b/arch/x86/include/asm/word-at-a-time.h
22845@@ -11,7 +11,7 @@
22846 * and shift, for example.
22847 */
22848 struct word_at_a_time {
22849- const unsigned long one_bits, high_bits;
22850+ unsigned long one_bits, high_bits;
22851 };
22852
22853 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
22854diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
22855index 48d34d2..90671c7 100644
22856--- a/arch/x86/include/asm/x86_init.h
22857+++ b/arch/x86/include/asm/x86_init.h
22858@@ -129,7 +129,7 @@ struct x86_init_ops {
22859 struct x86_init_timers timers;
22860 struct x86_init_iommu iommu;
22861 struct x86_init_pci pci;
22862-};
22863+} __no_const;
22864
22865 /**
22866 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
22867@@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
22868 void (*setup_percpu_clockev)(void);
22869 void (*early_percpu_clock_init)(void);
22870 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
22871-};
22872+} __no_const;
22873
22874 struct timespec;
22875
22876@@ -168,7 +168,7 @@ struct x86_platform_ops {
22877 void (*save_sched_clock_state)(void);
22878 void (*restore_sched_clock_state)(void);
22879 void (*apic_post_init)(void);
22880-};
22881+} __no_const;
22882
22883 struct pci_dev;
22884
22885@@ -177,12 +177,12 @@ struct x86_msi_ops {
22886 void (*teardown_msi_irq)(unsigned int irq);
22887 void (*teardown_msi_irqs)(struct pci_dev *dev);
22888 void (*restore_msi_irqs)(struct pci_dev *dev);
22889-};
22890+} __no_const;
22891
22892 struct x86_io_apic_ops {
22893 unsigned int (*read) (unsigned int apic, unsigned int reg);
22894 void (*disable)(void);
22895-};
22896+} __no_const;
22897
22898 extern struct x86_init_ops x86_init;
22899 extern struct x86_cpuinit_ops x86_cpuinit;
22900diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
22901index c44a5d5..7f83cfc 100644
22902--- a/arch/x86/include/asm/xen/page.h
22903+++ b/arch/x86/include/asm/xen/page.h
22904@@ -82,7 +82,7 @@ static inline int xen_safe_read_ulong(unsigned long *addr, unsigned long *val)
22905 * - get_phys_to_machine() is to be called by __pfn_to_mfn() only in special
22906 * cases needing an extended handling.
22907 */
22908-static inline unsigned long __pfn_to_mfn(unsigned long pfn)
22909+static inline unsigned long __intentional_overflow(-1) __pfn_to_mfn(unsigned long pfn)
22910 {
22911 unsigned long mfn;
22912
22913diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
22914index 0f457e6..5970c0a 100644
22915--- a/arch/x86/include/uapi/asm/e820.h
22916+++ b/arch/x86/include/uapi/asm/e820.h
22917@@ -69,7 +69,7 @@ struct e820map {
22918 #define ISA_START_ADDRESS 0xa0000
22919 #define ISA_END_ADDRESS 0x100000
22920
22921-#define BIOS_BEGIN 0x000a0000
22922+#define BIOS_BEGIN 0x000c0000
22923 #define BIOS_END 0x00100000
22924
22925 #define BIOS_ROM_BASE 0xffe00000
22926diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
22927index 0f15af4..501a76a 100644
22928--- a/arch/x86/kernel/Makefile
22929+++ b/arch/x86/kernel/Makefile
22930@@ -28,7 +28,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
22931 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
22932 obj-$(CONFIG_IRQ_WORK) += irq_work.o
22933 obj-y += probe_roms.o
22934-obj-$(CONFIG_X86_32) += i386_ksyms_32.o
22935+obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
22936 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
22937 obj-$(CONFIG_X86_64) += mcount_64.o
22938 obj-$(CONFIG_X86_ESPFIX64) += espfix_64.o
22939diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
22940index 9393896..adbaa90 100644
22941--- a/arch/x86/kernel/acpi/boot.c
22942+++ b/arch/x86/kernel/acpi/boot.c
22943@@ -1333,7 +1333,7 @@ static void __init acpi_reduced_hw_init(void)
22944 * If your system is blacklisted here, but you find that acpi=force
22945 * works for you, please contact linux-acpi@vger.kernel.org
22946 */
22947-static struct dmi_system_id __initdata acpi_dmi_table[] = {
22948+static const struct dmi_system_id __initconst acpi_dmi_table[] = {
22949 /*
22950 * Boxes that need ACPI disabled
22951 */
22952@@ -1408,7 +1408,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
22953 };
22954
22955 /* second table for DMI checks that should run after early-quirks */
22956-static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
22957+static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
22958 /*
22959 * HP laptops which use a DSDT reporting as HP/SB400/10000,
22960 * which includes some code which overrides all temperature
22961diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
22962index d1daead..acd77e2 100644
22963--- a/arch/x86/kernel/acpi/sleep.c
22964+++ b/arch/x86/kernel/acpi/sleep.c
22965@@ -99,8 +99,12 @@ int x86_acpi_suspend_lowlevel(void)
22966 #else /* CONFIG_64BIT */
22967 #ifdef CONFIG_SMP
22968 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
22969+
22970+ pax_open_kernel();
22971 early_gdt_descr.address =
22972 (unsigned long)get_cpu_gdt_table(smp_processor_id());
22973+ pax_close_kernel();
22974+
22975 initial_gs = per_cpu_offset(smp_processor_id());
22976 #endif
22977 initial_code = (unsigned long)wakeup_long64;
22978diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
22979index 0c26b1b..a766e85 100644
22980--- a/arch/x86/kernel/acpi/wakeup_32.S
22981+++ b/arch/x86/kernel/acpi/wakeup_32.S
22982@@ -31,13 +31,11 @@ wakeup_pmode_return:
22983 # and restore the stack ... but you need gdt for this to work
22984 movl saved_context_esp, %esp
22985
22986- movl %cs:saved_magic, %eax
22987- cmpl $0x12345678, %eax
22988+ cmpl $0x12345678, saved_magic
22989 jne bogus_magic
22990
22991 # jump to place where we left off
22992- movl saved_eip, %eax
22993- jmp *%eax
22994+ jmp *(saved_eip)
22995
22996 bogus_magic:
22997 jmp bogus_magic
22998diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
22999index 25f9093..21d2827 100644
23000--- a/arch/x86/kernel/alternative.c
23001+++ b/arch/x86/kernel/alternative.c
23002@@ -20,6 +20,7 @@
23003 #include <asm/tlbflush.h>
23004 #include <asm/io.h>
23005 #include <asm/fixmap.h>
23006+#include <asm/boot.h>
23007
23008 int __read_mostly alternatives_patched;
23009
23010@@ -261,7 +262,9 @@ static void __init_or_module add_nops(void *insns, unsigned int len)
23011 unsigned int noplen = len;
23012 if (noplen > ASM_NOP_MAX)
23013 noplen = ASM_NOP_MAX;
23014+ pax_open_kernel();
23015 memcpy(insns, ideal_nops[noplen], noplen);
23016+ pax_close_kernel();
23017 insns += noplen;
23018 len -= noplen;
23019 }
23020@@ -289,6 +292,13 @@ recompute_jump(struct alt_instr *a, u8 *orig_insn, u8 *repl_insn, u8 *insnbuf)
23021 if (a->replacementlen != 5)
23022 return;
23023
23024+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23025+ if (orig_insn < (u8 *)_text || (u8 *)_einittext <= orig_insn)
23026+ orig_insn = (u8 *)ktva_ktla((unsigned long)orig_insn);
23027+ else
23028+ orig_insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23029+#endif
23030+
23031 o_dspl = *(s32 *)(insnbuf + 1);
23032
23033 /* next_rip of the replacement JMP */
23034@@ -364,6 +374,7 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
23035 {
23036 struct alt_instr *a;
23037 u8 *instr, *replacement;
23038+ u8 *vinstr, *vreplacement;
23039 u8 insnbuf[MAX_PATCH_LEN];
23040
23041 DPRINTK("alt table %p -> %p", start, end);
23042@@ -379,46 +390,71 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
23043 for (a = start; a < end; a++) {
23044 int insnbuf_sz = 0;
23045
23046- instr = (u8 *)&a->instr_offset + a->instr_offset;
23047- replacement = (u8 *)&a->repl_offset + a->repl_offset;
23048+ vinstr = instr = (u8 *)&a->instr_offset + a->instr_offset;
23049+
23050+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23051+ if ((u8 *)_text - (____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR) <= instr &&
23052+ instr < (u8 *)_einittext - (____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR)) {
23053+ instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23054+ vinstr = (u8 *)ktla_ktva((unsigned long)instr);
23055+ } else if ((u8 *)_text <= instr && instr < (u8 *)_einittext) {
23056+ vinstr = (u8 *)ktla_ktva((unsigned long)instr);
23057+ } else {
23058+ instr = (u8 *)ktva_ktla((unsigned long)instr);
23059+ }
23060+#endif
23061+
23062+ vreplacement = replacement = (u8 *)&a->repl_offset + a->repl_offset;
23063+
23064+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23065+ if ((u8 *)_text - (____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR) <= replacement &&
23066+ replacement < (u8 *)_einittext - (____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR)) {
23067+ replacement += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23068+ vreplacement = (u8 *)ktla_ktva((unsigned long)replacement);
23069+ } else if ((u8 *)_text <= replacement && replacement < (u8 *)_einittext) {
23070+ vreplacement = (u8 *)ktla_ktva((unsigned long)replacement);
23071+ } else
23072+ replacement = (u8 *)ktva_ktla((unsigned long)replacement);
23073+#endif
23074+
23075 BUG_ON(a->instrlen > sizeof(insnbuf));
23076 BUG_ON(a->cpuid >= (NCAPINTS + NBUGINTS) * 32);
23077 if (!boot_cpu_has(a->cpuid)) {
23078 if (a->padlen > 1)
23079- optimize_nops(a, instr);
23080+ optimize_nops(a, vinstr);
23081
23082 continue;
23083 }
23084
23085- DPRINTK("feat: %d*32+%d, old: (%p, len: %d), repl: (%p, len: %d), pad: %d",
23086+ DPRINTK("feat: %d*32+%d, old: (%p/%p, len: %d), repl: (%p, len: %d), pad: %d",
23087 a->cpuid >> 5,
23088 a->cpuid & 0x1f,
23089- instr, a->instrlen,
23090- replacement, a->replacementlen, a->padlen);
23091+ instr, vinstr, a->instrlen,
23092+ vreplacement, a->replacementlen, a->padlen);
23093
23094- DUMP_BYTES(instr, a->instrlen, "%p: old_insn: ", instr);
23095- DUMP_BYTES(replacement, a->replacementlen, "%p: rpl_insn: ", replacement);
23096+ DUMP_BYTES(vinstr, a->instrlen, "%p: old_insn: ", vinstr);
23097+ DUMP_BYTES(vreplacement, a->replacementlen, "%p: rpl_insn: ", vreplacement);
23098
23099- memcpy(insnbuf, replacement, a->replacementlen);
23100+ memcpy(insnbuf, vreplacement, a->replacementlen);
23101 insnbuf_sz = a->replacementlen;
23102
23103 /* 0xe8 is a relative jump; fix the offset. */
23104 if (*insnbuf == 0xe8 && a->replacementlen == 5) {
23105- *(s32 *)(insnbuf + 1) += replacement - instr;
23106+ *(s32 *)(insnbuf + 1) += vreplacement - vinstr;
23107 DPRINTK("Fix CALL offset: 0x%x, CALL 0x%lx",
23108 *(s32 *)(insnbuf + 1),
23109- (unsigned long)instr + *(s32 *)(insnbuf + 1) + 5);
23110+ (unsigned long)vinstr + *(s32 *)(insnbuf + 1) + 5);
23111 }
23112
23113- if (a->replacementlen && is_jmp(replacement[0]))
23114- recompute_jump(a, instr, replacement, insnbuf);
23115+ if (a->replacementlen && is_jmp(vreplacement[0]))
23116+ recompute_jump(a, instr, vreplacement, insnbuf);
23117
23118 if (a->instrlen > a->replacementlen) {
23119 add_nops(insnbuf + a->replacementlen,
23120 a->instrlen - a->replacementlen);
23121 insnbuf_sz += a->instrlen - a->replacementlen;
23122 }
23123- DUMP_BYTES(insnbuf, insnbuf_sz, "%p: final_insn: ", instr);
23124+ DUMP_BYTES(insnbuf, insnbuf_sz, "%p: final_insn: ", vinstr);
23125
23126 text_poke_early(instr, insnbuf, insnbuf_sz);
23127 }
23128@@ -434,10 +470,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
23129 for (poff = start; poff < end; poff++) {
23130 u8 *ptr = (u8 *)poff + *poff;
23131
23132+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23133+ ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23134+ if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
23135+ ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23136+#endif
23137+
23138 if (!*poff || ptr < text || ptr >= text_end)
23139 continue;
23140 /* turn DS segment override prefix into lock prefix */
23141- if (*ptr == 0x3e)
23142+ if (*(u8 *)ktla_ktva((unsigned long)ptr) == 0x3e)
23143 text_poke(ptr, ((unsigned char []){0xf0}), 1);
23144 }
23145 mutex_unlock(&text_mutex);
23146@@ -452,10 +494,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
23147 for (poff = start; poff < end; poff++) {
23148 u8 *ptr = (u8 *)poff + *poff;
23149
23150+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23151+ ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23152+ if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
23153+ ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23154+#endif
23155+
23156 if (!*poff || ptr < text || ptr >= text_end)
23157 continue;
23158 /* turn lock prefix into DS segment override prefix */
23159- if (*ptr == 0xf0)
23160+ if (*(u8 *)ktla_ktva((unsigned long)ptr) == 0xf0)
23161 text_poke(ptr, ((unsigned char []){0x3E}), 1);
23162 }
23163 mutex_unlock(&text_mutex);
23164@@ -592,7 +640,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
23165
23166 BUG_ON(p->len > MAX_PATCH_LEN);
23167 /* prep the buffer with the original instructions */
23168- memcpy(insnbuf, p->instr, p->len);
23169+ memcpy(insnbuf, (const void *)ktla_ktva((unsigned long)p->instr), p->len);
23170 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
23171 (unsigned long)p->instr, p->len);
23172
23173@@ -639,7 +687,7 @@ void __init alternative_instructions(void)
23174 if (!uniproc_patched || num_possible_cpus() == 1)
23175 free_init_pages("SMP alternatives",
23176 (unsigned long)__smp_locks,
23177- (unsigned long)__smp_locks_end);
23178+ PAGE_ALIGN((unsigned long)__smp_locks_end));
23179 #endif
23180
23181 apply_paravirt(__parainstructions, __parainstructions_end);
23182@@ -660,13 +708,17 @@ void __init alternative_instructions(void)
23183 * instructions. And on the local CPU you need to be protected again NMI or MCE
23184 * handlers seeing an inconsistent instruction while you patch.
23185 */
23186-void *__init_or_module text_poke_early(void *addr, const void *opcode,
23187+void *__kprobes text_poke_early(void *addr, const void *opcode,
23188 size_t len)
23189 {
23190 unsigned long flags;
23191 local_irq_save(flags);
23192- memcpy(addr, opcode, len);
23193+
23194+ pax_open_kernel();
23195+ memcpy((void *)ktla_ktva((unsigned long)addr), opcode, len);
23196 sync_core();
23197+ pax_close_kernel();
23198+
23199 local_irq_restore(flags);
23200 /* Could also do a CLFLUSH here to speed up CPU recovery; but
23201 that causes hangs on some VIA CPUs. */
23202@@ -688,36 +740,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
23203 */
23204 void *text_poke(void *addr, const void *opcode, size_t len)
23205 {
23206- unsigned long flags;
23207- char *vaddr;
23208+ unsigned char *vaddr = (void *)ktla_ktva((unsigned long)addr);
23209 struct page *pages[2];
23210- int i;
23211+ size_t i;
23212
23213 if (!core_kernel_text((unsigned long)addr)) {
23214- pages[0] = vmalloc_to_page(addr);
23215- pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
23216+ pages[0] = vmalloc_to_page(vaddr);
23217+ pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
23218 } else {
23219- pages[0] = virt_to_page(addr);
23220+ pages[0] = virt_to_page(vaddr);
23221 WARN_ON(!PageReserved(pages[0]));
23222- pages[1] = virt_to_page(addr + PAGE_SIZE);
23223+ pages[1] = virt_to_page(vaddr + PAGE_SIZE);
23224 }
23225 BUG_ON(!pages[0]);
23226- local_irq_save(flags);
23227- set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
23228- if (pages[1])
23229- set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
23230- vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
23231- memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
23232- clear_fixmap(FIX_TEXT_POKE0);
23233- if (pages[1])
23234- clear_fixmap(FIX_TEXT_POKE1);
23235- local_flush_tlb();
23236- sync_core();
23237- /* Could also do a CLFLUSH here to speed up CPU recovery; but
23238- that causes hangs on some VIA CPUs. */
23239+ text_poke_early(addr, opcode, len);
23240 for (i = 0; i < len; i++)
23241- BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
23242- local_irq_restore(flags);
23243+ BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
23244 return addr;
23245 }
23246
23247@@ -771,7 +809,7 @@ int poke_int3_handler(struct pt_regs *regs)
23248 */
23249 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
23250 {
23251- unsigned char int3 = 0xcc;
23252+ const unsigned char int3 = 0xcc;
23253
23254 bp_int3_handler = handler;
23255 bp_int3_addr = (u8 *)addr + sizeof(int3);
23256diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
23257index 307a498..783e96a 100644
23258--- a/arch/x86/kernel/apic/apic.c
23259+++ b/arch/x86/kernel/apic/apic.c
23260@@ -171,7 +171,7 @@ int first_system_vector = FIRST_SYSTEM_VECTOR;
23261 /*
23262 * Debug level, exported for io_apic.c
23263 */
23264-unsigned int apic_verbosity;
23265+int apic_verbosity;
23266
23267 int pic_mode;
23268
23269@@ -1864,7 +1864,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
23270 apic_write(APIC_ESR, 0);
23271 v = apic_read(APIC_ESR);
23272 ack_APIC_irq();
23273- atomic_inc(&irq_err_count);
23274+ atomic_inc_unchecked(&irq_err_count);
23275
23276 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x",
23277 smp_processor_id(), v);
23278diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
23279index de918c4..32eed23 100644
23280--- a/arch/x86/kernel/apic/apic_flat_64.c
23281+++ b/arch/x86/kernel/apic/apic_flat_64.c
23282@@ -154,7 +154,7 @@ static int flat_probe(void)
23283 return 1;
23284 }
23285
23286-static struct apic apic_flat = {
23287+static struct apic apic_flat __read_only = {
23288 .name = "flat",
23289 .probe = flat_probe,
23290 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
23291@@ -260,7 +260,7 @@ static int physflat_probe(void)
23292 return 0;
23293 }
23294
23295-static struct apic apic_physflat = {
23296+static struct apic apic_physflat __read_only = {
23297
23298 .name = "physical flat",
23299 .probe = physflat_probe,
23300diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
23301index b205cdb..d8503ff 100644
23302--- a/arch/x86/kernel/apic/apic_noop.c
23303+++ b/arch/x86/kernel/apic/apic_noop.c
23304@@ -108,7 +108,7 @@ static void noop_apic_write(u32 reg, u32 v)
23305 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
23306 }
23307
23308-struct apic apic_noop = {
23309+struct apic apic_noop __read_only = {
23310 .name = "noop",
23311 .probe = noop_probe,
23312 .acpi_madt_oem_check = NULL,
23313diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
23314index c4a8d63..fe893ac 100644
23315--- a/arch/x86/kernel/apic/bigsmp_32.c
23316+++ b/arch/x86/kernel/apic/bigsmp_32.c
23317@@ -147,7 +147,7 @@ static int probe_bigsmp(void)
23318 return dmi_bigsmp;
23319 }
23320
23321-static struct apic apic_bigsmp = {
23322+static struct apic apic_bigsmp __read_only = {
23323
23324 .name = "bigsmp",
23325 .probe = probe_bigsmp,
23326diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
23327index 5880b48..5085f3e 100644
23328--- a/arch/x86/kernel/apic/io_apic.c
23329+++ b/arch/x86/kernel/apic/io_apic.c
23330@@ -1682,7 +1682,7 @@ static unsigned int startup_ioapic_irq(struct irq_data *data)
23331 return was_pending;
23332 }
23333
23334-atomic_t irq_mis_count;
23335+atomic_unchecked_t irq_mis_count;
23336
23337 #ifdef CONFIG_GENERIC_PENDING_IRQ
23338 static bool io_apic_level_ack_pending(struct mp_chip_data *data)
23339@@ -1821,7 +1821,7 @@ static void ioapic_ack_level(struct irq_data *irq_data)
23340 * at the cpu.
23341 */
23342 if (!(v & (1 << (i & 0x1f)))) {
23343- atomic_inc(&irq_mis_count);
23344+ atomic_inc_unchecked(&irq_mis_count);
23345 eoi_ioapic_pin(cfg->vector, irq_data->chip_data);
23346 }
23347
23348@@ -1867,7 +1867,7 @@ static int ioapic_set_affinity(struct irq_data *irq_data,
23349 return ret;
23350 }
23351
23352-static struct irq_chip ioapic_chip __read_mostly = {
23353+static struct irq_chip ioapic_chip = {
23354 .name = "IO-APIC",
23355 .irq_startup = startup_ioapic_irq,
23356 .irq_mask = mask_ioapic_irq,
23357@@ -1936,7 +1936,7 @@ static void ack_lapic_irq(struct irq_data *data)
23358 ack_APIC_irq();
23359 }
23360
23361-static struct irq_chip lapic_chip __read_mostly = {
23362+static struct irq_chip lapic_chip = {
23363 .name = "local-APIC",
23364 .irq_mask = mask_lapic_irq,
23365 .irq_unmask = unmask_lapic_irq,
23366diff --git a/arch/x86/kernel/apic/msi.c b/arch/x86/kernel/apic/msi.c
23367index 1a9d735..c58b5c5 100644
23368--- a/arch/x86/kernel/apic/msi.c
23369+++ b/arch/x86/kernel/apic/msi.c
23370@@ -267,7 +267,7 @@ static void hpet_msi_write_msg(struct irq_data *data, struct msi_msg *msg)
23371 hpet_msi_write(data->handler_data, msg);
23372 }
23373
23374-static struct irq_chip hpet_msi_controller = {
23375+static irq_chip_no_const hpet_msi_controller __read_only = {
23376 .name = "HPET-MSI",
23377 .irq_unmask = hpet_msi_unmask,
23378 .irq_mask = hpet_msi_mask,
23379diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
23380index bda4886..f9c7195 100644
23381--- a/arch/x86/kernel/apic/probe_32.c
23382+++ b/arch/x86/kernel/apic/probe_32.c
23383@@ -72,7 +72,7 @@ static int probe_default(void)
23384 return 1;
23385 }
23386
23387-static struct apic apic_default = {
23388+static struct apic apic_default __read_only = {
23389
23390 .name = "default",
23391 .probe = probe_default,
23392diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
23393index 2683f36..0bdc74c 100644
23394--- a/arch/x86/kernel/apic/vector.c
23395+++ b/arch/x86/kernel/apic/vector.c
23396@@ -36,7 +36,7 @@ static struct irq_chip lapic_controller;
23397 static struct apic_chip_data *legacy_irq_data[NR_IRQS_LEGACY];
23398 #endif
23399
23400-void lock_vector_lock(void)
23401+void lock_vector_lock(void) __acquires(vector_lock)
23402 {
23403 /* Used to the online set of cpus does not change
23404 * during assign_irq_vector.
23405@@ -44,7 +44,7 @@ void lock_vector_lock(void)
23406 raw_spin_lock(&vector_lock);
23407 }
23408
23409-void unlock_vector_lock(void)
23410+void unlock_vector_lock(void) __releases(vector_lock)
23411 {
23412 raw_spin_unlock(&vector_lock);
23413 }
23414diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
23415index ab3219b..e8033eb 100644
23416--- a/arch/x86/kernel/apic/x2apic_cluster.c
23417+++ b/arch/x86/kernel/apic/x2apic_cluster.c
23418@@ -182,7 +182,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
23419 return notifier_from_errno(err);
23420 }
23421
23422-static struct notifier_block __refdata x2apic_cpu_notifier = {
23423+static struct notifier_block x2apic_cpu_notifier = {
23424 .notifier_call = update_clusterinfo,
23425 };
23426
23427@@ -234,7 +234,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
23428 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
23429 }
23430
23431-static struct apic apic_x2apic_cluster = {
23432+static struct apic apic_x2apic_cluster __read_only = {
23433
23434 .name = "cluster x2apic",
23435 .probe = x2apic_cluster_probe,
23436diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
23437index 3ffd925..8c0f5a8 100644
23438--- a/arch/x86/kernel/apic/x2apic_phys.c
23439+++ b/arch/x86/kernel/apic/x2apic_phys.c
23440@@ -90,7 +90,7 @@ static int x2apic_phys_probe(void)
23441 return apic == &apic_x2apic_phys;
23442 }
23443
23444-static struct apic apic_x2apic_phys = {
23445+static struct apic apic_x2apic_phys __read_only = {
23446
23447 .name = "physical x2apic",
23448 .probe = x2apic_phys_probe,
23449diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
23450index c8d9295..9af2d03 100644
23451--- a/arch/x86/kernel/apic/x2apic_uv_x.c
23452+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
23453@@ -375,7 +375,7 @@ static int uv_probe(void)
23454 return apic == &apic_x2apic_uv_x;
23455 }
23456
23457-static struct apic __refdata apic_x2apic_uv_x = {
23458+static struct apic apic_x2apic_uv_x __read_only = {
23459
23460 .name = "UV large system",
23461 .probe = uv_probe,
23462diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
23463index 927ec92..de68f32 100644
23464--- a/arch/x86/kernel/apm_32.c
23465+++ b/arch/x86/kernel/apm_32.c
23466@@ -432,7 +432,7 @@ static DEFINE_MUTEX(apm_mutex);
23467 * This is for buggy BIOS's that refer to (real mode) segment 0x40
23468 * even though they are called in protected mode.
23469 */
23470-static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
23471+static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
23472 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
23473
23474 static const char driver_version[] = "1.16ac"; /* no spaces */
23475@@ -610,7 +610,10 @@ static long __apm_bios_call(void *_call)
23476 BUG_ON(cpu != 0);
23477 gdt = get_cpu_gdt_table(cpu);
23478 save_desc_40 = gdt[0x40 / 8];
23479+
23480+ pax_open_kernel();
23481 gdt[0x40 / 8] = bad_bios_desc;
23482+ pax_close_kernel();
23483
23484 apm_irq_save(flags);
23485 APM_DO_SAVE_SEGS;
23486@@ -619,7 +622,11 @@ static long __apm_bios_call(void *_call)
23487 &call->esi);
23488 APM_DO_RESTORE_SEGS;
23489 apm_irq_restore(flags);
23490+
23491+ pax_open_kernel();
23492 gdt[0x40 / 8] = save_desc_40;
23493+ pax_close_kernel();
23494+
23495 put_cpu();
23496
23497 return call->eax & 0xff;
23498@@ -686,7 +693,10 @@ static long __apm_bios_call_simple(void *_call)
23499 BUG_ON(cpu != 0);
23500 gdt = get_cpu_gdt_table(cpu);
23501 save_desc_40 = gdt[0x40 / 8];
23502+
23503+ pax_open_kernel();
23504 gdt[0x40 / 8] = bad_bios_desc;
23505+ pax_close_kernel();
23506
23507 apm_irq_save(flags);
23508 APM_DO_SAVE_SEGS;
23509@@ -694,7 +704,11 @@ static long __apm_bios_call_simple(void *_call)
23510 &call->eax);
23511 APM_DO_RESTORE_SEGS;
23512 apm_irq_restore(flags);
23513+
23514+ pax_open_kernel();
23515 gdt[0x40 / 8] = save_desc_40;
23516+ pax_close_kernel();
23517+
23518 put_cpu();
23519 return error;
23520 }
23521@@ -2039,7 +2053,7 @@ static int __init swab_apm_power_in_minutes(const struct dmi_system_id *d)
23522 return 0;
23523 }
23524
23525-static struct dmi_system_id __initdata apm_dmi_table[] = {
23526+static const struct dmi_system_id __initconst apm_dmi_table[] = {
23527 {
23528 print_if_true,
23529 KERN_WARNING "IBM T23 - BIOS 1.03b+ and controller firmware 1.02+ may be needed for Linux APM.",
23530@@ -2349,12 +2363,15 @@ static int __init apm_init(void)
23531 * code to that CPU.
23532 */
23533 gdt = get_cpu_gdt_table(0);
23534+
23535+ pax_open_kernel();
23536 set_desc_base(&gdt[APM_CS >> 3],
23537 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
23538 set_desc_base(&gdt[APM_CS_16 >> 3],
23539 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
23540 set_desc_base(&gdt[APM_DS >> 3],
23541 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
23542+ pax_close_kernel();
23543
23544 proc_create("apm", 0, NULL, &apm_file_ops);
23545
23546diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
23547index 8e3d22a1..37118b6 100644
23548--- a/arch/x86/kernel/asm-offsets.c
23549+++ b/arch/x86/kernel/asm-offsets.c
23550@@ -32,6 +32,8 @@ void common(void) {
23551 OFFSET(TI_flags, thread_info, flags);
23552 OFFSET(TI_status, thread_info, status);
23553 OFFSET(TI_addr_limit, thread_info, addr_limit);
23554+ OFFSET(TI_lowest_stack, thread_info, lowest_stack);
23555+ DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
23556
23557 BLANK();
23558 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
23559@@ -73,8 +75,26 @@ void common(void) {
23560 #endif
23561 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
23562 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
23563+
23564+#ifdef CONFIG_PAX_KERNEXEC
23565+ OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
23566 #endif
23567
23568+#ifdef CONFIG_PAX_MEMORY_UDEREF
23569+ OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
23570+ OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
23571+#ifdef CONFIG_X86_64
23572+ OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
23573+#endif
23574+#endif
23575+
23576+#endif
23577+
23578+ BLANK();
23579+ DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
23580+ DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
23581+ DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
23582+
23583 #ifdef CONFIG_XEN
23584 BLANK();
23585 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
23586diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
23587index d8f42f9..a46f1fc 100644
23588--- a/arch/x86/kernel/asm-offsets_64.c
23589+++ b/arch/x86/kernel/asm-offsets_64.c
23590@@ -59,6 +59,7 @@ int main(void)
23591 BLANK();
23592 #undef ENTRY
23593
23594+ DEFINE(TSS_size, sizeof(struct tss_struct));
23595 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
23596 OFFSET(TSS_sp0, tss_struct, x86_tss.sp0);
23597 BLANK();
23598diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
23599index 9bff687..5b899fb 100644
23600--- a/arch/x86/kernel/cpu/Makefile
23601+++ b/arch/x86/kernel/cpu/Makefile
23602@@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
23603 CFLAGS_REMOVE_perf_event.o = -pg
23604 endif
23605
23606-# Make sure load_percpu_segment has no stackprotector
23607-nostackp := $(call cc-option, -fno-stack-protector)
23608-CFLAGS_common.o := $(nostackp)
23609-
23610 obj-y := intel_cacheinfo.o scattered.o topology.o
23611 obj-y += common.o
23612 obj-y += rdrand.o
23613diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
23614index dd3a4ba..06672af 100644
23615--- a/arch/x86/kernel/cpu/amd.c
23616+++ b/arch/x86/kernel/cpu/amd.c
23617@@ -750,7 +750,7 @@ static void init_amd(struct cpuinfo_x86 *c)
23618 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
23619 {
23620 /* AMD errata T13 (order #21922) */
23621- if ((c->x86 == 6)) {
23622+ if (c->x86 == 6) {
23623 /* Duron Rev A0 */
23624 if (c->x86_model == 3 && c->x86_mask == 0)
23625 size = 64;
23626diff --git a/arch/x86/kernel/cpu/bugs_64.c b/arch/x86/kernel/cpu/bugs_64.c
23627index 04f0fe5..3c0598c 100644
23628--- a/arch/x86/kernel/cpu/bugs_64.c
23629+++ b/arch/x86/kernel/cpu/bugs_64.c
23630@@ -10,6 +10,7 @@
23631 #include <asm/processor.h>
23632 #include <asm/mtrr.h>
23633 #include <asm/cacheflush.h>
23634+#include <asm/sections.h>
23635
23636 void __init check_bugs(void)
23637 {
23638@@ -18,6 +19,7 @@ void __init check_bugs(void)
23639 printk(KERN_INFO "CPU: ");
23640 print_cpu_info(&boot_cpu_data);
23641 #endif
23642+ set_memory_nx((unsigned long)_sinitdata, (__START_KERNEL_map + KERNEL_IMAGE_SIZE - (unsigned long)_sinitdata) >> PAGE_SHIFT);
23643 alternative_instructions();
23644
23645 /*
23646diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
23647index cb9e5df..0d25636 100644
23648--- a/arch/x86/kernel/cpu/common.c
23649+++ b/arch/x86/kernel/cpu/common.c
23650@@ -91,60 +91,6 @@ static const struct cpu_dev default_cpu = {
23651
23652 static const struct cpu_dev *this_cpu = &default_cpu;
23653
23654-DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
23655-#ifdef CONFIG_X86_64
23656- /*
23657- * We need valid kernel segments for data and code in long mode too
23658- * IRET will check the segment types kkeil 2000/10/28
23659- * Also sysret mandates a special GDT layout
23660- *
23661- * TLS descriptors are currently at a different place compared to i386.
23662- * Hopefully nobody expects them at a fixed place (Wine?)
23663- */
23664- [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
23665- [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
23666- [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
23667- [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
23668- [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
23669- [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
23670-#else
23671- [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
23672- [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
23673- [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
23674- [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
23675- /*
23676- * Segments used for calling PnP BIOS have byte granularity.
23677- * They code segments and data segments have fixed 64k limits,
23678- * the transfer segment sizes are set at run time.
23679- */
23680- /* 32-bit code */
23681- [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
23682- /* 16-bit code */
23683- [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
23684- /* 16-bit data */
23685- [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
23686- /* 16-bit data */
23687- [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
23688- /* 16-bit data */
23689- [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
23690- /*
23691- * The APM segments have byte granularity and their bases
23692- * are set at run time. All have 64k limits.
23693- */
23694- /* 32-bit code */
23695- [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
23696- /* 16-bit code */
23697- [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
23698- /* data */
23699- [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
23700-
23701- [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
23702- [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
23703- GDT_STACK_CANARY_INIT
23704-#endif
23705-} };
23706-EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
23707-
23708 static int __init x86_mpx_setup(char *s)
23709 {
23710 /* require an exact match without trailing characters */
23711@@ -287,6 +233,109 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
23712 }
23713 }
23714
23715+#ifdef CONFIG_PAX_MEMORY_UDEREF
23716+#ifdef CONFIG_X86_64
23717+static bool uderef_enabled __read_only = true;
23718+unsigned long pax_user_shadow_base __read_only;
23719+EXPORT_SYMBOL(pax_user_shadow_base);
23720+extern char pax_enter_kernel_user[];
23721+extern char pax_exit_kernel_user[];
23722+
23723+static int __init setup_pax_weakuderef(char *str)
23724+{
23725+ if (uderef_enabled)
23726+ pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
23727+ return 1;
23728+}
23729+__setup("pax_weakuderef", setup_pax_weakuderef);
23730+#endif
23731+
23732+static int __init setup_pax_nouderef(char *str)
23733+{
23734+#ifdef CONFIG_X86_32
23735+ unsigned int cpu;
23736+ struct desc_struct *gdt;
23737+
23738+ for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
23739+ gdt = get_cpu_gdt_table(cpu);
23740+ gdt[GDT_ENTRY_KERNEL_DS].type = 3;
23741+ gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
23742+ gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
23743+ gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
23744+ }
23745+ loadsegment(ds, __KERNEL_DS);
23746+ loadsegment(es, __KERNEL_DS);
23747+ loadsegment(ss, __KERNEL_DS);
23748+#else
23749+ memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
23750+ memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
23751+ clone_pgd_mask = ~(pgdval_t)0UL;
23752+ pax_user_shadow_base = 0UL;
23753+ setup_clear_cpu_cap(X86_FEATURE_PCIDUDEREF);
23754+ uderef_enabled = false;
23755+#endif
23756+
23757+ return 0;
23758+}
23759+early_param("pax_nouderef", setup_pax_nouderef);
23760+#endif
23761+
23762+#ifdef CONFIG_X86_64
23763+static __init int setup_disable_pcid(char *arg)
23764+{
23765+ setup_clear_cpu_cap(X86_FEATURE_PCID);
23766+ setup_clear_cpu_cap(X86_FEATURE_INVPCID);
23767+
23768+#ifdef CONFIG_PAX_MEMORY_UDEREF
23769+ if (uderef_enabled)
23770+ pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
23771+#endif
23772+
23773+ return 1;
23774+}
23775+__setup("nopcid", setup_disable_pcid);
23776+
23777+static void setup_pcid(struct cpuinfo_x86 *c)
23778+{
23779+ if (cpu_has(c, X86_FEATURE_PCID)) {
23780+ printk("PAX: PCID detected\n");
23781+ cr4_set_bits(X86_CR4_PCIDE);
23782+ } else
23783+ clear_cpu_cap(c, X86_FEATURE_INVPCID);
23784+
23785+ if (cpu_has(c, X86_FEATURE_INVPCID))
23786+ printk("PAX: INVPCID detected\n");
23787+
23788+#ifdef CONFIG_PAX_MEMORY_UDEREF
23789+ if (!uderef_enabled) {
23790+ printk("PAX: UDEREF disabled\n");
23791+ return;
23792+ }
23793+
23794+ if (!cpu_has(c, X86_FEATURE_PCID)) {
23795+ pax_open_kernel();
23796+ pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
23797+ pax_close_kernel();
23798+ printk("PAX: slow and weak UDEREF enabled\n");
23799+ return;
23800+ }
23801+
23802+ set_cpu_cap(c, X86_FEATURE_PCIDUDEREF);
23803+
23804+ pax_open_kernel();
23805+ clone_pgd_mask = ~(pgdval_t)0UL;
23806+ pax_close_kernel();
23807+ if (pax_user_shadow_base)
23808+ printk("PAX: weak UDEREF enabled\n");
23809+ else {
23810+ set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
23811+ printk("PAX: strong UDEREF enabled\n");
23812+ }
23813+#endif
23814+
23815+}
23816+#endif
23817+
23818 /*
23819 * Some CPU features depend on higher CPUID levels, which may not always
23820 * be available due to CPUID level capping or broken virtualization
23821@@ -387,7 +436,7 @@ void switch_to_new_gdt(int cpu)
23822 {
23823 struct desc_ptr gdt_descr;
23824
23825- gdt_descr.address = (long)get_cpu_gdt_table(cpu);
23826+ gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
23827 gdt_descr.size = GDT_SIZE - 1;
23828 load_gdt(&gdt_descr);
23829 /* Reload the per-cpu base */
23830@@ -918,6 +967,20 @@ static void identify_cpu(struct cpuinfo_x86 *c)
23831 setup_smep(c);
23832 setup_smap(c);
23833
23834+#ifdef CONFIG_X86_32
23835+#ifdef CONFIG_PAX_PAGEEXEC
23836+ if (!(__supported_pte_mask & _PAGE_NX))
23837+ clear_cpu_cap(c, X86_FEATURE_PSE);
23838+#endif
23839+#if defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
23840+ clear_cpu_cap(c, X86_FEATURE_SEP);
23841+#endif
23842+#endif
23843+
23844+#ifdef CONFIG_X86_64
23845+ setup_pcid(c);
23846+#endif
23847+
23848 /*
23849 * The vendor-specific functions might have changed features.
23850 * Now we do "generic changes."
23851@@ -992,7 +1055,7 @@ void enable_sep_cpu(void)
23852 int cpu;
23853
23854 cpu = get_cpu();
23855- tss = &per_cpu(cpu_tss, cpu);
23856+ tss = cpu_tss + cpu;
23857
23858 if (!boot_cpu_has(X86_FEATURE_SEP))
23859 goto out;
23860@@ -1138,10 +1201,12 @@ static __init int setup_disablecpuid(char *arg)
23861 }
23862 __setup("clearcpuid=", setup_disablecpuid);
23863
23864+DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
23865+EXPORT_PER_CPU_SYMBOL(current_tinfo);
23866+
23867 #ifdef CONFIG_X86_64
23868-struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
23869-struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
23870- (unsigned long) debug_idt_table };
23871+struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
23872+const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
23873
23874 DEFINE_PER_CPU_FIRST(union irq_stack_union,
23875 irq_stack_union) __aligned(PAGE_SIZE) __visible;
23876@@ -1253,21 +1318,21 @@ EXPORT_PER_CPU_SYMBOL(current_task);
23877 DEFINE_PER_CPU(int, __preempt_count) = INIT_PREEMPT_COUNT;
23878 EXPORT_PER_CPU_SYMBOL(__preempt_count);
23879
23880+#ifdef CONFIG_CC_STACKPROTECTOR
23881+DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);
23882+#endif
23883+
23884+#endif /* CONFIG_X86_64 */
23885+
23886 /*
23887 * On x86_32, vm86 modifies tss.sp0, so sp0 isn't a reliable way to find
23888 * the top of the kernel stack. Use an extra percpu variable to track the
23889 * top of the kernel stack directly.
23890 */
23891 DEFINE_PER_CPU(unsigned long, cpu_current_top_of_stack) =
23892- (unsigned long)&init_thread_union + THREAD_SIZE;
23893+ (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
23894 EXPORT_PER_CPU_SYMBOL(cpu_current_top_of_stack);
23895
23896-#ifdef CONFIG_CC_STACKPROTECTOR
23897-DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);
23898-#endif
23899-
23900-#endif /* CONFIG_X86_64 */
23901-
23902 /*
23903 * Clear all 6 debug registers:
23904 */
23905@@ -1343,7 +1408,7 @@ void cpu_init(void)
23906 */
23907 load_ucode_ap();
23908
23909- t = &per_cpu(cpu_tss, cpu);
23910+ t = cpu_tss + cpu;
23911 oist = &per_cpu(orig_ist, cpu);
23912
23913 #ifdef CONFIG_NUMA
23914@@ -1375,7 +1440,6 @@ void cpu_init(void)
23915 wrmsrl(MSR_KERNEL_GS_BASE, 0);
23916 barrier();
23917
23918- x86_configure_nx();
23919 x2apic_setup();
23920
23921 /*
23922@@ -1427,7 +1491,7 @@ void cpu_init(void)
23923 {
23924 int cpu = smp_processor_id();
23925 struct task_struct *curr = current;
23926- struct tss_struct *t = &per_cpu(cpu_tss, cpu);
23927+ struct tss_struct *t = cpu_tss + cpu;
23928 struct thread_struct *thread = &curr->thread;
23929
23930 wait_for_master_cpu(cpu);
23931diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
23932index be4febc..f7af533 100644
23933--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
23934+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
23935@@ -519,25 +519,23 @@ cache_private_attrs_is_visible(struct kobject *kobj,
23936 return 0;
23937 }
23938
23939+static struct attribute *amd_l3_attrs[4];
23940+
23941 static struct attribute_group cache_private_group = {
23942 .is_visible = cache_private_attrs_is_visible,
23943+ .attrs = amd_l3_attrs,
23944 };
23945
23946 static void init_amd_l3_attrs(void)
23947 {
23948 int n = 1;
23949- static struct attribute **amd_l3_attrs;
23950-
23951- if (amd_l3_attrs) /* already initialized */
23952- return;
23953
23954 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
23955 n += 2;
23956 if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
23957 n += 1;
23958
23959- amd_l3_attrs = kcalloc(n, sizeof(*amd_l3_attrs), GFP_KERNEL);
23960- if (!amd_l3_attrs)
23961+ if (n > 1 && amd_l3_attrs[0]) /* already initialized */
23962 return;
23963
23964 n = 0;
23965@@ -547,8 +545,6 @@ static void init_amd_l3_attrs(void)
23966 }
23967 if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
23968 amd_l3_attrs[n++] = &dev_attr_subcaches.attr;
23969-
23970- cache_private_group.attrs = amd_l3_attrs;
23971 }
23972
23973 const struct attribute_group *
23974@@ -559,7 +555,7 @@ cache_get_priv_group(struct cacheinfo *this_leaf)
23975 if (this_leaf->level < 3 || !nb)
23976 return NULL;
23977
23978- if (nb && nb->l3_cache.indices)
23979+ if (nb->l3_cache.indices)
23980 init_amd_l3_attrs();
23981
23982 return &cache_private_group;
23983diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
23984index df919ff..3332bf7 100644
23985--- a/arch/x86/kernel/cpu/mcheck/mce.c
23986+++ b/arch/x86/kernel/cpu/mcheck/mce.c
23987@@ -47,6 +47,7 @@
23988 #include <asm/tlbflush.h>
23989 #include <asm/mce.h>
23990 #include <asm/msr.h>
23991+#include <asm/local.h>
23992
23993 #include "mce-internal.h"
23994
23995@@ -259,7 +260,7 @@ static void print_mce(struct mce *m)
23996 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
23997 m->cs, m->ip);
23998
23999- if (m->cs == __KERNEL_CS)
24000+ if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
24001 print_symbol("{%s}", m->ip);
24002 pr_cont("\n");
24003 }
24004@@ -292,10 +293,10 @@ static void print_mce(struct mce *m)
24005
24006 #define PANIC_TIMEOUT 5 /* 5 seconds */
24007
24008-static atomic_t mce_panicked;
24009+static atomic_unchecked_t mce_panicked;
24010
24011 static int fake_panic;
24012-static atomic_t mce_fake_panicked;
24013+static atomic_unchecked_t mce_fake_panicked;
24014
24015 /* Panic in progress. Enable interrupts and wait for final IPI */
24016 static void wait_for_panic(void)
24017@@ -319,7 +320,7 @@ static void mce_panic(const char *msg, struct mce *final, char *exp)
24018 /*
24019 * Make sure only one CPU runs in machine check panic
24020 */
24021- if (atomic_inc_return(&mce_panicked) > 1)
24022+ if (atomic_inc_return_unchecked(&mce_panicked) > 1)
24023 wait_for_panic();
24024 barrier();
24025
24026@@ -327,7 +328,7 @@ static void mce_panic(const char *msg, struct mce *final, char *exp)
24027 console_verbose();
24028 } else {
24029 /* Don't log too much for fake panic */
24030- if (atomic_inc_return(&mce_fake_panicked) > 1)
24031+ if (atomic_inc_return_unchecked(&mce_fake_panicked) > 1)
24032 return;
24033 }
24034 /* First print corrected ones that are still unlogged */
24035@@ -366,7 +367,7 @@ static void mce_panic(const char *msg, struct mce *final, char *exp)
24036 if (!fake_panic) {
24037 if (panic_timeout == 0)
24038 panic_timeout = mca_cfg.panic_timeout;
24039- panic(msg);
24040+ panic("%s", msg);
24041 } else
24042 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
24043 }
24044@@ -752,7 +753,7 @@ static int mce_timed_out(u64 *t, const char *msg)
24045 * might have been modified by someone else.
24046 */
24047 rmb();
24048- if (atomic_read(&mce_panicked))
24049+ if (atomic_read_unchecked(&mce_panicked))
24050 wait_for_panic();
24051 if (!mca_cfg.monarch_timeout)
24052 goto out;
24053@@ -1708,7 +1709,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
24054 }
24055
24056 /* Call the installed machine check handler for this CPU setup. */
24057-void (*machine_check_vector)(struct pt_regs *, long error_code) =
24058+void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
24059 unexpected_machine_check;
24060
24061 /*
24062@@ -1731,7 +1732,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
24063 return;
24064 }
24065
24066+ pax_open_kernel();
24067 machine_check_vector = do_machine_check;
24068+ pax_close_kernel();
24069
24070 __mcheck_cpu_init_generic();
24071 __mcheck_cpu_init_vendor(c);
24072@@ -1745,7 +1748,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
24073 */
24074
24075 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
24076-static int mce_chrdev_open_count; /* #times opened */
24077+static local_t mce_chrdev_open_count; /* #times opened */
24078 static int mce_chrdev_open_exclu; /* already open exclusive? */
24079
24080 static int mce_chrdev_open(struct inode *inode, struct file *file)
24081@@ -1753,7 +1756,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
24082 spin_lock(&mce_chrdev_state_lock);
24083
24084 if (mce_chrdev_open_exclu ||
24085- (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
24086+ (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
24087 spin_unlock(&mce_chrdev_state_lock);
24088
24089 return -EBUSY;
24090@@ -1761,7 +1764,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
24091
24092 if (file->f_flags & O_EXCL)
24093 mce_chrdev_open_exclu = 1;
24094- mce_chrdev_open_count++;
24095+ local_inc(&mce_chrdev_open_count);
24096
24097 spin_unlock(&mce_chrdev_state_lock);
24098
24099@@ -1772,7 +1775,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
24100 {
24101 spin_lock(&mce_chrdev_state_lock);
24102
24103- mce_chrdev_open_count--;
24104+ local_dec(&mce_chrdev_open_count);
24105 mce_chrdev_open_exclu = 0;
24106
24107 spin_unlock(&mce_chrdev_state_lock);
24108@@ -2448,7 +2451,7 @@ static __init void mce_init_banks(void)
24109
24110 for (i = 0; i < mca_cfg.banks; i++) {
24111 struct mce_bank *b = &mce_banks[i];
24112- struct device_attribute *a = &b->attr;
24113+ device_attribute_no_const *a = &b->attr;
24114
24115 sysfs_attr_init(&a->attr);
24116 a->attr.name = b->attrname;
24117@@ -2555,7 +2558,7 @@ struct dentry *mce_get_debugfs_dir(void)
24118 static void mce_reset(void)
24119 {
24120 cpu_missing = 0;
24121- atomic_set(&mce_fake_panicked, 0);
24122+ atomic_set_unchecked(&mce_fake_panicked, 0);
24123 atomic_set(&mce_executing, 0);
24124 atomic_set(&mce_callin, 0);
24125 atomic_set(&global_nwo, 0);
24126diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
24127index 737b0ad..09ec66e 100644
24128--- a/arch/x86/kernel/cpu/mcheck/p5.c
24129+++ b/arch/x86/kernel/cpu/mcheck/p5.c
24130@@ -12,6 +12,7 @@
24131 #include <asm/tlbflush.h>
24132 #include <asm/mce.h>
24133 #include <asm/msr.h>
24134+#include <asm/pgtable.h>
24135
24136 /* By default disabled */
24137 int mce_p5_enabled __read_mostly;
24138@@ -55,7 +56,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
24139 if (!cpu_has(c, X86_FEATURE_MCE))
24140 return;
24141
24142+ pax_open_kernel();
24143 machine_check_vector = pentium_machine_check;
24144+ pax_close_kernel();
24145 /* Make sure the vector pointer is visible before we enable MCEs: */
24146 wmb();
24147
24148diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
24149index 44f1382..315b292 100644
24150--- a/arch/x86/kernel/cpu/mcheck/winchip.c
24151+++ b/arch/x86/kernel/cpu/mcheck/winchip.c
24152@@ -11,6 +11,7 @@
24153 #include <asm/tlbflush.h>
24154 #include <asm/mce.h>
24155 #include <asm/msr.h>
24156+#include <asm/pgtable.h>
24157
24158 /* Machine check handler for WinChip C6: */
24159 static void winchip_machine_check(struct pt_regs *regs, long error_code)
24160@@ -28,7 +29,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
24161 {
24162 u32 lo, hi;
24163
24164+ pax_open_kernel();
24165 machine_check_vector = winchip_machine_check;
24166+ pax_close_kernel();
24167 /* Make sure the vector pointer is visible before we enable MCEs: */
24168 wmb();
24169
24170diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
24171index 6236a54..532026d 100644
24172--- a/arch/x86/kernel/cpu/microcode/core.c
24173+++ b/arch/x86/kernel/cpu/microcode/core.c
24174@@ -460,7 +460,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24175 return NOTIFY_OK;
24176 }
24177
24178-static struct notifier_block __refdata mc_cpu_notifier = {
24179+static struct notifier_block mc_cpu_notifier = {
24180 .notifier_call = mc_cpu_callback,
24181 };
24182
24183diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
24184index 969dc17..a9c3fdd 100644
24185--- a/arch/x86/kernel/cpu/microcode/intel.c
24186+++ b/arch/x86/kernel/cpu/microcode/intel.c
24187@@ -237,13 +237,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24188
24189 static int get_ucode_user(void *to, const void *from, size_t n)
24190 {
24191- return copy_from_user(to, from, n);
24192+ return copy_from_user(to, (const void __force_user *)from, n);
24193 }
24194
24195 static enum ucode_state
24196 request_microcode_user(int cpu, const void __user *buf, size_t size)
24197 {
24198- return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24199+ return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24200 }
24201
24202 static void microcode_fini_cpu(int cpu)
24203diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
24204index e7ed0d8..57a2ab9 100644
24205--- a/arch/x86/kernel/cpu/mtrr/main.c
24206+++ b/arch/x86/kernel/cpu/mtrr/main.c
24207@@ -72,7 +72,7 @@ static DEFINE_MUTEX(mtrr_mutex);
24208 u64 size_or_mask, size_and_mask;
24209 static bool mtrr_aps_delayed_init;
24210
24211-static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
24212+static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
24213
24214 const struct mtrr_ops *mtrr_if;
24215
24216diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
24217index 951884d..4796b75 100644
24218--- a/arch/x86/kernel/cpu/mtrr/mtrr.h
24219+++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
24220@@ -25,7 +25,7 @@ struct mtrr_ops {
24221 int (*validate_add_page)(unsigned long base, unsigned long size,
24222 unsigned int type);
24223 int (*have_wrcomb)(void);
24224-};
24225+} __do_const;
24226
24227 extern int generic_get_free_region(unsigned long base, unsigned long size,
24228 int replace_reg);
24229diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
24230index 9469dfa..2b026bc 100644
24231--- a/arch/x86/kernel/cpu/perf_event.c
24232+++ b/arch/x86/kernel/cpu/perf_event.c
24233@@ -1518,7 +1518,7 @@ static void __init pmu_check_apic(void)
24234
24235 }
24236
24237-static struct attribute_group x86_pmu_format_group = {
24238+static attribute_group_no_const x86_pmu_format_group = {
24239 .name = "format",
24240 .attrs = NULL,
24241 };
24242@@ -1617,7 +1617,7 @@ static struct attribute *events_attr[] = {
24243 NULL,
24244 };
24245
24246-static struct attribute_group x86_pmu_events_group = {
24247+static attribute_group_no_const x86_pmu_events_group = {
24248 .name = "events",
24249 .attrs = events_attr,
24250 };
24251@@ -2176,7 +2176,7 @@ valid_user_frame(const void __user *fp, unsigned long size)
24252 static unsigned long get_segment_base(unsigned int segment)
24253 {
24254 struct desc_struct *desc;
24255- int idx = segment >> 3;
24256+ unsigned int idx = segment >> 3;
24257
24258 if ((segment & SEGMENT_TI_MASK) == SEGMENT_LDT) {
24259 struct ldt_struct *ldt;
24260@@ -2194,7 +2194,7 @@ static unsigned long get_segment_base(unsigned int segment)
24261 if (idx > GDT_ENTRIES)
24262 return 0;
24263
24264- desc = raw_cpu_ptr(gdt_page.gdt) + idx;
24265+ desc = get_cpu_gdt_table(smp_processor_id()) + idx;
24266 }
24267
24268 return get_desc_base(desc);
24269@@ -2284,7 +2284,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
24270 break;
24271
24272 perf_callchain_store(entry, frame.return_address);
24273- fp = frame.next_frame;
24274+ fp = (const void __force_user *)frame.next_frame;
24275 }
24276 }
24277
24278diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
24279index 97242a9..cf9c30e 100644
24280--- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
24281+++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
24282@@ -402,7 +402,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
24283 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
24284 {
24285 struct attribute **attrs;
24286- struct attribute_group *attr_group;
24287+ attribute_group_no_const *attr_group;
24288 int i = 0, j;
24289
24290 while (amd_iommu_v2_event_descs[i].attr.attr.name)
24291diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
24292index 1b09c42..521004d 100644
24293--- a/arch/x86/kernel/cpu/perf_event_intel.c
24294+++ b/arch/x86/kernel/cpu/perf_event_intel.c
24295@@ -3019,10 +3019,10 @@ __init int intel_pmu_init(void)
24296 x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
24297
24298 if (boot_cpu_has(X86_FEATURE_PDCM)) {
24299- u64 capabilities;
24300+ u64 capabilities = x86_pmu.intel_cap.capabilities;
24301
24302- rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
24303- x86_pmu.intel_cap.capabilities = capabilities;
24304+ if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
24305+ x86_pmu.intel_cap.capabilities = capabilities;
24306 }
24307
24308 intel_ds_init();
24309diff --git a/arch/x86/kernel/cpu/perf_event_intel_bts.c b/arch/x86/kernel/cpu/perf_event_intel_bts.c
24310index 43dd672..78c0562 100644
24311--- a/arch/x86/kernel/cpu/perf_event_intel_bts.c
24312+++ b/arch/x86/kernel/cpu/perf_event_intel_bts.c
24313@@ -252,7 +252,7 @@ static void bts_event_start(struct perf_event *event, int flags)
24314 __bts_event_start(event);
24315
24316 /* PMI handler: this counter is running and likely generating PMIs */
24317- ACCESS_ONCE(bts->started) = 1;
24318+ ACCESS_ONCE_RW(bts->started) = 1;
24319 }
24320
24321 static void __bts_event_stop(struct perf_event *event)
24322@@ -266,7 +266,7 @@ static void __bts_event_stop(struct perf_event *event)
24323 if (event->hw.state & PERF_HES_STOPPED)
24324 return;
24325
24326- ACCESS_ONCE(event->hw.state) |= PERF_HES_STOPPED;
24327+ ACCESS_ONCE_RW(event->hw.state) |= PERF_HES_STOPPED;
24328 }
24329
24330 static void bts_event_stop(struct perf_event *event, int flags)
24331@@ -274,7 +274,7 @@ static void bts_event_stop(struct perf_event *event, int flags)
24332 struct bts_ctx *bts = this_cpu_ptr(&bts_ctx);
24333
24334 /* PMI handler: don't restart this counter */
24335- ACCESS_ONCE(bts->started) = 0;
24336+ ACCESS_ONCE_RW(bts->started) = 0;
24337
24338 __bts_event_stop(event);
24339
24340diff --git a/arch/x86/kernel/cpu/perf_event_intel_cqm.c b/arch/x86/kernel/cpu/perf_event_intel_cqm.c
24341index 377e8f8..2982f48 100644
24342--- a/arch/x86/kernel/cpu/perf_event_intel_cqm.c
24343+++ b/arch/x86/kernel/cpu/perf_event_intel_cqm.c
24344@@ -1364,7 +1364,9 @@ static int __init intel_cqm_init(void)
24345 goto out;
24346 }
24347
24348- event_attr_intel_cqm_llc_scale.event_str = str;
24349+ pax_open_kernel();
24350+ *(const char **)&event_attr_intel_cqm_llc_scale.event_str = str;
24351+ pax_close_kernel();
24352
24353 ret = intel_cqm_setup_rmid_cache();
24354 if (ret)
24355diff --git a/arch/x86/kernel/cpu/perf_event_intel_pt.c b/arch/x86/kernel/cpu/perf_event_intel_pt.c
24356index 183de71..bd34d52 100644
24357--- a/arch/x86/kernel/cpu/perf_event_intel_pt.c
24358+++ b/arch/x86/kernel/cpu/perf_event_intel_pt.c
24359@@ -116,16 +116,12 @@ static const struct attribute_group *pt_attr_groups[] = {
24360
24361 static int __init pt_pmu_hw_init(void)
24362 {
24363- struct dev_ext_attribute *de_attrs;
24364- struct attribute **attrs;
24365- size_t size;
24366- int ret;
24367+ static struct dev_ext_attribute de_attrs[ARRAY_SIZE(pt_caps)];
24368+ static struct attribute *attrs[ARRAY_SIZE(pt_caps)];
24369 long i;
24370
24371- attrs = NULL;
24372- ret = -ENODEV;
24373 if (!test_cpu_cap(&boot_cpu_data, X86_FEATURE_INTEL_PT))
24374- goto fail;
24375+ return -ENODEV;
24376
24377 for (i = 0; i < PT_CPUID_LEAVES; i++) {
24378 cpuid_count(20, i,
24379@@ -135,39 +131,25 @@ static int __init pt_pmu_hw_init(void)
24380 &pt_pmu.caps[CR_EDX + i*4]);
24381 }
24382
24383- ret = -ENOMEM;
24384- size = sizeof(struct attribute *) * (ARRAY_SIZE(pt_caps)+1);
24385- attrs = kzalloc(size, GFP_KERNEL);
24386- if (!attrs)
24387- goto fail;
24388-
24389- size = sizeof(struct dev_ext_attribute) * (ARRAY_SIZE(pt_caps)+1);
24390- de_attrs = kzalloc(size, GFP_KERNEL);
24391- if (!de_attrs)
24392- goto fail;
24393-
24394+ pax_open_kernel();
24395 for (i = 0; i < ARRAY_SIZE(pt_caps); i++) {
24396- struct dev_ext_attribute *de_attr = de_attrs + i;
24397+ struct dev_ext_attribute *de_attr = &de_attrs[i];
24398
24399- de_attr->attr.attr.name = pt_caps[i].name;
24400+ *(const char **)&de_attr->attr.attr.name = pt_caps[i].name;
24401
24402 sysfs_attr_init(&de_attr->attr.attr);
24403
24404- de_attr->attr.attr.mode = S_IRUGO;
24405- de_attr->attr.show = pt_cap_show;
24406- de_attr->var = (void *)i;
24407+ *(umode_t *)&de_attr->attr.attr.mode = S_IRUGO;
24408+ *(void **)&de_attr->attr.show = pt_cap_show;
24409+ *(void **)&de_attr->var = (void *)i;
24410
24411 attrs[i] = &de_attr->attr.attr;
24412 }
24413
24414- pt_cap_group.attrs = attrs;
24415+ *(struct attribute ***)&pt_cap_group.attrs = attrs;
24416+ pax_close_kernel();
24417
24418 return 0;
24419-
24420-fail:
24421- kfree(attrs);
24422-
24423- return ret;
24424 }
24425
24426 #define PT_CONFIG_MASK (RTIT_CTL_TSC_EN | RTIT_CTL_DISRETC)
24427@@ -929,7 +911,7 @@ static void pt_event_start(struct perf_event *event, int mode)
24428 return;
24429 }
24430
24431- ACCESS_ONCE(pt->handle_nmi) = 1;
24432+ ACCESS_ONCE_RW(pt->handle_nmi) = 1;
24433 event->hw.state = 0;
24434
24435 pt_config_buffer(buf->cur->table, buf->cur_idx,
24436@@ -946,7 +928,7 @@ static void pt_event_stop(struct perf_event *event, int mode)
24437 * Protect against the PMI racing with disabling wrmsr,
24438 * see comment in intel_pt_interrupt().
24439 */
24440- ACCESS_ONCE(pt->handle_nmi) = 0;
24441+ ACCESS_ONCE_RW(pt->handle_nmi) = 0;
24442 pt_config_start(false);
24443
24444 if (event->hw.state == PERF_HES_STOPPED)
24445diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
24446index 5cbd4e6..ee9388a 100644
24447--- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
24448+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
24449@@ -486,7 +486,7 @@ static struct attribute *rapl_events_hsw_attr[] = {
24450 NULL,
24451 };
24452
24453-static struct attribute_group rapl_pmu_events_group = {
24454+static attribute_group_no_const rapl_pmu_events_group __read_only = {
24455 .name = "events",
24456 .attrs = NULL, /* patched at runtime */
24457 };
24458diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
24459index 21b5e38..84f1f82 100644
24460--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
24461+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
24462@@ -731,7 +731,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
24463 static int __init uncore_type_init(struct intel_uncore_type *type)
24464 {
24465 struct intel_uncore_pmu *pmus;
24466- struct attribute_group *attr_group;
24467+ attribute_group_no_const *attr_group;
24468 struct attribute **attrs;
24469 int i, j;
24470
24471diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
24472index 0f77f0a..d3c6b7d 100644
24473--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
24474+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
24475@@ -115,7 +115,7 @@ struct intel_uncore_box {
24476 struct uncore_event_desc {
24477 struct kobj_attribute attr;
24478 const char *config;
24479-};
24480+} __do_const;
24481
24482 ssize_t uncore_event_show(struct kobject *kobj,
24483 struct kobj_attribute *attr, char *buf);
24484diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
24485index 83741a7..bd3507d 100644
24486--- a/arch/x86/kernel/cpuid.c
24487+++ b/arch/x86/kernel/cpuid.c
24488@@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
24489 return notifier_from_errno(err);
24490 }
24491
24492-static struct notifier_block __refdata cpuid_class_cpu_notifier =
24493+static struct notifier_block cpuid_class_cpu_notifier =
24494 {
24495 .notifier_call = cpuid_class_cpu_callback,
24496 };
24497diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
24498index afa64ad..dce67dd 100644
24499--- a/arch/x86/kernel/crash_dump_64.c
24500+++ b/arch/x86/kernel/crash_dump_64.c
24501@@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
24502 return -ENOMEM;
24503
24504 if (userbuf) {
24505- if (copy_to_user(buf, vaddr + offset, csize)) {
24506+ if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
24507 iounmap(vaddr);
24508 return -EFAULT;
24509 }
24510diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
24511index f6dfd93..892ade4 100644
24512--- a/arch/x86/kernel/doublefault.c
24513+++ b/arch/x86/kernel/doublefault.c
24514@@ -12,7 +12,7 @@
24515
24516 #define DOUBLEFAULT_STACKSIZE (1024)
24517 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
24518-#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
24519+#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
24520
24521 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
24522
24523@@ -22,7 +22,7 @@ static void doublefault_fn(void)
24524 unsigned long gdt, tss;
24525
24526 native_store_gdt(&gdt_desc);
24527- gdt = gdt_desc.address;
24528+ gdt = (unsigned long)gdt_desc.address;
24529
24530 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
24531
24532@@ -59,10 +59,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
24533 /* 0x2 bit is always set */
24534 .flags = X86_EFLAGS_SF | 0x2,
24535 .sp = STACK_START,
24536- .es = __USER_DS,
24537+ .es = __KERNEL_DS,
24538 .cs = __KERNEL_CS,
24539 .ss = __KERNEL_DS,
24540- .ds = __USER_DS,
24541+ .ds = __KERNEL_DS,
24542 .fs = __KERNEL_PERCPU,
24543
24544 .__cr3 = __pa_nodebug(swapper_pg_dir),
24545diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
24546index 9c30acf..8cf2411 100644
24547--- a/arch/x86/kernel/dumpstack.c
24548+++ b/arch/x86/kernel/dumpstack.c
24549@@ -2,6 +2,9 @@
24550 * Copyright (C) 1991, 1992 Linus Torvalds
24551 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
24552 */
24553+#ifdef CONFIG_GRKERNSEC_HIDESYM
24554+#define __INCLUDED_BY_HIDESYM 1
24555+#endif
24556 #include <linux/kallsyms.h>
24557 #include <linux/kprobes.h>
24558 #include <linux/uaccess.h>
24559@@ -35,23 +38,21 @@ static void printk_stack_address(unsigned long address, int reliable,
24560
24561 void printk_address(unsigned long address)
24562 {
24563- pr_cont(" [<%p>] %pS\n", (void *)address, (void *)address);
24564+ pr_cont(" [<%p>] %pA\n", (void *)address, (void *)address);
24565 }
24566
24567 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
24568 static void
24569 print_ftrace_graph_addr(unsigned long addr, void *data,
24570 const struct stacktrace_ops *ops,
24571- struct thread_info *tinfo, int *graph)
24572+ struct task_struct *task, int *graph)
24573 {
24574- struct task_struct *task;
24575 unsigned long ret_addr;
24576 int index;
24577
24578 if (addr != (unsigned long)return_to_handler)
24579 return;
24580
24581- task = tinfo->task;
24582 index = task->curr_ret_stack;
24583
24584 if (!task->ret_stack || index < *graph)
24585@@ -68,7 +69,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
24586 static inline void
24587 print_ftrace_graph_addr(unsigned long addr, void *data,
24588 const struct stacktrace_ops *ops,
24589- struct thread_info *tinfo, int *graph)
24590+ struct task_struct *task, int *graph)
24591 { }
24592 #endif
24593
24594@@ -79,10 +80,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
24595 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
24596 */
24597
24598-static inline int valid_stack_ptr(struct thread_info *tinfo,
24599- void *p, unsigned int size, void *end)
24600+static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
24601 {
24602- void *t = tinfo;
24603 if (end) {
24604 if (p < end && p >= (end-THREAD_SIZE))
24605 return 1;
24606@@ -93,14 +92,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
24607 }
24608
24609 unsigned long
24610-print_context_stack(struct thread_info *tinfo,
24611+print_context_stack(struct task_struct *task, void *stack_start,
24612 unsigned long *stack, unsigned long bp,
24613 const struct stacktrace_ops *ops, void *data,
24614 unsigned long *end, int *graph)
24615 {
24616 struct stack_frame *frame = (struct stack_frame *)bp;
24617
24618- while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
24619+ while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
24620 unsigned long addr;
24621
24622 addr = *stack;
24623@@ -112,7 +111,7 @@ print_context_stack(struct thread_info *tinfo,
24624 } else {
24625 ops->address(data, addr, 0);
24626 }
24627- print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
24628+ print_ftrace_graph_addr(addr, data, ops, task, graph);
24629 }
24630 stack++;
24631 }
24632@@ -121,7 +120,7 @@ print_context_stack(struct thread_info *tinfo,
24633 EXPORT_SYMBOL_GPL(print_context_stack);
24634
24635 unsigned long
24636-print_context_stack_bp(struct thread_info *tinfo,
24637+print_context_stack_bp(struct task_struct *task, void *stack_start,
24638 unsigned long *stack, unsigned long bp,
24639 const struct stacktrace_ops *ops, void *data,
24640 unsigned long *end, int *graph)
24641@@ -129,7 +128,7 @@ print_context_stack_bp(struct thread_info *tinfo,
24642 struct stack_frame *frame = (struct stack_frame *)bp;
24643 unsigned long *ret_addr = &frame->return_address;
24644
24645- while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
24646+ while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
24647 unsigned long addr = *ret_addr;
24648
24649 if (!__kernel_text_address(addr))
24650@@ -138,7 +137,7 @@ print_context_stack_bp(struct thread_info *tinfo,
24651 ops->address(data, addr, 1);
24652 frame = frame->next_frame;
24653 ret_addr = &frame->return_address;
24654- print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
24655+ print_ftrace_graph_addr(addr, data, ops, task, graph);
24656 }
24657
24658 return (unsigned long)frame;
24659@@ -226,6 +225,8 @@ unsigned long oops_begin(void)
24660 EXPORT_SYMBOL_GPL(oops_begin);
24661 NOKPROBE_SYMBOL(oops_begin);
24662
24663+extern void gr_handle_kernel_exploit(void);
24664+
24665 void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
24666 {
24667 if (regs && kexec_should_crash(current))
24668@@ -247,7 +248,10 @@ void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
24669 panic("Fatal exception in interrupt");
24670 if (panic_on_oops)
24671 panic("Fatal exception");
24672- do_exit(signr);
24673+
24674+ gr_handle_kernel_exploit();
24675+
24676+ do_group_exit(signr);
24677 }
24678 NOKPROBE_SYMBOL(oops_end);
24679
24680diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
24681index 464ffd6..01f2cda 100644
24682--- a/arch/x86/kernel/dumpstack_32.c
24683+++ b/arch/x86/kernel/dumpstack_32.c
24684@@ -61,15 +61,14 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24685 bp = stack_frame(task, regs);
24686
24687 for (;;) {
24688- struct thread_info *context;
24689+ void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
24690 void *end_stack;
24691
24692 end_stack = is_hardirq_stack(stack, cpu);
24693 if (!end_stack)
24694 end_stack = is_softirq_stack(stack, cpu);
24695
24696- context = task_thread_info(task);
24697- bp = ops->walk_stack(context, stack, bp, ops, data,
24698+ bp = ops->walk_stack(task, stack_start, stack, bp, ops, data,
24699 end_stack, &graph);
24700
24701 /* Stop if not on irq stack */
24702@@ -137,16 +136,17 @@ void show_regs(struct pt_regs *regs)
24703 unsigned int code_len = code_bytes;
24704 unsigned char c;
24705 u8 *ip;
24706+ unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
24707
24708 pr_emerg("Stack:\n");
24709 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
24710
24711 pr_emerg("Code:");
24712
24713- ip = (u8 *)regs->ip - code_prologue;
24714+ ip = (u8 *)regs->ip - code_prologue + cs_base;
24715 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
24716 /* try starting at IP */
24717- ip = (u8 *)regs->ip;
24718+ ip = (u8 *)regs->ip + cs_base;
24719 code_len = code_len - code_prologue + 1;
24720 }
24721 for (i = 0; i < code_len; i++, ip++) {
24722@@ -155,7 +155,7 @@ void show_regs(struct pt_regs *regs)
24723 pr_cont(" Bad EIP value.");
24724 break;
24725 }
24726- if (ip == (u8 *)regs->ip)
24727+ if (ip == (u8 *)regs->ip + cs_base)
24728 pr_cont(" <%02x>", c);
24729 else
24730 pr_cont(" %02x", c);
24731@@ -168,6 +168,7 @@ int is_valid_bugaddr(unsigned long ip)
24732 {
24733 unsigned short ud2;
24734
24735+ ip = ktla_ktva(ip);
24736 if (ip < PAGE_OFFSET)
24737 return 0;
24738 if (probe_kernel_address((unsigned short *)ip, ud2))
24739@@ -175,3 +176,15 @@ int is_valid_bugaddr(unsigned long ip)
24740
24741 return ud2 == 0x0b0f;
24742 }
24743+
24744+#if defined(CONFIG_PAX_MEMORY_STACKLEAK) || defined(CONFIG_PAX_USERCOPY)
24745+void __used pax_check_alloca(unsigned long size)
24746+{
24747+ unsigned long sp = (unsigned long)&sp, stack_left;
24748+
24749+ /* all kernel stacks are of the same size */
24750+ stack_left = sp & (THREAD_SIZE - 1);
24751+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
24752+}
24753+EXPORT_SYMBOL(pax_check_alloca);
24754+#endif
24755diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
24756index 5f1c626..1cba97e 100644
24757--- a/arch/x86/kernel/dumpstack_64.c
24758+++ b/arch/x86/kernel/dumpstack_64.c
24759@@ -153,12 +153,12 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24760 const struct stacktrace_ops *ops, void *data)
24761 {
24762 const unsigned cpu = get_cpu();
24763- struct thread_info *tinfo;
24764 unsigned long *irq_stack = (unsigned long *)per_cpu(irq_stack_ptr, cpu);
24765 unsigned long dummy;
24766 unsigned used = 0;
24767 int graph = 0;
24768 int done = 0;
24769+ void *stack_start;
24770
24771 if (!task)
24772 task = current;
24773@@ -179,7 +179,6 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24774 * current stack address. If the stacks consist of nested
24775 * exceptions
24776 */
24777- tinfo = task_thread_info(task);
24778 while (!done) {
24779 unsigned long *stack_end;
24780 enum stack_type stype;
24781@@ -202,7 +201,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24782 if (ops->stack(data, id) < 0)
24783 break;
24784
24785- bp = ops->walk_stack(tinfo, stack, bp, ops,
24786+ bp = ops->walk_stack(task, stack_end - EXCEPTION_STKSZ, stack, bp, ops,
24787 data, stack_end, &graph);
24788 ops->stack(data, "<EOE>");
24789 /*
24790@@ -210,6 +209,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24791 * second-to-last pointer (index -2 to end) in the
24792 * exception stack:
24793 */
24794+ if ((u16)stack_end[-1] != __KERNEL_DS)
24795+ goto out;
24796 stack = (unsigned long *) stack_end[-2];
24797 done = 0;
24798 break;
24799@@ -218,7 +219,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24800
24801 if (ops->stack(data, "IRQ") < 0)
24802 break;
24803- bp = ops->walk_stack(tinfo, stack, bp,
24804+ bp = ops->walk_stack(task, irq_stack, stack, bp,
24805 ops, data, stack_end, &graph);
24806 /*
24807 * We link to the next stack (which would be
24808@@ -240,7 +241,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24809 /*
24810 * This handles the process stack:
24811 */
24812- bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
24813+ stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
24814+ bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
24815+out:
24816 put_cpu();
24817 }
24818 EXPORT_SYMBOL(dump_trace);
24819@@ -347,8 +350,55 @@ int is_valid_bugaddr(unsigned long ip)
24820 {
24821 unsigned short ud2;
24822
24823- if (__copy_from_user(&ud2, (const void __user *) ip, sizeof(ud2)))
24824+ if (probe_kernel_address((unsigned short *)ip, ud2))
24825 return 0;
24826
24827 return ud2 == 0x0b0f;
24828 }
24829+
24830+#if defined(CONFIG_PAX_MEMORY_STACKLEAK) || defined(CONFIG_PAX_USERCOPY)
24831+void __used pax_check_alloca(unsigned long size)
24832+{
24833+ unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
24834+ unsigned cpu, used;
24835+ char *id;
24836+
24837+ /* check the process stack first */
24838+ stack_start = (unsigned long)task_stack_page(current);
24839+ stack_end = stack_start + THREAD_SIZE;
24840+ if (likely(stack_start <= sp && sp < stack_end)) {
24841+ unsigned long stack_left = sp & (THREAD_SIZE - 1);
24842+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
24843+ return;
24844+ }
24845+
24846+ cpu = get_cpu();
24847+
24848+ /* check the irq stacks */
24849+ stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
24850+ stack_start = stack_end - IRQ_STACK_SIZE;
24851+ if (stack_start <= sp && sp < stack_end) {
24852+ unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
24853+ put_cpu();
24854+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
24855+ return;
24856+ }
24857+
24858+ /* check the exception stacks */
24859+ used = 0;
24860+ stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
24861+ stack_start = stack_end - EXCEPTION_STKSZ;
24862+ if (stack_end && stack_start <= sp && sp < stack_end) {
24863+ unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
24864+ put_cpu();
24865+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
24866+ return;
24867+ }
24868+
24869+ put_cpu();
24870+
24871+ /* unknown stack */
24872+ BUG();
24873+}
24874+EXPORT_SYMBOL(pax_check_alloca);
24875+#endif
24876diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
24877index a102564..d1f0b73 100644
24878--- a/arch/x86/kernel/e820.c
24879+++ b/arch/x86/kernel/e820.c
24880@@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
24881
24882 static void early_panic(char *msg)
24883 {
24884- early_printk(msg);
24885- panic(msg);
24886+ early_printk("%s", msg);
24887+ panic("%s", msg);
24888 }
24889
24890 static int userdef __initdata;
24891diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
24892index eec40f5..4fee808 100644
24893--- a/arch/x86/kernel/early_printk.c
24894+++ b/arch/x86/kernel/early_printk.c
24895@@ -7,6 +7,7 @@
24896 #include <linux/pci_regs.h>
24897 #include <linux/pci_ids.h>
24898 #include <linux/errno.h>
24899+#include <linux/sched.h>
24900 #include <asm/io.h>
24901 #include <asm/processor.h>
24902 #include <asm/fcntl.h>
24903diff --git a/arch/x86/kernel/espfix_64.c b/arch/x86/kernel/espfix_64.c
24904index ce95676..af5c012 100644
24905--- a/arch/x86/kernel/espfix_64.c
24906+++ b/arch/x86/kernel/espfix_64.c
24907@@ -41,6 +41,7 @@
24908 #include <asm/pgalloc.h>
24909 #include <asm/setup.h>
24910 #include <asm/espfix.h>
24911+#include <asm/bug.h>
24912
24913 /*
24914 * Note: we only need 6*8 = 48 bytes for the espfix stack, but round
24915@@ -70,8 +71,10 @@ static DEFINE_MUTEX(espfix_init_mutex);
24916 #define ESPFIX_MAX_PAGES DIV_ROUND_UP(CONFIG_NR_CPUS, ESPFIX_STACKS_PER_PAGE)
24917 static void *espfix_pages[ESPFIX_MAX_PAGES];
24918
24919-static __page_aligned_bss pud_t espfix_pud_page[PTRS_PER_PUD]
24920- __aligned(PAGE_SIZE);
24921+static __page_aligned_rodata pud_t espfix_pud_page[PTRS_PER_PUD];
24922+static __page_aligned_rodata pmd_t espfix_pmd_page[PTRS_PER_PMD];
24923+static __page_aligned_rodata pte_t espfix_pte_page[PTRS_PER_PTE];
24924+static __page_aligned_rodata char espfix_stack_page[ESPFIX_MAX_PAGES][PAGE_SIZE];
24925
24926 static unsigned int page_random, slot_random;
24927
24928@@ -122,10 +125,19 @@ static void init_espfix_random(void)
24929 void __init init_espfix_bsp(void)
24930 {
24931 pgd_t *pgd_p;
24932+ pud_t *pud_p;
24933+ unsigned long index = pgd_index(ESPFIX_BASE_ADDR);
24934
24935 /* Install the espfix pud into the kernel page directory */
24936- pgd_p = &init_level4_pgt[pgd_index(ESPFIX_BASE_ADDR)];
24937- pgd_populate(&init_mm, pgd_p, (pud_t *)espfix_pud_page);
24938+ pgd_p = &init_level4_pgt[index];
24939+ pud_p = espfix_pud_page;
24940+ paravirt_alloc_pud(&init_mm, __pa(pud_p) >> PAGE_SHIFT);
24941+ set_pgd(pgd_p, __pgd(PGTABLE_PROT | __pa(pud_p)));
24942+
24943+#ifdef CONFIG_PAX_PER_CPU_PGD
24944+ clone_pgd_range(get_cpu_pgd(0, kernel) + index, swapper_pg_dir + index, 1);
24945+ clone_pgd_range(get_cpu_pgd(0, user) + index, swapper_pg_dir + index, 1);
24946+#endif
24947
24948 /* Randomize the locations */
24949 init_espfix_random();
24950@@ -170,35 +182,39 @@ void init_espfix_ap(int cpu)
24951 pud_p = &espfix_pud_page[pud_index(addr)];
24952 pud = *pud_p;
24953 if (!pud_present(pud)) {
24954- struct page *page = alloc_pages_node(node, PGALLOC_GFP, 0);
24955-
24956- pmd_p = (pmd_t *)page_address(page);
24957+ if (cpu)
24958+ pmd_p = page_address(alloc_pages_node(node, PGALLOC_GFP, 0));
24959+ else
24960+ pmd_p = espfix_pmd_page;
24961 pud = __pud(__pa(pmd_p) | (PGTABLE_PROT & ptemask));
24962 paravirt_alloc_pmd(&init_mm, __pa(pmd_p) >> PAGE_SHIFT);
24963 for (n = 0; n < ESPFIX_PUD_CLONES; n++)
24964 set_pud(&pud_p[n], pud);
24965- }
24966+ } else
24967+ BUG_ON(!cpu);
24968
24969 pmd_p = pmd_offset(&pud, addr);
24970 pmd = *pmd_p;
24971 if (!pmd_present(pmd)) {
24972- struct page *page = alloc_pages_node(node, PGALLOC_GFP, 0);
24973-
24974- pte_p = (pte_t *)page_address(page);
24975+ if (cpu)
24976+ pte_p = page_address(alloc_pages_node(node, PGALLOC_GFP, 0));
24977+ else
24978+ pte_p = espfix_pte_page;
24979 pmd = __pmd(__pa(pte_p) | (PGTABLE_PROT & ptemask));
24980 paravirt_alloc_pte(&init_mm, __pa(pte_p) >> PAGE_SHIFT);
24981 for (n = 0; n < ESPFIX_PMD_CLONES; n++)
24982 set_pmd(&pmd_p[n], pmd);
24983- }
24984+ } else
24985+ BUG_ON(!cpu);
24986
24987 pte_p = pte_offset_kernel(&pmd, addr);
24988- stack_page = page_address(alloc_pages_node(node, GFP_KERNEL, 0));
24989+ stack_page = espfix_stack_page[page];
24990 pte = __pte(__pa(stack_page) | (__PAGE_KERNEL_RO & ptemask));
24991 for (n = 0; n < ESPFIX_PTE_CLONES; n++)
24992 set_pte(&pte_p[n*PTE_STRIDE], pte);
24993
24994 /* Job is done for this CPU and any CPU which shares this page */
24995- ACCESS_ONCE(espfix_pages[page]) = stack_page;
24996+ ACCESS_ONCE_RW(espfix_pages[page]) = stack_page;
24997
24998 unlock_done:
24999 mutex_unlock(&espfix_init_mutex);
25000diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
25001index d25097c..84b0d51 100644
25002--- a/arch/x86/kernel/fpu/core.c
25003+++ b/arch/x86/kernel/fpu/core.c
25004@@ -127,7 +127,7 @@ void __kernel_fpu_end(void)
25005 struct fpu *fpu = &current->thread.fpu;
25006
25007 if (fpu->fpregs_active)
25008- copy_kernel_to_fpregs(&fpu->state);
25009+ copy_kernel_to_fpregs(fpu->state);
25010 else
25011 __fpregs_deactivate_hw();
25012
25013@@ -238,7 +238,7 @@ static void fpu_copy(struct fpu *dst_fpu, struct fpu *src_fpu)
25014 * leak into the child task:
25015 */
25016 if (use_eager_fpu())
25017- memset(&dst_fpu->state.xsave, 0, xstate_size);
25018+ memset(&dst_fpu->state->xsave, 0, xstate_size);
25019
25020 /*
25021 * Save current FPU registers directly into the child
25022@@ -285,7 +285,7 @@ void fpu__activate_curr(struct fpu *fpu)
25023 WARN_ON_FPU(fpu != &current->thread.fpu);
25024
25025 if (!fpu->fpstate_active) {
25026- fpstate_init(&fpu->state);
25027+ fpstate_init(fpu->state);
25028
25029 /* Safe to do for the current task: */
25030 fpu->fpstate_active = 1;
25031@@ -311,7 +311,7 @@ void fpu__activate_fpstate_read(struct fpu *fpu)
25032 fpu__save(fpu);
25033 } else {
25034 if (!fpu->fpstate_active) {
25035- fpstate_init(&fpu->state);
25036+ fpstate_init(fpu->state);
25037
25038 /* Safe to do for current and for stopped child tasks: */
25039 fpu->fpstate_active = 1;
25040@@ -344,7 +344,7 @@ void fpu__activate_fpstate_write(struct fpu *fpu)
25041 /* Invalidate any lazy state: */
25042 fpu->last_cpu = -1;
25043 } else {
25044- fpstate_init(&fpu->state);
25045+ fpstate_init(fpu->state);
25046
25047 /* Safe to do for stopped child tasks: */
25048 fpu->fpstate_active = 1;
25049@@ -368,7 +368,7 @@ void fpu__restore(struct fpu *fpu)
25050 /* Avoid __kernel_fpu_begin() right after fpregs_activate() */
25051 kernel_fpu_disable();
25052 fpregs_activate(fpu);
25053- copy_kernel_to_fpregs(&fpu->state);
25054+ copy_kernel_to_fpregs(fpu->state);
25055 fpu->counter++;
25056 kernel_fpu_enable();
25057 }
25058@@ -442,25 +442,25 @@ void fpu__clear(struct fpu *fpu)
25059 static inline unsigned short get_fpu_cwd(struct fpu *fpu)
25060 {
25061 if (cpu_has_fxsr) {
25062- return fpu->state.fxsave.cwd;
25063+ return fpu->state->fxsave.cwd;
25064 } else {
25065- return (unsigned short)fpu->state.fsave.cwd;
25066+ return (unsigned short)fpu->state->fsave.cwd;
25067 }
25068 }
25069
25070 static inline unsigned short get_fpu_swd(struct fpu *fpu)
25071 {
25072 if (cpu_has_fxsr) {
25073- return fpu->state.fxsave.swd;
25074+ return fpu->state->fxsave.swd;
25075 } else {
25076- return (unsigned short)fpu->state.fsave.swd;
25077+ return (unsigned short)fpu->state->fsave.swd;
25078 }
25079 }
25080
25081 static inline unsigned short get_fpu_mxcsr(struct fpu *fpu)
25082 {
25083 if (cpu_has_xmm) {
25084- return fpu->state.fxsave.mxcsr;
25085+ return fpu->state->fxsave.mxcsr;
25086 } else {
25087 return MXCSR_DEFAULT;
25088 }
25089diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
25090index d14e9ac..fab0813 100644
25091--- a/arch/x86/kernel/fpu/init.c
25092+++ b/arch/x86/kernel/fpu/init.c
25093@@ -42,7 +42,7 @@ static void fpu__init_cpu_generic(void)
25094 /* Flush out any pending x87 state: */
25095 #ifdef CONFIG_MATH_EMULATION
25096 if (!cpu_has_fpu)
25097- fpstate_init_soft(&current->thread.fpu.state.soft);
25098+ fpstate_init_soft(&current->thread.fpu.state->soft);
25099 else
25100 #endif
25101 asm volatile ("fninit");
25102@@ -147,37 +147,21 @@ EXPORT_SYMBOL_GPL(xstate_size);
25103 #define CHECK_MEMBER_AT_END_OF(TYPE, MEMBER) \
25104 BUILD_BUG_ON(sizeof(TYPE) != offsetofend(TYPE, MEMBER))
25105
25106+union fpregs_state init_fpregs_state;
25107+
25108 /*
25109 * We append the 'struct fpu' to the task_struct:
25110 */
25111 static void __init fpu__init_task_struct_size(void)
25112 {
25113- int task_size = sizeof(struct task_struct);
25114-
25115- /*
25116- * Subtract off the static size of the register state.
25117- * It potentially has a bunch of padding.
25118- */
25119- task_size -= sizeof(((struct task_struct *)0)->thread.fpu.state);
25120-
25121- /*
25122- * Add back the dynamically-calculated register state
25123- * size.
25124- */
25125- task_size += xstate_size;
25126-
25127 /*
25128 * We dynamically size 'struct fpu', so we require that
25129- * it be at the end of 'thread_struct' and that
25130- * 'thread_struct' be at the end of 'task_struct'. If
25131+ * it be at the end of 'thread_struct'. If
25132 * you hit a compile error here, check the structure to
25133 * see if something got added to the end.
25134 */
25135 CHECK_MEMBER_AT_END_OF(struct fpu, state);
25136 CHECK_MEMBER_AT_END_OF(struct thread_struct, fpu);
25137- CHECK_MEMBER_AT_END_OF(struct task_struct, thread);
25138-
25139- arch_task_struct_size = task_size;
25140 }
25141
25142 /*
25143diff --git a/arch/x86/kernel/fpu/regset.c b/arch/x86/kernel/fpu/regset.c
25144index dc60810..6c8a1fa 100644
25145--- a/arch/x86/kernel/fpu/regset.c
25146+++ b/arch/x86/kernel/fpu/regset.c
25147@@ -37,7 +37,7 @@ int xfpregs_get(struct task_struct *target, const struct user_regset *regset,
25148 fpstate_sanitize_xstate(fpu);
25149
25150 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
25151- &fpu->state.fxsave, 0, -1);
25152+ &fpu->state->fxsave, 0, -1);
25153 }
25154
25155 int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
25156@@ -54,19 +54,19 @@ int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
25157 fpstate_sanitize_xstate(fpu);
25158
25159 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
25160- &fpu->state.fxsave, 0, -1);
25161+ &fpu->state->fxsave, 0, -1);
25162
25163 /*
25164 * mxcsr reserved bits must be masked to zero for security reasons.
25165 */
25166- fpu->state.fxsave.mxcsr &= mxcsr_feature_mask;
25167+ fpu->state->fxsave.mxcsr &= mxcsr_feature_mask;
25168
25169 /*
25170 * update the header bits in the xsave header, indicating the
25171 * presence of FP and SSE state.
25172 */
25173 if (cpu_has_xsave)
25174- fpu->state.xsave.header.xfeatures |= XSTATE_FPSSE;
25175+ fpu->state->xsave.header.xfeatures |= XSTATE_FPSSE;
25176
25177 return ret;
25178 }
25179@@ -84,7 +84,7 @@ int xstateregs_get(struct task_struct *target, const struct user_regset *regset,
25180
25181 fpu__activate_fpstate_read(fpu);
25182
25183- xsave = &fpu->state.xsave;
25184+ xsave = &fpu->state->xsave;
25185
25186 /*
25187 * Copy the 48bytes defined by the software first into the xstate
25188@@ -113,7 +113,7 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset,
25189
25190 fpu__activate_fpstate_write(fpu);
25191
25192- xsave = &fpu->state.xsave;
25193+ xsave = &fpu->state->xsave;
25194
25195 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, xsave, 0, -1);
25196 /*
25197@@ -204,7 +204,7 @@ static inline u32 twd_fxsr_to_i387(struct fxregs_state *fxsave)
25198 void
25199 convert_from_fxsr(struct user_i387_ia32_struct *env, struct task_struct *tsk)
25200 {
25201- struct fxregs_state *fxsave = &tsk->thread.fpu.state.fxsave;
25202+ struct fxregs_state *fxsave = &tsk->thread.fpu.state->fxsave;
25203 struct _fpreg *to = (struct _fpreg *) &env->st_space[0];
25204 struct _fpxreg *from = (struct _fpxreg *) &fxsave->st_space[0];
25205 int i;
25206@@ -242,7 +242,7 @@ void convert_to_fxsr(struct task_struct *tsk,
25207 const struct user_i387_ia32_struct *env)
25208
25209 {
25210- struct fxregs_state *fxsave = &tsk->thread.fpu.state.fxsave;
25211+ struct fxregs_state *fxsave = &tsk->thread.fpu.state->fxsave;
25212 struct _fpreg *from = (struct _fpreg *) &env->st_space[0];
25213 struct _fpxreg *to = (struct _fpxreg *) &fxsave->st_space[0];
25214 int i;
25215@@ -280,7 +280,7 @@ int fpregs_get(struct task_struct *target, const struct user_regset *regset,
25216
25217 if (!cpu_has_fxsr)
25218 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
25219- &fpu->state.fsave, 0,
25220+ &fpu->state->fsave, 0,
25221 -1);
25222
25223 fpstate_sanitize_xstate(fpu);
25224@@ -311,7 +311,7 @@ int fpregs_set(struct task_struct *target, const struct user_regset *regset,
25225
25226 if (!cpu_has_fxsr)
25227 return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
25228- &fpu->state.fsave, 0,
25229+ &fpu->state->fsave, 0,
25230 -1);
25231
25232 if (pos > 0 || count < sizeof(env))
25233@@ -326,7 +326,7 @@ int fpregs_set(struct task_struct *target, const struct user_regset *regset,
25234 * presence of FP.
25235 */
25236 if (cpu_has_xsave)
25237- fpu->state.xsave.header.xfeatures |= XSTATE_FP;
25238+ fpu->state->xsave.header.xfeatures |= XSTATE_FP;
25239 return ret;
25240 }
25241
25242diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
25243index 50ec9af..bb871ca 100644
25244--- a/arch/x86/kernel/fpu/signal.c
25245+++ b/arch/x86/kernel/fpu/signal.c
25246@@ -54,7 +54,7 @@ static inline int check_for_xstate(struct fxregs_state __user *buf,
25247 static inline int save_fsave_header(struct task_struct *tsk, void __user *buf)
25248 {
25249 if (use_fxsr()) {
25250- struct xregs_state *xsave = &tsk->thread.fpu.state.xsave;
25251+ struct xregs_state *xsave = &tsk->thread.fpu.state->xsave;
25252 struct user_i387_ia32_struct env;
25253 struct _fpstate_ia32 __user *fp = buf;
25254
25255@@ -83,18 +83,18 @@ static inline int save_xstate_epilog(void __user *buf, int ia32_frame)
25256
25257 /* Setup the bytes not touched by the [f]xsave and reserved for SW. */
25258 sw_bytes = ia32_frame ? &fx_sw_reserved_ia32 : &fx_sw_reserved;
25259- err = __copy_to_user(&x->i387.sw_reserved, sw_bytes, sizeof(*sw_bytes));
25260+ err = __copy_to_user(x->i387.sw_reserved, sw_bytes, sizeof(*sw_bytes));
25261
25262 if (!use_xsave())
25263 return err;
25264
25265- err |= __put_user(FP_XSTATE_MAGIC2, (__u32 *)(buf + xstate_size));
25266+ err |= __put_user(FP_XSTATE_MAGIC2, (__u32 __user *)(buf + xstate_size));
25267
25268 /*
25269 * Read the xfeatures which we copied (directly from the cpu or
25270 * from the state in task struct) to the user buffers.
25271 */
25272- err |= __get_user(xfeatures, (__u32 *)&x->header.xfeatures);
25273+ err |= __get_user(xfeatures, (__u32 __user *)&x->header.xfeatures);
25274
25275 /*
25276 * For legacy compatible, we always set FP/SSE bits in the bit
25277@@ -109,7 +109,7 @@ static inline int save_xstate_epilog(void __user *buf, int ia32_frame)
25278 */
25279 xfeatures |= XSTATE_FPSSE;
25280
25281- err |= __put_user(xfeatures, (__u32 *)&x->header.xfeatures);
25282+ err |= __put_user(xfeatures, (__u32 __user *)&x->header.xfeatures);
25283
25284 return err;
25285 }
25286@@ -118,6 +118,7 @@ static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf)
25287 {
25288 int err;
25289
25290+ buf = (struct xregs_state __user *)____m(buf);
25291 if (use_xsave())
25292 err = copy_xregs_to_user(buf);
25293 else if (use_fxsr())
25294@@ -152,7 +153,7 @@ static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf)
25295 */
25296 int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size)
25297 {
25298- struct xregs_state *xsave = &current->thread.fpu.state.xsave;
25299+ struct xregs_state *xsave = &current->thread.fpu.state->xsave;
25300 struct task_struct *tsk = current;
25301 int ia32_fxstate = (buf != buf_fx);
25302
25303@@ -195,7 +196,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
25304 struct user_i387_ia32_struct *ia32_env,
25305 u64 xfeatures, int fx_only)
25306 {
25307- struct xregs_state *xsave = &tsk->thread.fpu.state.xsave;
25308+ struct xregs_state *xsave = &tsk->thread.fpu.state->xsave;
25309 struct xstate_header *header = &xsave->header;
25310
25311 if (use_xsave()) {
25312@@ -228,6 +229,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
25313 */
25314 static inline int copy_user_to_fpregs_zeroing(void __user *buf, u64 xbv, int fx_only)
25315 {
25316+ buf = (void __user *)____m(buf);
25317 if (use_xsave()) {
25318 if ((unsigned long)buf % 64 || fx_only) {
25319 u64 init_bv = xfeatures_mask & ~XSTATE_FPSSE;
25320@@ -308,9 +310,9 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)
25321 */
25322 fpu__drop(fpu);
25323
25324- if (__copy_from_user(&fpu->state.xsave, buf_fx, state_size) ||
25325+ if (__copy_from_user(&fpu->state->xsave, buf_fx, state_size) ||
25326 __copy_from_user(&env, buf, sizeof(env))) {
25327- fpstate_init(&fpu->state);
25328+ fpstate_init(fpu->state);
25329 err = -1;
25330 } else {
25331 sanitize_restored_xstate(tsk, &env, xfeatures, fx_only);
25332diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
25333index 62fc001..5ce38be 100644
25334--- a/arch/x86/kernel/fpu/xstate.c
25335+++ b/arch/x86/kernel/fpu/xstate.c
25336@@ -93,14 +93,14 @@ EXPORT_SYMBOL_GPL(cpu_has_xfeatures);
25337 */
25338 void fpstate_sanitize_xstate(struct fpu *fpu)
25339 {
25340- struct fxregs_state *fx = &fpu->state.fxsave;
25341+ struct fxregs_state *fx = &fpu->state->fxsave;
25342 int feature_bit;
25343 u64 xfeatures;
25344
25345 if (!use_xsaveopt())
25346 return;
25347
25348- xfeatures = fpu->state.xsave.header.xfeatures;
25349+ xfeatures = fpu->state->xsave.header.xfeatures;
25350
25351 /*
25352 * None of the feature bits are in init state. So nothing else
25353@@ -402,7 +402,7 @@ void *get_xsave_addr(struct xregs_state *xsave, int xstate_feature)
25354 if (!boot_cpu_has(X86_FEATURE_XSAVE))
25355 return NULL;
25356
25357- xsave = &current->thread.fpu.state.xsave;
25358+ xsave = &current->thread.fpu.state->xsave;
25359 /*
25360 * We should not ever be requesting features that we
25361 * have not enabled. Remember that pcntxt_mask is
25362@@ -457,5 +457,5 @@ const void *get_xsave_field_ptr(int xsave_state)
25363 */
25364 fpu__save(fpu);
25365
25366- return get_xsave_addr(&fpu->state.xsave, xsave_state);
25367+ return get_xsave_addr(&fpu->state->xsave, xsave_state);
25368 }
25369diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
25370index 8b7b0a5..02219db 100644
25371--- a/arch/x86/kernel/ftrace.c
25372+++ b/arch/x86/kernel/ftrace.c
25373@@ -89,7 +89,7 @@ static unsigned long text_ip_addr(unsigned long ip)
25374 * kernel identity mapping to modify code.
25375 */
25376 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
25377- ip = (unsigned long)__va(__pa_symbol(ip));
25378+ ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
25379
25380 return ip;
25381 }
25382@@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
25383 {
25384 unsigned char replaced[MCOUNT_INSN_SIZE];
25385
25386+ ip = ktla_ktva(ip);
25387+
25388 /*
25389 * Note: Due to modules and __init, code can
25390 * disappear and change, we need to protect against faulting
25391@@ -230,7 +232,7 @@ static int update_ftrace_func(unsigned long ip, void *new)
25392 unsigned char old[MCOUNT_INSN_SIZE];
25393 int ret;
25394
25395- memcpy(old, (void *)ip, MCOUNT_INSN_SIZE);
25396+ memcpy(old, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE);
25397
25398 ftrace_update_func = ip;
25399 /* Make sure the breakpoints see the ftrace_update_func update */
25400@@ -311,7 +313,7 @@ static int add_break(unsigned long ip, const char *old)
25401 unsigned char replaced[MCOUNT_INSN_SIZE];
25402 unsigned char brk = BREAKPOINT_INSTRUCTION;
25403
25404- if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
25405+ if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
25406 return -EFAULT;
25407
25408 /* Make sure it is what we expect it to be */
25409@@ -670,11 +672,11 @@ static unsigned char *ftrace_jmp_replace(unsigned long ip, unsigned long addr)
25410 /* Module allocation simplifies allocating memory for code */
25411 static inline void *alloc_tramp(unsigned long size)
25412 {
25413- return module_alloc(size);
25414+ return module_alloc_exec(size);
25415 }
25416 static inline void tramp_free(void *tramp)
25417 {
25418- module_memfree(tramp);
25419+ module_memfree_exec(tramp);
25420 }
25421 #else
25422 /* Trampolines can only be created if modules are supported */
25423@@ -753,7 +755,9 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
25424 *tramp_size = size + MCOUNT_INSN_SIZE + sizeof(void *);
25425
25426 /* Copy ftrace_caller onto the trampoline memory */
25427+ pax_open_kernel();
25428 ret = probe_kernel_read(trampoline, (void *)start_offset, size);
25429+ pax_close_kernel();
25430 if (WARN_ON(ret < 0)) {
25431 tramp_free(trampoline);
25432 return 0;
25433@@ -763,6 +767,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
25434
25435 /* The trampoline ends with a jmp to ftrace_return */
25436 jmp = ftrace_jmp_replace(ip, (unsigned long)ftrace_return);
25437+ pax_open_kernel();
25438 memcpy(trampoline + size, jmp, MCOUNT_INSN_SIZE);
25439
25440 /*
25441@@ -775,6 +780,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
25442
25443 ptr = (unsigned long *)(trampoline + size + MCOUNT_INSN_SIZE);
25444 *ptr = (unsigned long)ops;
25445+ pax_close_kernel();
25446
25447 op_offset -= start_offset;
25448 memcpy(&op_ptr, trampoline + op_offset, OP_REF_SIZE);
25449@@ -792,7 +798,9 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
25450 op_ptr.offset = offset;
25451
25452 /* put in the new offset to the ftrace_ops */
25453+ pax_open_kernel();
25454 memcpy(trampoline + op_offset, &op_ptr, OP_REF_SIZE);
25455+ pax_close_kernel();
25456
25457 /* ALLOC_TRAMP flags lets us know we created it */
25458 ops->flags |= FTRACE_OPS_FL_ALLOC_TRAMP;
25459diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
25460index f129a9a..af8f6da 100644
25461--- a/arch/x86/kernel/head64.c
25462+++ b/arch/x86/kernel/head64.c
25463@@ -68,12 +68,12 @@ again:
25464 pgd = *pgd_p;
25465
25466 /*
25467- * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
25468- * critical -- __PAGE_OFFSET would point us back into the dynamic
25469+ * The use of __early_va rather than __va here is critical:
25470+ * __va would point us back into the dynamic
25471 * range and we might end up looping forever...
25472 */
25473 if (pgd)
25474- pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
25475+ pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
25476 else {
25477 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
25478 reset_early_page_tables();
25479@@ -83,13 +83,13 @@ again:
25480 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
25481 for (i = 0; i < PTRS_PER_PUD; i++)
25482 pud_p[i] = 0;
25483- *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
25484+ *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
25485 }
25486 pud_p += pud_index(address);
25487 pud = *pud_p;
25488
25489 if (pud)
25490- pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
25491+ pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
25492 else {
25493 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
25494 reset_early_page_tables();
25495@@ -99,7 +99,7 @@ again:
25496 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
25497 for (i = 0; i < PTRS_PER_PMD; i++)
25498 pmd_p[i] = 0;
25499- *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
25500+ *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
25501 }
25502 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
25503 pmd_p[pmd_index(address)] = pmd;
25504@@ -163,8 +163,6 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data)
25505
25506 clear_bss();
25507
25508- clear_page(init_level4_pgt);
25509-
25510 kasan_early_init();
25511
25512 for (i = 0; i < NUM_EXCEPTION_VECTORS; i++)
25513diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
25514index 0e2d96f..5889003 100644
25515--- a/arch/x86/kernel/head_32.S
25516+++ b/arch/x86/kernel/head_32.S
25517@@ -27,6 +27,12 @@
25518 /* Physical address */
25519 #define pa(X) ((X) - __PAGE_OFFSET)
25520
25521+#ifdef CONFIG_PAX_KERNEXEC
25522+#define ta(X) (X)
25523+#else
25524+#define ta(X) ((X) - __PAGE_OFFSET)
25525+#endif
25526+
25527 /*
25528 * References to members of the new_cpu_data structure.
25529 */
25530@@ -56,11 +62,7 @@
25531 * and small than max_low_pfn, otherwise will waste some page table entries
25532 */
25533
25534-#if PTRS_PER_PMD > 1
25535-#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
25536-#else
25537-#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
25538-#endif
25539+#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
25540
25541 /*
25542 * Number of possible pages in the lowmem region.
25543@@ -86,6 +88,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
25544 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
25545
25546 /*
25547+ * Real beginning of normal "text" segment
25548+ */
25549+ENTRY(stext)
25550+ENTRY(_stext)
25551+
25552+/*
25553 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
25554 * %esi points to the real-mode code as a 32-bit pointer.
25555 * CS and DS must be 4 GB flat segments, but we don't depend on
25556@@ -93,6 +101,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
25557 * can.
25558 */
25559 __HEAD
25560+
25561+#ifdef CONFIG_PAX_KERNEXEC
25562+ jmp startup_32
25563+/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
25564+.fill PAGE_SIZE-5,1,0xcc
25565+#endif
25566+
25567 ENTRY(startup_32)
25568 movl pa(stack_start),%ecx
25569
25570@@ -114,6 +129,66 @@ ENTRY(startup_32)
25571 2:
25572 leal -__PAGE_OFFSET(%ecx),%esp
25573
25574+#ifdef CONFIG_SMP
25575+ movl $pa(cpu_gdt_table),%edi
25576+ movl $__per_cpu_load,%eax
25577+ movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
25578+ rorl $16,%eax
25579+ movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
25580+ movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
25581+ movl $__per_cpu_end - 1,%eax
25582+ subl $__per_cpu_start,%eax
25583+ cmpl $0x100000,%eax
25584+ jb 1f
25585+ shrl $PAGE_SHIFT,%eax
25586+ orb $0x80,GDT_ENTRY_PERCPU * 8 + 6(%edi)
25587+1:
25588+ movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
25589+ shrl $16,%eax
25590+ orb %al,GDT_ENTRY_PERCPU * 8 + 6(%edi)
25591+#endif
25592+
25593+#ifdef CONFIG_PAX_MEMORY_UDEREF
25594+ movl $NR_CPUS,%ecx
25595+ movl $pa(cpu_gdt_table),%edi
25596+1:
25597+ movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
25598+ movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
25599+ movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
25600+ addl $PAGE_SIZE_asm,%edi
25601+ loop 1b
25602+#endif
25603+
25604+#ifdef CONFIG_PAX_KERNEXEC
25605+ movl $pa(boot_gdt),%edi
25606+ movl $__LOAD_PHYSICAL_ADDR,%eax
25607+ movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
25608+ rorl $16,%eax
25609+ movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
25610+ movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
25611+ rorl $16,%eax
25612+
25613+ ljmp $(__BOOT_CS),$1f
25614+1:
25615+
25616+ movl $NR_CPUS,%ecx
25617+ movl $pa(cpu_gdt_table),%edi
25618+ addl $__PAGE_OFFSET,%eax
25619+1:
25620+ movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
25621+ movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
25622+ movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
25623+ movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
25624+ rorl $16,%eax
25625+ movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
25626+ movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
25627+ movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
25628+ movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
25629+ rorl $16,%eax
25630+ addl $PAGE_SIZE_asm,%edi
25631+ loop 1b
25632+#endif
25633+
25634 /*
25635 * Clear BSS first so that there are no surprises...
25636 */
25637@@ -209,8 +284,11 @@ ENTRY(startup_32)
25638 movl %eax, pa(max_pfn_mapped)
25639
25640 /* Do early initialization of the fixmap area */
25641- movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
25642- movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
25643+#ifdef CONFIG_COMPAT_VDSO
25644+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
25645+#else
25646+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
25647+#endif
25648 #else /* Not PAE */
25649
25650 page_pde_offset = (__PAGE_OFFSET >> 20);
25651@@ -240,8 +318,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
25652 movl %eax, pa(max_pfn_mapped)
25653
25654 /* Do early initialization of the fixmap area */
25655- movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
25656- movl %eax,pa(initial_page_table+0xffc)
25657+#ifdef CONFIG_COMPAT_VDSO
25658+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
25659+#else
25660+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
25661+#endif
25662 #endif
25663
25664 #ifdef CONFIG_PARAVIRT
25665@@ -255,9 +336,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
25666 cmpl $num_subarch_entries, %eax
25667 jae bad_subarch
25668
25669- movl pa(subarch_entries)(,%eax,4), %eax
25670- subl $__PAGE_OFFSET, %eax
25671- jmp *%eax
25672+ jmp *pa(subarch_entries)(,%eax,4)
25673
25674 bad_subarch:
25675 WEAK(lguest_entry)
25676@@ -269,10 +348,10 @@ WEAK(xen_entry)
25677 __INITDATA
25678
25679 subarch_entries:
25680- .long default_entry /* normal x86/PC */
25681- .long lguest_entry /* lguest hypervisor */
25682- .long xen_entry /* Xen hypervisor */
25683- .long default_entry /* Moorestown MID */
25684+ .long ta(default_entry) /* normal x86/PC */
25685+ .long ta(lguest_entry) /* lguest hypervisor */
25686+ .long ta(xen_entry) /* Xen hypervisor */
25687+ .long ta(default_entry) /* Moorestown MID */
25688 num_subarch_entries = (. - subarch_entries) / 4
25689 .previous
25690 #else
25691@@ -362,6 +441,7 @@ default_entry:
25692 movl pa(mmu_cr4_features),%eax
25693 movl %eax,%cr4
25694
25695+#ifdef CONFIG_X86_PAE
25696 testb $X86_CR4_PAE, %al # check if PAE is enabled
25697 jz enable_paging
25698
25699@@ -390,6 +470,9 @@ default_entry:
25700 /* Make changes effective */
25701 wrmsr
25702
25703+ btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
25704+#endif
25705+
25706 enable_paging:
25707
25708 /*
25709@@ -457,14 +540,20 @@ is486:
25710 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
25711 movl %eax,%ss # after changing gdt.
25712
25713- movl $(__USER_DS),%eax # DS/ES contains default USER segment
25714+# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
25715 movl %eax,%ds
25716 movl %eax,%es
25717
25718 movl $(__KERNEL_PERCPU), %eax
25719 movl %eax,%fs # set this cpu's percpu
25720
25721+#ifdef CONFIG_CC_STACKPROTECTOR
25722 movl $(__KERNEL_STACK_CANARY),%eax
25723+#elif defined(CONFIG_PAX_MEMORY_UDEREF)
25724+ movl $(__USER_DS),%eax
25725+#else
25726+ xorl %eax,%eax
25727+#endif
25728 movl %eax,%gs
25729
25730 xorl %eax,%eax # Clear LDT
25731@@ -521,8 +610,11 @@ setup_once:
25732 * relocation. Manually set base address in stack canary
25733 * segment descriptor.
25734 */
25735- movl $gdt_page,%eax
25736+ movl $cpu_gdt_table,%eax
25737 movl $stack_canary,%ecx
25738+#ifdef CONFIG_SMP
25739+ addl $__per_cpu_load,%ecx
25740+#endif
25741 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
25742 shrl $16, %ecx
25743 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
25744@@ -559,7 +651,7 @@ early_idt_handler_common:
25745 cmpl $2,(%esp) # X86_TRAP_NMI
25746 je .Lis_nmi # Ignore NMI
25747
25748- cmpl $2,%ss:early_recursion_flag
25749+ cmpl $1,%ss:early_recursion_flag
25750 je hlt_loop
25751 incl %ss:early_recursion_flag
25752
25753@@ -597,8 +689,8 @@ early_idt_handler_common:
25754 pushl (20+6*4)(%esp) /* trapno */
25755 pushl $fault_msg
25756 call printk
25757-#endif
25758 call dump_stack
25759+#endif
25760 hlt_loop:
25761 hlt
25762 jmp hlt_loop
25763@@ -618,8 +710,11 @@ ENDPROC(early_idt_handler_common)
25764 /* This is the default interrupt "handler" :-) */
25765 ALIGN
25766 ignore_int:
25767- cld
25768 #ifdef CONFIG_PRINTK
25769+ cmpl $2,%ss:early_recursion_flag
25770+ je hlt_loop
25771+ incl %ss:early_recursion_flag
25772+ cld
25773 pushl %eax
25774 pushl %ecx
25775 pushl %edx
25776@@ -628,9 +723,6 @@ ignore_int:
25777 movl $(__KERNEL_DS),%eax
25778 movl %eax,%ds
25779 movl %eax,%es
25780- cmpl $2,early_recursion_flag
25781- je hlt_loop
25782- incl early_recursion_flag
25783 pushl 16(%esp)
25784 pushl 24(%esp)
25785 pushl 32(%esp)
25786@@ -664,29 +756,34 @@ ENTRY(setup_once_ref)
25787 /*
25788 * BSS section
25789 */
25790-__PAGE_ALIGNED_BSS
25791- .align PAGE_SIZE
25792 #ifdef CONFIG_X86_PAE
25793+.section .initial_pg_pmd,"a",@progbits
25794 initial_pg_pmd:
25795 .fill 1024*KPMDS,4,0
25796 #else
25797+.section .initial_page_table,"a",@progbits
25798 ENTRY(initial_page_table)
25799 .fill 1024,4,0
25800 #endif
25801+.section .initial_pg_fixmap,"a",@progbits
25802 initial_pg_fixmap:
25803 .fill 1024,4,0
25804+.section .empty_zero_page,"a",@progbits
25805 ENTRY(empty_zero_page)
25806 .fill 4096,1,0
25807+.section .swapper_pg_dir,"a",@progbits
25808 ENTRY(swapper_pg_dir)
25809+#ifdef CONFIG_X86_PAE
25810+ .fill 4,8,0
25811+#else
25812 .fill 1024,4,0
25813+#endif
25814
25815 /*
25816 * This starts the data section.
25817 */
25818 #ifdef CONFIG_X86_PAE
25819-__PAGE_ALIGNED_DATA
25820- /* Page-aligned for the benefit of paravirt? */
25821- .align PAGE_SIZE
25822+.section .initial_page_table,"a",@progbits
25823 ENTRY(initial_page_table)
25824 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
25825 # if KPMDS == 3
25826@@ -705,12 +802,20 @@ ENTRY(initial_page_table)
25827 # error "Kernel PMDs should be 1, 2 or 3"
25828 # endif
25829 .align PAGE_SIZE /* needs to be page-sized too */
25830+
25831+#ifdef CONFIG_PAX_PER_CPU_PGD
25832+ENTRY(cpu_pgd)
25833+ .rept 2*NR_CPUS
25834+ .fill 4,8,0
25835+ .endr
25836+#endif
25837+
25838 #endif
25839
25840 .data
25841 .balign 4
25842 ENTRY(stack_start)
25843- .long init_thread_union+THREAD_SIZE
25844+ .long init_thread_union+THREAD_SIZE-8
25845
25846 __INITRODATA
25847 int_msg:
25848@@ -738,7 +843,7 @@ fault_msg:
25849 * segment size, and 32-bit linear address value:
25850 */
25851
25852- .data
25853+.section .rodata,"a",@progbits
25854 .globl boot_gdt_descr
25855 .globl idt_descr
25856
25857@@ -747,7 +852,7 @@ fault_msg:
25858 .word 0 # 32 bit align gdt_desc.address
25859 boot_gdt_descr:
25860 .word __BOOT_DS+7
25861- .long boot_gdt - __PAGE_OFFSET
25862+ .long pa(boot_gdt)
25863
25864 .word 0 # 32-bit align idt_desc.address
25865 idt_descr:
25866@@ -758,7 +863,7 @@ idt_descr:
25867 .word 0 # 32 bit align gdt_desc.address
25868 ENTRY(early_gdt_descr)
25869 .word GDT_ENTRIES*8-1
25870- .long gdt_page /* Overwritten for secondary CPUs */
25871+ .long cpu_gdt_table /* Overwritten for secondary CPUs */
25872
25873 /*
25874 * The boot_gdt must mirror the equivalent in setup.S and is
25875@@ -767,5 +872,65 @@ ENTRY(early_gdt_descr)
25876 .align L1_CACHE_BYTES
25877 ENTRY(boot_gdt)
25878 .fill GDT_ENTRY_BOOT_CS,8,0
25879- .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
25880- .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
25881+ .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
25882+ .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
25883+
25884+ .align PAGE_SIZE_asm
25885+ENTRY(cpu_gdt_table)
25886+ .rept NR_CPUS
25887+ .quad 0x0000000000000000 /* NULL descriptor */
25888+ .quad 0x0000000000000000 /* 0x0b reserved */
25889+ .quad 0x0000000000000000 /* 0x13 reserved */
25890+ .quad 0x0000000000000000 /* 0x1b reserved */
25891+
25892+#ifdef CONFIG_PAX_KERNEXEC
25893+ .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
25894+#else
25895+ .quad 0x0000000000000000 /* 0x20 unused */
25896+#endif
25897+
25898+ .quad 0x0000000000000000 /* 0x28 unused */
25899+ .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
25900+ .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
25901+ .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
25902+ .quad 0x0000000000000000 /* 0x4b reserved */
25903+ .quad 0x0000000000000000 /* 0x53 reserved */
25904+ .quad 0x0000000000000000 /* 0x5b reserved */
25905+
25906+ .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
25907+ .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
25908+ .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
25909+ .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
25910+
25911+ .quad 0x0000000000000000 /* 0x80 TSS descriptor */
25912+ .quad 0x0000000000000000 /* 0x88 LDT descriptor */
25913+
25914+ /*
25915+ * Segments used for calling PnP BIOS have byte granularity.
25916+ * The code segments and data segments have fixed 64k limits,
25917+ * the transfer segment sizes are set at run time.
25918+ */
25919+ .quad 0x00409b000000ffff /* 0x90 32-bit code */
25920+ .quad 0x00009b000000ffff /* 0x98 16-bit code */
25921+ .quad 0x000093000000ffff /* 0xa0 16-bit data */
25922+ .quad 0x0000930000000000 /* 0xa8 16-bit data */
25923+ .quad 0x0000930000000000 /* 0xb0 16-bit data */
25924+
25925+ /*
25926+ * The APM segments have byte granularity and their bases
25927+ * are set at run time. All have 64k limits.
25928+ */
25929+ .quad 0x00409b000000ffff /* 0xb8 APM CS code */
25930+ .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
25931+ .quad 0x004093000000ffff /* 0xc8 APM DS data */
25932+
25933+ .quad 0x00c093000000ffff /* 0xd0 - ESPFIX SS */
25934+ .quad 0x0040930000000000 /* 0xd8 - PERCPU */
25935+ .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
25936+ .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
25937+ .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
25938+ .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
25939+
25940+ /* Be sure this is zeroed to avoid false validations in Xen */
25941+ .fill PAGE_SIZE_asm - GDT_SIZE,1,0
25942+ .endr
25943diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
25944index 1d40ca8..4d38dbd 100644
25945--- a/arch/x86/kernel/head_64.S
25946+++ b/arch/x86/kernel/head_64.S
25947@@ -20,6 +20,8 @@
25948 #include <asm/processor-flags.h>
25949 #include <asm/percpu.h>
25950 #include <asm/nops.h>
25951+#include <asm/cpufeature.h>
25952+#include <asm/alternative-asm.h>
25953
25954 #ifdef CONFIG_PARAVIRT
25955 #include <asm/asm-offsets.h>
25956@@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
25957 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
25958 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
25959 L3_START_KERNEL = pud_index(__START_KERNEL_map)
25960+L4_VMALLOC_START = pgd_index(VMALLOC_START)
25961+L3_VMALLOC_START = pud_index(VMALLOC_START)
25962+L4_VMALLOC_END = pgd_index(VMALLOC_END)
25963+L3_VMALLOC_END = pud_index(VMALLOC_END)
25964+L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
25965+L3_VMEMMAP_START = pud_index(VMEMMAP_START)
25966
25967 .text
25968 __HEAD
25969@@ -89,11 +97,33 @@ startup_64:
25970 * Fixup the physical addresses in the page table
25971 */
25972 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
25973+ addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
25974+ addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
25975+ addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
25976+ addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
25977+ addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
25978
25979- addq %rbp, level3_kernel_pgt + (510*8)(%rip)
25980- addq %rbp, level3_kernel_pgt + (511*8)(%rip)
25981+ addq %rbp, level3_ident_pgt + (0*8)(%rip)
25982+#ifndef CONFIG_XEN
25983+ addq %rbp, level3_ident_pgt + (1*8)(%rip)
25984+#endif
25985
25986+ addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
25987+
25988+ addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
25989+ addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
25990+
25991+ addq %rbp, level2_ident_pgt + (0*8)(%rip)
25992+
25993+ addq %rbp, level2_fixmap_pgt + (0*8)(%rip)
25994+ addq %rbp, level2_fixmap_pgt + (1*8)(%rip)
25995+ addq %rbp, level2_fixmap_pgt + (2*8)(%rip)
25996+ addq %rbp, level2_fixmap_pgt + (3*8)(%rip)
25997+
25998+ addq %rbp, level2_fixmap_pgt + (504*8)(%rip)
25999+ addq %rbp, level2_fixmap_pgt + (505*8)(%rip)
26000 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
26001+ addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
26002
26003 /*
26004 * Set up the identity mapping for the switchover. These
26005@@ -174,11 +204,12 @@ ENTRY(secondary_startup_64)
26006 * after the boot processor executes this code.
26007 */
26008
26009+ orq $-1, %rbp
26010 movq $(init_level4_pgt - __START_KERNEL_map), %rax
26011 1:
26012
26013- /* Enable PAE mode and PGE */
26014- movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
26015+ /* Enable PAE mode and PSE/PGE */
26016+ movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
26017 movq %rcx, %cr4
26018
26019 /* Setup early boot stage 4 level pagetables. */
26020@@ -199,10 +230,21 @@ ENTRY(secondary_startup_64)
26021 movl $MSR_EFER, %ecx
26022 rdmsr
26023 btsl $_EFER_SCE, %eax /* Enable System Call */
26024- btl $20,%edi /* No Execute supported? */
26025+ btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
26026 jnc 1f
26027 btsl $_EFER_NX, %eax
26028+ cmpq $-1, %rbp
26029+ je 1f
26030 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
26031+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_PAGE_OFFSET(%rip)
26032+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_START(%rip)
26033+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_END(%rip)
26034+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMEMMAP_START(%rip)
26035+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*504(%rip)
26036+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*505(%rip)
26037+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*506(%rip)
26038+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*507(%rip)
26039+ btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
26040 1: wrmsr /* Make changes effective */
26041
26042 /* Setup cr0 */
26043@@ -282,6 +324,7 @@ ENTRY(secondary_startup_64)
26044 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
26045 * address given in m16:64.
26046 */
26047+ pax_set_fptr_mask
26048 movq initial_code(%rip),%rax
26049 pushq $0 # fake return address to stop unwinder
26050 pushq $__KERNEL_CS # set correct cs
26051@@ -313,7 +356,7 @@ ENDPROC(start_cpu0)
26052 .quad INIT_PER_CPU_VAR(irq_stack_union)
26053
26054 GLOBAL(stack_start)
26055- .quad init_thread_union+THREAD_SIZE-8
26056+ .quad init_thread_union+THREAD_SIZE-16
26057 .word 0
26058 __FINITDATA
26059
26060@@ -393,7 +436,7 @@ early_idt_handler_common:
26061 call dump_stack
26062 #ifdef CONFIG_KALLSYMS
26063 leaq early_idt_ripmsg(%rip),%rdi
26064- movq 40(%rsp),%rsi # %rip again
26065+ movq 88(%rsp),%rsi # %rip again
26066 call __print_symbol
26067 #endif
26068 #endif /* EARLY_PRINTK */
26069@@ -422,6 +465,7 @@ ENDPROC(early_idt_handler_common)
26070 early_recursion_flag:
26071 .long 0
26072
26073+ .section .rodata,"a",@progbits
26074 #ifdef CONFIG_EARLY_PRINTK
26075 early_idt_msg:
26076 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
26077@@ -444,40 +488,67 @@ GLOBAL(name)
26078 __INITDATA
26079 NEXT_PAGE(early_level4_pgt)
26080 .fill 511,8,0
26081- .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
26082+ .quad level3_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
26083
26084 NEXT_PAGE(early_dynamic_pgts)
26085 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
26086
26087- .data
26088+ .section .rodata,"a",@progbits
26089
26090-#ifndef CONFIG_XEN
26091 NEXT_PAGE(init_level4_pgt)
26092- .fill 512,8,0
26093-#else
26094-NEXT_PAGE(init_level4_pgt)
26095- .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
26096 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
26097 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
26098+ .org init_level4_pgt + L4_VMALLOC_START*8, 0
26099+ .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
26100+ .org init_level4_pgt + L4_VMALLOC_END*8, 0
26101+ .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
26102+ .org init_level4_pgt + L4_VMEMMAP_START*8, 0
26103+ .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
26104 .org init_level4_pgt + L4_START_KERNEL*8, 0
26105 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
26106- .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
26107+ .quad level3_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
26108+
26109+#ifdef CONFIG_PAX_PER_CPU_PGD
26110+NEXT_PAGE(cpu_pgd)
26111+ .rept 2*NR_CPUS
26112+ .fill 512,8,0
26113+ .endr
26114+#endif
26115
26116 NEXT_PAGE(level3_ident_pgt)
26117 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
26118+#ifdef CONFIG_XEN
26119 .fill 511, 8, 0
26120+#else
26121+ .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
26122+ .fill 510,8,0
26123+#endif
26124+
26125+NEXT_PAGE(level3_vmalloc_start_pgt)
26126+ .fill 512,8,0
26127+
26128+NEXT_PAGE(level3_vmalloc_end_pgt)
26129+ .fill 512,8,0
26130+
26131+NEXT_PAGE(level3_vmemmap_pgt)
26132+ .fill L3_VMEMMAP_START,8,0
26133+ .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
26134+
26135 NEXT_PAGE(level2_ident_pgt)
26136- /* Since I easily can, map the first 1G.
26137+ .quad level1_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
26138+ /* Since I easily can, map the first 2G.
26139 * Don't set NX because code runs from these pages.
26140 */
26141- PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
26142-#endif
26143+ PMDS(PMD_SIZE, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD - 1)
26144
26145 NEXT_PAGE(level3_kernel_pgt)
26146 .fill L3_START_KERNEL,8,0
26147 /* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */
26148 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
26149- .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
26150+ .quad level2_fixmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
26151+
26152+NEXT_PAGE(level2_vmemmap_pgt)
26153+ .fill 512,8,0
26154
26155 NEXT_PAGE(level2_kernel_pgt)
26156 /*
26157@@ -494,31 +565,79 @@ NEXT_PAGE(level2_kernel_pgt)
26158 KERNEL_IMAGE_SIZE/PMD_SIZE)
26159
26160 NEXT_PAGE(level2_fixmap_pgt)
26161- .fill 506,8,0
26162- .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
26163- /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
26164- .fill 5,8,0
26165+ .quad level1_modules_pgt - __START_KERNEL_map + 0 * PAGE_SIZE + _KERNPG_TABLE
26166+ .quad level1_modules_pgt - __START_KERNEL_map + 1 * PAGE_SIZE + _KERNPG_TABLE
26167+ .quad level1_modules_pgt - __START_KERNEL_map + 2 * PAGE_SIZE + _KERNPG_TABLE
26168+ .quad level1_modules_pgt - __START_KERNEL_map + 3 * PAGE_SIZE + _KERNPG_TABLE
26169+ .fill 500,8,0
26170+ .quad level1_fixmap_pgt - __START_KERNEL_map + 0 * PAGE_SIZE + _KERNPG_TABLE
26171+ .quad level1_fixmap_pgt - __START_KERNEL_map + 1 * PAGE_SIZE + _KERNPG_TABLE
26172+ .quad level1_fixmap_pgt - __START_KERNEL_map + 2 * PAGE_SIZE + _KERNPG_TABLE
26173+ .quad level1_vsyscall_pgt - __START_KERNEL_map + _KERNPG_TABLE
26174+ /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
26175+ .fill 4,8,0
26176+
26177+NEXT_PAGE(level1_ident_pgt)
26178+ .fill 512,8,0
26179+
26180+NEXT_PAGE(level1_modules_pgt)
26181+ .fill 4*512,8,0
26182
26183 NEXT_PAGE(level1_fixmap_pgt)
26184+ .fill 3*512,8,0
26185+
26186+NEXT_PAGE(level1_vsyscall_pgt)
26187 .fill 512,8,0
26188
26189 #undef PMDS
26190
26191- .data
26192+ .align PAGE_SIZE
26193+ENTRY(cpu_gdt_table)
26194+ .rept NR_CPUS
26195+ .quad 0x0000000000000000 /* NULL descriptor */
26196+ .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
26197+ .quad 0x00af9b000000ffff /* __KERNEL_CS */
26198+ .quad 0x00cf93000000ffff /* __KERNEL_DS */
26199+ .quad 0x00cffb000000ffff /* __USER32_CS */
26200+ .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
26201+ .quad 0x00affb000000ffff /* __USER_CS */
26202+
26203+#ifdef CONFIG_PAX_KERNEXEC
26204+ .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
26205+#else
26206+ .quad 0x0 /* unused */
26207+#endif
26208+
26209+ .quad 0,0 /* TSS */
26210+ .quad 0,0 /* LDT */
26211+ .quad 0,0,0 /* three TLS descriptors */
26212+ .quad 0x0000f40000000000 /* node/CPU stored in limit */
26213+ /* asm/segment.h:GDT_ENTRIES must match this */
26214+
26215+#ifdef CONFIG_PAX_MEMORY_UDEREF
26216+ .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
26217+#else
26218+ .quad 0x0 /* unused */
26219+#endif
26220+
26221+ /* zero the remaining page */
26222+ .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
26223+ .endr
26224+
26225 .align 16
26226 .globl early_gdt_descr
26227 early_gdt_descr:
26228 .word GDT_ENTRIES*8-1
26229 early_gdt_descr_base:
26230- .quad INIT_PER_CPU_VAR(gdt_page)
26231+ .quad cpu_gdt_table
26232
26233 ENTRY(phys_base)
26234 /* This must match the first entry in level2_kernel_pgt */
26235 .quad 0x0000000000000000
26236
26237 #include "../../x86/xen/xen-head.S"
26238-
26239- __PAGE_ALIGNED_BSS
26240+
26241+ .section .rodata,"a",@progbits
26242 NEXT_PAGE(empty_zero_page)
26243 .skip PAGE_SIZE
26244
26245diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
26246index 64341aa..b1e6632 100644
26247--- a/arch/x86/kernel/i386_ksyms_32.c
26248+++ b/arch/x86/kernel/i386_ksyms_32.c
26249@@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
26250 EXPORT_SYMBOL(cmpxchg8b_emu);
26251 #endif
26252
26253+EXPORT_SYMBOL_GPL(cpu_gdt_table);
26254+
26255 /* Networking helper routines. */
26256 EXPORT_SYMBOL(csum_partial_copy_generic);
26257+EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
26258+EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
26259
26260 EXPORT_SYMBOL(__get_user_1);
26261 EXPORT_SYMBOL(__get_user_2);
26262@@ -42,3 +46,11 @@ EXPORT_SYMBOL(empty_zero_page);
26263 EXPORT_SYMBOL(___preempt_schedule);
26264 EXPORT_SYMBOL(___preempt_schedule_notrace);
26265 #endif
26266+
26267+#ifdef CONFIG_PAX_KERNEXEC
26268+EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
26269+#endif
26270+
26271+#ifdef CONFIG_PAX_PER_CPU_PGD
26272+EXPORT_SYMBOL(cpu_pgd);
26273+#endif
26274diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
26275index 16cb827..372334f 100644
26276--- a/arch/x86/kernel/i8259.c
26277+++ b/arch/x86/kernel/i8259.c
26278@@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
26279 static void make_8259A_irq(unsigned int irq)
26280 {
26281 disable_irq_nosync(irq);
26282- io_apic_irqs &= ~(1<<irq);
26283+ io_apic_irqs &= ~(1UL<<irq);
26284 irq_set_chip_and_handler(irq, &i8259A_chip, handle_level_irq);
26285 enable_irq(irq);
26286 }
26287@@ -208,7 +208,7 @@ spurious_8259A_irq:
26288 "spurious 8259A interrupt: IRQ%d.\n", irq);
26289 spurious_irq_mask |= irqmask;
26290 }
26291- atomic_inc(&irq_err_count);
26292+ atomic_inc_unchecked(&irq_err_count);
26293 /*
26294 * Theoretically we do not have to handle this IRQ,
26295 * but in Linux this does not cause problems and is
26296@@ -349,14 +349,16 @@ static void init_8259A(int auto_eoi)
26297 /* (slave's support for AEOI in flat mode is to be investigated) */
26298 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
26299
26300+ pax_open_kernel();
26301 if (auto_eoi)
26302 /*
26303 * In AEOI mode we just have to mask the interrupt
26304 * when acking.
26305 */
26306- i8259A_chip.irq_mask_ack = disable_8259A_irq;
26307+ *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
26308 else
26309- i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
26310+ *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
26311+ pax_close_kernel();
26312
26313 udelay(100); /* wait for 8259A to initialize */
26314
26315diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
26316index a979b5b..1d6db75 100644
26317--- a/arch/x86/kernel/io_delay.c
26318+++ b/arch/x86/kernel/io_delay.c
26319@@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
26320 * Quirk table for systems that misbehave (lock up, etc.) if port
26321 * 0x80 is used:
26322 */
26323-static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
26324+static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
26325 {
26326 .callback = dmi_io_delay_0xed_port,
26327 .ident = "Compaq Presario V6000",
26328diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
26329index 37dae79..620dd84 100644
26330--- a/arch/x86/kernel/ioport.c
26331+++ b/arch/x86/kernel/ioport.c
26332@@ -6,6 +6,7 @@
26333 #include <linux/sched.h>
26334 #include <linux/kernel.h>
26335 #include <linux/capability.h>
26336+#include <linux/security.h>
26337 #include <linux/errno.h>
26338 #include <linux/types.h>
26339 #include <linux/ioport.h>
26340@@ -30,6 +31,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
26341 return -EINVAL;
26342 if (turn_on && !capable(CAP_SYS_RAWIO))
26343 return -EPERM;
26344+#ifdef CONFIG_GRKERNSEC_IO
26345+ if (turn_on && grsec_disable_privio) {
26346+ gr_handle_ioperm();
26347+ return -ENODEV;
26348+ }
26349+#endif
26350
26351 /*
26352 * If it's the first ioperm() call in this thread's lifetime, set the
26353@@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
26354 * because the ->io_bitmap_max value must match the bitmap
26355 * contents:
26356 */
26357- tss = &per_cpu(cpu_tss, get_cpu());
26358+ tss = cpu_tss + get_cpu();
26359
26360 if (turn_on)
26361 bitmap_clear(t->io_bitmap_ptr, from, num);
26362@@ -105,6 +112,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
26363 if (level > old) {
26364 if (!capable(CAP_SYS_RAWIO))
26365 return -EPERM;
26366+#ifdef CONFIG_GRKERNSEC_IO
26367+ if (grsec_disable_privio) {
26368+ gr_handle_iopl();
26369+ return -ENODEV;
26370+ }
26371+#endif
26372 }
26373 regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
26374 t->iopl = level << 12;
26375diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
26376index c7dfe1b..146f63c 100644
26377--- a/arch/x86/kernel/irq.c
26378+++ b/arch/x86/kernel/irq.c
26379@@ -28,7 +28,7 @@ EXPORT_PER_CPU_SYMBOL(irq_stat);
26380 DEFINE_PER_CPU(struct pt_regs *, irq_regs);
26381 EXPORT_PER_CPU_SYMBOL(irq_regs);
26382
26383-atomic_t irq_err_count;
26384+atomic_unchecked_t irq_err_count;
26385
26386 /* Function pointer for generic interrupt vector handling */
26387 void (*x86_platform_ipi_callback)(void) = NULL;
26388@@ -144,9 +144,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
26389 seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count);
26390 seq_puts(p, " Hypervisor callback interrupts\n");
26391 #endif
26392- seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
26393+ seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
26394 #if defined(CONFIG_X86_IO_APIC)
26395- seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
26396+ seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
26397 #endif
26398 #ifdef CONFIG_HAVE_KVM
26399 seq_printf(p, "%*s: ", prec, "PIN");
26400@@ -198,7 +198,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
26401
26402 u64 arch_irq_stat(void)
26403 {
26404- u64 sum = atomic_read(&irq_err_count);
26405+ u64 sum = atomic_read_unchecked(&irq_err_count);
26406 return sum;
26407 }
26408
26409diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
26410index cd74f59..588af0b 100644
26411--- a/arch/x86/kernel/irq_32.c
26412+++ b/arch/x86/kernel/irq_32.c
26413@@ -23,6 +23,8 @@
26414
26415 #ifdef CONFIG_DEBUG_STACKOVERFLOW
26416
26417+extern void gr_handle_kernel_exploit(void);
26418+
26419 int sysctl_panic_on_stackoverflow __read_mostly;
26420
26421 /* Debugging check for stack overflow: is there less than 1KB free? */
26422@@ -33,13 +35,14 @@ static int check_stack_overflow(void)
26423 __asm__ __volatile__("andl %%esp,%0" :
26424 "=r" (sp) : "0" (THREAD_SIZE - 1));
26425
26426- return sp < (sizeof(struct thread_info) + STACK_WARN);
26427+ return sp < STACK_WARN;
26428 }
26429
26430 static void print_stack_overflow(void)
26431 {
26432 printk(KERN_WARNING "low stack detected by irq handler\n");
26433 dump_stack();
26434+ gr_handle_kernel_exploit();
26435 if (sysctl_panic_on_stackoverflow)
26436 panic("low stack detected by irq handler - check messages\n");
26437 }
26438@@ -71,10 +74,9 @@ static inline void *current_stack(void)
26439 static inline int
26440 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
26441 {
26442- struct irq_stack *curstk, *irqstk;
26443+ struct irq_stack *irqstk;
26444 u32 *isp, *prev_esp, arg1, arg2;
26445
26446- curstk = (struct irq_stack *) current_stack();
26447 irqstk = __this_cpu_read(hardirq_stack);
26448
26449 /*
26450@@ -83,15 +85,19 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
26451 * handler) we can't do that and just have to keep using the
26452 * current stack (which is the irq stack already after all)
26453 */
26454- if (unlikely(curstk == irqstk))
26455+ if (unlikely((void *)current_stack_pointer - (void *)irqstk < THREAD_SIZE))
26456 return 0;
26457
26458- isp = (u32 *) ((char *)irqstk + sizeof(*irqstk));
26459+ isp = (u32 *) ((char *)irqstk + sizeof(*irqstk) - 8);
26460
26461 /* Save the next esp at the bottom of the stack */
26462 prev_esp = (u32 *)irqstk;
26463 *prev_esp = current_stack_pointer();
26464
26465+#ifdef CONFIG_PAX_MEMORY_UDEREF
26466+ __set_fs(MAKE_MM_SEG(0));
26467+#endif
26468+
26469 if (unlikely(overflow))
26470 call_on_stack(print_stack_overflow, isp);
26471
26472@@ -102,6 +108,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
26473 : "0" (irq), "1" (desc), "2" (isp),
26474 "D" (desc->handle_irq)
26475 : "memory", "cc", "ecx");
26476+
26477+#ifdef CONFIG_PAX_MEMORY_UDEREF
26478+ __set_fs(current_thread_info()->addr_limit);
26479+#endif
26480+
26481 return 1;
26482 }
26483
26484@@ -110,32 +121,18 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
26485 */
26486 void irq_ctx_init(int cpu)
26487 {
26488- struct irq_stack *irqstk;
26489-
26490 if (per_cpu(hardirq_stack, cpu))
26491 return;
26492
26493- irqstk = page_address(alloc_pages_node(cpu_to_node(cpu),
26494- THREADINFO_GFP,
26495- THREAD_SIZE_ORDER));
26496- per_cpu(hardirq_stack, cpu) = irqstk;
26497-
26498- irqstk = page_address(alloc_pages_node(cpu_to_node(cpu),
26499- THREADINFO_GFP,
26500- THREAD_SIZE_ORDER));
26501- per_cpu(softirq_stack, cpu) = irqstk;
26502-
26503- printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
26504- cpu, per_cpu(hardirq_stack, cpu), per_cpu(softirq_stack, cpu));
26505+ per_cpu(hardirq_stack, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
26506+ per_cpu(softirq_stack, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
26507 }
26508
26509 void do_softirq_own_stack(void)
26510 {
26511- struct thread_info *curstk;
26512 struct irq_stack *irqstk;
26513 u32 *isp, *prev_esp;
26514
26515- curstk = current_stack();
26516 irqstk = __this_cpu_read(softirq_stack);
26517
26518 /* build the stack frame on the softirq stack */
26519@@ -145,7 +142,16 @@ void do_softirq_own_stack(void)
26520 prev_esp = (u32 *)irqstk;
26521 *prev_esp = current_stack_pointer();
26522
26523+#ifdef CONFIG_PAX_MEMORY_UDEREF
26524+ __set_fs(MAKE_MM_SEG(0));
26525+#endif
26526+
26527 call_on_stack(__do_softirq, isp);
26528+
26529+#ifdef CONFIG_PAX_MEMORY_UDEREF
26530+ __set_fs(current_thread_info()->addr_limit);
26531+#endif
26532+
26533 }
26534
26535 bool handle_irq(unsigned irq, struct pt_regs *regs)
26536diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
26537index bc4604e..0be227d 100644
26538--- a/arch/x86/kernel/irq_64.c
26539+++ b/arch/x86/kernel/irq_64.c
26540@@ -20,6 +20,8 @@
26541 #include <asm/idle.h>
26542 #include <asm/apic.h>
26543
26544+extern void gr_handle_kernel_exploit(void);
26545+
26546 int sysctl_panic_on_stackoverflow;
26547
26548 /*
26549@@ -63,6 +65,8 @@ static inline void stack_overflow_check(struct pt_regs *regs)
26550 irq_stack_top, irq_stack_bottom,
26551 estack_top, estack_bottom);
26552
26553+ gr_handle_kernel_exploit();
26554+
26555 if (sysctl_panic_on_stackoverflow)
26556 panic("low stack detected by irq handler - check messages\n");
26557 #endif
26558diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
26559index 26d5a55..063fef8 100644
26560--- a/arch/x86/kernel/jump_label.c
26561+++ b/arch/x86/kernel/jump_label.c
26562@@ -31,6 +31,8 @@ static void bug_at(unsigned char *ip, int line)
26563 * Something went wrong. Crash the box, as something could be
26564 * corrupting the kernel.
26565 */
26566+ ip = (unsigned char *)ktla_ktva((unsigned long)ip);
26567+ pr_warning("Unexpected op at %pS [%p] %s:%d\n", ip, ip, __FILE__, line);
26568 pr_warning("Unexpected op at %pS [%p] (%02x %02x %02x %02x %02x) %s:%d\n",
26569 ip, ip, ip[0], ip[1], ip[2], ip[3], ip[4], __FILE__, line);
26570 BUG();
26571@@ -51,7 +53,7 @@ static void __jump_label_transform(struct jump_entry *entry,
26572 * Jump label is enabled for the first time.
26573 * So we expect a default_nop...
26574 */
26575- if (unlikely(memcmp((void *)entry->code, default_nop, 5)
26576+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5)
26577 != 0))
26578 bug_at((void *)entry->code, __LINE__);
26579 } else {
26580@@ -59,7 +61,7 @@ static void __jump_label_transform(struct jump_entry *entry,
26581 * ...otherwise expect an ideal_nop. Otherwise
26582 * something went horribly wrong.
26583 */
26584- if (unlikely(memcmp((void *)entry->code, ideal_nop, 5)
26585+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), ideal_nop, 5)
26586 != 0))
26587 bug_at((void *)entry->code, __LINE__);
26588 }
26589@@ -75,13 +77,13 @@ static void __jump_label_transform(struct jump_entry *entry,
26590 * are converting the default nop to the ideal nop.
26591 */
26592 if (init) {
26593- if (unlikely(memcmp((void *)entry->code, default_nop, 5) != 0))
26594+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5) != 0))
26595 bug_at((void *)entry->code, __LINE__);
26596 } else {
26597 code.jump = 0xe9;
26598 code.offset = entry->target -
26599 (entry->code + JUMP_LABEL_NOP_SIZE);
26600- if (unlikely(memcmp((void *)entry->code, &code, 5) != 0))
26601+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), &code, 5) != 0))
26602 bug_at((void *)entry->code, __LINE__);
26603 }
26604 memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
26605diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
26606index d6178d9..598681f 100644
26607--- a/arch/x86/kernel/kgdb.c
26608+++ b/arch/x86/kernel/kgdb.c
26609@@ -228,7 +228,10 @@ static void kgdb_correct_hw_break(void)
26610 bp->attr.bp_addr = breakinfo[breakno].addr;
26611 bp->attr.bp_len = breakinfo[breakno].len;
26612 bp->attr.bp_type = breakinfo[breakno].type;
26613- info->address = breakinfo[breakno].addr;
26614+ if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
26615+ info->address = ktla_ktva(breakinfo[breakno].addr);
26616+ else
26617+ info->address = breakinfo[breakno].addr;
26618 info->len = breakinfo[breakno].len;
26619 info->type = breakinfo[breakno].type;
26620 val = arch_install_hw_breakpoint(bp);
26621@@ -475,12 +478,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
26622 case 'k':
26623 /* clear the trace bit */
26624 linux_regs->flags &= ~X86_EFLAGS_TF;
26625- atomic_set(&kgdb_cpu_doing_single_step, -1);
26626+ atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
26627
26628 /* set the trace bit if we're stepping */
26629 if (remcomInBuffer[0] == 's') {
26630 linux_regs->flags |= X86_EFLAGS_TF;
26631- atomic_set(&kgdb_cpu_doing_single_step,
26632+ atomic_set_unchecked(&kgdb_cpu_doing_single_step,
26633 raw_smp_processor_id());
26634 }
26635
26636@@ -545,7 +548,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
26637
26638 switch (cmd) {
26639 case DIE_DEBUG:
26640- if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
26641+ if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
26642 if (user_mode(regs))
26643 return single_step_cont(regs, args);
26644 break;
26645@@ -750,11 +753,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
26646 #endif /* CONFIG_DEBUG_RODATA */
26647
26648 bpt->type = BP_BREAKPOINT;
26649- err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
26650+ err = probe_kernel_read(bpt->saved_instr, (const void *)ktla_ktva(bpt->bpt_addr),
26651 BREAK_INSTR_SIZE);
26652 if (err)
26653 return err;
26654- err = probe_kernel_write((char *)bpt->bpt_addr,
26655+ err = probe_kernel_write((void *)ktla_ktva(bpt->bpt_addr),
26656 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
26657 #ifdef CONFIG_DEBUG_RODATA
26658 if (!err)
26659@@ -767,7 +770,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
26660 return -EBUSY;
26661 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
26662 BREAK_INSTR_SIZE);
26663- err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
26664+ err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
26665 if (err)
26666 return err;
26667 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
26668@@ -792,13 +795,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
26669 if (mutex_is_locked(&text_mutex))
26670 goto knl_write;
26671 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
26672- err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
26673+ err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
26674 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
26675 goto knl_write;
26676 return err;
26677 knl_write:
26678 #endif /* CONFIG_DEBUG_RODATA */
26679- return probe_kernel_write((char *)bpt->bpt_addr,
26680+ return probe_kernel_write((void *)ktla_ktva(bpt->bpt_addr),
26681 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
26682 }
26683
26684diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
26685index 1deffe6..3be342a 100644
26686--- a/arch/x86/kernel/kprobes/core.c
26687+++ b/arch/x86/kernel/kprobes/core.c
26688@@ -120,9 +120,12 @@ __synthesize_relative_insn(void *from, void *to, u8 op)
26689 s32 raddr;
26690 } __packed *insn;
26691
26692- insn = (struct __arch_relative_insn *)from;
26693+ insn = (struct __arch_relative_insn *)ktla_ktva((unsigned long)from);
26694+
26695+ pax_open_kernel();
26696 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
26697 insn->op = op;
26698+ pax_close_kernel();
26699 }
26700
26701 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
26702@@ -168,7 +171,7 @@ int can_boost(kprobe_opcode_t *opcodes)
26703 kprobe_opcode_t opcode;
26704 kprobe_opcode_t *orig_opcodes = opcodes;
26705
26706- if (search_exception_tables((unsigned long)opcodes))
26707+ if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
26708 return 0; /* Page fault may occur on this address. */
26709
26710 retry:
26711@@ -260,12 +263,12 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
26712 * Fortunately, we know that the original code is the ideal 5-byte
26713 * long NOP.
26714 */
26715- memcpy(buf, (void *)addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
26716+ memcpy(buf, (void *)ktla_ktva(addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
26717 if (faddr)
26718 memcpy(buf, ideal_nops[NOP_ATOMIC5], 5);
26719 else
26720 buf[0] = kp->opcode;
26721- return (unsigned long)buf;
26722+ return ktva_ktla((unsigned long)buf);
26723 }
26724
26725 /*
26726@@ -367,7 +370,9 @@ int __copy_instruction(u8 *dest, u8 *src)
26727 /* Another subsystem puts a breakpoint, failed to recover */
26728 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
26729 return 0;
26730+ pax_open_kernel();
26731 memcpy(dest, insn.kaddr, length);
26732+ pax_close_kernel();
26733
26734 #ifdef CONFIG_X86_64
26735 if (insn_rip_relative(&insn)) {
26736@@ -394,7 +399,9 @@ int __copy_instruction(u8 *dest, u8 *src)
26737 return 0;
26738 }
26739 disp = (u8 *) dest + insn_offset_displacement(&insn);
26740+ pax_open_kernel();
26741 *(s32 *) disp = (s32) newdisp;
26742+ pax_close_kernel();
26743 }
26744 #endif
26745 return length;
26746@@ -536,7 +543,7 @@ static void setup_singlestep(struct kprobe *p, struct pt_regs *regs,
26747 * nor set current_kprobe, because it doesn't use single
26748 * stepping.
26749 */
26750- regs->ip = (unsigned long)p->ainsn.insn;
26751+ regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
26752 preempt_enable_no_resched();
26753 return;
26754 }
26755@@ -553,9 +560,9 @@ static void setup_singlestep(struct kprobe *p, struct pt_regs *regs,
26756 regs->flags &= ~X86_EFLAGS_IF;
26757 /* single step inline if the instruction is an int3 */
26758 if (p->opcode == BREAKPOINT_INSTRUCTION)
26759- regs->ip = (unsigned long)p->addr;
26760+ regs->ip = ktla_ktva((unsigned long)p->addr);
26761 else
26762- regs->ip = (unsigned long)p->ainsn.insn;
26763+ regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
26764 }
26765 NOKPROBE_SYMBOL(setup_singlestep);
26766
26767@@ -640,7 +647,7 @@ int kprobe_int3_handler(struct pt_regs *regs)
26768 setup_singlestep(p, regs, kcb, 0);
26769 return 1;
26770 }
26771- } else if (*addr != BREAKPOINT_INSTRUCTION) {
26772+ } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
26773 /*
26774 * The breakpoint instruction was removed right
26775 * after we hit it. Another cpu has removed
26776@@ -687,6 +694,9 @@ static void __used kretprobe_trampoline_holder(void)
26777 " movq %rax, 152(%rsp)\n"
26778 RESTORE_REGS_STRING
26779 " popfq\n"
26780+#ifdef KERNEXEC_PLUGIN
26781+ " btsq $63,(%rsp)\n"
26782+#endif
26783 #else
26784 " pushf\n"
26785 SAVE_REGS_STRING
26786@@ -827,7 +837,7 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs,
26787 struct kprobe_ctlblk *kcb)
26788 {
26789 unsigned long *tos = stack_addr(regs);
26790- unsigned long copy_ip = (unsigned long)p->ainsn.insn;
26791+ unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
26792 unsigned long orig_ip = (unsigned long)p->addr;
26793 kprobe_opcode_t *insn = p->ainsn.insn;
26794
26795diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
26796index 7b3b9d1..e2478b91 100644
26797--- a/arch/x86/kernel/kprobes/opt.c
26798+++ b/arch/x86/kernel/kprobes/opt.c
26799@@ -79,6 +79,7 @@ found:
26800 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
26801 static void synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
26802 {
26803+ pax_open_kernel();
26804 #ifdef CONFIG_X86_64
26805 *addr++ = 0x48;
26806 *addr++ = 0xbf;
26807@@ -86,6 +87,7 @@ static void synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
26808 *addr++ = 0xb8;
26809 #endif
26810 *(unsigned long *)addr = val;
26811+ pax_close_kernel();
26812 }
26813
26814 asm (
26815@@ -342,7 +344,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
26816 * Verify if the address gap is in 2GB range, because this uses
26817 * a relative jump.
26818 */
26819- rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
26820+ rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
26821 if (abs(rel) > 0x7fffffff) {
26822 __arch_remove_optimized_kprobe(op, 0);
26823 return -ERANGE;
26824@@ -359,16 +361,18 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
26825 op->optinsn.size = ret;
26826
26827 /* Copy arch-dep-instance from template */
26828- memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
26829+ pax_open_kernel();
26830+ memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
26831+ pax_close_kernel();
26832
26833 /* Set probe information */
26834 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
26835
26836 /* Set probe function call */
26837- synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
26838+ synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
26839
26840 /* Set returning jmp instruction at the tail of out-of-line buffer */
26841- synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
26842+ synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
26843 (u8 *)op->kp.addr + op->optinsn.size);
26844
26845 flush_icache_range((unsigned long) buf,
26846@@ -393,7 +397,7 @@ void arch_optimize_kprobes(struct list_head *oplist)
26847 WARN_ON(kprobe_disabled(&op->kp));
26848
26849 /* Backup instructions which will be replaced by jump address */
26850- memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
26851+ memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
26852 RELATIVE_ADDR_SIZE);
26853
26854 insn_buf[0] = RELATIVEJUMP_OPCODE;
26855@@ -441,7 +445,7 @@ int setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
26856 /* This kprobe is really able to run optimized path. */
26857 op = container_of(p, struct optimized_kprobe, kp);
26858 /* Detour through copied instructions */
26859- regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
26860+ regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
26861 if (!reenter)
26862 reset_current_kprobe();
26863 preempt_enable_no_resched();
26864diff --git a/arch/x86/kernel/ksysfs.c b/arch/x86/kernel/ksysfs.c
26865index c2bedae..25e7ab60 100644
26866--- a/arch/x86/kernel/ksysfs.c
26867+++ b/arch/x86/kernel/ksysfs.c
26868@@ -184,7 +184,7 @@ out:
26869
26870 static struct kobj_attribute type_attr = __ATTR_RO(type);
26871
26872-static struct bin_attribute data_attr = {
26873+static bin_attribute_no_const data_attr __read_only = {
26874 .attr = {
26875 .name = "data",
26876 .mode = S_IRUGO,
26877diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
26878index 49487b4..a94a0d3 100644
26879--- a/arch/x86/kernel/kvmclock.c
26880+++ b/arch/x86/kernel/kvmclock.c
26881@@ -29,7 +29,7 @@
26882 #include <asm/x86_init.h>
26883 #include <asm/reboot.h>
26884
26885-static int kvmclock = 1;
26886+static int kvmclock __read_only = 1;
26887 static int msr_kvm_system_time = MSR_KVM_SYSTEM_TIME;
26888 static int msr_kvm_wall_clock = MSR_KVM_WALL_CLOCK;
26889
26890@@ -41,7 +41,7 @@ static int parse_no_kvmclock(char *arg)
26891 early_param("no-kvmclock", parse_no_kvmclock);
26892
26893 /* The hypervisor will put information about time periodically here */
26894-static struct pvclock_vsyscall_time_info *hv_clock;
26895+static struct pvclock_vsyscall_time_info hv_clock[NR_CPUS] __page_aligned_bss;
26896 static struct pvclock_wall_clock wall_clock;
26897
26898 /*
26899@@ -132,7 +132,7 @@ bool kvm_check_and_clear_guest_paused(void)
26900 struct pvclock_vcpu_time_info *src;
26901 int cpu = smp_processor_id();
26902
26903- if (!hv_clock)
26904+ if (!kvmclock)
26905 return ret;
26906
26907 src = &hv_clock[cpu].pvti;
26908@@ -159,7 +159,7 @@ int kvm_register_clock(char *txt)
26909 int low, high, ret;
26910 struct pvclock_vcpu_time_info *src;
26911
26912- if (!hv_clock)
26913+ if (!kvmclock)
26914 return 0;
26915
26916 src = &hv_clock[cpu].pvti;
26917@@ -219,7 +219,6 @@ static void kvm_shutdown(void)
26918 void __init kvmclock_init(void)
26919 {
26920 struct pvclock_vcpu_time_info *vcpu_time;
26921- unsigned long mem;
26922 int size, cpu;
26923 u8 flags;
26924
26925@@ -237,15 +236,8 @@ void __init kvmclock_init(void)
26926 printk(KERN_INFO "kvm-clock: Using msrs %x and %x",
26927 msr_kvm_system_time, msr_kvm_wall_clock);
26928
26929- mem = memblock_alloc(size, PAGE_SIZE);
26930- if (!mem)
26931- return;
26932- hv_clock = __va(mem);
26933- memset(hv_clock, 0, size);
26934-
26935 if (kvm_register_clock("primary cpu clock")) {
26936- hv_clock = NULL;
26937- memblock_free(mem, size);
26938+ kvmclock = 0;
26939 return;
26940 }
26941 pv_time_ops.sched_clock = kvm_clock_read;
26942@@ -286,7 +278,7 @@ int __init kvm_setup_vsyscall_timeinfo(void)
26943 struct pvclock_vcpu_time_info *vcpu_time;
26944 unsigned int size;
26945
26946- if (!hv_clock)
26947+ if (!kvmclock)
26948 return 0;
26949
26950 size = PAGE_ALIGN(sizeof(struct pvclock_vsyscall_time_info)*NR_CPUS);
26951diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
26952index 2bcc052..864eb84 100644
26953--- a/arch/x86/kernel/ldt.c
26954+++ b/arch/x86/kernel/ldt.c
26955@@ -11,6 +11,7 @@
26956 #include <linux/sched.h>
26957 #include <linux/string.h>
26958 #include <linux/mm.h>
26959+#include <linux/ratelimit.h>
26960 #include <linux/smp.h>
26961 #include <linux/slab.h>
26962 #include <linux/vmalloc.h>
26963@@ -21,6 +22,14 @@
26964 #include <asm/mmu_context.h>
26965 #include <asm/syscalls.h>
26966
26967+#ifdef CONFIG_GRKERNSEC
26968+int sysctl_modify_ldt __read_only = 0;
26969+#elif defined(CONFIG_DEFAULT_MODIFY_LDT_SYSCALL)
26970+int sysctl_modify_ldt __read_only = 1;
26971+#else
26972+int sysctl_modify_ldt __read_only = 0;
26973+#endif
26974+
26975 /* context.lock is held for us, so we don't need any locking. */
26976 static void flush_ldt(void *current_mm)
26977 {
26978@@ -109,6 +118,23 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
26979 struct mm_struct *old_mm;
26980 int retval = 0;
26981
26982+ if (tsk == current) {
26983+ mm->context.vdso = 0;
26984+
26985+#ifdef CONFIG_X86_32
26986+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
26987+ mm->context.user_cs_base = 0UL;
26988+ mm->context.user_cs_limit = ~0UL;
26989+
26990+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
26991+ cpumask_clear(&mm->context.cpu_user_cs_mask);
26992+#endif
26993+
26994+#endif
26995+#endif
26996+
26997+ }
26998+
26999 mutex_init(&mm->context.lock);
27000 old_mm = current->mm;
27001 if (!old_mm) {
27002@@ -235,6 +261,14 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
27003 /* The user wants to clear the entry. */
27004 memset(&ldt, 0, sizeof(ldt));
27005 } else {
27006+
27007+#ifdef CONFIG_PAX_SEGMEXEC
27008+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
27009+ error = -EINVAL;
27010+ goto out;
27011+ }
27012+#endif
27013+
27014 if (!IS_ENABLED(CONFIG_X86_16BIT) && !ldt_info.seg_32bit) {
27015 error = -EINVAL;
27016 goto out;
27017@@ -276,6 +310,15 @@ asmlinkage int sys_modify_ldt(int func, void __user *ptr,
27018 {
27019 int ret = -ENOSYS;
27020
27021+ if (!sysctl_modify_ldt) {
27022+ printk_ratelimited(KERN_INFO
27023+ "Denied a call to modify_ldt() from %s[%d] (uid: %d)."
27024+ " Adjust sysctl if this was not an exploit attempt.\n",
27025+ current->comm, task_pid_nr(current),
27026+ from_kuid_munged(current_user_ns(), current_uid()));
27027+ return ret;
27028+ }
27029+
27030 switch (func) {
27031 case 0:
27032 ret = read_ldt(ptr, bytecount);
27033diff --git a/arch/x86/kernel/livepatch.c b/arch/x86/kernel/livepatch.c
27034index ff3c3101d..d7c0cd8 100644
27035--- a/arch/x86/kernel/livepatch.c
27036+++ b/arch/x86/kernel/livepatch.c
27037@@ -41,9 +41,10 @@ int klp_write_module_reloc(struct module *mod, unsigned long type,
27038 int ret, numpages, size = 4;
27039 bool readonly;
27040 unsigned long val;
27041- unsigned long core = (unsigned long)mod->module_core;
27042- unsigned long core_ro_size = mod->core_ro_size;
27043- unsigned long core_size = mod->core_size;
27044+ unsigned long core_rx = (unsigned long)mod->module_core_rx;
27045+ unsigned long core_rw = (unsigned long)mod->module_core_rw;
27046+ unsigned long core_size_rx = mod->core_size_rx;
27047+ unsigned long core_size_rw = mod->core_size_rw;
27048
27049 switch (type) {
27050 case R_X86_64_NONE:
27051@@ -66,11 +67,12 @@ int klp_write_module_reloc(struct module *mod, unsigned long type,
27052 return -EINVAL;
27053 }
27054
27055- if (loc < core || loc >= core + core_size)
27056+ if ((loc < core_rx || loc >= core_rx + core_size_rx) &&
27057+ (loc < core_rw || loc >= core_rw + core_size_rw))
27058 /* loc does not point to any symbol inside the module */
27059 return -EINVAL;
27060
27061- if (loc < core + core_ro_size)
27062+ if (loc < core_rx + core_size_rx)
27063 readonly = true;
27064 else
27065 readonly = false;
27066diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
27067index 469b23d..5449cfe 100644
27068--- a/arch/x86/kernel/machine_kexec_32.c
27069+++ b/arch/x86/kernel/machine_kexec_32.c
27070@@ -26,7 +26,7 @@
27071 #include <asm/cacheflush.h>
27072 #include <asm/debugreg.h>
27073
27074-static void set_idt(void *newidt, __u16 limit)
27075+static void set_idt(struct desc_struct *newidt, __u16 limit)
27076 {
27077 struct desc_ptr curidt;
27078
27079@@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
27080 }
27081
27082
27083-static void set_gdt(void *newgdt, __u16 limit)
27084+static void set_gdt(struct desc_struct *newgdt, __u16 limit)
27085 {
27086 struct desc_ptr curgdt;
27087
27088@@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
27089 }
27090
27091 control_page = page_address(image->control_code_page);
27092- memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
27093+ memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
27094
27095 relocate_kernel_ptr = control_page;
27096 page_list[PA_CONTROL_PAGE] = __pa(control_page);
27097diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S
27098index 94ea120..4154cea 100644
27099--- a/arch/x86/kernel/mcount_64.S
27100+++ b/arch/x86/kernel/mcount_64.S
27101@@ -7,7 +7,7 @@
27102 #include <linux/linkage.h>
27103 #include <asm/ptrace.h>
27104 #include <asm/ftrace.h>
27105-
27106+#include <asm/alternative-asm.h>
27107
27108 .code64
27109 .section .entry.text, "ax"
27110@@ -148,8 +148,9 @@
27111 #ifdef CONFIG_DYNAMIC_FTRACE
27112
27113 ENTRY(function_hook)
27114+ pax_force_retaddr
27115 retq
27116-END(function_hook)
27117+ENDPROC(function_hook)
27118
27119 ENTRY(ftrace_caller)
27120 /* save_mcount_regs fills in first two parameters */
27121@@ -181,8 +182,9 @@ GLOBAL(ftrace_graph_call)
27122 #endif
27123
27124 GLOBAL(ftrace_stub)
27125+ pax_force_retaddr
27126 retq
27127-END(ftrace_caller)
27128+ENDPROC(ftrace_caller)
27129
27130 ENTRY(ftrace_regs_caller)
27131 /* Save the current flags before any operations that can change them */
27132@@ -253,7 +255,7 @@ GLOBAL(ftrace_regs_caller_end)
27133
27134 jmp ftrace_return
27135
27136-END(ftrace_regs_caller)
27137+ENDPROC(ftrace_regs_caller)
27138
27139
27140 #else /* ! CONFIG_DYNAMIC_FTRACE */
27141@@ -272,18 +274,20 @@ fgraph_trace:
27142 #endif
27143
27144 GLOBAL(ftrace_stub)
27145+ pax_force_retaddr
27146 retq
27147
27148 trace:
27149 /* save_mcount_regs fills in first two parameters */
27150 save_mcount_regs
27151
27152+ pax_force_fptr ftrace_trace_function
27153 call *ftrace_trace_function
27154
27155 restore_mcount_regs
27156
27157 jmp fgraph_trace
27158-END(function_hook)
27159+ENDPROC(function_hook)
27160 #endif /* CONFIG_DYNAMIC_FTRACE */
27161 #endif /* CONFIG_FUNCTION_TRACER */
27162
27163@@ -305,8 +309,9 @@ ENTRY(ftrace_graph_caller)
27164
27165 restore_mcount_regs
27166
27167+ pax_force_retaddr
27168 retq
27169-END(ftrace_graph_caller)
27170+ENDPROC(ftrace_graph_caller)
27171
27172 GLOBAL(return_to_handler)
27173 subq $24, %rsp
27174@@ -322,5 +327,7 @@ GLOBAL(return_to_handler)
27175 movq 8(%rsp), %rdx
27176 movq (%rsp), %rax
27177 addq $24, %rsp
27178+ pax_force_fptr %rdi
27179 jmp *%rdi
27180+ENDPROC(return_to_handler)
27181 #endif
27182diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
27183index 005c03e..7000fe4 100644
27184--- a/arch/x86/kernel/module.c
27185+++ b/arch/x86/kernel/module.c
27186@@ -75,17 +75,17 @@ static unsigned long int get_module_load_offset(void)
27187 }
27188 #endif
27189
27190-void *module_alloc(unsigned long size)
27191+static inline void *__module_alloc(unsigned long size, pgprot_t prot)
27192 {
27193 void *p;
27194
27195- if (PAGE_ALIGN(size) > MODULES_LEN)
27196+ if (!size || PAGE_ALIGN(size) > MODULES_LEN)
27197 return NULL;
27198
27199 p = __vmalloc_node_range(size, MODULE_ALIGN,
27200 MODULES_VADDR + get_module_load_offset(),
27201- MODULES_END, GFP_KERNEL | __GFP_HIGHMEM,
27202- PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
27203+ MODULES_END, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO,
27204+ prot, 0, NUMA_NO_NODE,
27205 __builtin_return_address(0));
27206 if (p && (kasan_module_alloc(p, size) < 0)) {
27207 vfree(p);
27208@@ -95,6 +95,51 @@ void *module_alloc(unsigned long size)
27209 return p;
27210 }
27211
27212+void *module_alloc(unsigned long size)
27213+{
27214+
27215+#ifdef CONFIG_PAX_KERNEXEC
27216+ return __module_alloc(size, PAGE_KERNEL);
27217+#else
27218+ return __module_alloc(size, PAGE_KERNEL_EXEC);
27219+#endif
27220+
27221+}
27222+
27223+#ifdef CONFIG_PAX_KERNEXEC
27224+#ifdef CONFIG_X86_32
27225+void *module_alloc_exec(unsigned long size)
27226+{
27227+ struct vm_struct *area;
27228+
27229+ if (size == 0)
27230+ return NULL;
27231+
27232+ area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
27233+return area ? area->addr : NULL;
27234+}
27235+EXPORT_SYMBOL(module_alloc_exec);
27236+
27237+void module_memfree_exec(void *module_region)
27238+{
27239+ vunmap(module_region);
27240+}
27241+EXPORT_SYMBOL(module_memfree_exec);
27242+#else
27243+void module_memfree_exec(void *module_region)
27244+{
27245+ module_memfree(module_region);
27246+}
27247+EXPORT_SYMBOL(module_memfree_exec);
27248+
27249+void *module_alloc_exec(unsigned long size)
27250+{
27251+ return __module_alloc(size, PAGE_KERNEL_RX);
27252+}
27253+EXPORT_SYMBOL(module_alloc_exec);
27254+#endif
27255+#endif
27256+
27257 #ifdef CONFIG_X86_32
27258 int apply_relocate(Elf32_Shdr *sechdrs,
27259 const char *strtab,
27260@@ -105,14 +150,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
27261 unsigned int i;
27262 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
27263 Elf32_Sym *sym;
27264- uint32_t *location;
27265+ uint32_t *plocation, location;
27266
27267 DEBUGP("Applying relocate section %u to %u\n",
27268 relsec, sechdrs[relsec].sh_info);
27269 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
27270 /* This is where to make the change */
27271- location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
27272- + rel[i].r_offset;
27273+ plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
27274+ location = (uint32_t)plocation;
27275+ if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
27276+ plocation = (uint32_t *)ktla_ktva((unsigned long)plocation);
27277 /* This is the symbol it is referring to. Note that all
27278 undefined symbols have been resolved. */
27279 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
27280@@ -121,11 +168,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
27281 switch (ELF32_R_TYPE(rel[i].r_info)) {
27282 case R_386_32:
27283 /* We add the value into the location given */
27284- *location += sym->st_value;
27285+ pax_open_kernel();
27286+ *plocation += sym->st_value;
27287+ pax_close_kernel();
27288 break;
27289 case R_386_PC32:
27290 /* Add the value, subtract its position */
27291- *location += sym->st_value - (uint32_t)location;
27292+ pax_open_kernel();
27293+ *plocation += sym->st_value - location;
27294+ pax_close_kernel();
27295 break;
27296 default:
27297 pr_err("%s: Unknown relocation: %u\n",
27298@@ -170,21 +221,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
27299 case R_X86_64_NONE:
27300 break;
27301 case R_X86_64_64:
27302+ pax_open_kernel();
27303 *(u64 *)loc = val;
27304+ pax_close_kernel();
27305 break;
27306 case R_X86_64_32:
27307+ pax_open_kernel();
27308 *(u32 *)loc = val;
27309+ pax_close_kernel();
27310 if (val != *(u32 *)loc)
27311 goto overflow;
27312 break;
27313 case R_X86_64_32S:
27314+ pax_open_kernel();
27315 *(s32 *)loc = val;
27316+ pax_close_kernel();
27317 if ((s64)val != *(s32 *)loc)
27318 goto overflow;
27319 break;
27320 case R_X86_64_PC32:
27321 val -= (u64)loc;
27322+ pax_open_kernel();
27323 *(u32 *)loc = val;
27324+ pax_close_kernel();
27325+
27326 #if 0
27327 if ((s64)val != *(s32 *)loc)
27328 goto overflow;
27329diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
27330index 113e707..0a690e1 100644
27331--- a/arch/x86/kernel/msr.c
27332+++ b/arch/x86/kernel/msr.c
27333@@ -39,6 +39,7 @@
27334 #include <linux/notifier.h>
27335 #include <linux/uaccess.h>
27336 #include <linux/gfp.h>
27337+#include <linux/grsecurity.h>
27338
27339 #include <asm/processor.h>
27340 #include <asm/msr.h>
27341@@ -105,6 +106,11 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
27342 int err = 0;
27343 ssize_t bytes = 0;
27344
27345+#ifdef CONFIG_GRKERNSEC_KMEM
27346+ gr_handle_msr_write();
27347+ return -EPERM;
27348+#endif
27349+
27350 if (count % 8)
27351 return -EINVAL; /* Invalid chunk size */
27352
27353@@ -152,6 +158,10 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg)
27354 err = -EBADF;
27355 break;
27356 }
27357+#ifdef CONFIG_GRKERNSEC_KMEM
27358+ gr_handle_msr_write();
27359+ return -EPERM;
27360+#endif
27361 if (copy_from_user(&regs, uregs, sizeof regs)) {
27362 err = -EFAULT;
27363 break;
27364@@ -235,7 +245,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
27365 return notifier_from_errno(err);
27366 }
27367
27368-static struct notifier_block __refdata msr_class_cpu_notifier = {
27369+static struct notifier_block msr_class_cpu_notifier = {
27370 .notifier_call = msr_class_cpu_callback,
27371 };
27372
27373diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
27374index d05bd2e..f690edd 100644
27375--- a/arch/x86/kernel/nmi.c
27376+++ b/arch/x86/kernel/nmi.c
27377@@ -98,16 +98,16 @@ fs_initcall(nmi_warning_debugfs);
27378
27379 static void nmi_max_handler(struct irq_work *w)
27380 {
27381- struct nmiaction *a = container_of(w, struct nmiaction, irq_work);
27382+ struct nmiwork *n = container_of(w, struct nmiwork, irq_work);
27383 int remainder_ns, decimal_msecs;
27384- u64 whole_msecs = ACCESS_ONCE(a->max_duration);
27385+ u64 whole_msecs = ACCESS_ONCE(n->max_duration);
27386
27387 remainder_ns = do_div(whole_msecs, (1000 * 1000));
27388 decimal_msecs = remainder_ns / 1000;
27389
27390 printk_ratelimited(KERN_INFO
27391 "INFO: NMI handler (%ps) took too long to run: %lld.%03d msecs\n",
27392- a->handler, whole_msecs, decimal_msecs);
27393+ n->action->handler, whole_msecs, decimal_msecs);
27394 }
27395
27396 static int nmi_handle(unsigned int type, struct pt_regs *regs, bool b2b)
27397@@ -134,11 +134,11 @@ static int nmi_handle(unsigned int type, struct pt_regs *regs, bool b2b)
27398 delta = sched_clock() - delta;
27399 trace_nmi_handler(a->handler, (int)delta, thishandled);
27400
27401- if (delta < nmi_longest_ns || delta < a->max_duration)
27402+ if (delta < nmi_longest_ns || delta < a->work->max_duration)
27403 continue;
27404
27405- a->max_duration = delta;
27406- irq_work_queue(&a->irq_work);
27407+ a->work->max_duration = delta;
27408+ irq_work_queue(&a->work->irq_work);
27409 }
27410
27411 rcu_read_unlock();
27412@@ -148,7 +148,7 @@ static int nmi_handle(unsigned int type, struct pt_regs *regs, bool b2b)
27413 }
27414 NOKPROBE_SYMBOL(nmi_handle);
27415
27416-int __register_nmi_handler(unsigned int type, struct nmiaction *action)
27417+int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
27418 {
27419 struct nmi_desc *desc = nmi_to_desc(type);
27420 unsigned long flags;
27421@@ -156,7 +156,8 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
27422 if (!action->handler)
27423 return -EINVAL;
27424
27425- init_irq_work(&action->irq_work, nmi_max_handler);
27426+ action->work->action = action;
27427+ init_irq_work(&action->work->irq_work, nmi_max_handler);
27428
27429 spin_lock_irqsave(&desc->lock, flags);
27430
27431@@ -174,9 +175,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
27432 * event confuses some handlers (kdump uses this flag)
27433 */
27434 if (action->flags & NMI_FLAG_FIRST)
27435- list_add_rcu(&action->list, &desc->head);
27436+ pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
27437 else
27438- list_add_tail_rcu(&action->list, &desc->head);
27439+ pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
27440
27441 spin_unlock_irqrestore(&desc->lock, flags);
27442 return 0;
27443@@ -199,7 +200,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
27444 if (!strcmp(n->name, name)) {
27445 WARN(in_nmi(),
27446 "Trying to free NMI (%s) from NMI context!\n", n->name);
27447- list_del_rcu(&n->list);
27448+ pax_list_del_rcu((struct list_head *)&n->list);
27449 break;
27450 }
27451 }
27452@@ -481,6 +482,17 @@ static DEFINE_PER_CPU(int, update_debug_stack);
27453 dotraplinkage notrace void
27454 do_nmi(struct pt_regs *regs, long error_code)
27455 {
27456+
27457+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27458+ if (!user_mode(regs)) {
27459+ unsigned long cs = regs->cs & 0xFFFF;
27460+ unsigned long ip = ktva_ktla(regs->ip);
27461+
27462+ if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
27463+ regs->ip = ip;
27464+ }
27465+#endif
27466+
27467 if (this_cpu_read(nmi_state) != NMI_NOT_RUNNING) {
27468 this_cpu_write(nmi_state, NMI_LATCHED);
27469 return;
27470diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
27471index 6d9582e..f746287 100644
27472--- a/arch/x86/kernel/nmi_selftest.c
27473+++ b/arch/x86/kernel/nmi_selftest.c
27474@@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
27475 {
27476 /* trap all the unknown NMIs we may generate */
27477 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
27478- __initdata);
27479+ __initconst);
27480 }
27481
27482 static void __init cleanup_nmi_testsuite(void)
27483@@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
27484 unsigned long timeout;
27485
27486 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
27487- NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
27488+ NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
27489 nmi_fail = FAILURE;
27490 return;
27491 }
27492diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
27493index 33ee3e0..da3519a 100644
27494--- a/arch/x86/kernel/paravirt-spinlocks.c
27495+++ b/arch/x86/kernel/paravirt-spinlocks.c
27496@@ -23,7 +23,7 @@ bool pv_is_native_spin_unlock(void)
27497 }
27498 #endif
27499
27500-struct pv_lock_ops pv_lock_ops = {
27501+struct pv_lock_ops pv_lock_ops __read_only = {
27502 #ifdef CONFIG_SMP
27503 #ifdef CONFIG_QUEUED_SPINLOCKS
27504 .queued_spin_lock_slowpath = native_queued_spin_lock_slowpath,
27505diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
27506index ebb5657..dde2f45 100644
27507--- a/arch/x86/kernel/paravirt.c
27508+++ b/arch/x86/kernel/paravirt.c
27509@@ -64,6 +64,9 @@ u64 _paravirt_ident_64(u64 x)
27510 {
27511 return x;
27512 }
27513+#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
27514+PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
27515+#endif
27516
27517 void __init default_banner(void)
27518 {
27519@@ -150,16 +153,20 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
27520
27521 if (opfunc == NULL)
27522 /* If there's no function, patch it with a ud2a (BUG) */
27523- ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
27524- else if (opfunc == _paravirt_nop)
27525+ ret = paravirt_patch_insns(insnbuf, len, (const char *)ktva_ktla((unsigned long)ud2a), ud2a+sizeof(ud2a));
27526+ else if (opfunc == (void *)_paravirt_nop)
27527 /* If the operation is a nop, then nop the callsite */
27528 ret = paravirt_patch_nop();
27529
27530 /* identity functions just return their single argument */
27531- else if (opfunc == _paravirt_ident_32)
27532+ else if (opfunc == (void *)_paravirt_ident_32)
27533 ret = paravirt_patch_ident_32(insnbuf, len);
27534- else if (opfunc == _paravirt_ident_64)
27535+ else if (opfunc == (void *)_paravirt_ident_64)
27536 ret = paravirt_patch_ident_64(insnbuf, len);
27537+#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
27538+ else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
27539+ ret = paravirt_patch_ident_64(insnbuf, len);
27540+#endif
27541
27542 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
27543 #ifdef CONFIG_X86_32
27544@@ -186,7 +193,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
27545 if (insn_len > len || start == NULL)
27546 insn_len = len;
27547 else
27548- memcpy(insnbuf, start, insn_len);
27549+ memcpy(insnbuf, (const char *)ktla_ktva((unsigned long)start), insn_len);
27550
27551 return insn_len;
27552 }
27553@@ -310,7 +317,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
27554 return this_cpu_read(paravirt_lazy_mode);
27555 }
27556
27557-struct pv_info pv_info = {
27558+struct pv_info pv_info __read_only = {
27559 .name = "bare hardware",
27560 .paravirt_enabled = 0,
27561 .kernel_rpl = 0,
27562@@ -321,16 +328,16 @@ struct pv_info pv_info = {
27563 #endif
27564 };
27565
27566-struct pv_init_ops pv_init_ops = {
27567+struct pv_init_ops pv_init_ops __read_only = {
27568 .patch = native_patch,
27569 };
27570
27571-struct pv_time_ops pv_time_ops = {
27572+struct pv_time_ops pv_time_ops __read_only = {
27573 .sched_clock = native_sched_clock,
27574 .steal_clock = native_steal_clock,
27575 };
27576
27577-__visible struct pv_irq_ops pv_irq_ops = {
27578+__visible struct pv_irq_ops pv_irq_ops __read_only = {
27579 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
27580 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
27581 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
27582@@ -342,7 +349,7 @@ __visible struct pv_irq_ops pv_irq_ops = {
27583 #endif
27584 };
27585
27586-__visible struct pv_cpu_ops pv_cpu_ops = {
27587+__visible struct pv_cpu_ops pv_cpu_ops __read_only = {
27588 .cpuid = native_cpuid,
27589 .get_debugreg = native_get_debugreg,
27590 .set_debugreg = native_set_debugreg,
27591@@ -405,21 +412,26 @@ NOKPROBE_SYMBOL(native_get_debugreg);
27592 NOKPROBE_SYMBOL(native_set_debugreg);
27593 NOKPROBE_SYMBOL(native_load_idt);
27594
27595-struct pv_apic_ops pv_apic_ops = {
27596+struct pv_apic_ops pv_apic_ops __read_only= {
27597 #ifdef CONFIG_X86_LOCAL_APIC
27598 .startup_ipi_hook = paravirt_nop,
27599 #endif
27600 };
27601
27602-#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
27603+#ifdef CONFIG_X86_32
27604+#ifdef CONFIG_X86_PAE
27605+/* 64-bit pagetable entries */
27606+#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
27607+#else
27608 /* 32-bit pagetable entries */
27609 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
27610+#endif
27611 #else
27612 /* 64-bit pagetable entries */
27613 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
27614 #endif
27615
27616-struct pv_mmu_ops pv_mmu_ops = {
27617+struct pv_mmu_ops pv_mmu_ops __read_only = {
27618
27619 .read_cr2 = native_read_cr2,
27620 .write_cr2 = native_write_cr2,
27621@@ -469,6 +481,7 @@ struct pv_mmu_ops pv_mmu_ops = {
27622 .make_pud = PTE_IDENT,
27623
27624 .set_pgd = native_set_pgd,
27625+ .set_pgd_batched = native_set_pgd_batched,
27626 #endif
27627 #endif /* CONFIG_PGTABLE_LEVELS >= 3 */
27628
27629@@ -489,6 +502,12 @@ struct pv_mmu_ops pv_mmu_ops = {
27630 },
27631
27632 .set_fixmap = native_set_fixmap,
27633+
27634+#ifdef CONFIG_PAX_KERNEXEC
27635+ .pax_open_kernel = native_pax_open_kernel,
27636+ .pax_close_kernel = native_pax_close_kernel,
27637+#endif
27638+
27639 };
27640
27641 EXPORT_SYMBOL_GPL(pv_time_ops);
27642diff --git a/arch/x86/kernel/paravirt_patch_64.c b/arch/x86/kernel/paravirt_patch_64.c
27643index 8aa0558..465512e 100644
27644--- a/arch/x86/kernel/paravirt_patch_64.c
27645+++ b/arch/x86/kernel/paravirt_patch_64.c
27646@@ -9,7 +9,11 @@ DEF_NATIVE(pv_irq_ops, save_fl, "pushfq; popq %rax");
27647 DEF_NATIVE(pv_mmu_ops, read_cr2, "movq %cr2, %rax");
27648 DEF_NATIVE(pv_mmu_ops, read_cr3, "movq %cr3, %rax");
27649 DEF_NATIVE(pv_mmu_ops, write_cr3, "movq %rdi, %cr3");
27650+
27651+#ifndef CONFIG_PAX_MEMORY_UDEREF
27652 DEF_NATIVE(pv_mmu_ops, flush_tlb_single, "invlpg (%rdi)");
27653+#endif
27654+
27655 DEF_NATIVE(pv_cpu_ops, clts, "clts");
27656 DEF_NATIVE(pv_cpu_ops, wbinvd, "wbinvd");
27657
27658@@ -62,7 +66,11 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
27659 PATCH_SITE(pv_mmu_ops, read_cr3);
27660 PATCH_SITE(pv_mmu_ops, write_cr3);
27661 PATCH_SITE(pv_cpu_ops, clts);
27662+
27663+#ifndef CONFIG_PAX_MEMORY_UDEREF
27664 PATCH_SITE(pv_mmu_ops, flush_tlb_single);
27665+#endif
27666+
27667 PATCH_SITE(pv_cpu_ops, wbinvd);
27668 #if defined(CONFIG_PARAVIRT_SPINLOCKS) && defined(CONFIG_QUEUED_SPINLOCKS)
27669 case PARAVIRT_PATCH(pv_lock_ops.queued_spin_unlock):
27670diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
27671index 0497f71..7186c0d 100644
27672--- a/arch/x86/kernel/pci-calgary_64.c
27673+++ b/arch/x86/kernel/pci-calgary_64.c
27674@@ -1347,7 +1347,7 @@ static void __init get_tce_space_from_tar(void)
27675 tce_space = be64_to_cpu(readq(target));
27676 tce_space = tce_space & TAR_SW_BITS;
27677
27678- tce_space = tce_space & (~specified_table_size);
27679+ tce_space = tce_space & (~(unsigned long)specified_table_size);
27680 info->tce_space = (u64 *)__va(tce_space);
27681 }
27682 }
27683diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
27684index 35ccf75..7a15747 100644
27685--- a/arch/x86/kernel/pci-iommu_table.c
27686+++ b/arch/x86/kernel/pci-iommu_table.c
27687@@ -2,7 +2,7 @@
27688 #include <asm/iommu_table.h>
27689 #include <linux/string.h>
27690 #include <linux/kallsyms.h>
27691-
27692+#include <linux/sched.h>
27693
27694 #define DEBUG 1
27695
27696diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
27697index adf0392..88a7576 100644
27698--- a/arch/x86/kernel/pci-swiotlb.c
27699+++ b/arch/x86/kernel/pci-swiotlb.c
27700@@ -40,7 +40,7 @@ void x86_swiotlb_free_coherent(struct device *dev, size_t size,
27701 struct dma_attrs *attrs)
27702 {
27703 if (is_swiotlb_buffer(dma_to_phys(dev, dma_addr)))
27704- swiotlb_free_coherent(dev, size, vaddr, dma_addr);
27705+ swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
27706 else
27707 dma_generic_free_coherent(dev, size, vaddr, dma_addr, attrs);
27708 }
27709diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
27710index c27cad7..47e3f47 100644
27711--- a/arch/x86/kernel/process.c
27712+++ b/arch/x86/kernel/process.c
27713@@ -15,6 +15,7 @@
27714 #include <linux/dmi.h>
27715 #include <linux/utsname.h>
27716 #include <linux/stackprotector.h>
27717+#include <linux/kthread.h>
27718 #include <linux/tick.h>
27719 #include <linux/cpuidle.h>
27720 #include <trace/events/power.h>
27721@@ -37,7 +38,8 @@
27722 * section. Since TSS's are completely CPU-local, we want them
27723 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
27724 */
27725-__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss) = {
27726+struct tss_struct cpu_tss[NR_CPUS] __visible ____cacheline_internodealigned_in_smp = {
27727+ [0 ... NR_CPUS-1] = {
27728 .x86_tss = {
27729 .sp0 = TOP_OF_INIT_STACK,
27730 #ifdef CONFIG_X86_32
27731@@ -55,6 +57,7 @@ __visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss) = {
27732 */
27733 .io_bitmap = { [0 ... IO_BITMAP_LONGS] = ~0 },
27734 #endif
27735+}
27736 };
27737 EXPORT_PER_CPU_SYMBOL(cpu_tss);
27738
27739@@ -75,17 +78,35 @@ void idle_notifier_unregister(struct notifier_block *n)
27740 EXPORT_SYMBOL_GPL(idle_notifier_unregister);
27741 #endif
27742
27743+struct kmem_cache *fpregs_state_cachep;
27744+EXPORT_SYMBOL(fpregs_state_cachep);
27745+
27746+void __init arch_task_cache_init(void)
27747+{
27748+ /* create a slab on which task_structs can be allocated */
27749+ fpregs_state_cachep =
27750+ kmem_cache_create("fpregs_state", xstate_size,
27751+ ARCH_MIN_TASKALIGN, SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
27752+}
27753+
27754 /*
27755 * this gets called so that we can store lazy state into memory and copy the
27756 * current task into the new thread.
27757 */
27758 int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
27759 {
27760- memcpy(dst, src, arch_task_struct_size);
27761+ *dst = *src;
27762
27763+ dst->thread.fpu.state = kmem_cache_alloc_node(fpregs_state_cachep, GFP_KERNEL, tsk_fork_get_node(src));
27764 return fpu__copy(&dst->thread.fpu, &src->thread.fpu);
27765 }
27766
27767+void arch_release_task_struct(struct task_struct *tsk)
27768+{
27769+ kmem_cache_free(fpregs_state_cachep, tsk->thread.fpu.state);
27770+ tsk->thread.fpu.state = NULL;
27771+}
27772+
27773 /*
27774 * Free current thread data structures etc..
27775 */
27776@@ -97,7 +118,7 @@ void exit_thread(void)
27777 struct fpu *fpu = &t->fpu;
27778
27779 if (bp) {
27780- struct tss_struct *tss = &per_cpu(cpu_tss, get_cpu());
27781+ struct tss_struct *tss = cpu_tss + get_cpu();
27782
27783 t->io_bitmap_ptr = NULL;
27784 clear_thread_flag(TIF_IO_BITMAP);
27785@@ -117,6 +138,9 @@ void flush_thread(void)
27786 {
27787 struct task_struct *tsk = current;
27788
27789+#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
27790+ loadsegment(gs, 0);
27791+#endif
27792 flush_ptrace_hw_breakpoint(tsk);
27793 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
27794
27795@@ -258,7 +282,7 @@ static void __exit_idle(void)
27796 void exit_idle(void)
27797 {
27798 /* idle loop has pid 0 */
27799- if (current->pid)
27800+ if (task_pid_nr(current))
27801 return;
27802 __exit_idle();
27803 }
27804@@ -311,7 +335,7 @@ bool xen_set_default_idle(void)
27805 return ret;
27806 }
27807 #endif
27808-void stop_this_cpu(void *dummy)
27809+__noreturn void stop_this_cpu(void *dummy)
27810 {
27811 local_irq_disable();
27812 /*
27813@@ -488,16 +512,40 @@ static int __init idle_setup(char *str)
27814 }
27815 early_param("idle", idle_setup);
27816
27817-unsigned long arch_align_stack(unsigned long sp)
27818-{
27819- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
27820- sp -= get_random_int() % 8192;
27821- return sp & ~0xf;
27822-}
27823-
27824 unsigned long arch_randomize_brk(struct mm_struct *mm)
27825 {
27826 unsigned long range_end = mm->brk + 0x02000000;
27827 return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
27828 }
27829
27830+#ifdef CONFIG_PAX_RANDKSTACK
27831+void pax_randomize_kstack(struct pt_regs *regs)
27832+{
27833+ struct thread_struct *thread = &current->thread;
27834+ unsigned long time;
27835+
27836+ if (!randomize_va_space)
27837+ return;
27838+
27839+ if (v8086_mode(regs))
27840+ return;
27841+
27842+ rdtscl(time);
27843+
27844+ /* P4 seems to return a 0 LSB, ignore it */
27845+#ifdef CONFIG_MPENTIUM4
27846+ time &= 0x3EUL;
27847+ time <<= 2;
27848+#elif defined(CONFIG_X86_64)
27849+ time &= 0xFUL;
27850+ time <<= 4;
27851+#else
27852+ time &= 0x1FUL;
27853+ time <<= 3;
27854+#endif
27855+
27856+ thread->sp0 ^= time;
27857+ load_sp0(cpu_tss + smp_processor_id(), thread);
27858+ this_cpu_write(cpu_current_top_of_stack, thread->sp0);
27859+}
27860+#endif
27861diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
27862index f73c962..6589332 100644
27863--- a/arch/x86/kernel/process_32.c
27864+++ b/arch/x86/kernel/process_32.c
27865@@ -63,6 +63,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
27866 unsigned long thread_saved_pc(struct task_struct *tsk)
27867 {
27868 return ((unsigned long *)tsk->thread.sp)[3];
27869+//XXX return tsk->thread.eip;
27870 }
27871
27872 void __show_regs(struct pt_regs *regs, int all)
27873@@ -75,16 +76,15 @@ void __show_regs(struct pt_regs *regs, int all)
27874 if (user_mode(regs)) {
27875 sp = regs->sp;
27876 ss = regs->ss & 0xffff;
27877- gs = get_user_gs(regs);
27878 } else {
27879 sp = kernel_stack_pointer(regs);
27880 savesegment(ss, ss);
27881- savesegment(gs, gs);
27882 }
27883+ gs = get_user_gs(regs);
27884
27885 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
27886 (u16)regs->cs, regs->ip, regs->flags,
27887- smp_processor_id());
27888+ raw_smp_processor_id());
27889 print_symbol("EIP is at %s\n", regs->ip);
27890
27891 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
27892@@ -131,21 +131,22 @@ void release_thread(struct task_struct *dead_task)
27893 int copy_thread_tls(unsigned long clone_flags, unsigned long sp,
27894 unsigned long arg, struct task_struct *p, unsigned long tls)
27895 {
27896- struct pt_regs *childregs = task_pt_regs(p);
27897+ struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
27898 struct task_struct *tsk;
27899 int err;
27900
27901 p->thread.sp = (unsigned long) childregs;
27902 p->thread.sp0 = (unsigned long) (childregs+1);
27903+ p->tinfo.lowest_stack = (unsigned long)task_stack_page(p) + 2 * sizeof(unsigned long);
27904 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
27905
27906 if (unlikely(p->flags & PF_KTHREAD)) {
27907 /* kernel thread */
27908 memset(childregs, 0, sizeof(struct pt_regs));
27909 p->thread.ip = (unsigned long) ret_from_kernel_thread;
27910- task_user_gs(p) = __KERNEL_STACK_CANARY;
27911- childregs->ds = __USER_DS;
27912- childregs->es = __USER_DS;
27913+ savesegment(gs, childregs->gs);
27914+ childregs->ds = __KERNEL_DS;
27915+ childregs->es = __KERNEL_DS;
27916 childregs->fs = __KERNEL_PERCPU;
27917 childregs->bx = sp; /* function */
27918 childregs->bp = arg;
27919@@ -245,7 +246,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27920 struct fpu *prev_fpu = &prev->fpu;
27921 struct fpu *next_fpu = &next->fpu;
27922 int cpu = smp_processor_id();
27923- struct tss_struct *tss = &per_cpu(cpu_tss, cpu);
27924+ struct tss_struct *tss = cpu_tss + cpu;
27925 fpu_switch_t fpu_switch;
27926
27927 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
27928@@ -264,6 +265,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27929 */
27930 lazy_save_gs(prev->gs);
27931
27932+#ifdef CONFIG_PAX_MEMORY_UDEREF
27933+ __set_fs(task_thread_info(next_p)->addr_limit);
27934+#endif
27935+
27936 /*
27937 * Load the per-thread Thread-Local Storage descriptor.
27938 */
27939@@ -307,9 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27940 * current_thread_info().
27941 */
27942 load_sp0(tss, next);
27943- this_cpu_write(cpu_current_top_of_stack,
27944- (unsigned long)task_stack_page(next_p) +
27945- THREAD_SIZE);
27946+ this_cpu_write(current_task, next_p);
27947+ this_cpu_write(current_tinfo, &next_p->tinfo);
27948+ this_cpu_write(cpu_current_top_of_stack, next->sp0);
27949
27950 /*
27951 * Restore %gs if needed (which is common)
27952@@ -319,8 +324,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27953
27954 switch_fpu_finish(next_fpu, fpu_switch);
27955
27956- this_cpu_write(current_task, next_p);
27957-
27958 return prev_p;
27959 }
27960
27961@@ -350,4 +353,3 @@ unsigned long get_wchan(struct task_struct *p)
27962 } while (count++ < 16);
27963 return 0;
27964 }
27965-
27966diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
27967index a90ac95..ebac33e 100644
27968--- a/arch/x86/kernel/process_64.c
27969+++ b/arch/x86/kernel/process_64.c
27970@@ -157,9 +157,10 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long sp,
27971 struct pt_regs *childregs;
27972 struct task_struct *me = current;
27973
27974- p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
27975+ p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
27976 childregs = task_pt_regs(p);
27977 p->thread.sp = (unsigned long) childregs;
27978+ p->tinfo.lowest_stack = (unsigned long)task_stack_page(p) + 2 * sizeof(unsigned long);
27979 set_tsk_thread_flag(p, TIF_FORK);
27980 p->thread.io_bitmap_ptr = NULL;
27981
27982@@ -169,6 +170,8 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long sp,
27983 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
27984 savesegment(es, p->thread.es);
27985 savesegment(ds, p->thread.ds);
27986+ savesegment(ss, p->thread.ss);
27987+ BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
27988 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
27989
27990 if (unlikely(p->flags & PF_KTHREAD)) {
27991@@ -276,7 +279,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27992 struct fpu *prev_fpu = &prev->fpu;
27993 struct fpu *next_fpu = &next->fpu;
27994 int cpu = smp_processor_id();
27995- struct tss_struct *tss = &per_cpu(cpu_tss, cpu);
27996+ struct tss_struct *tss = cpu_tss + cpu;
27997 unsigned fsindex, gsindex;
27998 fpu_switch_t fpu_switch;
27999
28000@@ -327,6 +330,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
28001 if (unlikely(next->ds | prev->ds))
28002 loadsegment(ds, next->ds);
28003
28004+ savesegment(ss, prev->ss);
28005+ if (unlikely(next->ss != prev->ss))
28006+ loadsegment(ss, next->ss);
28007+
28008 /*
28009 * Switch FS and GS.
28010 *
28011@@ -398,6 +405,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
28012 * Switch the PDA and FPU contexts.
28013 */
28014 this_cpu_write(current_task, next_p);
28015+ this_cpu_write(current_tinfo, &next_p->tinfo);
28016
28017 /*
28018 * If it were not for PREEMPT_ACTIVE we could guarantee that the
28019@@ -410,6 +418,8 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
28020 /* Reload esp0 and ss1. This changes current_thread_info(). */
28021 load_sp0(tss, next);
28022
28023+ this_cpu_write(cpu_current_top_of_stack, next->sp0);
28024+
28025 /*
28026 * Now maybe reload the debug registers and handle I/O bitmaps
28027 */
28028@@ -510,7 +520,6 @@ unsigned long get_wchan(struct task_struct *p)
28029
28030 if (!p || p == current || p->state == TASK_RUNNING)
28031 return 0;
28032-
28033 start = (unsigned long)task_stack_page(p);
28034 if (!start)
28035 return 0;
28036@@ -535,7 +544,10 @@ unsigned long get_wchan(struct task_struct *p)
28037 */
28038 top = start + THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING;
28039 top -= 2 * sizeof(unsigned long);
28040- bottom = start + sizeof(struct thread_info);
28041+ /* not adding sizeof(thread_info) since it's not located on the stack
28042+ with PaX patched in
28043+ */
28044+ bottom = start;
28045
28046 sp = READ_ONCE(p->thread.sp);
28047 if (sp < bottom || sp > top)
28048diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
28049index 9be72bc..f4329c5 100644
28050--- a/arch/x86/kernel/ptrace.c
28051+++ b/arch/x86/kernel/ptrace.c
28052@@ -186,10 +186,10 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
28053 unsigned long sp = (unsigned long)&regs->sp;
28054 u32 *prev_esp;
28055
28056- if (context == (sp & ~(THREAD_SIZE - 1)))
28057+ if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
28058 return sp;
28059
28060- prev_esp = (u32 *)(context);
28061+ prev_esp = *(u32 **)(context);
28062 if (prev_esp)
28063 return (unsigned long)prev_esp;
28064
28065@@ -446,6 +446,20 @@ static int putreg(struct task_struct *child,
28066 if (child->thread.gs != value)
28067 return do_arch_prctl(child, ARCH_SET_GS, value);
28068 return 0;
28069+
28070+ case offsetof(struct user_regs_struct,ip):
28071+ /*
28072+ * Protect against any attempt to set ip to an
28073+ * impossible address. There are dragons lurking if the
28074+ * address is noncanonical. (This explicitly allows
28075+ * setting ip to TASK_SIZE_MAX, because user code can do
28076+ * that all by itself by running off the end of its
28077+ * address space.
28078+ */
28079+ if (value > TASK_SIZE_MAX)
28080+ return -EIO;
28081+ break;
28082+
28083 #endif
28084 }
28085
28086@@ -582,7 +596,7 @@ static void ptrace_triggered(struct perf_event *bp,
28087 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
28088 {
28089 int i;
28090- int dr7 = 0;
28091+ unsigned long dr7 = 0;
28092 struct arch_hw_breakpoint *info;
28093
28094 for (i = 0; i < HBP_NUM; i++) {
28095@@ -816,7 +830,7 @@ long arch_ptrace(struct task_struct *child, long request,
28096 unsigned long addr, unsigned long data)
28097 {
28098 int ret;
28099- unsigned long __user *datap = (unsigned long __user *)data;
28100+ unsigned long __user *datap = (__force unsigned long __user *)data;
28101
28102 switch (request) {
28103 /* read the word at location addr in the USER area. */
28104@@ -901,14 +915,14 @@ long arch_ptrace(struct task_struct *child, long request,
28105 if ((int) addr < 0)
28106 return -EIO;
28107 ret = do_get_thread_area(child, addr,
28108- (struct user_desc __user *)data);
28109+ (__force struct user_desc __user *) data);
28110 break;
28111
28112 case PTRACE_SET_THREAD_AREA:
28113 if ((int) addr < 0)
28114 return -EIO;
28115 ret = do_set_thread_area(child, addr,
28116- (struct user_desc __user *)data, 0);
28117+ (__force struct user_desc __user *) data, 0);
28118 break;
28119 #endif
28120
28121@@ -1286,7 +1300,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
28122
28123 #ifdef CONFIG_X86_64
28124
28125-static struct user_regset x86_64_regsets[] __read_mostly = {
28126+static user_regset_no_const x86_64_regsets[] __read_only = {
28127 [REGSET_GENERAL] = {
28128 .core_note_type = NT_PRSTATUS,
28129 .n = sizeof(struct user_regs_struct) / sizeof(long),
28130@@ -1327,7 +1341,7 @@ static const struct user_regset_view user_x86_64_view = {
28131 #endif /* CONFIG_X86_64 */
28132
28133 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
28134-static struct user_regset x86_32_regsets[] __read_mostly = {
28135+static user_regset_no_const x86_32_regsets[] __read_only = {
28136 [REGSET_GENERAL] = {
28137 .core_note_type = NT_PRSTATUS,
28138 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
28139@@ -1380,7 +1394,7 @@ static const struct user_regset_view user_x86_32_view = {
28140 */
28141 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
28142
28143-void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
28144+void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
28145 {
28146 #ifdef CONFIG_X86_64
28147 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
28148@@ -1415,7 +1429,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
28149 memset(info, 0, sizeof(*info));
28150 info->si_signo = SIGTRAP;
28151 info->si_code = si_code;
28152- info->si_addr = user_mode(regs) ? (void __user *)regs->ip : NULL;
28153+ info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
28154 }
28155
28156 void user_single_step_siginfo(struct task_struct *tsk,
28157@@ -1449,6 +1463,10 @@ static void do_audit_syscall_entry(struct pt_regs *regs, u32 arch)
28158 }
28159 }
28160
28161+#ifdef CONFIG_GRKERNSEC_SETXID
28162+extern void gr_delayed_cred_worker(void);
28163+#endif
28164+
28165 /*
28166 * We can return 0 to resume the syscall or anything else to go to phase
28167 * 2. If we resume the syscall, we need to put something appropriate in
28168@@ -1556,6 +1574,11 @@ long syscall_trace_enter_phase2(struct pt_regs *regs, u32 arch,
28169
28170 BUG_ON(regs != task_pt_regs(current));
28171
28172+#ifdef CONFIG_GRKERNSEC_SETXID
28173+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
28174+ gr_delayed_cred_worker();
28175+#endif
28176+
28177 /*
28178 * If we stepped into a sysenter/syscall insn, it trapped in
28179 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
28180@@ -1614,6 +1637,11 @@ void syscall_trace_leave(struct pt_regs *regs)
28181 */
28182 user_exit();
28183
28184+#ifdef CONFIG_GRKERNSEC_SETXID
28185+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
28186+ gr_delayed_cred_worker();
28187+#endif
28188+
28189 audit_syscall_exit(regs);
28190
28191 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
28192diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
28193index 2f355d2..e75ed0a 100644
28194--- a/arch/x86/kernel/pvclock.c
28195+++ b/arch/x86/kernel/pvclock.c
28196@@ -51,11 +51,11 @@ void pvclock_touch_watchdogs(void)
28197 reset_hung_task_detector();
28198 }
28199
28200-static atomic64_t last_value = ATOMIC64_INIT(0);
28201+static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
28202
28203 void pvclock_resume(void)
28204 {
28205- atomic64_set(&last_value, 0);
28206+ atomic64_set_unchecked(&last_value, 0);
28207 }
28208
28209 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
28210@@ -105,11 +105,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
28211 * updating at the same time, and one of them could be slightly behind,
28212 * making the assumption that last_value always go forward fail to hold.
28213 */
28214- last = atomic64_read(&last_value);
28215+ last = atomic64_read_unchecked(&last_value);
28216 do {
28217 if (ret < last)
28218 return last;
28219- last = atomic64_cmpxchg(&last_value, last, ret);
28220+ last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
28221 } while (unlikely(last != ret));
28222
28223 return ret;
28224diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
28225index 86db4bc..a50a54a 100644
28226--- a/arch/x86/kernel/reboot.c
28227+++ b/arch/x86/kernel/reboot.c
28228@@ -70,6 +70,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
28229
28230 void __noreturn machine_real_restart(unsigned int type)
28231 {
28232+
28233+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
28234+ struct desc_struct *gdt;
28235+#endif
28236+
28237 local_irq_disable();
28238
28239 /*
28240@@ -97,7 +102,29 @@ void __noreturn machine_real_restart(unsigned int type)
28241
28242 /* Jump to the identity-mapped low memory code */
28243 #ifdef CONFIG_X86_32
28244- asm volatile("jmpl *%0" : :
28245+
28246+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
28247+ gdt = get_cpu_gdt_table(smp_processor_id());
28248+ pax_open_kernel();
28249+#ifdef CONFIG_PAX_MEMORY_UDEREF
28250+ gdt[GDT_ENTRY_KERNEL_DS].type = 3;
28251+ gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
28252+ loadsegment(ds, __KERNEL_DS);
28253+ loadsegment(es, __KERNEL_DS);
28254+ loadsegment(ss, __KERNEL_DS);
28255+#endif
28256+#ifdef CONFIG_PAX_KERNEXEC
28257+ gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
28258+ gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
28259+ gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
28260+ gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
28261+ gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
28262+ gdt[GDT_ENTRY_KERNEL_CS].g = 1;
28263+#endif
28264+ pax_close_kernel();
28265+#endif
28266+
28267+ asm volatile("ljmpl *%0" : :
28268 "rm" (real_mode_header->machine_real_restart_asm),
28269 "a" (type));
28270 #else
28271@@ -137,7 +164,7 @@ static int __init set_kbd_reboot(const struct dmi_system_id *d)
28272 /*
28273 * This is a single dmi_table handling all reboot quirks.
28274 */
28275-static struct dmi_system_id __initdata reboot_dmi_table[] = {
28276+static const struct dmi_system_id __initconst reboot_dmi_table[] = {
28277
28278 /* Acer */
28279 { /* Handle reboot issue on Acer Aspire one */
28280@@ -511,7 +538,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
28281 * This means that this function can never return, it can misbehave
28282 * by not rebooting properly and hanging.
28283 */
28284-static void native_machine_emergency_restart(void)
28285+static void __noreturn native_machine_emergency_restart(void)
28286 {
28287 int i;
28288 int attempt = 0;
28289@@ -631,13 +658,13 @@ void native_machine_shutdown(void)
28290 #endif
28291 }
28292
28293-static void __machine_emergency_restart(int emergency)
28294+static void __noreturn __machine_emergency_restart(int emergency)
28295 {
28296 reboot_emergency = emergency;
28297 machine_ops.emergency_restart();
28298 }
28299
28300-static void native_machine_restart(char *__unused)
28301+static void __noreturn native_machine_restart(char *__unused)
28302 {
28303 pr_notice("machine restart\n");
28304
28305@@ -646,7 +673,7 @@ static void native_machine_restart(char *__unused)
28306 __machine_emergency_restart(0);
28307 }
28308
28309-static void native_machine_halt(void)
28310+static void __noreturn native_machine_halt(void)
28311 {
28312 /* Stop other cpus and apics */
28313 machine_shutdown();
28314@@ -656,7 +683,7 @@ static void native_machine_halt(void)
28315 stop_this_cpu(NULL);
28316 }
28317
28318-static void native_machine_power_off(void)
28319+static void __noreturn native_machine_power_off(void)
28320 {
28321 if (pm_power_off) {
28322 if (!reboot_force)
28323@@ -665,9 +692,10 @@ static void native_machine_power_off(void)
28324 }
28325 /* A fallback in case there is no PM info available */
28326 tboot_shutdown(TB_SHUTDOWN_HALT);
28327+ unreachable();
28328 }
28329
28330-struct machine_ops machine_ops = {
28331+struct machine_ops machine_ops __read_only = {
28332 .power_off = native_machine_power_off,
28333 .shutdown = native_machine_shutdown,
28334 .emergency_restart = native_machine_emergency_restart,
28335diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
28336index c8e41e9..64049ef 100644
28337--- a/arch/x86/kernel/reboot_fixups_32.c
28338+++ b/arch/x86/kernel/reboot_fixups_32.c
28339@@ -57,7 +57,7 @@ struct device_fixup {
28340 unsigned int vendor;
28341 unsigned int device;
28342 void (*reboot_fixup)(struct pci_dev *);
28343-};
28344+} __do_const;
28345
28346 /*
28347 * PCI ids solely used for fixups_table go here
28348diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
28349index 98111b3..73ca125 100644
28350--- a/arch/x86/kernel/relocate_kernel_64.S
28351+++ b/arch/x86/kernel/relocate_kernel_64.S
28352@@ -96,8 +96,7 @@ relocate_kernel:
28353
28354 /* jump to identity mapped page */
28355 addq $(identity_mapped - relocate_kernel), %r8
28356- pushq %r8
28357- ret
28358+ jmp *%r8
28359
28360 identity_mapped:
28361 /* set return address to 0 if not preserving context */
28362diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
28363index 80f874b..b3eff67 100644
28364--- a/arch/x86/kernel/setup.c
28365+++ b/arch/x86/kernel/setup.c
28366@@ -111,6 +111,7 @@
28367 #include <asm/mce.h>
28368 #include <asm/alternative.h>
28369 #include <asm/prom.h>
28370+#include <asm/boot.h>
28371
28372 /*
28373 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
28374@@ -206,10 +207,12 @@ EXPORT_SYMBOL(boot_cpu_data);
28375 #endif
28376
28377
28378-#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
28379-__visible unsigned long mmu_cr4_features;
28380+#ifdef CONFIG_X86_64
28381+__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
28382+#elif defined(CONFIG_X86_PAE)
28383+__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
28384 #else
28385-__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
28386+__visible unsigned long mmu_cr4_features __read_only;
28387 #endif
28388
28389 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
28390@@ -772,7 +775,7 @@ static void __init trim_bios_range(void)
28391 * area (640->1Mb) as ram even though it is not.
28392 * take them out.
28393 */
28394- e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
28395+ e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
28396
28397 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
28398 }
28399@@ -780,7 +783,7 @@ static void __init trim_bios_range(void)
28400 /* called before trim_bios_range() to spare extra sanitize */
28401 static void __init e820_add_kernel_range(void)
28402 {
28403- u64 start = __pa_symbol(_text);
28404+ u64 start = __pa_symbol(ktla_ktva((unsigned long)_text));
28405 u64 size = __pa_symbol(_end) - start;
28406
28407 /*
28408@@ -861,8 +864,8 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
28409
28410 void __init setup_arch(char **cmdline_p)
28411 {
28412- memblock_reserve(__pa_symbol(_text),
28413- (unsigned long)__bss_stop - (unsigned long)_text);
28414+ memblock_reserve(__pa_symbol(ktla_ktva((unsigned long)_text)),
28415+ (unsigned long)__bss_stop - ktla_ktva((unsigned long)_text));
28416
28417 early_reserve_initrd();
28418
28419@@ -960,16 +963,16 @@ void __init setup_arch(char **cmdline_p)
28420
28421 if (!boot_params.hdr.root_flags)
28422 root_mountflags &= ~MS_RDONLY;
28423- init_mm.start_code = (unsigned long) _text;
28424- init_mm.end_code = (unsigned long) _etext;
28425- init_mm.end_data = (unsigned long) _edata;
28426+ init_mm.start_code = ktla_ktva((unsigned long)_text);
28427+ init_mm.end_code = ktla_ktva((unsigned long)_etext);
28428+ init_mm.end_data = (unsigned long)_edata;
28429 init_mm.brk = _brk_end;
28430
28431 mpx_mm_init(&init_mm);
28432
28433- code_resource.start = __pa_symbol(_text);
28434- code_resource.end = __pa_symbol(_etext)-1;
28435- data_resource.start = __pa_symbol(_etext);
28436+ code_resource.start = __pa_symbol(ktla_ktva((unsigned long)_text));
28437+ code_resource.end = __pa_symbol(ktla_ktva((unsigned long)_etext))-1;
28438+ data_resource.start = __pa_symbol(_sdata);
28439 data_resource.end = __pa_symbol(_edata)-1;
28440 bss_resource.start = __pa_symbol(__bss_start);
28441 bss_resource.end = __pa_symbol(__bss_stop)-1;
28442diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
28443index e4fcb87..9c06c55 100644
28444--- a/arch/x86/kernel/setup_percpu.c
28445+++ b/arch/x86/kernel/setup_percpu.c
28446@@ -21,19 +21,17 @@
28447 #include <asm/cpu.h>
28448 #include <asm/stackprotector.h>
28449
28450-DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
28451+#ifdef CONFIG_SMP
28452+DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
28453 EXPORT_PER_CPU_SYMBOL(cpu_number);
28454+#endif
28455
28456-#ifdef CONFIG_X86_64
28457 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
28458-#else
28459-#define BOOT_PERCPU_OFFSET 0
28460-#endif
28461
28462 DEFINE_PER_CPU_READ_MOSTLY(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
28463 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
28464
28465-unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
28466+unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
28467 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
28468 };
28469 EXPORT_SYMBOL(__per_cpu_offset);
28470@@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
28471 {
28472 #ifdef CONFIG_NEED_MULTIPLE_NODES
28473 pg_data_t *last = NULL;
28474- unsigned int cpu;
28475+ int cpu;
28476
28477 for_each_possible_cpu(cpu) {
28478 int node = early_cpu_to_node(cpu);
28479@@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
28480 {
28481 #ifdef CONFIG_X86_32
28482 struct desc_struct gdt;
28483+ unsigned long base = per_cpu_offset(cpu);
28484
28485- pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
28486- 0x2 | DESCTYPE_S, 0x8);
28487- gdt.s = 1;
28488+ pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
28489+ 0x83 | DESCTYPE_S, 0xC);
28490 write_gdt_entry(get_cpu_gdt_table(cpu),
28491 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
28492 #endif
28493@@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
28494 /* alrighty, percpu areas up and running */
28495 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
28496 for_each_possible_cpu(cpu) {
28497+#ifdef CONFIG_CC_STACKPROTECTOR
28498+#ifdef CONFIG_X86_32
28499+ unsigned long canary = per_cpu(stack_canary.canary, cpu);
28500+#endif
28501+#endif
28502 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
28503 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
28504 per_cpu(cpu_number, cpu) = cpu;
28505@@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
28506 */
28507 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
28508 #endif
28509+#ifdef CONFIG_CC_STACKPROTECTOR
28510+#ifdef CONFIG_X86_32
28511+ if (!cpu)
28512+ per_cpu(stack_canary.canary, cpu) = canary;
28513+#endif
28514+#endif
28515 /*
28516 * Up to this point, the boot CPU has been using .init.data
28517 * area. Reload any changed state for the boot CPU.
28518diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
28519index 71820c4..ad16f6b 100644
28520--- a/arch/x86/kernel/signal.c
28521+++ b/arch/x86/kernel/signal.c
28522@@ -189,7 +189,7 @@ static unsigned long align_sigframe(unsigned long sp)
28523 * Align the stack pointer according to the i386 ABI,
28524 * i.e. so that on function entry ((sp + 4) & 15) == 0.
28525 */
28526- sp = ((sp + 4) & -16ul) - 4;
28527+ sp = ((sp - 12) & -16ul) - 4;
28528 #else /* !CONFIG_X86_32 */
28529 sp = round_down(sp, 16) - 8;
28530 #endif
28531@@ -298,10 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
28532 }
28533
28534 if (current->mm->context.vdso)
28535- restorer = current->mm->context.vdso +
28536- selected_vdso32->sym___kernel_sigreturn;
28537+ restorer = (void __force_user *)(current->mm->context.vdso + selected_vdso32->sym___kernel_sigreturn);
28538 else
28539- restorer = &frame->retcode;
28540+ restorer = (void __user *)&frame->retcode;
28541 if (ksig->ka.sa.sa_flags & SA_RESTORER)
28542 restorer = ksig->ka.sa.sa_restorer;
28543
28544@@ -315,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
28545 * reasons and because gdb uses it as a signature to notice
28546 * signal handler stack frames.
28547 */
28548- err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
28549+ err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
28550
28551 if (err)
28552 return -EFAULT;
28553@@ -362,8 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
28554 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
28555
28556 /* Set up to return from userspace. */
28557- restorer = current->mm->context.vdso +
28558- selected_vdso32->sym___kernel_rt_sigreturn;
28559+ if (current->mm->context.vdso)
28560+ restorer = (void __force_user *)(current->mm->context.vdso + selected_vdso32->sym___kernel_rt_sigreturn);
28561+ else
28562+ restorer = (void __user *)&frame->retcode;
28563 if (ksig->ka.sa.sa_flags & SA_RESTORER)
28564 restorer = ksig->ka.sa.sa_restorer;
28565 put_user_ex(restorer, &frame->pretcode);
28566@@ -375,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
28567 * reasons and because gdb uses it as a signature to notice
28568 * signal handler stack frames.
28569 */
28570- put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
28571+ put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
28572 } put_user_catch(err);
28573
28574 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
28575@@ -611,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
28576 {
28577 int usig = ksig->sig;
28578 sigset_t *set = sigmask_to_save();
28579- compat_sigset_t *cset = (compat_sigset_t *) set;
28580+ sigset_t sigcopy;
28581+ compat_sigset_t *cset;
28582+
28583+ sigcopy = *set;
28584+
28585+ cset = (compat_sigset_t *) &sigcopy;
28586
28587 /* Set up the stack frame */
28588 if (is_ia32_frame()) {
28589@@ -622,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
28590 } else if (is_x32_frame()) {
28591 return x32_setup_rt_frame(ksig, cset, regs);
28592 } else {
28593- return __setup_rt_frame(ksig->sig, ksig, set, regs);
28594+ return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
28595 }
28596 }
28597
28598diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
28599index 15aaa69..66103af 100644
28600--- a/arch/x86/kernel/smp.c
28601+++ b/arch/x86/kernel/smp.c
28602@@ -334,7 +334,7 @@ static int __init nonmi_ipi_setup(char *str)
28603
28604 __setup("nonmi_ipi", nonmi_ipi_setup);
28605
28606-struct smp_ops smp_ops = {
28607+struct smp_ops smp_ops __read_only = {
28608 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
28609 .smp_prepare_cpus = native_smp_prepare_cpus,
28610 .smp_cpus_done = native_smp_cpus_done,
28611diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
28612index b1f3ed9c..b76221b 100644
28613--- a/arch/x86/kernel/smpboot.c
28614+++ b/arch/x86/kernel/smpboot.c
28615@@ -220,14 +220,17 @@ static void notrace start_secondary(void *unused)
28616
28617 enable_start_cpu0 = 0;
28618
28619-#ifdef CONFIG_X86_32
28620+ /* otherwise gcc will move up smp_processor_id before the cpu_init */
28621+ barrier();
28622+
28623 /* switch away from the initial page table */
28624+#ifdef CONFIG_PAX_PER_CPU_PGD
28625+ load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
28626+#else
28627 load_cr3(swapper_pg_dir);
28628+#endif
28629 __flush_tlb_all();
28630-#endif
28631
28632- /* otherwise gcc will move up smp_processor_id before the cpu_init */
28633- barrier();
28634 /*
28635 * Check TSC synchronization with the BP:
28636 */
28637@@ -808,16 +811,15 @@ void common_cpu_up(unsigned int cpu, struct task_struct *idle)
28638 alternatives_enable_smp();
28639
28640 per_cpu(current_task, cpu) = idle;
28641+ per_cpu(current_tinfo, cpu) = &idle->tinfo;
28642
28643 #ifdef CONFIG_X86_32
28644- /* Stack for startup_32 can be just as for start_secondary onwards */
28645 irq_ctx_init(cpu);
28646- per_cpu(cpu_current_top_of_stack, cpu) =
28647- (unsigned long)task_stack_page(idle) + THREAD_SIZE;
28648 #else
28649 clear_tsk_thread_flag(idle, TIF_FORK);
28650 initial_gs = per_cpu_offset(cpu);
28651 #endif
28652+ per_cpu(cpu_current_top_of_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
28653 }
28654
28655 /*
28656@@ -838,9 +840,11 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
28657 unsigned long timeout;
28658
28659 idle->thread.sp = (unsigned long) (((struct pt_regs *)
28660- (THREAD_SIZE + task_stack_page(idle))) - 1);
28661+ (THREAD_SIZE - 16 + task_stack_page(idle))) - 1);
28662
28663+ pax_open_kernel();
28664 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
28665+ pax_close_kernel();
28666 initial_code = (unsigned long)start_secondary;
28667 stack_start = idle->thread.sp;
28668
28669@@ -992,6 +996,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
28670
28671 common_cpu_up(cpu, tidle);
28672
28673+#ifdef CONFIG_PAX_PER_CPU_PGD
28674+ clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
28675+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28676+ KERNEL_PGD_PTRS);
28677+ clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
28678+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28679+ KERNEL_PGD_PTRS);
28680+#endif
28681+
28682 /*
28683 * We have to walk the irq descriptors to setup the vector
28684 * space for the cpu which comes online. Prevent irq
28685diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
28686index 0ccb53a..fbc4759 100644
28687--- a/arch/x86/kernel/step.c
28688+++ b/arch/x86/kernel/step.c
28689@@ -44,7 +44,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
28690 addr += base;
28691 }
28692 mutex_unlock(&child->mm->context.lock);
28693- }
28694+ } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
28695+ addr = ktla_ktva(addr);
28696
28697 return addr;
28698 }
28699@@ -55,6 +56,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
28700 unsigned char opcode[15];
28701 unsigned long addr = convert_ip_to_linear(child, regs);
28702
28703+ if (addr == -EINVAL)
28704+ return 0;
28705+
28706 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
28707 for (i = 0; i < copied; i++) {
28708 switch (opcode[i]) {
28709diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
28710new file mode 100644
28711index 0000000..5877189
28712--- /dev/null
28713+++ b/arch/x86/kernel/sys_i386_32.c
28714@@ -0,0 +1,189 @@
28715+/*
28716+ * This file contains various random system calls that
28717+ * have a non-standard calling sequence on the Linux/i386
28718+ * platform.
28719+ */
28720+
28721+#include <linux/errno.h>
28722+#include <linux/sched.h>
28723+#include <linux/mm.h>
28724+#include <linux/fs.h>
28725+#include <linux/smp.h>
28726+#include <linux/sem.h>
28727+#include <linux/msg.h>
28728+#include <linux/shm.h>
28729+#include <linux/stat.h>
28730+#include <linux/syscalls.h>
28731+#include <linux/mman.h>
28732+#include <linux/file.h>
28733+#include <linux/utsname.h>
28734+#include <linux/ipc.h>
28735+#include <linux/elf.h>
28736+
28737+#include <linux/uaccess.h>
28738+#include <linux/unistd.h>
28739+
28740+#include <asm/syscalls.h>
28741+
28742+int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
28743+{
28744+ unsigned long pax_task_size = TASK_SIZE;
28745+
28746+#ifdef CONFIG_PAX_SEGMEXEC
28747+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
28748+ pax_task_size = SEGMEXEC_TASK_SIZE;
28749+#endif
28750+
28751+ if (flags & MAP_FIXED)
28752+ if (len > pax_task_size || addr > pax_task_size - len)
28753+ return -EINVAL;
28754+
28755+ return 0;
28756+}
28757+
28758+/*
28759+ * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
28760+ */
28761+static unsigned long get_align_mask(void)
28762+{
28763+ if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
28764+ return 0;
28765+
28766+ if (!(current->flags & PF_RANDOMIZE))
28767+ return 0;
28768+
28769+ return va_align.mask;
28770+}
28771+
28772+unsigned long
28773+arch_get_unmapped_area(struct file *filp, unsigned long addr,
28774+ unsigned long len, unsigned long pgoff, unsigned long flags)
28775+{
28776+ struct mm_struct *mm = current->mm;
28777+ struct vm_area_struct *vma;
28778+ unsigned long pax_task_size = TASK_SIZE;
28779+ struct vm_unmapped_area_info info;
28780+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
28781+
28782+#ifdef CONFIG_PAX_SEGMEXEC
28783+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
28784+ pax_task_size = SEGMEXEC_TASK_SIZE;
28785+#endif
28786+
28787+ pax_task_size -= PAGE_SIZE;
28788+
28789+ if (len > pax_task_size)
28790+ return -ENOMEM;
28791+
28792+ if (flags & MAP_FIXED)
28793+ return addr;
28794+
28795+#ifdef CONFIG_PAX_RANDMMAP
28796+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28797+#endif
28798+
28799+ if (addr) {
28800+ addr = PAGE_ALIGN(addr);
28801+ if (pax_task_size - len >= addr) {
28802+ vma = find_vma(mm, addr);
28803+ if (check_heap_stack_gap(vma, addr, len, offset))
28804+ return addr;
28805+ }
28806+ }
28807+
28808+ info.flags = 0;
28809+ info.length = len;
28810+ info.align_mask = filp ? get_align_mask() : 0;
28811+ info.align_offset = pgoff << PAGE_SHIFT;
28812+ info.threadstack_offset = offset;
28813+
28814+#ifdef CONFIG_PAX_PAGEEXEC
28815+ if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
28816+ info.low_limit = 0x00110000UL;
28817+ info.high_limit = mm->start_code;
28818+
28819+#ifdef CONFIG_PAX_RANDMMAP
28820+ if (mm->pax_flags & MF_PAX_RANDMMAP)
28821+ info.low_limit += mm->delta_mmap & 0x03FFF000UL;
28822+#endif
28823+
28824+ if (info.low_limit < info.high_limit) {
28825+ addr = vm_unmapped_area(&info);
28826+ if (!IS_ERR_VALUE(addr))
28827+ return addr;
28828+ }
28829+ } else
28830+#endif
28831+
28832+ info.low_limit = mm->mmap_base;
28833+ info.high_limit = pax_task_size;
28834+
28835+ return vm_unmapped_area(&info);
28836+}
28837+
28838+unsigned long
28839+arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
28840+ const unsigned long len, const unsigned long pgoff,
28841+ const unsigned long flags)
28842+{
28843+ struct vm_area_struct *vma;
28844+ struct mm_struct *mm = current->mm;
28845+ unsigned long addr = addr0, pax_task_size = TASK_SIZE;
28846+ struct vm_unmapped_area_info info;
28847+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
28848+
28849+#ifdef CONFIG_PAX_SEGMEXEC
28850+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
28851+ pax_task_size = SEGMEXEC_TASK_SIZE;
28852+#endif
28853+
28854+ pax_task_size -= PAGE_SIZE;
28855+
28856+ /* requested length too big for entire address space */
28857+ if (len > pax_task_size)
28858+ return -ENOMEM;
28859+
28860+ if (flags & MAP_FIXED)
28861+ return addr;
28862+
28863+#ifdef CONFIG_PAX_PAGEEXEC
28864+ if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
28865+ goto bottomup;
28866+#endif
28867+
28868+#ifdef CONFIG_PAX_RANDMMAP
28869+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28870+#endif
28871+
28872+ /* requesting a specific address */
28873+ if (addr) {
28874+ addr = PAGE_ALIGN(addr);
28875+ if (pax_task_size - len >= addr) {
28876+ vma = find_vma(mm, addr);
28877+ if (check_heap_stack_gap(vma, addr, len, offset))
28878+ return addr;
28879+ }
28880+ }
28881+
28882+ info.flags = VM_UNMAPPED_AREA_TOPDOWN;
28883+ info.length = len;
28884+ info.low_limit = PAGE_SIZE;
28885+ info.high_limit = mm->mmap_base;
28886+ info.align_mask = filp ? get_align_mask() : 0;
28887+ info.align_offset = pgoff << PAGE_SHIFT;
28888+ info.threadstack_offset = offset;
28889+
28890+ addr = vm_unmapped_area(&info);
28891+ if (!(addr & ~PAGE_MASK))
28892+ return addr;
28893+ VM_BUG_ON(addr != -ENOMEM);
28894+
28895+bottomup:
28896+ /*
28897+ * A failed mmap() very likely causes application failure,
28898+ * so fall back to the bottom-up function here. This scenario
28899+ * can happen with large stack limits and large mmap()
28900+ * allocations.
28901+ */
28902+ return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
28903+}
28904diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
28905index 10e0272..b4bb9a7 100644
28906--- a/arch/x86/kernel/sys_x86_64.c
28907+++ b/arch/x86/kernel/sys_x86_64.c
28908@@ -97,8 +97,8 @@ out:
28909 return error;
28910 }
28911
28912-static void find_start_end(unsigned long flags, unsigned long *begin,
28913- unsigned long *end)
28914+static void find_start_end(struct mm_struct *mm, unsigned long flags,
28915+ unsigned long *begin, unsigned long *end)
28916 {
28917 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
28918 unsigned long new_begin;
28919@@ -117,7 +117,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
28920 *begin = new_begin;
28921 }
28922 } else {
28923- *begin = current->mm->mmap_legacy_base;
28924+ *begin = mm->mmap_legacy_base;
28925 *end = TASK_SIZE;
28926 }
28927 }
28928@@ -130,20 +130,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
28929 struct vm_area_struct *vma;
28930 struct vm_unmapped_area_info info;
28931 unsigned long begin, end;
28932+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
28933
28934 if (flags & MAP_FIXED)
28935 return addr;
28936
28937- find_start_end(flags, &begin, &end);
28938+ find_start_end(mm, flags, &begin, &end);
28939
28940 if (len > end)
28941 return -ENOMEM;
28942
28943+#ifdef CONFIG_PAX_RANDMMAP
28944+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28945+#endif
28946+
28947 if (addr) {
28948 addr = PAGE_ALIGN(addr);
28949 vma = find_vma(mm, addr);
28950- if (end - len >= addr &&
28951- (!vma || addr + len <= vma->vm_start))
28952+ if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28953 return addr;
28954 }
28955
28956@@ -157,6 +161,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
28957 info.align_mask = get_align_mask();
28958 info.align_offset += get_align_bits();
28959 }
28960+ info.threadstack_offset = offset;
28961 return vm_unmapped_area(&info);
28962 }
28963
28964@@ -169,6 +174,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
28965 struct mm_struct *mm = current->mm;
28966 unsigned long addr = addr0;
28967 struct vm_unmapped_area_info info;
28968+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
28969
28970 /* requested length too big for entire address space */
28971 if (len > TASK_SIZE)
28972@@ -181,12 +187,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
28973 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
28974 goto bottomup;
28975
28976+#ifdef CONFIG_PAX_RANDMMAP
28977+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28978+#endif
28979+
28980 /* requesting a specific address */
28981 if (addr) {
28982 addr = PAGE_ALIGN(addr);
28983 vma = find_vma(mm, addr);
28984- if (TASK_SIZE - len >= addr &&
28985- (!vma || addr + len <= vma->vm_start))
28986+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28987 return addr;
28988 }
28989
28990@@ -200,6 +209,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
28991 info.align_mask = get_align_mask();
28992 info.align_offset += get_align_bits();
28993 }
28994+ info.threadstack_offset = offset;
28995 addr = vm_unmapped_area(&info);
28996 if (!(addr & ~PAGE_MASK))
28997 return addr;
28998diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
28999index 91a4496..42fc304 100644
29000--- a/arch/x86/kernel/tboot.c
29001+++ b/arch/x86/kernel/tboot.c
29002@@ -44,6 +44,7 @@
29003 #include <asm/setup.h>
29004 #include <asm/e820.h>
29005 #include <asm/io.h>
29006+#include <asm/tlbflush.h>
29007
29008 #include "../realmode/rm/wakeup.h"
29009
29010@@ -221,7 +222,7 @@ static int tboot_setup_sleep(void)
29011
29012 void tboot_shutdown(u32 shutdown_type)
29013 {
29014- void (*shutdown)(void);
29015+ void (* __noreturn shutdown)(void);
29016
29017 if (!tboot_enabled())
29018 return;
29019@@ -242,8 +243,9 @@ void tboot_shutdown(u32 shutdown_type)
29020 tboot->shutdown_type = shutdown_type;
29021
29022 switch_to_tboot_pt();
29023+ cr4_clear_bits(X86_CR4_PCIDE);
29024
29025- shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
29026+ shutdown = (void *)(unsigned long)tboot->shutdown_entry;
29027 shutdown();
29028
29029 /* should not reach here */
29030@@ -310,7 +312,7 @@ static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
29031 return -ENODEV;
29032 }
29033
29034-static atomic_t ap_wfs_count;
29035+static atomic_unchecked_t ap_wfs_count;
29036
29037 static int tboot_wait_for_aps(int num_aps)
29038 {
29039@@ -334,9 +336,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
29040 {
29041 switch (action) {
29042 case CPU_DYING:
29043- atomic_inc(&ap_wfs_count);
29044+ atomic_inc_unchecked(&ap_wfs_count);
29045 if (num_online_cpus() == 1)
29046- if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
29047+ if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
29048 return NOTIFY_BAD;
29049 break;
29050 }
29051@@ -422,7 +424,7 @@ static __init int tboot_late_init(void)
29052
29053 tboot_create_trampoline();
29054
29055- atomic_set(&ap_wfs_count, 0);
29056+ atomic_set_unchecked(&ap_wfs_count, 0);
29057 register_hotcpu_notifier(&tboot_cpu_notifier);
29058
29059 #ifdef CONFIG_DEBUG_FS
29060diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
29061index d39c091..1df4349 100644
29062--- a/arch/x86/kernel/time.c
29063+++ b/arch/x86/kernel/time.c
29064@@ -32,7 +32,7 @@ unsigned long profile_pc(struct pt_regs *regs)
29065
29066 if (!user_mode(regs) && in_lock_functions(pc)) {
29067 #ifdef CONFIG_FRAME_POINTER
29068- return *(unsigned long *)(regs->bp + sizeof(long));
29069+ return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
29070 #else
29071 unsigned long *sp =
29072 (unsigned long *)kernel_stack_pointer(regs);
29073@@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
29074 * or above a saved flags. Eflags has bits 22-31 zero,
29075 * kernel addresses don't.
29076 */
29077+
29078+#ifdef CONFIG_PAX_KERNEXEC
29079+ return ktla_ktva(sp[0]);
29080+#else
29081 if (sp[0] >> 22)
29082 return sp[0];
29083 if (sp[1] >> 22)
29084 return sp[1];
29085 #endif
29086+
29087+#endif
29088 }
29089 return pc;
29090 }
29091diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
29092index 7fc5e84..c6e445a 100644
29093--- a/arch/x86/kernel/tls.c
29094+++ b/arch/x86/kernel/tls.c
29095@@ -139,6 +139,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
29096 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
29097 return -EINVAL;
29098
29099+#ifdef CONFIG_PAX_SEGMEXEC
29100+ if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
29101+ return -EINVAL;
29102+#endif
29103+
29104 set_tls_desc(p, idx, &info, 1);
29105
29106 return 0;
29107@@ -256,7 +261,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
29108
29109 if (kbuf)
29110 info = kbuf;
29111- else if (__copy_from_user(infobuf, ubuf, count))
29112+ else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
29113 return -EFAULT;
29114 else
29115 info = infobuf;
29116diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
29117index 1c113db..287b42e 100644
29118--- a/arch/x86/kernel/tracepoint.c
29119+++ b/arch/x86/kernel/tracepoint.c
29120@@ -9,11 +9,11 @@
29121 #include <linux/atomic.h>
29122
29123 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
29124-struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
29125+const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
29126 (unsigned long) trace_idt_table };
29127
29128 /* No need to be aligned, but done to keep all IDTs defined the same way. */
29129-gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
29130+gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
29131
29132 static int trace_irq_vector_refcount;
29133 static DEFINE_MUTEX(irq_vector_mutex);
29134diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
29135index f579192..aed90b8 100644
29136--- a/arch/x86/kernel/traps.c
29137+++ b/arch/x86/kernel/traps.c
29138@@ -69,7 +69,7 @@
29139 #include <asm/proto.h>
29140
29141 /* No need to be aligned, but done to keep all IDTs defined the same way. */
29142-gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
29143+gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
29144 #else
29145 #include <asm/processor-flags.h>
29146 #include <asm/setup.h>
29147@@ -77,7 +77,7 @@ gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
29148 #endif
29149
29150 /* Must be page-aligned because the real IDT is used in a fixmap. */
29151-gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
29152+gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
29153
29154 DECLARE_BITMAP(used_vectors, NR_VECTORS);
29155 EXPORT_SYMBOL_GPL(used_vectors);
29156@@ -174,7 +174,7 @@ void ist_begin_non_atomic(struct pt_regs *regs)
29157 * will catch asm bugs and any attempt to use ist_preempt_enable
29158 * from double_fault.
29159 */
29160- BUG_ON((unsigned long)(current_top_of_stack() -
29161+ BUG_ON((unsigned long)(current_top_of_stack(smp_processor_id()) -
29162 current_stack_pointer()) >= THREAD_SIZE);
29163
29164 preempt_count_sub(HARDIRQ_OFFSET);
29165@@ -191,7 +191,7 @@ void ist_end_non_atomic(void)
29166 }
29167
29168 static nokprobe_inline int
29169-do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
29170+do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
29171 struct pt_regs *regs, long error_code)
29172 {
29173 if (v8086_mode(regs)) {
29174@@ -211,8 +211,20 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
29175 if (!fixup_exception(regs)) {
29176 tsk->thread.error_code = error_code;
29177 tsk->thread.trap_nr = trapnr;
29178+
29179+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29180+ if (trapnr == X86_TRAP_SS && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
29181+ str = "PAX: suspicious stack segment fault";
29182+#endif
29183+
29184 die(str, regs, error_code);
29185 }
29186+
29187+#ifdef CONFIG_PAX_REFCOUNT
29188+ if (trapnr == X86_TRAP_OF)
29189+ pax_report_refcount_overflow(regs);
29190+#endif
29191+
29192 return 0;
29193 }
29194
29195@@ -251,7 +263,7 @@ static siginfo_t *fill_trap_info(struct pt_regs *regs, int signr, int trapnr,
29196 }
29197
29198 static void
29199-do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
29200+do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
29201 long error_code, siginfo_t *info)
29202 {
29203 struct task_struct *tsk = current;
29204@@ -275,7 +287,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
29205 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
29206 printk_ratelimit()) {
29207 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
29208- tsk->comm, tsk->pid, str,
29209+ tsk->comm, task_pid_nr(tsk), str,
29210 regs->ip, regs->sp, error_code);
29211 print_vma_addr(" in ", regs->ip);
29212 pr_cont("\n");
29213@@ -357,6 +369,11 @@ dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
29214 tsk->thread.error_code = error_code;
29215 tsk->thread.trap_nr = X86_TRAP_DF;
29216
29217+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
29218+ if ((unsigned long)tsk->stack - regs->sp <= PAGE_SIZE)
29219+ die("grsec: kernel stack overflow detected", regs, error_code);
29220+#endif
29221+
29222 #ifdef CONFIG_DOUBLEFAULT
29223 df_debug(regs, error_code);
29224 #endif
29225@@ -473,11 +490,35 @@ do_general_protection(struct pt_regs *regs, long error_code)
29226 tsk->thread.error_code = error_code;
29227 tsk->thread.trap_nr = X86_TRAP_GP;
29228 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
29229- X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
29230+ X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
29231+
29232+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29233+ if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
29234+ die("PAX: suspicious general protection fault", regs, error_code);
29235+ else
29236+#endif
29237+
29238 die("general protection fault", regs, error_code);
29239+ }
29240 goto exit;
29241 }
29242
29243+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
29244+ if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
29245+ struct mm_struct *mm = tsk->mm;
29246+ unsigned long limit;
29247+
29248+ down_write(&mm->mmap_sem);
29249+ limit = mm->context.user_cs_limit;
29250+ if (limit < TASK_SIZE) {
29251+ track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
29252+ up_write(&mm->mmap_sem);
29253+ return;
29254+ }
29255+ up_write(&mm->mmap_sem);
29256+ }
29257+#endif
29258+
29259 tsk->thread.error_code = error_code;
29260 tsk->thread.trap_nr = X86_TRAP_GP;
29261
29262@@ -576,6 +617,9 @@ struct bad_iret_stack *fixup_bad_iret(struct bad_iret_stack *s)
29263 container_of(task_pt_regs(current),
29264 struct bad_iret_stack, regs);
29265
29266+ if ((current->thread.sp0 ^ (unsigned long)s) < THREAD_SIZE)
29267+ new_stack = s;
29268+
29269 /* Copy the IRET target to the new stack. */
29270 memmove(&new_stack->regs.ip, (void *)s->regs.sp, 5*8);
29271
29272diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
29273index dc9af7a..1bc625e 100644
29274--- a/arch/x86/kernel/tsc.c
29275+++ b/arch/x86/kernel/tsc.c
29276@@ -151,7 +151,7 @@ static void cyc2ns_write_end(int cpu, struct cyc2ns_data *data)
29277 */
29278 smp_wmb();
29279
29280- ACCESS_ONCE(c2n->head) = data;
29281+ ACCESS_ONCE_RW(c2n->head) = data;
29282 }
29283
29284 /*
29285diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
29286index 6647624..2056791 100644
29287--- a/arch/x86/kernel/uprobes.c
29288+++ b/arch/x86/kernel/uprobes.c
29289@@ -978,7 +978,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
29290
29291 if (nleft != rasize) {
29292 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
29293- "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
29294+ "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
29295
29296 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
29297 }
29298diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
29299index b9242ba..50c5edd 100644
29300--- a/arch/x86/kernel/verify_cpu.S
29301+++ b/arch/x86/kernel/verify_cpu.S
29302@@ -20,6 +20,7 @@
29303 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
29304 * arch/x86/kernel/trampoline_64.S: secondary processor verification
29305 * arch/x86/kernel/head_32.S: processor startup
29306+ * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
29307 *
29308 * verify_cpu, returns the status of longmode and SSE in register %eax.
29309 * 0: Success 1: Failure
29310diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
29311index fc9db6e..2c5865d 100644
29312--- a/arch/x86/kernel/vm86_32.c
29313+++ b/arch/x86/kernel/vm86_32.c
29314@@ -44,6 +44,7 @@
29315 #include <linux/ptrace.h>
29316 #include <linux/audit.h>
29317 #include <linux/stddef.h>
29318+#include <linux/grsecurity.h>
29319
29320 #include <asm/uaccess.h>
29321 #include <asm/io.h>
29322@@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
29323 do_exit(SIGSEGV);
29324 }
29325
29326- tss = &per_cpu(cpu_tss, get_cpu());
29327+ tss = cpu_tss + get_cpu();
29328 current->thread.sp0 = current->thread.saved_sp0;
29329 current->thread.sysenter_cs = __KERNEL_CS;
29330 load_sp0(tss, &current->thread);
29331@@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
29332
29333 if (tsk->thread.saved_sp0)
29334 return -EPERM;
29335+
29336+#ifdef CONFIG_GRKERNSEC_VM86
29337+ if (!capable(CAP_SYS_RAWIO)) {
29338+ gr_handle_vm86();
29339+ return -EPERM;
29340+ }
29341+#endif
29342+
29343 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
29344 offsetof(struct kernel_vm86_struct, vm86plus) -
29345 sizeof(info.regs));
29346@@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
29347 int tmp;
29348 struct vm86plus_struct __user *v86;
29349
29350+#ifdef CONFIG_GRKERNSEC_VM86
29351+ if (!capable(CAP_SYS_RAWIO)) {
29352+ gr_handle_vm86();
29353+ return -EPERM;
29354+ }
29355+#endif
29356+
29357 tsk = current;
29358 switch (cmd) {
29359 case VM86_REQUEST_IRQ:
29360@@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
29361 tsk->thread.saved_fs = info->regs32->fs;
29362 tsk->thread.saved_gs = get_user_gs(info->regs32);
29363
29364- tss = &per_cpu(cpu_tss, get_cpu());
29365+ tss = cpu_tss + get_cpu();
29366 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
29367 if (cpu_has_sep)
29368 tsk->thread.sysenter_cs = 0;
29369@@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
29370 goto cannot_handle;
29371 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
29372 goto cannot_handle;
29373- intr_ptr = (unsigned long __user *) (i << 2);
29374+ intr_ptr = (__force unsigned long __user *) (i << 2);
29375 if (get_user(segoffs, intr_ptr))
29376 goto cannot_handle;
29377 if ((segoffs >> 16) == BIOSSEG)
29378diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
29379index 00bf300..03e1c3b 100644
29380--- a/arch/x86/kernel/vmlinux.lds.S
29381+++ b/arch/x86/kernel/vmlinux.lds.S
29382@@ -26,6 +26,13 @@
29383 #include <asm/page_types.h>
29384 #include <asm/cache.h>
29385 #include <asm/boot.h>
29386+#include <asm/segment.h>
29387+
29388+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29389+#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
29390+#else
29391+#define __KERNEL_TEXT_OFFSET 0
29392+#endif
29393
29394 #undef i386 /* in case the preprocessor is a 32bit one */
29395
29396@@ -69,30 +76,43 @@ jiffies_64 = jiffies;
29397
29398 PHDRS {
29399 text PT_LOAD FLAGS(5); /* R_E */
29400+#ifdef CONFIG_X86_32
29401+ module PT_LOAD FLAGS(5); /* R_E */
29402+#endif
29403+#ifdef CONFIG_XEN
29404+ rodata PT_LOAD FLAGS(5); /* R_E */
29405+#else
29406+ rodata PT_LOAD FLAGS(4); /* R__ */
29407+#endif
29408 data PT_LOAD FLAGS(6); /* RW_ */
29409-#ifdef CONFIG_X86_64
29410+ init.begin PT_LOAD FLAGS(6); /* RW_ */
29411 #ifdef CONFIG_SMP
29412 percpu PT_LOAD FLAGS(6); /* RW_ */
29413 #endif
29414- init PT_LOAD FLAGS(7); /* RWE */
29415-#endif
29416+ text.init PT_LOAD FLAGS(5); /* R_E */
29417+ text.exit PT_LOAD FLAGS(5); /* R_E */
29418+ init PT_LOAD FLAGS(6); /* RW_ */
29419 note PT_NOTE FLAGS(0); /* ___ */
29420 }
29421
29422 SECTIONS
29423 {
29424 #ifdef CONFIG_X86_32
29425- . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
29426- phys_startup_32 = startup_32 - LOAD_OFFSET;
29427+ . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
29428 #else
29429- . = __START_KERNEL;
29430- phys_startup_64 = startup_64 - LOAD_OFFSET;
29431+ . = __START_KERNEL;
29432 #endif
29433
29434 /* Text and read-only data */
29435- .text : AT(ADDR(.text) - LOAD_OFFSET) {
29436- _text = .;
29437+ .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
29438 /* bootstrapping code */
29439+#ifdef CONFIG_X86_32
29440+ phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
29441+#else
29442+ phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
29443+#endif
29444+ __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
29445+ _text = .;
29446 HEAD_TEXT
29447 . = ALIGN(8);
29448 _stext = .;
29449@@ -104,13 +124,47 @@ SECTIONS
29450 IRQENTRY_TEXT
29451 *(.fixup)
29452 *(.gnu.warning)
29453- /* End of text section */
29454- _etext = .;
29455 } :text = 0x9090
29456
29457- NOTES :text :note
29458+ . += __KERNEL_TEXT_OFFSET;
29459
29460- EXCEPTION_TABLE(16) :text = 0x9090
29461+#ifdef CONFIG_X86_32
29462+ . = ALIGN(PAGE_SIZE);
29463+ .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
29464+
29465+#ifdef CONFIG_PAX_KERNEXEC
29466+ MODULES_EXEC_VADDR = .;
29467+ BYTE(0)
29468+ . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
29469+ . = ALIGN(HPAGE_SIZE) - 1;
29470+ MODULES_EXEC_END = .;
29471+#endif
29472+
29473+ } :module
29474+#endif
29475+
29476+ .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
29477+ /* End of text section */
29478+ BYTE(0)
29479+ _etext = . - __KERNEL_TEXT_OFFSET;
29480+ }
29481+
29482+#ifdef CONFIG_X86_32
29483+ . = ALIGN(PAGE_SIZE);
29484+ .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
29485+ . = ALIGN(PAGE_SIZE);
29486+ *(.empty_zero_page)
29487+ *(.initial_pg_fixmap)
29488+ *(.initial_pg_pmd)
29489+ *(.initial_page_table)
29490+ *(.swapper_pg_dir)
29491+ } :rodata
29492+#endif
29493+
29494+ . = ALIGN(PAGE_SIZE);
29495+ NOTES :rodata :note
29496+
29497+ EXCEPTION_TABLE(16) :rodata
29498
29499 #if defined(CONFIG_DEBUG_RODATA)
29500 /* .text should occupy whole number of pages */
29501@@ -122,16 +176,20 @@ SECTIONS
29502
29503 /* Data */
29504 .data : AT(ADDR(.data) - LOAD_OFFSET) {
29505+
29506+#ifdef CONFIG_PAX_KERNEXEC
29507+ . = ALIGN(HPAGE_SIZE);
29508+#else
29509+ . = ALIGN(PAGE_SIZE);
29510+#endif
29511+
29512 /* Start of data section */
29513 _sdata = .;
29514
29515 /* init_task */
29516 INIT_TASK_DATA(THREAD_SIZE)
29517
29518-#ifdef CONFIG_X86_32
29519- /* 32 bit has nosave before _edata */
29520 NOSAVE_DATA
29521-#endif
29522
29523 PAGE_ALIGNED_DATA(PAGE_SIZE)
29524
29525@@ -174,12 +232,19 @@ SECTIONS
29526 . = ALIGN(__vvar_page + PAGE_SIZE, PAGE_SIZE);
29527
29528 /* Init code and data - will be freed after init */
29529- . = ALIGN(PAGE_SIZE);
29530 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
29531+ BYTE(0)
29532+
29533+#ifdef CONFIG_PAX_KERNEXEC
29534+ . = ALIGN(HPAGE_SIZE);
29535+#else
29536+ . = ALIGN(PAGE_SIZE);
29537+#endif
29538+
29539 __init_begin = .; /* paired with __init_end */
29540- }
29541+ } :init.begin
29542
29543-#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
29544+#ifdef CONFIG_SMP
29545 /*
29546 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
29547 * output PHDR, so the next output section - .init.text - should
29548@@ -190,12 +255,33 @@ SECTIONS
29549 "per-CPU data too large - increase CONFIG_PHYSICAL_START")
29550 #endif
29551
29552- INIT_TEXT_SECTION(PAGE_SIZE)
29553-#ifdef CONFIG_X86_64
29554- :init
29555+ . = ALIGN(PAGE_SIZE);
29556+ init_begin = .;
29557+ .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
29558+ VMLINUX_SYMBOL(_sinittext) = .;
29559+ INIT_TEXT
29560+ . = ALIGN(PAGE_SIZE);
29561+ } :text.init
29562+
29563+ /*
29564+ * .exit.text is discard at runtime, not link time, to deal with
29565+ * references from .altinstructions and .eh_frame
29566+ */
29567+ .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
29568+ EXIT_TEXT
29569+ VMLINUX_SYMBOL(_einittext) = .;
29570+
29571+#ifdef CONFIG_PAX_KERNEXEC
29572+ . = ALIGN(HPAGE_SIZE);
29573+#else
29574+ . = ALIGN(16);
29575 #endif
29576
29577- INIT_DATA_SECTION(16)
29578+ } :text.exit
29579+ . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
29580+
29581+ . = ALIGN(PAGE_SIZE);
29582+ INIT_DATA_SECTION(16) :init
29583
29584 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
29585 __x86_cpu_dev_start = .;
29586@@ -266,19 +352,12 @@ SECTIONS
29587 }
29588
29589 . = ALIGN(8);
29590- /*
29591- * .exit.text is discard at runtime, not link time, to deal with
29592- * references from .altinstructions and .eh_frame
29593- */
29594- .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
29595- EXIT_TEXT
29596- }
29597
29598 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
29599 EXIT_DATA
29600 }
29601
29602-#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
29603+#ifndef CONFIG_SMP
29604 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
29605 #endif
29606
29607@@ -297,16 +376,10 @@ SECTIONS
29608 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
29609 __smp_locks = .;
29610 *(.smp_locks)
29611- . = ALIGN(PAGE_SIZE);
29612 __smp_locks_end = .;
29613+ . = ALIGN(PAGE_SIZE);
29614 }
29615
29616-#ifdef CONFIG_X86_64
29617- .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
29618- NOSAVE_DATA
29619- }
29620-#endif
29621-
29622 /* BSS */
29623 . = ALIGN(PAGE_SIZE);
29624 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
29625@@ -322,6 +395,7 @@ SECTIONS
29626 __brk_base = .;
29627 . += 64 * 1024; /* 64k alignment slop space */
29628 *(.brk_reservation) /* areas brk users have reserved */
29629+ . = ALIGN(HPAGE_SIZE);
29630 __brk_limit = .;
29631 }
29632
29633@@ -348,13 +422,12 @@ SECTIONS
29634 * for the boot processor.
29635 */
29636 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
29637-INIT_PER_CPU(gdt_page);
29638 INIT_PER_CPU(irq_stack_union);
29639
29640 /*
29641 * Build-time check on the image size:
29642 */
29643-. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
29644+. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
29645 "kernel image bigger than KERNEL_IMAGE_SIZE");
29646
29647 #ifdef CONFIG_SMP
29648diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
29649index a0695be..33e180c 100644
29650--- a/arch/x86/kernel/x8664_ksyms_64.c
29651+++ b/arch/x86/kernel/x8664_ksyms_64.c
29652@@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
29653 EXPORT_SYMBOL(copy_user_generic_unrolled);
29654 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
29655 EXPORT_SYMBOL(__copy_user_nocache);
29656-EXPORT_SYMBOL(_copy_from_user);
29657-EXPORT_SYMBOL(_copy_to_user);
29658
29659 EXPORT_SYMBOL(copy_page);
29660 EXPORT_SYMBOL(clear_page);
29661@@ -77,3 +75,7 @@ EXPORT_SYMBOL(native_load_gs_index);
29662 EXPORT_SYMBOL(___preempt_schedule);
29663 EXPORT_SYMBOL(___preempt_schedule_notrace);
29664 #endif
29665+
29666+#ifdef CONFIG_PAX_PER_CPU_PGD
29667+EXPORT_SYMBOL(cpu_pgd);
29668+#endif
29669diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
29670index 3839628..2e5b5b35 100644
29671--- a/arch/x86/kernel/x86_init.c
29672+++ b/arch/x86/kernel/x86_init.c
29673@@ -92,7 +92,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
29674 static void default_nmi_init(void) { };
29675 static int default_i8042_detect(void) { return 1; };
29676
29677-struct x86_platform_ops x86_platform = {
29678+struct x86_platform_ops x86_platform __read_only = {
29679 .calibrate_tsc = native_calibrate_tsc,
29680 .get_wallclock = mach_get_cmos_time,
29681 .set_wallclock = mach_set_rtc_mmss,
29682@@ -108,7 +108,7 @@ struct x86_platform_ops x86_platform = {
29683 EXPORT_SYMBOL_GPL(x86_platform);
29684
29685 #if defined(CONFIG_PCI_MSI)
29686-struct x86_msi_ops x86_msi = {
29687+struct x86_msi_ops x86_msi __read_only = {
29688 .setup_msi_irqs = native_setup_msi_irqs,
29689 .teardown_msi_irq = native_teardown_msi_irq,
29690 .teardown_msi_irqs = default_teardown_msi_irqs,
29691@@ -137,7 +137,7 @@ void arch_restore_msi_irqs(struct pci_dev *dev)
29692 }
29693 #endif
29694
29695-struct x86_io_apic_ops x86_io_apic_ops = {
29696+struct x86_io_apic_ops x86_io_apic_ops __read_only = {
29697 .read = native_io_apic_read,
29698 .disable = native_disable_io_apic,
29699 };
29700diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
29701index 2fbea25..9e0f8c7 100644
29702--- a/arch/x86/kvm/cpuid.c
29703+++ b/arch/x86/kvm/cpuid.c
29704@@ -206,15 +206,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
29705 struct kvm_cpuid2 *cpuid,
29706 struct kvm_cpuid_entry2 __user *entries)
29707 {
29708- int r;
29709+ int r, i;
29710
29711 r = -E2BIG;
29712 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
29713 goto out;
29714 r = -EFAULT;
29715- if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
29716- cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
29717+ if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
29718 goto out;
29719+ for (i = 0; i < cpuid->nent; ++i) {
29720+ struct kvm_cpuid_entry2 cpuid_entry;
29721+ if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
29722+ goto out;
29723+ vcpu->arch.cpuid_entries[i] = cpuid_entry;
29724+ }
29725 vcpu->arch.cpuid_nent = cpuid->nent;
29726 kvm_apic_set_version(vcpu);
29727 kvm_x86_ops->cpuid_update(vcpu);
29728@@ -227,15 +232,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
29729 struct kvm_cpuid2 *cpuid,
29730 struct kvm_cpuid_entry2 __user *entries)
29731 {
29732- int r;
29733+ int r, i;
29734
29735 r = -E2BIG;
29736 if (cpuid->nent < vcpu->arch.cpuid_nent)
29737 goto out;
29738 r = -EFAULT;
29739- if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
29740- vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
29741+ if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
29742 goto out;
29743+ for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
29744+ struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
29745+ if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
29746+ goto out;
29747+ }
29748 return 0;
29749
29750 out:
29751diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
29752index e7a4fde..623af93 100644
29753--- a/arch/x86/kvm/emulate.c
29754+++ b/arch/x86/kvm/emulate.c
29755@@ -3847,7 +3847,7 @@ static int check_cr_write(struct x86_emulate_ctxt *ctxt)
29756 int cr = ctxt->modrm_reg;
29757 u64 efer = 0;
29758
29759- static u64 cr_reserved_bits[] = {
29760+ static const u64 cr_reserved_bits[] = {
29761 0xffffffff00000000ULL,
29762 0, 0, 0, /* CR3 checked later */
29763 CR4_RESERVED_BITS,
29764diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
29765index 2a5ca97..ce8577a 100644
29766--- a/arch/x86/kvm/lapic.c
29767+++ b/arch/x86/kvm/lapic.c
29768@@ -56,7 +56,7 @@
29769 #define APIC_BUS_CYCLE_NS 1
29770
29771 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
29772-#define apic_debug(fmt, arg...)
29773+#define apic_debug(fmt, arg...) do {} while (0)
29774
29775 #define APIC_LVT_NUM 6
29776 /* 14 is the version for Xeon and Pentium 8.4.8*/
29777diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
29778index 0f67d7e..4b9fa11 100644
29779--- a/arch/x86/kvm/paging_tmpl.h
29780+++ b/arch/x86/kvm/paging_tmpl.h
29781@@ -343,7 +343,7 @@ retry_walk:
29782 if (unlikely(kvm_is_error_hva(host_addr)))
29783 goto error;
29784
29785- ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
29786+ ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
29787 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
29788 goto error;
29789 walker->ptep_user[walker->level - 1] = ptep_user;
29790diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
29791index 2d32b67..2cd298b 100644
29792--- a/arch/x86/kvm/svm.c
29793+++ b/arch/x86/kvm/svm.c
29794@@ -3586,7 +3586,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
29795 int cpu = raw_smp_processor_id();
29796
29797 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
29798+
29799+ pax_open_kernel();
29800 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
29801+ pax_close_kernel();
29802+
29803 load_TR_desc();
29804 }
29805
29806@@ -3982,6 +3986,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
29807 #endif
29808 #endif
29809
29810+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
29811+ __set_fs(current_thread_info()->addr_limit);
29812+#endif
29813+
29814 reload_tss(vcpu);
29815
29816 local_irq_disable();
29817diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
29818index aa9e8229..ab09cc4 100644
29819--- a/arch/x86/kvm/vmx.c
29820+++ b/arch/x86/kvm/vmx.c
29821@@ -1440,12 +1440,12 @@ static void vmcs_write64(unsigned long field, u64 value)
29822 #endif
29823 }
29824
29825-static void vmcs_clear_bits(unsigned long field, u32 mask)
29826+static void vmcs_clear_bits(unsigned long field, unsigned long mask)
29827 {
29828 vmcs_writel(field, vmcs_readl(field) & ~mask);
29829 }
29830
29831-static void vmcs_set_bits(unsigned long field, u32 mask)
29832+static void vmcs_set_bits(unsigned long field, unsigned long mask)
29833 {
29834 vmcs_writel(field, vmcs_readl(field) | mask);
29835 }
29836@@ -1705,7 +1705,11 @@ static void reload_tss(void)
29837 struct desc_struct *descs;
29838
29839 descs = (void *)gdt->address;
29840+
29841+ pax_open_kernel();
29842 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
29843+ pax_close_kernel();
29844+
29845 load_TR_desc();
29846 }
29847
29848@@ -1941,6 +1945,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
29849 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
29850 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
29851
29852+#ifdef CONFIG_PAX_PER_CPU_PGD
29853+ vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
29854+#endif
29855+
29856 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
29857 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
29858 vmx->loaded_vmcs->cpu = cpu;
29859@@ -2232,7 +2240,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
29860 * reads and returns guest's timestamp counter "register"
29861 * guest_tsc = host_tsc + tsc_offset -- 21.3
29862 */
29863-static u64 guest_read_tsc(void)
29864+static u64 __intentional_overflow(-1) guest_read_tsc(void)
29865 {
29866 u64 host_tsc, tsc_offset;
29867
29868@@ -4459,7 +4467,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
29869 unsigned long cr4;
29870
29871 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
29872+
29873+#ifndef CONFIG_PAX_PER_CPU_PGD
29874 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
29875+#endif
29876
29877 /* Save the most likely value for this task's CR4 in the VMCS. */
29878 cr4 = cr4_read_shadow();
29879@@ -4486,7 +4497,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
29880 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
29881 vmx->host_idt_base = dt.address;
29882
29883- vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
29884+ vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
29885
29886 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
29887 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
29888@@ -6097,11 +6108,17 @@ static __init int hardware_setup(void)
29889 * page upon invalidation. No need to do anything if not
29890 * using the APIC_ACCESS_ADDR VMCS field.
29891 */
29892- if (!flexpriority_enabled)
29893- kvm_x86_ops->set_apic_access_page_addr = NULL;
29894+ if (!flexpriority_enabled) {
29895+ pax_open_kernel();
29896+ *(void **)&kvm_x86_ops->set_apic_access_page_addr = NULL;
29897+ pax_close_kernel();
29898+ }
29899
29900- if (!cpu_has_vmx_tpr_shadow())
29901- kvm_x86_ops->update_cr8_intercept = NULL;
29902+ if (!cpu_has_vmx_tpr_shadow()) {
29903+ pax_open_kernel();
29904+ *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
29905+ pax_close_kernel();
29906+ }
29907
29908 if (enable_ept && !cpu_has_vmx_ept_2m_page())
29909 kvm_disable_largepages();
29910@@ -6112,14 +6129,16 @@ static __init int hardware_setup(void)
29911 if (!cpu_has_vmx_apicv())
29912 enable_apicv = 0;
29913
29914+ pax_open_kernel();
29915 if (enable_apicv)
29916- kvm_x86_ops->update_cr8_intercept = NULL;
29917+ *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
29918 else {
29919- kvm_x86_ops->hwapic_irr_update = NULL;
29920- kvm_x86_ops->hwapic_isr_update = NULL;
29921- kvm_x86_ops->deliver_posted_interrupt = NULL;
29922- kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
29923+ *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
29924+ *(void **)&kvm_x86_ops->hwapic_isr_update = NULL;
29925+ *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
29926+ *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
29927 }
29928+ pax_close_kernel();
29929
29930 vmx_disable_intercept_for_msr(MSR_FS_BASE, false);
29931 vmx_disable_intercept_for_msr(MSR_GS_BASE, false);
29932@@ -6174,10 +6193,12 @@ static __init int hardware_setup(void)
29933 enable_pml = 0;
29934
29935 if (!enable_pml) {
29936- kvm_x86_ops->slot_enable_log_dirty = NULL;
29937- kvm_x86_ops->slot_disable_log_dirty = NULL;
29938- kvm_x86_ops->flush_log_dirty = NULL;
29939- kvm_x86_ops->enable_log_dirty_pt_masked = NULL;
29940+ pax_open_kernel();
29941+ *(void **)&kvm_x86_ops->slot_enable_log_dirty = NULL;
29942+ *(void **)&kvm_x86_ops->slot_disable_log_dirty = NULL;
29943+ *(void **)&kvm_x86_ops->flush_log_dirty = NULL;
29944+ *(void **)&kvm_x86_ops->enable_log_dirty_pt_masked = NULL;
29945+ pax_close_kernel();
29946 }
29947
29948 return alloc_kvm_area();
29949@@ -8380,6 +8401,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
29950 "jmp 2f \n\t"
29951 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
29952 "2: "
29953+
29954+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29955+ "ljmp %[cs],$3f\n\t"
29956+ "3: "
29957+#endif
29958+
29959 /* Save guest registers, load host registers, keep flags */
29960 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
29961 "pop %0 \n\t"
29962@@ -8432,6 +8459,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
29963 #endif
29964 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
29965 [wordsize]"i"(sizeof(ulong))
29966+
29967+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29968+ ,[cs]"i"(__KERNEL_CS)
29969+#endif
29970+
29971 : "cc", "memory"
29972 #ifdef CONFIG_X86_64
29973 , "rax", "rbx", "rdi", "rsi"
29974@@ -8445,7 +8477,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
29975 if (debugctlmsr)
29976 update_debugctlmsr(debugctlmsr);
29977
29978-#ifndef CONFIG_X86_64
29979+#ifdef CONFIG_X86_32
29980 /*
29981 * The sysexit path does not restore ds/es, so we must set them to
29982 * a reasonable value ourselves.
29983@@ -8454,8 +8486,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
29984 * may be executed in interrupt context, which saves and restore segments
29985 * around it, nullifying its effect.
29986 */
29987- loadsegment(ds, __USER_DS);
29988- loadsegment(es, __USER_DS);
29989+ loadsegment(ds, __KERNEL_DS);
29990+ loadsegment(es, __KERNEL_DS);
29991+ loadsegment(ss, __KERNEL_DS);
29992+
29993+#ifdef CONFIG_PAX_KERNEXEC
29994+ loadsegment(fs, __KERNEL_PERCPU);
29995+#endif
29996+
29997+#ifdef CONFIG_PAX_MEMORY_UDEREF
29998+ __set_fs(current_thread_info()->addr_limit);
29999+#endif
30000+
30001 #endif
30002
30003 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
30004diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
30005index 32c6e6a..d6c5bc2 100644
30006--- a/arch/x86/kvm/x86.c
30007+++ b/arch/x86/kvm/x86.c
30008@@ -1842,8 +1842,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
30009 {
30010 struct kvm *kvm = vcpu->kvm;
30011 int lm = is_long_mode(vcpu);
30012- u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
30013- : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
30014+ u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
30015+ : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
30016 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
30017 : kvm->arch.xen_hvm_config.blob_size_32;
30018 u32 page_num = data & ~PAGE_MASK;
30019@@ -2733,6 +2733,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
30020 if (n < msr_list.nmsrs)
30021 goto out;
30022 r = -EFAULT;
30023+ if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
30024+ goto out;
30025 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
30026 num_msrs_to_save * sizeof(u32)))
30027 goto out;
30028@@ -3093,7 +3095,7 @@ static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu,
30029
30030 static void fill_xsave(u8 *dest, struct kvm_vcpu *vcpu)
30031 {
30032- struct xregs_state *xsave = &vcpu->arch.guest_fpu.state.xsave;
30033+ struct xregs_state *xsave = &vcpu->arch.guest_fpu.state->xsave;
30034 u64 xstate_bv = xsave->header.xfeatures;
30035 u64 valid;
30036
30037@@ -3129,7 +3131,7 @@ static void fill_xsave(u8 *dest, struct kvm_vcpu *vcpu)
30038
30039 static void load_xsave(struct kvm_vcpu *vcpu, u8 *src)
30040 {
30041- struct xregs_state *xsave = &vcpu->arch.guest_fpu.state.xsave;
30042+ struct xregs_state *xsave = &vcpu->arch.guest_fpu.state->xsave;
30043 u64 xstate_bv = *(u64 *)(src + XSAVE_HDR_OFFSET);
30044 u64 valid;
30045
30046@@ -3173,7 +3175,7 @@ static void kvm_vcpu_ioctl_x86_get_xsave(struct kvm_vcpu *vcpu,
30047 fill_xsave((u8 *) guest_xsave->region, vcpu);
30048 } else {
30049 memcpy(guest_xsave->region,
30050- &vcpu->arch.guest_fpu.state.fxsave,
30051+ &vcpu->arch.guest_fpu.state->fxsave,
30052 sizeof(struct fxregs_state));
30053 *(u64 *)&guest_xsave->region[XSAVE_HDR_OFFSET / sizeof(u32)] =
30054 XSTATE_FPSSE;
30055@@ -3198,7 +3200,7 @@ static int kvm_vcpu_ioctl_x86_set_xsave(struct kvm_vcpu *vcpu,
30056 } else {
30057 if (xstate_bv & ~XSTATE_FPSSE)
30058 return -EINVAL;
30059- memcpy(&vcpu->arch.guest_fpu.state.fxsave,
30060+ memcpy(&vcpu->arch.guest_fpu.state->fxsave,
30061 guest_xsave->region, sizeof(struct fxregs_state));
30062 }
30063 return 0;
30064@@ -5788,7 +5790,7 @@ static struct notifier_block pvclock_gtod_notifier = {
30065 };
30066 #endif
30067
30068-int kvm_arch_init(void *opaque)
30069+int kvm_arch_init(const void *opaque)
30070 {
30071 int r;
30072 struct kvm_x86_ops *ops = opaque;
30073@@ -7212,7 +7214,7 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
30074 int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
30075 {
30076 struct fxregs_state *fxsave =
30077- &vcpu->arch.guest_fpu.state.fxsave;
30078+ &vcpu->arch.guest_fpu.state->fxsave;
30079
30080 memcpy(fpu->fpr, fxsave->st_space, 128);
30081 fpu->fcw = fxsave->cwd;
30082@@ -7229,7 +7231,7 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
30083 int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
30084 {
30085 struct fxregs_state *fxsave =
30086- &vcpu->arch.guest_fpu.state.fxsave;
30087+ &vcpu->arch.guest_fpu.state->fxsave;
30088
30089 memcpy(fxsave->st_space, fpu->fpr, 128);
30090 fxsave->cwd = fpu->fcw;
30091@@ -7245,9 +7247,9 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
30092
30093 static void fx_init(struct kvm_vcpu *vcpu)
30094 {
30095- fpstate_init(&vcpu->arch.guest_fpu.state);
30096+ fpstate_init(vcpu->arch.guest_fpu.state);
30097 if (cpu_has_xsaves)
30098- vcpu->arch.guest_fpu.state.xsave.header.xcomp_bv =
30099+ vcpu->arch.guest_fpu.state->xsave.header.xcomp_bv =
30100 host_xcr0 | XSTATE_COMPACTION_ENABLED;
30101
30102 /*
30103@@ -7271,7 +7273,7 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
30104 kvm_put_guest_xcr0(vcpu);
30105 vcpu->guest_fpu_loaded = 1;
30106 __kernel_fpu_begin();
30107- __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu.state);
30108+ __copy_kernel_to_fpregs(vcpu->arch.guest_fpu.state);
30109 trace_kvm_fpu(1);
30110 }
30111
30112@@ -7549,6 +7551,8 @@ bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu)
30113
30114 struct static_key kvm_no_apic_vcpu __read_mostly;
30115
30116+extern struct kmem_cache *fpregs_state_cachep;
30117+
30118 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
30119 {
30120 struct page *page;
30121@@ -7565,11 +7569,14 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
30122 else
30123 vcpu->arch.mp_state = KVM_MP_STATE_UNINITIALIZED;
30124
30125- page = alloc_page(GFP_KERNEL | __GFP_ZERO);
30126- if (!page) {
30127- r = -ENOMEM;
30128+ r = -ENOMEM;
30129+ vcpu->arch.guest_fpu.state = kmem_cache_alloc(fpregs_state_cachep, GFP_KERNEL);
30130+ if (!vcpu->arch.guest_fpu.state)
30131 goto fail;
30132- }
30133+
30134+ page = alloc_page(GFP_KERNEL | __GFP_ZERO);
30135+ if (!page)
30136+ goto fail_free_fpregs;
30137 vcpu->arch.pio_data = page_address(page);
30138
30139 kvm_set_tsc_khz(vcpu, max_tsc_khz);
30140@@ -7623,6 +7630,9 @@ fail_mmu_destroy:
30141 kvm_mmu_destroy(vcpu);
30142 fail_free_pio_data:
30143 free_page((unsigned long)vcpu->arch.pio_data);
30144+fail_free_fpregs:
30145+ kmem_cache_free(fpregs_state_cachep, vcpu->arch.guest_fpu.state);
30146+ vcpu->arch.guest_fpu.state = NULL;
30147 fail:
30148 return r;
30149 }
30150@@ -7640,6 +7650,8 @@ void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
30151 free_page((unsigned long)vcpu->arch.pio_data);
30152 if (!irqchip_in_kernel(vcpu->kvm))
30153 static_key_slow_dec(&kvm_no_apic_vcpu);
30154+ kmem_cache_free(fpregs_state_cachep, vcpu->arch.guest_fpu.state);
30155+ vcpu->arch.guest_fpu.state = NULL;
30156 }
30157
30158 void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu)
30159diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
30160index f2dc08c..d85d906 100644
30161--- a/arch/x86/lguest/boot.c
30162+++ b/arch/x86/lguest/boot.c
30163@@ -1341,9 +1341,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
30164 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
30165 * Launcher to reboot us.
30166 */
30167-static void lguest_restart(char *reason)
30168+static __noreturn void lguest_restart(char *reason)
30169 {
30170 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
30171+ BUG();
30172 }
30173
30174 /*G:050
30175diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
30176index 9b0ca8f..bb4af41 100644
30177--- a/arch/x86/lib/atomic64_386_32.S
30178+++ b/arch/x86/lib/atomic64_386_32.S
30179@@ -45,6 +45,10 @@ BEGIN(read)
30180 movl (v), %eax
30181 movl 4(v), %edx
30182 RET_ENDP
30183+BEGIN(read_unchecked)
30184+ movl (v), %eax
30185+ movl 4(v), %edx
30186+RET_ENDP
30187 #undef v
30188
30189 #define v %esi
30190@@ -52,6 +56,10 @@ BEGIN(set)
30191 movl %ebx, (v)
30192 movl %ecx, 4(v)
30193 RET_ENDP
30194+BEGIN(set_unchecked)
30195+ movl %ebx, (v)
30196+ movl %ecx, 4(v)
30197+RET_ENDP
30198 #undef v
30199
30200 #define v %esi
30201@@ -67,6 +75,20 @@ RET_ENDP
30202 BEGIN(add)
30203 addl %eax, (v)
30204 adcl %edx, 4(v)
30205+
30206+#ifdef CONFIG_PAX_REFCOUNT
30207+ jno 0f
30208+ subl %eax, (v)
30209+ sbbl %edx, 4(v)
30210+ int $4
30211+0:
30212+ _ASM_EXTABLE(0b, 0b)
30213+#endif
30214+
30215+RET_ENDP
30216+BEGIN(add_unchecked)
30217+ addl %eax, (v)
30218+ adcl %edx, 4(v)
30219 RET_ENDP
30220 #undef v
30221
30222@@ -74,6 +96,24 @@ RET_ENDP
30223 BEGIN(add_return)
30224 addl (v), %eax
30225 adcl 4(v), %edx
30226+
30227+#ifdef CONFIG_PAX_REFCOUNT
30228+ into
30229+1234:
30230+ _ASM_EXTABLE(1234b, 2f)
30231+#endif
30232+
30233+ movl %eax, (v)
30234+ movl %edx, 4(v)
30235+
30236+#ifdef CONFIG_PAX_REFCOUNT
30237+2:
30238+#endif
30239+
30240+RET_ENDP
30241+BEGIN(add_return_unchecked)
30242+ addl (v), %eax
30243+ adcl 4(v), %edx
30244 movl %eax, (v)
30245 movl %edx, 4(v)
30246 RET_ENDP
30247@@ -83,6 +123,20 @@ RET_ENDP
30248 BEGIN(sub)
30249 subl %eax, (v)
30250 sbbl %edx, 4(v)
30251+
30252+#ifdef CONFIG_PAX_REFCOUNT
30253+ jno 0f
30254+ addl %eax, (v)
30255+ adcl %edx, 4(v)
30256+ int $4
30257+0:
30258+ _ASM_EXTABLE(0b, 0b)
30259+#endif
30260+
30261+RET_ENDP
30262+BEGIN(sub_unchecked)
30263+ subl %eax, (v)
30264+ sbbl %edx, 4(v)
30265 RET_ENDP
30266 #undef v
30267
30268@@ -93,6 +147,27 @@ BEGIN(sub_return)
30269 sbbl $0, %edx
30270 addl (v), %eax
30271 adcl 4(v), %edx
30272+
30273+#ifdef CONFIG_PAX_REFCOUNT
30274+ into
30275+1234:
30276+ _ASM_EXTABLE(1234b, 2f)
30277+#endif
30278+
30279+ movl %eax, (v)
30280+ movl %edx, 4(v)
30281+
30282+#ifdef CONFIG_PAX_REFCOUNT
30283+2:
30284+#endif
30285+
30286+RET_ENDP
30287+BEGIN(sub_return_unchecked)
30288+ negl %edx
30289+ negl %eax
30290+ sbbl $0, %edx
30291+ addl (v), %eax
30292+ adcl 4(v), %edx
30293 movl %eax, (v)
30294 movl %edx, 4(v)
30295 RET_ENDP
30296@@ -102,6 +177,20 @@ RET_ENDP
30297 BEGIN(inc)
30298 addl $1, (v)
30299 adcl $0, 4(v)
30300+
30301+#ifdef CONFIG_PAX_REFCOUNT
30302+ jno 0f
30303+ subl $1, (v)
30304+ sbbl $0, 4(v)
30305+ int $4
30306+0:
30307+ _ASM_EXTABLE(0b, 0b)
30308+#endif
30309+
30310+RET_ENDP
30311+BEGIN(inc_unchecked)
30312+ addl $1, (v)
30313+ adcl $0, 4(v)
30314 RET_ENDP
30315 #undef v
30316
30317@@ -111,6 +200,26 @@ BEGIN(inc_return)
30318 movl 4(v), %edx
30319 addl $1, %eax
30320 adcl $0, %edx
30321+
30322+#ifdef CONFIG_PAX_REFCOUNT
30323+ into
30324+1234:
30325+ _ASM_EXTABLE(1234b, 2f)
30326+#endif
30327+
30328+ movl %eax, (v)
30329+ movl %edx, 4(v)
30330+
30331+#ifdef CONFIG_PAX_REFCOUNT
30332+2:
30333+#endif
30334+
30335+RET_ENDP
30336+BEGIN(inc_return_unchecked)
30337+ movl (v), %eax
30338+ movl 4(v), %edx
30339+ addl $1, %eax
30340+ adcl $0, %edx
30341 movl %eax, (v)
30342 movl %edx, 4(v)
30343 RET_ENDP
30344@@ -120,6 +229,20 @@ RET_ENDP
30345 BEGIN(dec)
30346 subl $1, (v)
30347 sbbl $0, 4(v)
30348+
30349+#ifdef CONFIG_PAX_REFCOUNT
30350+ jno 0f
30351+ addl $1, (v)
30352+ adcl $0, 4(v)
30353+ int $4
30354+0:
30355+ _ASM_EXTABLE(0b, 0b)
30356+#endif
30357+
30358+RET_ENDP
30359+BEGIN(dec_unchecked)
30360+ subl $1, (v)
30361+ sbbl $0, 4(v)
30362 RET_ENDP
30363 #undef v
30364
30365@@ -129,6 +252,26 @@ BEGIN(dec_return)
30366 movl 4(v), %edx
30367 subl $1, %eax
30368 sbbl $0, %edx
30369+
30370+#ifdef CONFIG_PAX_REFCOUNT
30371+ into
30372+1234:
30373+ _ASM_EXTABLE(1234b, 2f)
30374+#endif
30375+
30376+ movl %eax, (v)
30377+ movl %edx, 4(v)
30378+
30379+#ifdef CONFIG_PAX_REFCOUNT
30380+2:
30381+#endif
30382+
30383+RET_ENDP
30384+BEGIN(dec_return_unchecked)
30385+ movl (v), %eax
30386+ movl 4(v), %edx
30387+ subl $1, %eax
30388+ sbbl $0, %edx
30389 movl %eax, (v)
30390 movl %edx, 4(v)
30391 RET_ENDP
30392@@ -140,6 +283,13 @@ BEGIN(add_unless)
30393 adcl %edx, %edi
30394 addl (v), %eax
30395 adcl 4(v), %edx
30396+
30397+#ifdef CONFIG_PAX_REFCOUNT
30398+ into
30399+1234:
30400+ _ASM_EXTABLE(1234b, 2f)
30401+#endif
30402+
30403 cmpl %eax, %ecx
30404 je 3f
30405 1:
30406@@ -165,6 +315,13 @@ BEGIN(inc_not_zero)
30407 1:
30408 addl $1, %eax
30409 adcl $0, %edx
30410+
30411+#ifdef CONFIG_PAX_REFCOUNT
30412+ into
30413+1234:
30414+ _ASM_EXTABLE(1234b, 2f)
30415+#endif
30416+
30417 movl %eax, (v)
30418 movl %edx, 4(v)
30419 movl $1, %eax
30420@@ -183,6 +340,13 @@ BEGIN(dec_if_positive)
30421 movl 4(v), %edx
30422 subl $1, %eax
30423 sbbl $0, %edx
30424+
30425+#ifdef CONFIG_PAX_REFCOUNT
30426+ into
30427+1234:
30428+ _ASM_EXTABLE(1234b, 1f)
30429+#endif
30430+
30431 js 1f
30432 movl %eax, (v)
30433 movl %edx, 4(v)
30434diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
30435index db3ae854..b8ad0de 100644
30436--- a/arch/x86/lib/atomic64_cx8_32.S
30437+++ b/arch/x86/lib/atomic64_cx8_32.S
30438@@ -22,9 +22,16 @@
30439
30440 ENTRY(atomic64_read_cx8)
30441 read64 %ecx
30442+ pax_force_retaddr
30443 ret
30444 ENDPROC(atomic64_read_cx8)
30445
30446+ENTRY(atomic64_read_unchecked_cx8)
30447+ read64 %ecx
30448+ pax_force_retaddr
30449+ ret
30450+ENDPROC(atomic64_read_unchecked_cx8)
30451+
30452 ENTRY(atomic64_set_cx8)
30453 1:
30454 /* we don't need LOCK_PREFIX since aligned 64-bit writes
30455@@ -32,20 +39,33 @@ ENTRY(atomic64_set_cx8)
30456 cmpxchg8b (%esi)
30457 jne 1b
30458
30459+ pax_force_retaddr
30460 ret
30461 ENDPROC(atomic64_set_cx8)
30462
30463+ENTRY(atomic64_set_unchecked_cx8)
30464+1:
30465+/* we don't need LOCK_PREFIX since aligned 64-bit writes
30466+ * are atomic on 586 and newer */
30467+ cmpxchg8b (%esi)
30468+ jne 1b
30469+
30470+ pax_force_retaddr
30471+ ret
30472+ENDPROC(atomic64_set_unchecked_cx8)
30473+
30474 ENTRY(atomic64_xchg_cx8)
30475 1:
30476 LOCK_PREFIX
30477 cmpxchg8b (%esi)
30478 jne 1b
30479
30480+ pax_force_retaddr
30481 ret
30482 ENDPROC(atomic64_xchg_cx8)
30483
30484-.macro addsub_return func ins insc
30485-ENTRY(atomic64_\func\()_return_cx8)
30486+.macro addsub_return func ins insc unchecked=""
30487+ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
30488 pushl %ebp
30489 pushl %ebx
30490 pushl %esi
30491@@ -61,26 +81,43 @@ ENTRY(atomic64_\func\()_return_cx8)
30492 movl %edx, %ecx
30493 \ins\()l %esi, %ebx
30494 \insc\()l %edi, %ecx
30495+
30496+.ifb \unchecked
30497+#ifdef CONFIG_PAX_REFCOUNT
30498+ into
30499+2:
30500+ _ASM_EXTABLE(2b, 3f)
30501+#endif
30502+.endif
30503+
30504 LOCK_PREFIX
30505 cmpxchg8b (%ebp)
30506 jne 1b
30507-
30508-10:
30509 movl %ebx, %eax
30510 movl %ecx, %edx
30511+
30512+.ifb \unchecked
30513+#ifdef CONFIG_PAX_REFCOUNT
30514+3:
30515+#endif
30516+.endif
30517+
30518 popl %edi
30519 popl %esi
30520 popl %ebx
30521 popl %ebp
30522+ pax_force_retaddr
30523 ret
30524-ENDPROC(atomic64_\func\()_return_cx8)
30525+ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
30526 .endm
30527
30528 addsub_return add add adc
30529 addsub_return sub sub sbb
30530+addsub_return add add adc _unchecked
30531+addsub_return sub sub sbb _unchecked
30532
30533-.macro incdec_return func ins insc
30534-ENTRY(atomic64_\func\()_return_cx8)
30535+.macro incdec_return func ins insc unchecked=""
30536+ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
30537 pushl %ebx
30538
30539 read64 %esi
30540@@ -89,20 +126,37 @@ ENTRY(atomic64_\func\()_return_cx8)
30541 movl %edx, %ecx
30542 \ins\()l $1, %ebx
30543 \insc\()l $0, %ecx
30544+
30545+.ifb \unchecked
30546+#ifdef CONFIG_PAX_REFCOUNT
30547+ into
30548+2:
30549+ _ASM_EXTABLE(2b, 3f)
30550+#endif
30551+.endif
30552+
30553 LOCK_PREFIX
30554 cmpxchg8b (%esi)
30555 jne 1b
30556-
30557-10:
30558 movl %ebx, %eax
30559 movl %ecx, %edx
30560+
30561+.ifb \unchecked
30562+#ifdef CONFIG_PAX_REFCOUNT
30563+3:
30564+#endif
30565+.endif
30566+
30567 popl %ebx
30568+ pax_force_retaddr
30569 ret
30570-ENDPROC(atomic64_\func\()_return_cx8)
30571+ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
30572 .endm
30573
30574 incdec_return inc add adc
30575 incdec_return dec sub sbb
30576+incdec_return inc add adc _unchecked
30577+incdec_return dec sub sbb _unchecked
30578
30579 ENTRY(atomic64_dec_if_positive_cx8)
30580 pushl %ebx
30581@@ -113,6 +167,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
30582 movl %edx, %ecx
30583 subl $1, %ebx
30584 sbb $0, %ecx
30585+
30586+#ifdef CONFIG_PAX_REFCOUNT
30587+ into
30588+1234:
30589+ _ASM_EXTABLE(1234b, 2f)
30590+#endif
30591+
30592 js 2f
30593 LOCK_PREFIX
30594 cmpxchg8b (%esi)
30595@@ -122,6 +183,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
30596 movl %ebx, %eax
30597 movl %ecx, %edx
30598 popl %ebx
30599+ pax_force_retaddr
30600 ret
30601 ENDPROC(atomic64_dec_if_positive_cx8)
30602
30603@@ -144,6 +206,13 @@ ENTRY(atomic64_add_unless_cx8)
30604 movl %edx, %ecx
30605 addl %ebp, %ebx
30606 adcl %edi, %ecx
30607+
30608+#ifdef CONFIG_PAX_REFCOUNT
30609+ into
30610+1234:
30611+ _ASM_EXTABLE(1234b, 3f)
30612+#endif
30613+
30614 LOCK_PREFIX
30615 cmpxchg8b (%esi)
30616 jne 1b
30617@@ -153,6 +222,7 @@ ENTRY(atomic64_add_unless_cx8)
30618 addl $8, %esp
30619 popl %ebx
30620 popl %ebp
30621+ pax_force_retaddr
30622 ret
30623 4:
30624 cmpl %edx, 4(%esp)
30625@@ -173,6 +243,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
30626 xorl %ecx, %ecx
30627 addl $1, %ebx
30628 adcl %edx, %ecx
30629+
30630+#ifdef CONFIG_PAX_REFCOUNT
30631+ into
30632+1234:
30633+ _ASM_EXTABLE(1234b, 3f)
30634+#endif
30635+
30636 LOCK_PREFIX
30637 cmpxchg8b (%esi)
30638 jne 1b
30639@@ -180,5 +257,6 @@ ENTRY(atomic64_inc_not_zero_cx8)
30640 movl $1, %eax
30641 3:
30642 popl %ebx
30643+ pax_force_retaddr
30644 ret
30645 ENDPROC(atomic64_inc_not_zero_cx8)
30646diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
30647index c1e6232..ebbeba7 100644
30648--- a/arch/x86/lib/checksum_32.S
30649+++ b/arch/x86/lib/checksum_32.S
30650@@ -28,7 +28,8 @@
30651 #include <linux/linkage.h>
30652 #include <asm/errno.h>
30653 #include <asm/asm.h>
30654-
30655+#include <asm/segment.h>
30656+
30657 /*
30658 * computes a partial checksum, e.g. for TCP/UDP fragments
30659 */
30660@@ -280,7 +281,22 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
30661
30662 #define ARGBASE 16
30663 #define FP 12
30664-
30665+
30666+ENTRY(csum_partial_copy_generic_to_user)
30667+
30668+#ifdef CONFIG_PAX_MEMORY_UDEREF
30669+ pushl %gs
30670+ popl %es
30671+ jmp csum_partial_copy_generic
30672+#endif
30673+
30674+ENTRY(csum_partial_copy_generic_from_user)
30675+
30676+#ifdef CONFIG_PAX_MEMORY_UDEREF
30677+ pushl %gs
30678+ popl %ds
30679+#endif
30680+
30681 ENTRY(csum_partial_copy_generic)
30682 subl $4,%esp
30683 pushl %edi
30684@@ -299,7 +315,7 @@ ENTRY(csum_partial_copy_generic)
30685 jmp 4f
30686 SRC(1: movw (%esi), %bx )
30687 addl $2, %esi
30688-DST( movw %bx, (%edi) )
30689+DST( movw %bx, %es:(%edi) )
30690 addl $2, %edi
30691 addw %bx, %ax
30692 adcl $0, %eax
30693@@ -311,30 +327,30 @@ DST( movw %bx, (%edi) )
30694 SRC(1: movl (%esi), %ebx )
30695 SRC( movl 4(%esi), %edx )
30696 adcl %ebx, %eax
30697-DST( movl %ebx, (%edi) )
30698+DST( movl %ebx, %es:(%edi) )
30699 adcl %edx, %eax
30700-DST( movl %edx, 4(%edi) )
30701+DST( movl %edx, %es:4(%edi) )
30702
30703 SRC( movl 8(%esi), %ebx )
30704 SRC( movl 12(%esi), %edx )
30705 adcl %ebx, %eax
30706-DST( movl %ebx, 8(%edi) )
30707+DST( movl %ebx, %es:8(%edi) )
30708 adcl %edx, %eax
30709-DST( movl %edx, 12(%edi) )
30710+DST( movl %edx, %es:12(%edi) )
30711
30712 SRC( movl 16(%esi), %ebx )
30713 SRC( movl 20(%esi), %edx )
30714 adcl %ebx, %eax
30715-DST( movl %ebx, 16(%edi) )
30716+DST( movl %ebx, %es:16(%edi) )
30717 adcl %edx, %eax
30718-DST( movl %edx, 20(%edi) )
30719+DST( movl %edx, %es:20(%edi) )
30720
30721 SRC( movl 24(%esi), %ebx )
30722 SRC( movl 28(%esi), %edx )
30723 adcl %ebx, %eax
30724-DST( movl %ebx, 24(%edi) )
30725+DST( movl %ebx, %es:24(%edi) )
30726 adcl %edx, %eax
30727-DST( movl %edx, 28(%edi) )
30728+DST( movl %edx, %es:28(%edi) )
30729
30730 lea 32(%esi), %esi
30731 lea 32(%edi), %edi
30732@@ -348,7 +364,7 @@ DST( movl %edx, 28(%edi) )
30733 shrl $2, %edx # This clears CF
30734 SRC(3: movl (%esi), %ebx )
30735 adcl %ebx, %eax
30736-DST( movl %ebx, (%edi) )
30737+DST( movl %ebx, %es:(%edi) )
30738 lea 4(%esi), %esi
30739 lea 4(%edi), %edi
30740 dec %edx
30741@@ -360,12 +376,12 @@ DST( movl %ebx, (%edi) )
30742 jb 5f
30743 SRC( movw (%esi), %cx )
30744 leal 2(%esi), %esi
30745-DST( movw %cx, (%edi) )
30746+DST( movw %cx, %es:(%edi) )
30747 leal 2(%edi), %edi
30748 je 6f
30749 shll $16,%ecx
30750 SRC(5: movb (%esi), %cl )
30751-DST( movb %cl, (%edi) )
30752+DST( movb %cl, %es:(%edi) )
30753 6: addl %ecx, %eax
30754 adcl $0, %eax
30755 7:
30756@@ -376,7 +392,7 @@ DST( movb %cl, (%edi) )
30757
30758 6001:
30759 movl ARGBASE+20(%esp), %ebx # src_err_ptr
30760- movl $-EFAULT, (%ebx)
30761+ movl $-EFAULT, %ss:(%ebx)
30762
30763 # zero the complete destination - computing the rest
30764 # is too much work
30765@@ -389,34 +405,58 @@ DST( movb %cl, (%edi) )
30766
30767 6002:
30768 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
30769- movl $-EFAULT,(%ebx)
30770+ movl $-EFAULT,%ss:(%ebx)
30771 jmp 5000b
30772
30773 .previous
30774
30775+#ifdef CONFIG_PAX_MEMORY_UDEREF
30776+ pushl %ss
30777+ popl %ds
30778+ pushl %ss
30779+ popl %es
30780+#endif
30781+
30782 popl %ebx
30783 popl %esi
30784 popl %edi
30785 popl %ecx # equivalent to addl $4,%esp
30786 ret
30787-ENDPROC(csum_partial_copy_generic)
30788+ENDPROC(csum_partial_copy_generic_to_user)
30789
30790 #else
30791
30792 /* Version for PentiumII/PPro */
30793
30794 #define ROUND1(x) \
30795+ nop; nop; nop; \
30796 SRC(movl x(%esi), %ebx ) ; \
30797 addl %ebx, %eax ; \
30798- DST(movl %ebx, x(%edi) ) ;
30799+ DST(movl %ebx, %es:x(%edi)) ;
30800
30801 #define ROUND(x) \
30802+ nop; nop; nop; \
30803 SRC(movl x(%esi), %ebx ) ; \
30804 adcl %ebx, %eax ; \
30805- DST(movl %ebx, x(%edi) ) ;
30806+ DST(movl %ebx, %es:x(%edi)) ;
30807
30808 #define ARGBASE 12
30809-
30810+
30811+ENTRY(csum_partial_copy_generic_to_user)
30812+
30813+#ifdef CONFIG_PAX_MEMORY_UDEREF
30814+ pushl %gs
30815+ popl %es
30816+ jmp csum_partial_copy_generic
30817+#endif
30818+
30819+ENTRY(csum_partial_copy_generic_from_user)
30820+
30821+#ifdef CONFIG_PAX_MEMORY_UDEREF
30822+ pushl %gs
30823+ popl %ds
30824+#endif
30825+
30826 ENTRY(csum_partial_copy_generic)
30827 pushl %ebx
30828 pushl %edi
30829@@ -435,7 +475,7 @@ ENTRY(csum_partial_copy_generic)
30830 subl %ebx, %edi
30831 lea -1(%esi),%edx
30832 andl $-32,%edx
30833- lea 3f(%ebx,%ebx), %ebx
30834+ lea 3f(%ebx,%ebx,2), %ebx
30835 testl %esi, %esi
30836 jmp *%ebx
30837 1: addl $64,%esi
30838@@ -456,19 +496,19 @@ ENTRY(csum_partial_copy_generic)
30839 jb 5f
30840 SRC( movw (%esi), %dx )
30841 leal 2(%esi), %esi
30842-DST( movw %dx, (%edi) )
30843+DST( movw %dx, %es:(%edi) )
30844 leal 2(%edi), %edi
30845 je 6f
30846 shll $16,%edx
30847 5:
30848 SRC( movb (%esi), %dl )
30849-DST( movb %dl, (%edi) )
30850+DST( movb %dl, %es:(%edi) )
30851 6: addl %edx, %eax
30852 adcl $0, %eax
30853 7:
30854 .section .fixup, "ax"
30855 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
30856- movl $-EFAULT, (%ebx)
30857+ movl $-EFAULT, %ss:(%ebx)
30858 # zero the complete destination (computing the rest is too much work)
30859 movl ARGBASE+8(%esp),%edi # dst
30860 movl ARGBASE+12(%esp),%ecx # len
30861@@ -476,15 +516,22 @@ DST( movb %dl, (%edi) )
30862 rep; stosb
30863 jmp 7b
30864 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
30865- movl $-EFAULT, (%ebx)
30866+ movl $-EFAULT, %ss:(%ebx)
30867 jmp 7b
30868 .previous
30869
30870+#ifdef CONFIG_PAX_MEMORY_UDEREF
30871+ pushl %ss
30872+ popl %ds
30873+ pushl %ss
30874+ popl %es
30875+#endif
30876+
30877 popl %esi
30878 popl %edi
30879 popl %ebx
30880 ret
30881-ENDPROC(csum_partial_copy_generic)
30882+ENDPROC(csum_partial_copy_generic_to_user)
30883
30884 #undef ROUND
30885 #undef ROUND1
30886diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
30887index a2fe51b..507dab0 100644
30888--- a/arch/x86/lib/clear_page_64.S
30889+++ b/arch/x86/lib/clear_page_64.S
30890@@ -21,6 +21,7 @@ ENTRY(clear_page)
30891 movl $4096/8,%ecx
30892 xorl %eax,%eax
30893 rep stosq
30894+ pax_force_retaddr
30895 ret
30896 ENDPROC(clear_page)
30897
30898@@ -43,6 +44,7 @@ ENTRY(clear_page_orig)
30899 leaq 64(%rdi),%rdi
30900 jnz .Lloop
30901 nop
30902+ pax_force_retaddr
30903 ret
30904 ENDPROC(clear_page_orig)
30905
30906@@ -50,5 +52,6 @@ ENTRY(clear_page_c_e)
30907 movl $4096,%ecx
30908 xorl %eax,%eax
30909 rep stosb
30910+ pax_force_retaddr
30911 ret
30912 ENDPROC(clear_page_c_e)
30913diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
30914index 9b33024..e52ee44 100644
30915--- a/arch/x86/lib/cmpxchg16b_emu.S
30916+++ b/arch/x86/lib/cmpxchg16b_emu.S
30917@@ -7,6 +7,7 @@
30918 */
30919 #include <linux/linkage.h>
30920 #include <asm/percpu.h>
30921+#include <asm/alternative-asm.h>
30922
30923 .text
30924
30925@@ -43,11 +44,13 @@ ENTRY(this_cpu_cmpxchg16b_emu)
30926
30927 popfq
30928 mov $1, %al
30929+ pax_force_retaddr
30930 ret
30931
30932 .Lnot_same:
30933 popfq
30934 xor %al,%al
30935+ pax_force_retaddr
30936 ret
30937
30938 ENDPROC(this_cpu_cmpxchg16b_emu)
30939diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
30940index 009f982..9b3db5e 100644
30941--- a/arch/x86/lib/copy_page_64.S
30942+++ b/arch/x86/lib/copy_page_64.S
30943@@ -15,13 +15,14 @@ ENTRY(copy_page)
30944 ALTERNATIVE "jmp copy_page_regs", "", X86_FEATURE_REP_GOOD
30945 movl $4096/8, %ecx
30946 rep movsq
30947+ pax_force_retaddr
30948 ret
30949 ENDPROC(copy_page)
30950
30951 ENTRY(copy_page_regs)
30952 subq $2*8, %rsp
30953 movq %rbx, (%rsp)
30954- movq %r12, 1*8(%rsp)
30955+ movq %r13, 1*8(%rsp)
30956
30957 movl $(4096/64)-5, %ecx
30958 .p2align 4
30959@@ -34,7 +35,7 @@ ENTRY(copy_page_regs)
30960 movq 0x8*4(%rsi), %r9
30961 movq 0x8*5(%rsi), %r10
30962 movq 0x8*6(%rsi), %r11
30963- movq 0x8*7(%rsi), %r12
30964+ movq 0x8*7(%rsi), %r13
30965
30966 prefetcht0 5*64(%rsi)
30967
30968@@ -45,7 +46,7 @@ ENTRY(copy_page_regs)
30969 movq %r9, 0x8*4(%rdi)
30970 movq %r10, 0x8*5(%rdi)
30971 movq %r11, 0x8*6(%rdi)
30972- movq %r12, 0x8*7(%rdi)
30973+ movq %r13, 0x8*7(%rdi)
30974
30975 leaq 64 (%rsi), %rsi
30976 leaq 64 (%rdi), %rdi
30977@@ -64,7 +65,7 @@ ENTRY(copy_page_regs)
30978 movq 0x8*4(%rsi), %r9
30979 movq 0x8*5(%rsi), %r10
30980 movq 0x8*6(%rsi), %r11
30981- movq 0x8*7(%rsi), %r12
30982+ movq 0x8*7(%rsi), %r13
30983
30984 movq %rax, 0x8*0(%rdi)
30985 movq %rbx, 0x8*1(%rdi)
30986@@ -73,14 +74,15 @@ ENTRY(copy_page_regs)
30987 movq %r9, 0x8*4(%rdi)
30988 movq %r10, 0x8*5(%rdi)
30989 movq %r11, 0x8*6(%rdi)
30990- movq %r12, 0x8*7(%rdi)
30991+ movq %r13, 0x8*7(%rdi)
30992
30993 leaq 64(%rdi), %rdi
30994 leaq 64(%rsi), %rsi
30995 jnz .Loop2
30996
30997 movq (%rsp), %rbx
30998- movq 1*8(%rsp), %r12
30999+ movq 1*8(%rsp), %r13
31000 addq $2*8, %rsp
31001+ pax_force_retaddr
31002 ret
31003 ENDPROC(copy_page_regs)
31004diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
31005index 982ce34..8e14731 100644
31006--- a/arch/x86/lib/copy_user_64.S
31007+++ b/arch/x86/lib/copy_user_64.S
31008@@ -14,50 +14,7 @@
31009 #include <asm/alternative-asm.h>
31010 #include <asm/asm.h>
31011 #include <asm/smap.h>
31012-
31013-/* Standard copy_to_user with segment limit checking */
31014-ENTRY(_copy_to_user)
31015- GET_THREAD_INFO(%rax)
31016- movq %rdi,%rcx
31017- addq %rdx,%rcx
31018- jc bad_to_user
31019- cmpq TI_addr_limit(%rax),%rcx
31020- ja bad_to_user
31021- ALTERNATIVE_2 "jmp copy_user_generic_unrolled", \
31022- "jmp copy_user_generic_string", \
31023- X86_FEATURE_REP_GOOD, \
31024- "jmp copy_user_enhanced_fast_string", \
31025- X86_FEATURE_ERMS
31026-ENDPROC(_copy_to_user)
31027-
31028-/* Standard copy_from_user with segment limit checking */
31029-ENTRY(_copy_from_user)
31030- GET_THREAD_INFO(%rax)
31031- movq %rsi,%rcx
31032- addq %rdx,%rcx
31033- jc bad_from_user
31034- cmpq TI_addr_limit(%rax),%rcx
31035- ja bad_from_user
31036- ALTERNATIVE_2 "jmp copy_user_generic_unrolled", \
31037- "jmp copy_user_generic_string", \
31038- X86_FEATURE_REP_GOOD, \
31039- "jmp copy_user_enhanced_fast_string", \
31040- X86_FEATURE_ERMS
31041-ENDPROC(_copy_from_user)
31042-
31043- .section .fixup,"ax"
31044- /* must zero dest */
31045-ENTRY(bad_from_user)
31046-bad_from_user:
31047- movl %edx,%ecx
31048- xorl %eax,%eax
31049- rep
31050- stosb
31051-bad_to_user:
31052- movl %edx,%eax
31053- ret
31054-ENDPROC(bad_from_user)
31055- .previous
31056+#include <asm/pgtable.h>
31057
31058 /*
31059 * copy_user_generic_unrolled - memory copy with exception handling.
31060@@ -73,6 +30,7 @@ ENDPROC(bad_from_user)
31061 * eax uncopied bytes or 0 if successful.
31062 */
31063 ENTRY(copy_user_generic_unrolled)
31064+ ASM_PAX_OPEN_USERLAND
31065 ASM_STAC
31066 cmpl $8,%edx
31067 jb 20f /* less then 8 bytes, go to byte copy loop */
31068@@ -122,6 +80,8 @@ ENTRY(copy_user_generic_unrolled)
31069 jnz 21b
31070 23: xor %eax,%eax
31071 ASM_CLAC
31072+ ASM_PAX_CLOSE_USERLAND
31073+ pax_force_retaddr
31074 ret
31075
31076 .section .fixup,"ax"
31077@@ -175,6 +135,7 @@ ENDPROC(copy_user_generic_unrolled)
31078 * eax uncopied bytes or 0 if successful.
31079 */
31080 ENTRY(copy_user_generic_string)
31081+ ASM_PAX_OPEN_USERLAND
31082 ASM_STAC
31083 cmpl $8,%edx
31084 jb 2f /* less than 8 bytes, go to byte copy loop */
31085@@ -189,6 +150,8 @@ ENTRY(copy_user_generic_string)
31086 movsb
31087 xorl %eax,%eax
31088 ASM_CLAC
31089+ ASM_PAX_CLOSE_USERLAND
31090+ pax_force_retaddr
31091 ret
31092
31093 .section .fixup,"ax"
31094@@ -214,12 +177,15 @@ ENDPROC(copy_user_generic_string)
31095 * eax uncopied bytes or 0 if successful.
31096 */
31097 ENTRY(copy_user_enhanced_fast_string)
31098+ ASM_PAX_OPEN_USERLAND
31099 ASM_STAC
31100 movl %edx,%ecx
31101 1: rep
31102 movsb
31103 xorl %eax,%eax
31104 ASM_CLAC
31105+ ASM_PAX_CLOSE_USERLAND
31106+ pax_force_retaddr
31107 ret
31108
31109 .section .fixup,"ax"
31110@@ -235,6 +201,16 @@ ENDPROC(copy_user_enhanced_fast_string)
31111 * This will force destination/source out of cache for more performance.
31112 */
31113 ENTRY(__copy_user_nocache)
31114+
31115+#ifdef CONFIG_PAX_MEMORY_UDEREF
31116+ mov pax_user_shadow_base,%rcx
31117+ cmp %rcx,%rsi
31118+ jae 1f
31119+ add %rcx,%rsi
31120+1:
31121+#endif
31122+
31123+ ASM_PAX_OPEN_USERLAND
31124 ASM_STAC
31125 cmpl $8,%edx
31126 jb 20f /* less then 8 bytes, go to byte copy loop */
31127@@ -284,7 +260,9 @@ ENTRY(__copy_user_nocache)
31128 jnz 21b
31129 23: xorl %eax,%eax
31130 ASM_CLAC
31131+ ASM_PAX_CLOSE_USERLAND
31132 sfence
31133+ pax_force_retaddr
31134 ret
31135
31136 .section .fixup,"ax"
31137diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
31138index 7e48807..cc966ff 100644
31139--- a/arch/x86/lib/csum-copy_64.S
31140+++ b/arch/x86/lib/csum-copy_64.S
31141@@ -8,6 +8,7 @@
31142 #include <linux/linkage.h>
31143 #include <asm/errno.h>
31144 #include <asm/asm.h>
31145+#include <asm/alternative-asm.h>
31146
31147 /*
31148 * Checksum copy with exception handling.
31149@@ -52,7 +53,7 @@ ENTRY(csum_partial_copy_generic)
31150 .Lignore:
31151 subq $7*8, %rsp
31152 movq %rbx, 2*8(%rsp)
31153- movq %r12, 3*8(%rsp)
31154+ movq %r15, 3*8(%rsp)
31155 movq %r14, 4*8(%rsp)
31156 movq %r13, 5*8(%rsp)
31157 movq %rbp, 6*8(%rsp)
31158@@ -64,16 +65,16 @@ ENTRY(csum_partial_copy_generic)
31159 movl %edx, %ecx
31160
31161 xorl %r9d, %r9d
31162- movq %rcx, %r12
31163+ movq %rcx, %r15
31164
31165- shrq $6, %r12
31166+ shrq $6, %r15
31167 jz .Lhandle_tail /* < 64 */
31168
31169 clc
31170
31171 /* main loop. clear in 64 byte blocks */
31172 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
31173- /* r11: temp3, rdx: temp4, r12 loopcnt */
31174+ /* r11: temp3, rdx: temp4, r15 loopcnt */
31175 /* r10: temp5, rbp: temp6, r14 temp7, r13 temp8 */
31176 .p2align 4
31177 .Lloop:
31178@@ -107,7 +108,7 @@ ENTRY(csum_partial_copy_generic)
31179 adcq %r14, %rax
31180 adcq %r13, %rax
31181
31182- decl %r12d
31183+ decl %r15d
31184
31185 dest
31186 movq %rbx, (%rsi)
31187@@ -200,11 +201,12 @@ ENTRY(csum_partial_copy_generic)
31188
31189 .Lende:
31190 movq 2*8(%rsp), %rbx
31191- movq 3*8(%rsp), %r12
31192+ movq 3*8(%rsp), %r15
31193 movq 4*8(%rsp), %r14
31194 movq 5*8(%rsp), %r13
31195 movq 6*8(%rsp), %rbp
31196 addq $7*8, %rsp
31197+ pax_force_retaddr
31198 ret
31199
31200 /* Exception handlers. Very simple, zeroing is done in the wrappers */
31201diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
31202index 1318f75..44c30fd 100644
31203--- a/arch/x86/lib/csum-wrappers_64.c
31204+++ b/arch/x86/lib/csum-wrappers_64.c
31205@@ -52,10 +52,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
31206 len -= 2;
31207 }
31208 }
31209+ pax_open_userland();
31210 stac();
31211- isum = csum_partial_copy_generic((__force const void *)src,
31212+ isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
31213 dst, len, isum, errp, NULL);
31214 clac();
31215+ pax_close_userland();
31216 if (unlikely(*errp))
31217 goto out_err;
31218
31219@@ -109,10 +111,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
31220 }
31221
31222 *errp = 0;
31223+ pax_open_userland();
31224 stac();
31225- ret = csum_partial_copy_generic(src, (void __force *)dst,
31226+ ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
31227 len, isum, NULL, errp);
31228 clac();
31229+ pax_close_userland();
31230 return ret;
31231 }
31232 EXPORT_SYMBOL(csum_partial_copy_to_user);
31233diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
31234index 46668cd..a3bdfb9 100644
31235--- a/arch/x86/lib/getuser.S
31236+++ b/arch/x86/lib/getuser.S
31237@@ -32,42 +32,93 @@
31238 #include <asm/thread_info.h>
31239 #include <asm/asm.h>
31240 #include <asm/smap.h>
31241+#include <asm/segment.h>
31242+#include <asm/pgtable.h>
31243+#include <asm/alternative-asm.h>
31244+
31245+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
31246+#define __copyuser_seg gs;
31247+#else
31248+#define __copyuser_seg
31249+#endif
31250
31251 .text
31252 ENTRY(__get_user_1)
31253+
31254+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31255 GET_THREAD_INFO(%_ASM_DX)
31256 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31257 jae bad_get_user
31258+
31259+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31260+ mov pax_user_shadow_base,%_ASM_DX
31261+ cmp %_ASM_DX,%_ASM_AX
31262+ jae 1234f
31263+ add %_ASM_DX,%_ASM_AX
31264+1234:
31265+#endif
31266+
31267+#endif
31268+
31269 ASM_STAC
31270-1: movzbl (%_ASM_AX),%edx
31271+1: __copyuser_seg movzbl (%_ASM_AX),%edx
31272 xor %eax,%eax
31273 ASM_CLAC
31274+ pax_force_retaddr
31275 ret
31276 ENDPROC(__get_user_1)
31277
31278 ENTRY(__get_user_2)
31279 add $1,%_ASM_AX
31280+
31281+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31282 jc bad_get_user
31283 GET_THREAD_INFO(%_ASM_DX)
31284 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31285 jae bad_get_user
31286+
31287+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31288+ mov pax_user_shadow_base,%_ASM_DX
31289+ cmp %_ASM_DX,%_ASM_AX
31290+ jae 1234f
31291+ add %_ASM_DX,%_ASM_AX
31292+1234:
31293+#endif
31294+
31295+#endif
31296+
31297 ASM_STAC
31298-2: movzwl -1(%_ASM_AX),%edx
31299+2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
31300 xor %eax,%eax
31301 ASM_CLAC
31302+ pax_force_retaddr
31303 ret
31304 ENDPROC(__get_user_2)
31305
31306 ENTRY(__get_user_4)
31307 add $3,%_ASM_AX
31308+
31309+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31310 jc bad_get_user
31311 GET_THREAD_INFO(%_ASM_DX)
31312 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31313 jae bad_get_user
31314+
31315+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31316+ mov pax_user_shadow_base,%_ASM_DX
31317+ cmp %_ASM_DX,%_ASM_AX
31318+ jae 1234f
31319+ add %_ASM_DX,%_ASM_AX
31320+1234:
31321+#endif
31322+
31323+#endif
31324+
31325 ASM_STAC
31326-3: movl -3(%_ASM_AX),%edx
31327+3: __copyuser_seg movl -3(%_ASM_AX),%edx
31328 xor %eax,%eax
31329 ASM_CLAC
31330+ pax_force_retaddr
31331 ret
31332 ENDPROC(__get_user_4)
31333
31334@@ -78,10 +129,20 @@ ENTRY(__get_user_8)
31335 GET_THREAD_INFO(%_ASM_DX)
31336 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31337 jae bad_get_user
31338+
31339+#ifdef CONFIG_PAX_MEMORY_UDEREF
31340+ mov pax_user_shadow_base,%_ASM_DX
31341+ cmp %_ASM_DX,%_ASM_AX
31342+ jae 1234f
31343+ add %_ASM_DX,%_ASM_AX
31344+1234:
31345+#endif
31346+
31347 ASM_STAC
31348 4: movq -7(%_ASM_AX),%rdx
31349 xor %eax,%eax
31350 ASM_CLAC
31351+ pax_force_retaddr
31352 ret
31353 #else
31354 add $7,%_ASM_AX
31355@@ -90,10 +151,11 @@ ENTRY(__get_user_8)
31356 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31357 jae bad_get_user_8
31358 ASM_STAC
31359-4: movl -7(%_ASM_AX),%edx
31360-5: movl -3(%_ASM_AX),%ecx
31361+4: __copyuser_seg movl -7(%_ASM_AX),%edx
31362+5: __copyuser_seg movl -3(%_ASM_AX),%ecx
31363 xor %eax,%eax
31364 ASM_CLAC
31365+ pax_force_retaddr
31366 ret
31367 #endif
31368 ENDPROC(__get_user_8)
31369@@ -103,6 +165,7 @@ bad_get_user:
31370 xor %edx,%edx
31371 mov $(-EFAULT),%_ASM_AX
31372 ASM_CLAC
31373+ pax_force_retaddr
31374 ret
31375 END(bad_get_user)
31376
31377@@ -112,6 +175,7 @@ bad_get_user_8:
31378 xor %ecx,%ecx
31379 mov $(-EFAULT),%_ASM_AX
31380 ASM_CLAC
31381+ pax_force_retaddr
31382 ret
31383 END(bad_get_user_8)
31384 #endif
31385diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
31386index 8f72b33..4667a46 100644
31387--- a/arch/x86/lib/insn.c
31388+++ b/arch/x86/lib/insn.c
31389@@ -20,8 +20,10 @@
31390
31391 #ifdef __KERNEL__
31392 #include <linux/string.h>
31393+#include <asm/pgtable_types.h>
31394 #else
31395 #include <string.h>
31396+#define ktla_ktva(addr) addr
31397 #endif
31398 #include <asm/inat.h>
31399 #include <asm/insn.h>
31400@@ -60,9 +62,9 @@ void insn_init(struct insn *insn, const void *kaddr, int buf_len, int x86_64)
31401 buf_len = MAX_INSN_SIZE;
31402
31403 memset(insn, 0, sizeof(*insn));
31404- insn->kaddr = kaddr;
31405- insn->end_kaddr = kaddr + buf_len;
31406- insn->next_byte = kaddr;
31407+ insn->kaddr = (void *)ktla_ktva((unsigned long)kaddr);
31408+ insn->end_kaddr = insn->kaddr + buf_len;
31409+ insn->next_byte = insn->kaddr;
31410 insn->x86_64 = x86_64 ? 1 : 0;
31411 insn->opnd_bytes = 4;
31412 if (x86_64)
31413diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
31414index 33147fe..12a8815 100644
31415--- a/arch/x86/lib/iomap_copy_64.S
31416+++ b/arch/x86/lib/iomap_copy_64.S
31417@@ -16,6 +16,7 @@
31418 */
31419
31420 #include <linux/linkage.h>
31421+#include <asm/alternative-asm.h>
31422
31423 /*
31424 * override generic version in lib/iomap_copy.c
31425@@ -23,5 +24,6 @@
31426 ENTRY(__iowrite32_copy)
31427 movl %edx,%ecx
31428 rep movsd
31429+ pax_force_retaddr
31430 ret
31431 ENDPROC(__iowrite32_copy)
31432diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
31433index 16698bb..971d300 100644
31434--- a/arch/x86/lib/memcpy_64.S
31435+++ b/arch/x86/lib/memcpy_64.S
31436@@ -36,6 +36,7 @@ ENTRY(memcpy)
31437 rep movsq
31438 movl %edx, %ecx
31439 rep movsb
31440+ pax_force_retaddr
31441 ret
31442 ENDPROC(memcpy)
31443 ENDPROC(__memcpy)
31444@@ -48,6 +49,7 @@ ENTRY(memcpy_erms)
31445 movq %rdi, %rax
31446 movq %rdx, %rcx
31447 rep movsb
31448+ pax_force_retaddr
31449 ret
31450 ENDPROC(memcpy_erms)
31451
31452@@ -132,6 +134,7 @@ ENTRY(memcpy_orig)
31453 movq %r9, 1*8(%rdi)
31454 movq %r10, -2*8(%rdi, %rdx)
31455 movq %r11, -1*8(%rdi, %rdx)
31456+ pax_force_retaddr
31457 retq
31458 .p2align 4
31459 .Lless_16bytes:
31460@@ -144,6 +147,7 @@ ENTRY(memcpy_orig)
31461 movq -1*8(%rsi, %rdx), %r9
31462 movq %r8, 0*8(%rdi)
31463 movq %r9, -1*8(%rdi, %rdx)
31464+ pax_force_retaddr
31465 retq
31466 .p2align 4
31467 .Lless_8bytes:
31468@@ -157,6 +161,7 @@ ENTRY(memcpy_orig)
31469 movl -4(%rsi, %rdx), %r8d
31470 movl %ecx, (%rdi)
31471 movl %r8d, -4(%rdi, %rdx)
31472+ pax_force_retaddr
31473 retq
31474 .p2align 4
31475 .Lless_3bytes:
31476@@ -175,5 +180,6 @@ ENTRY(memcpy_orig)
31477 movb %cl, (%rdi)
31478
31479 .Lend:
31480+ pax_force_retaddr
31481 retq
31482 ENDPROC(memcpy_orig)
31483diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
31484index ca2afdd..2e474fa 100644
31485--- a/arch/x86/lib/memmove_64.S
31486+++ b/arch/x86/lib/memmove_64.S
31487@@ -41,7 +41,7 @@ ENTRY(__memmove)
31488 jg 2f
31489
31490 .Lmemmove_begin_forward:
31491- ALTERNATIVE "", "movq %rdx, %rcx; rep movsb; retq", X86_FEATURE_ERMS
31492+ ALTERNATIVE "", "movq %rdx, %rcx; rep movsb; pax_force_retaddr; retq", X86_FEATURE_ERMS
31493
31494 /*
31495 * movsq instruction have many startup latency
31496@@ -204,6 +204,7 @@ ENTRY(__memmove)
31497 movb (%rsi), %r11b
31498 movb %r11b, (%rdi)
31499 13:
31500+ pax_force_retaddr
31501 retq
31502 ENDPROC(__memmove)
31503 ENDPROC(memmove)
31504diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
31505index 2661fad..b584d5c 100644
31506--- a/arch/x86/lib/memset_64.S
31507+++ b/arch/x86/lib/memset_64.S
31508@@ -40,6 +40,7 @@ ENTRY(__memset)
31509 movl %edx,%ecx
31510 rep stosb
31511 movq %r9,%rax
31512+ pax_force_retaddr
31513 ret
31514 ENDPROC(memset)
31515 ENDPROC(__memset)
31516@@ -61,6 +62,7 @@ ENTRY(memset_erms)
31517 movq %rdx,%rcx
31518 rep stosb
31519 movq %r9,%rax
31520+ pax_force_retaddr
31521 ret
31522 ENDPROC(memset_erms)
31523
31524@@ -123,6 +125,7 @@ ENTRY(memset_orig)
31525
31526 .Lende:
31527 movq %r10,%rax
31528+ pax_force_retaddr
31529 ret
31530
31531 .Lbad_alignment:
31532diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
31533index e5e3ed8..d7c08c2 100644
31534--- a/arch/x86/lib/mmx_32.c
31535+++ b/arch/x86/lib/mmx_32.c
31536@@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
31537 {
31538 void *p;
31539 int i;
31540+ unsigned long cr0;
31541
31542 if (unlikely(in_interrupt()))
31543 return __memcpy(to, from, len);
31544@@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
31545 kernel_fpu_begin();
31546
31547 __asm__ __volatile__ (
31548- "1: prefetch (%0)\n" /* This set is 28 bytes */
31549- " prefetch 64(%0)\n"
31550- " prefetch 128(%0)\n"
31551- " prefetch 192(%0)\n"
31552- " prefetch 256(%0)\n"
31553+ "1: prefetch (%1)\n" /* This set is 28 bytes */
31554+ " prefetch 64(%1)\n"
31555+ " prefetch 128(%1)\n"
31556+ " prefetch 192(%1)\n"
31557+ " prefetch 256(%1)\n"
31558 "2: \n"
31559 ".section .fixup, \"ax\"\n"
31560- "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31561+ "3: \n"
31562+
31563+#ifdef CONFIG_PAX_KERNEXEC
31564+ " movl %%cr0, %0\n"
31565+ " movl %0, %%eax\n"
31566+ " andl $0xFFFEFFFF, %%eax\n"
31567+ " movl %%eax, %%cr0\n"
31568+#endif
31569+
31570+ " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31571+
31572+#ifdef CONFIG_PAX_KERNEXEC
31573+ " movl %0, %%cr0\n"
31574+#endif
31575+
31576 " jmp 2b\n"
31577 ".previous\n"
31578 _ASM_EXTABLE(1b, 3b)
31579- : : "r" (from));
31580+ : "=&r" (cr0) : "r" (from) : "ax");
31581
31582 for ( ; i > 5; i--) {
31583 __asm__ __volatile__ (
31584- "1: prefetch 320(%0)\n"
31585- "2: movq (%0), %%mm0\n"
31586- " movq 8(%0), %%mm1\n"
31587- " movq 16(%0), %%mm2\n"
31588- " movq 24(%0), %%mm3\n"
31589- " movq %%mm0, (%1)\n"
31590- " movq %%mm1, 8(%1)\n"
31591- " movq %%mm2, 16(%1)\n"
31592- " movq %%mm3, 24(%1)\n"
31593- " movq 32(%0), %%mm0\n"
31594- " movq 40(%0), %%mm1\n"
31595- " movq 48(%0), %%mm2\n"
31596- " movq 56(%0), %%mm3\n"
31597- " movq %%mm0, 32(%1)\n"
31598- " movq %%mm1, 40(%1)\n"
31599- " movq %%mm2, 48(%1)\n"
31600- " movq %%mm3, 56(%1)\n"
31601+ "1: prefetch 320(%1)\n"
31602+ "2: movq (%1), %%mm0\n"
31603+ " movq 8(%1), %%mm1\n"
31604+ " movq 16(%1), %%mm2\n"
31605+ " movq 24(%1), %%mm3\n"
31606+ " movq %%mm0, (%2)\n"
31607+ " movq %%mm1, 8(%2)\n"
31608+ " movq %%mm2, 16(%2)\n"
31609+ " movq %%mm3, 24(%2)\n"
31610+ " movq 32(%1), %%mm0\n"
31611+ " movq 40(%1), %%mm1\n"
31612+ " movq 48(%1), %%mm2\n"
31613+ " movq 56(%1), %%mm3\n"
31614+ " movq %%mm0, 32(%2)\n"
31615+ " movq %%mm1, 40(%2)\n"
31616+ " movq %%mm2, 48(%2)\n"
31617+ " movq %%mm3, 56(%2)\n"
31618 ".section .fixup, \"ax\"\n"
31619- "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31620+ "3:\n"
31621+
31622+#ifdef CONFIG_PAX_KERNEXEC
31623+ " movl %%cr0, %0\n"
31624+ " movl %0, %%eax\n"
31625+ " andl $0xFFFEFFFF, %%eax\n"
31626+ " movl %%eax, %%cr0\n"
31627+#endif
31628+
31629+ " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31630+
31631+#ifdef CONFIG_PAX_KERNEXEC
31632+ " movl %0, %%cr0\n"
31633+#endif
31634+
31635 " jmp 2b\n"
31636 ".previous\n"
31637 _ASM_EXTABLE(1b, 3b)
31638- : : "r" (from), "r" (to) : "memory");
31639+ : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
31640
31641 from += 64;
31642 to += 64;
31643@@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
31644 static void fast_copy_page(void *to, void *from)
31645 {
31646 int i;
31647+ unsigned long cr0;
31648
31649 kernel_fpu_begin();
31650
31651@@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
31652 * but that is for later. -AV
31653 */
31654 __asm__ __volatile__(
31655- "1: prefetch (%0)\n"
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"
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) : : "r" (from));
31686+ _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
31687
31688 for (i = 0; i < (4096-320)/64; i++) {
31689 __asm__ __volatile__ (
31690- "1: prefetch 320(%0)\n"
31691- "2: movq (%0), %%mm0\n"
31692- " movntq %%mm0, (%1)\n"
31693- " movq 8(%0), %%mm1\n"
31694- " movntq %%mm1, 8(%1)\n"
31695- " movq 16(%0), %%mm2\n"
31696- " movntq %%mm2, 16(%1)\n"
31697- " movq 24(%0), %%mm3\n"
31698- " movntq %%mm3, 24(%1)\n"
31699- " movq 32(%0), %%mm4\n"
31700- " movntq %%mm4, 32(%1)\n"
31701- " movq 40(%0), %%mm5\n"
31702- " movntq %%mm5, 40(%1)\n"
31703- " movq 48(%0), %%mm6\n"
31704- " movntq %%mm6, 48(%1)\n"
31705- " movq 56(%0), %%mm7\n"
31706- " movntq %%mm7, 56(%1)\n"
31707+ "1: prefetch 320(%1)\n"
31708+ "2: movq (%1), %%mm0\n"
31709+ " movntq %%mm0, (%2)\n"
31710+ " movq 8(%1), %%mm1\n"
31711+ " movntq %%mm1, 8(%2)\n"
31712+ " movq 16(%1), %%mm2\n"
31713+ " movntq %%mm2, 16(%2)\n"
31714+ " movq 24(%1), %%mm3\n"
31715+ " movntq %%mm3, 24(%2)\n"
31716+ " movq 32(%1), %%mm4\n"
31717+ " movntq %%mm4, 32(%2)\n"
31718+ " movq 40(%1), %%mm5\n"
31719+ " movntq %%mm5, 40(%2)\n"
31720+ " movq 48(%1), %%mm6\n"
31721+ " movntq %%mm6, 48(%2)\n"
31722+ " movq 56(%1), %%mm7\n"
31723+ " movntq %%mm7, 56(%2)\n"
31724 ".section .fixup, \"ax\"\n"
31725- "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31726+ "3:\n"
31727+
31728+#ifdef CONFIG_PAX_KERNEXEC
31729+ " movl %%cr0, %0\n"
31730+ " movl %0, %%eax\n"
31731+ " andl $0xFFFEFFFF, %%eax\n"
31732+ " movl %%eax, %%cr0\n"
31733+#endif
31734+
31735+ " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31736+
31737+#ifdef CONFIG_PAX_KERNEXEC
31738+ " movl %0, %%cr0\n"
31739+#endif
31740+
31741 " jmp 2b\n"
31742 ".previous\n"
31743- _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
31744+ _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
31745
31746 from += 64;
31747 to += 64;
31748@@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
31749 static void fast_copy_page(void *to, void *from)
31750 {
31751 int i;
31752+ unsigned long cr0;
31753
31754 kernel_fpu_begin();
31755
31756 __asm__ __volatile__ (
31757- "1: prefetch (%0)\n"
31758- " prefetch 64(%0)\n"
31759- " prefetch 128(%0)\n"
31760- " prefetch 192(%0)\n"
31761- " prefetch 256(%0)\n"
31762+ "1: prefetch (%1)\n"
31763+ " prefetch 64(%1)\n"
31764+ " prefetch 128(%1)\n"
31765+ " prefetch 192(%1)\n"
31766+ " prefetch 256(%1)\n"
31767 "2: \n"
31768 ".section .fixup, \"ax\"\n"
31769- "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31770+ "3: \n"
31771+
31772+#ifdef CONFIG_PAX_KERNEXEC
31773+ " movl %%cr0, %0\n"
31774+ " movl %0, %%eax\n"
31775+ " andl $0xFFFEFFFF, %%eax\n"
31776+ " movl %%eax, %%cr0\n"
31777+#endif
31778+
31779+ " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31780+
31781+#ifdef CONFIG_PAX_KERNEXEC
31782+ " movl %0, %%cr0\n"
31783+#endif
31784+
31785 " jmp 2b\n"
31786 ".previous\n"
31787- _ASM_EXTABLE(1b, 3b) : : "r" (from));
31788+ _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
31789
31790 for (i = 0; i < 4096/64; i++) {
31791 __asm__ __volatile__ (
31792- "1: prefetch 320(%0)\n"
31793- "2: movq (%0), %%mm0\n"
31794- " movq 8(%0), %%mm1\n"
31795- " movq 16(%0), %%mm2\n"
31796- " movq 24(%0), %%mm3\n"
31797- " movq %%mm0, (%1)\n"
31798- " movq %%mm1, 8(%1)\n"
31799- " movq %%mm2, 16(%1)\n"
31800- " movq %%mm3, 24(%1)\n"
31801- " movq 32(%0), %%mm0\n"
31802- " movq 40(%0), %%mm1\n"
31803- " movq 48(%0), %%mm2\n"
31804- " movq 56(%0), %%mm3\n"
31805- " movq %%mm0, 32(%1)\n"
31806- " movq %%mm1, 40(%1)\n"
31807- " movq %%mm2, 48(%1)\n"
31808- " movq %%mm3, 56(%1)\n"
31809+ "1: prefetch 320(%1)\n"
31810+ "2: movq (%1), %%mm0\n"
31811+ " movq 8(%1), %%mm1\n"
31812+ " movq 16(%1), %%mm2\n"
31813+ " movq 24(%1), %%mm3\n"
31814+ " movq %%mm0, (%2)\n"
31815+ " movq %%mm1, 8(%2)\n"
31816+ " movq %%mm2, 16(%2)\n"
31817+ " movq %%mm3, 24(%2)\n"
31818+ " movq 32(%1), %%mm0\n"
31819+ " movq 40(%1), %%mm1\n"
31820+ " movq 48(%1), %%mm2\n"
31821+ " movq 56(%1), %%mm3\n"
31822+ " movq %%mm0, 32(%2)\n"
31823+ " movq %%mm1, 40(%2)\n"
31824+ " movq %%mm2, 48(%2)\n"
31825+ " movq %%mm3, 56(%2)\n"
31826 ".section .fixup, \"ax\"\n"
31827- "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31828+ "3:\n"
31829+
31830+#ifdef CONFIG_PAX_KERNEXEC
31831+ " movl %%cr0, %0\n"
31832+ " movl %0, %%eax\n"
31833+ " andl $0xFFFEFFFF, %%eax\n"
31834+ " movl %%eax, %%cr0\n"
31835+#endif
31836+
31837+ " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31838+
31839+#ifdef CONFIG_PAX_KERNEXEC
31840+ " movl %0, %%cr0\n"
31841+#endif
31842+
31843 " jmp 2b\n"
31844 ".previous\n"
31845 _ASM_EXTABLE(1b, 3b)
31846- : : "r" (from), "r" (to) : "memory");
31847+ : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
31848
31849 from += 64;
31850 to += 64;
31851diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
31852index c815564..303dcfa 100644
31853--- a/arch/x86/lib/msr-reg.S
31854+++ b/arch/x86/lib/msr-reg.S
31855@@ -2,6 +2,7 @@
31856 #include <linux/errno.h>
31857 #include <asm/asm.h>
31858 #include <asm/msr.h>
31859+#include <asm/alternative-asm.h>
31860
31861 #ifdef CONFIG_X86_64
31862 /*
31863@@ -34,6 +35,7 @@ ENTRY(\op\()_safe_regs)
31864 movl %edi, 28(%r10)
31865 popq %rbp
31866 popq %rbx
31867+ pax_force_retaddr
31868 ret
31869 3:
31870 movl $-EIO, %r11d
31871diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
31872index e0817a1..bc9cf66 100644
31873--- a/arch/x86/lib/putuser.S
31874+++ b/arch/x86/lib/putuser.S
31875@@ -15,7 +15,9 @@
31876 #include <asm/errno.h>
31877 #include <asm/asm.h>
31878 #include <asm/smap.h>
31879-
31880+#include <asm/segment.h>
31881+#include <asm/pgtable.h>
31882+#include <asm/alternative-asm.h>
31883
31884 /*
31885 * __put_user_X
31886@@ -29,55 +31,124 @@
31887 * as they get called from within inline assembly.
31888 */
31889
31890-#define ENTER GET_THREAD_INFO(%_ASM_BX)
31891-#define EXIT ASM_CLAC ; \
31892+#define ENTER
31893+#define EXIT ASM_CLAC ; \
31894+ pax_force_retaddr ; \
31895 ret
31896
31897+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31898+#define _DEST %_ASM_CX,%_ASM_BX
31899+#else
31900+#define _DEST %_ASM_CX
31901+#endif
31902+
31903+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
31904+#define __copyuser_seg gs;
31905+#else
31906+#define __copyuser_seg
31907+#endif
31908+
31909 .text
31910 ENTRY(__put_user_1)
31911 ENTER
31912+
31913+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31914+ GET_THREAD_INFO(%_ASM_BX)
31915 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
31916 jae bad_put_user
31917+
31918+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31919+ mov pax_user_shadow_base,%_ASM_BX
31920+ cmp %_ASM_BX,%_ASM_CX
31921+ jb 1234f
31922+ xor %ebx,%ebx
31923+1234:
31924+#endif
31925+
31926+#endif
31927+
31928 ASM_STAC
31929-1: movb %al,(%_ASM_CX)
31930+1: __copyuser_seg movb %al,(_DEST)
31931 xor %eax,%eax
31932 EXIT
31933 ENDPROC(__put_user_1)
31934
31935 ENTRY(__put_user_2)
31936 ENTER
31937+
31938+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31939+ GET_THREAD_INFO(%_ASM_BX)
31940 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
31941 sub $1,%_ASM_BX
31942 cmp %_ASM_BX,%_ASM_CX
31943 jae bad_put_user
31944+
31945+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31946+ mov pax_user_shadow_base,%_ASM_BX
31947+ cmp %_ASM_BX,%_ASM_CX
31948+ jb 1234f
31949+ xor %ebx,%ebx
31950+1234:
31951+#endif
31952+
31953+#endif
31954+
31955 ASM_STAC
31956-2: movw %ax,(%_ASM_CX)
31957+2: __copyuser_seg movw %ax,(_DEST)
31958 xor %eax,%eax
31959 EXIT
31960 ENDPROC(__put_user_2)
31961
31962 ENTRY(__put_user_4)
31963 ENTER
31964+
31965+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31966+ GET_THREAD_INFO(%_ASM_BX)
31967 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
31968 sub $3,%_ASM_BX
31969 cmp %_ASM_BX,%_ASM_CX
31970 jae bad_put_user
31971+
31972+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31973+ mov pax_user_shadow_base,%_ASM_BX
31974+ cmp %_ASM_BX,%_ASM_CX
31975+ jb 1234f
31976+ xor %ebx,%ebx
31977+1234:
31978+#endif
31979+
31980+#endif
31981+
31982 ASM_STAC
31983-3: movl %eax,(%_ASM_CX)
31984+3: __copyuser_seg movl %eax,(_DEST)
31985 xor %eax,%eax
31986 EXIT
31987 ENDPROC(__put_user_4)
31988
31989 ENTRY(__put_user_8)
31990 ENTER
31991+
31992+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31993+ GET_THREAD_INFO(%_ASM_BX)
31994 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
31995 sub $7,%_ASM_BX
31996 cmp %_ASM_BX,%_ASM_CX
31997 jae bad_put_user
31998+
31999+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32000+ mov pax_user_shadow_base,%_ASM_BX
32001+ cmp %_ASM_BX,%_ASM_CX
32002+ jb 1234f
32003+ xor %ebx,%ebx
32004+1234:
32005+#endif
32006+
32007+#endif
32008+
32009 ASM_STAC
32010-4: mov %_ASM_AX,(%_ASM_CX)
32011+4: __copyuser_seg mov %_ASM_AX,(_DEST)
32012 #ifdef CONFIG_X86_32
32013-5: movl %edx,4(%_ASM_CX)
32014+5: __copyuser_seg movl %edx,4(_DEST)
32015 #endif
32016 xor %eax,%eax
32017 EXIT
32018diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
32019index 40027db..37bb69d 100644
32020--- a/arch/x86/lib/rwsem.S
32021+++ b/arch/x86/lib/rwsem.S
32022@@ -90,6 +90,7 @@ ENTRY(call_rwsem_down_read_failed)
32023 call rwsem_down_read_failed
32024 __ASM_SIZE(pop,) %__ASM_REG(dx)
32025 restore_common_regs
32026+ pax_force_retaddr
32027 ret
32028 ENDPROC(call_rwsem_down_read_failed)
32029
32030@@ -98,6 +99,7 @@ ENTRY(call_rwsem_down_write_failed)
32031 movq %rax,%rdi
32032 call rwsem_down_write_failed
32033 restore_common_regs
32034+ pax_force_retaddr
32035 ret
32036 ENDPROC(call_rwsem_down_write_failed)
32037
32038@@ -109,7 +111,8 @@ ENTRY(call_rwsem_wake)
32039 movq %rax,%rdi
32040 call rwsem_wake
32041 restore_common_regs
32042-1: ret
32043+1: pax_force_retaddr
32044+ ret
32045 ENDPROC(call_rwsem_wake)
32046
32047 ENTRY(call_rwsem_downgrade_wake)
32048@@ -119,5 +122,6 @@ ENTRY(call_rwsem_downgrade_wake)
32049 call rwsem_downgrade_wake
32050 __ASM_SIZE(pop,) %__ASM_REG(dx)
32051 restore_common_regs
32052+ pax_force_retaddr
32053 ret
32054 ENDPROC(call_rwsem_downgrade_wake)
32055diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
32056index 91d93b9..4b22130 100644
32057--- a/arch/x86/lib/usercopy_32.c
32058+++ b/arch/x86/lib/usercopy_32.c
32059@@ -42,11 +42,13 @@ do { \
32060 int __d0; \
32061 might_fault(); \
32062 __asm__ __volatile__( \
32063+ __COPYUSER_SET_ES \
32064 ASM_STAC "\n" \
32065 "0: rep; stosl\n" \
32066 " movl %2,%0\n" \
32067 "1: rep; stosb\n" \
32068 "2: " ASM_CLAC "\n" \
32069+ __COPYUSER_RESTORE_ES \
32070 ".section .fixup,\"ax\"\n" \
32071 "3: lea 0(%2,%0,4),%0\n" \
32072 " jmp 2b\n" \
32073@@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
32074
32075 #ifdef CONFIG_X86_INTEL_USERCOPY
32076 static unsigned long
32077-__copy_user_intel(void __user *to, const void *from, unsigned long size)
32078+__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
32079 {
32080 int d0, d1;
32081 __asm__ __volatile__(
32082@@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
32083 " .align 2,0x90\n"
32084 "3: movl 0(%4), %%eax\n"
32085 "4: movl 4(%4), %%edx\n"
32086- "5: movl %%eax, 0(%3)\n"
32087- "6: movl %%edx, 4(%3)\n"
32088+ "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
32089+ "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
32090 "7: movl 8(%4), %%eax\n"
32091 "8: movl 12(%4),%%edx\n"
32092- "9: movl %%eax, 8(%3)\n"
32093- "10: movl %%edx, 12(%3)\n"
32094+ "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
32095+ "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
32096 "11: movl 16(%4), %%eax\n"
32097 "12: movl 20(%4), %%edx\n"
32098- "13: movl %%eax, 16(%3)\n"
32099- "14: movl %%edx, 20(%3)\n"
32100+ "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
32101+ "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
32102 "15: movl 24(%4), %%eax\n"
32103 "16: movl 28(%4), %%edx\n"
32104- "17: movl %%eax, 24(%3)\n"
32105- "18: movl %%edx, 28(%3)\n"
32106+ "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
32107+ "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
32108 "19: movl 32(%4), %%eax\n"
32109 "20: movl 36(%4), %%edx\n"
32110- "21: movl %%eax, 32(%3)\n"
32111- "22: movl %%edx, 36(%3)\n"
32112+ "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
32113+ "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
32114 "23: movl 40(%4), %%eax\n"
32115 "24: movl 44(%4), %%edx\n"
32116- "25: movl %%eax, 40(%3)\n"
32117- "26: movl %%edx, 44(%3)\n"
32118+ "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
32119+ "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
32120 "27: movl 48(%4), %%eax\n"
32121 "28: movl 52(%4), %%edx\n"
32122- "29: movl %%eax, 48(%3)\n"
32123- "30: movl %%edx, 52(%3)\n"
32124+ "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
32125+ "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
32126 "31: movl 56(%4), %%eax\n"
32127 "32: movl 60(%4), %%edx\n"
32128- "33: movl %%eax, 56(%3)\n"
32129- "34: movl %%edx, 60(%3)\n"
32130+ "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
32131+ "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
32132 " addl $-64, %0\n"
32133 " addl $64, %4\n"
32134 " addl $64, %3\n"
32135@@ -149,10 +151,116 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
32136 " shrl $2, %0\n"
32137 " andl $3, %%eax\n"
32138 " cld\n"
32139+ __COPYUSER_SET_ES
32140 "99: rep; movsl\n"
32141 "36: movl %%eax, %0\n"
32142 "37: rep; movsb\n"
32143 "100:\n"
32144+ __COPYUSER_RESTORE_ES
32145+ ".section .fixup,\"ax\"\n"
32146+ "101: lea 0(%%eax,%0,4),%0\n"
32147+ " jmp 100b\n"
32148+ ".previous\n"
32149+ _ASM_EXTABLE(1b,100b)
32150+ _ASM_EXTABLE(2b,100b)
32151+ _ASM_EXTABLE(3b,100b)
32152+ _ASM_EXTABLE(4b,100b)
32153+ _ASM_EXTABLE(5b,100b)
32154+ _ASM_EXTABLE(6b,100b)
32155+ _ASM_EXTABLE(7b,100b)
32156+ _ASM_EXTABLE(8b,100b)
32157+ _ASM_EXTABLE(9b,100b)
32158+ _ASM_EXTABLE(10b,100b)
32159+ _ASM_EXTABLE(11b,100b)
32160+ _ASM_EXTABLE(12b,100b)
32161+ _ASM_EXTABLE(13b,100b)
32162+ _ASM_EXTABLE(14b,100b)
32163+ _ASM_EXTABLE(15b,100b)
32164+ _ASM_EXTABLE(16b,100b)
32165+ _ASM_EXTABLE(17b,100b)
32166+ _ASM_EXTABLE(18b,100b)
32167+ _ASM_EXTABLE(19b,100b)
32168+ _ASM_EXTABLE(20b,100b)
32169+ _ASM_EXTABLE(21b,100b)
32170+ _ASM_EXTABLE(22b,100b)
32171+ _ASM_EXTABLE(23b,100b)
32172+ _ASM_EXTABLE(24b,100b)
32173+ _ASM_EXTABLE(25b,100b)
32174+ _ASM_EXTABLE(26b,100b)
32175+ _ASM_EXTABLE(27b,100b)
32176+ _ASM_EXTABLE(28b,100b)
32177+ _ASM_EXTABLE(29b,100b)
32178+ _ASM_EXTABLE(30b,100b)
32179+ _ASM_EXTABLE(31b,100b)
32180+ _ASM_EXTABLE(32b,100b)
32181+ _ASM_EXTABLE(33b,100b)
32182+ _ASM_EXTABLE(34b,100b)
32183+ _ASM_EXTABLE(35b,100b)
32184+ _ASM_EXTABLE(36b,100b)
32185+ _ASM_EXTABLE(37b,100b)
32186+ _ASM_EXTABLE(99b,101b)
32187+ : "=&c"(size), "=&D" (d0), "=&S" (d1)
32188+ : "1"(to), "2"(from), "0"(size)
32189+ : "eax", "edx", "memory");
32190+ return size;
32191+}
32192+
32193+static unsigned long
32194+__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
32195+{
32196+ int d0, d1;
32197+ __asm__ __volatile__(
32198+ " .align 2,0x90\n"
32199+ "1: "__copyuser_seg" movl 32(%4), %%eax\n"
32200+ " cmpl $67, %0\n"
32201+ " jbe 3f\n"
32202+ "2: "__copyuser_seg" movl 64(%4), %%eax\n"
32203+ " .align 2,0x90\n"
32204+ "3: "__copyuser_seg" movl 0(%4), %%eax\n"
32205+ "4: "__copyuser_seg" movl 4(%4), %%edx\n"
32206+ "5: movl %%eax, 0(%3)\n"
32207+ "6: movl %%edx, 4(%3)\n"
32208+ "7: "__copyuser_seg" movl 8(%4), %%eax\n"
32209+ "8: "__copyuser_seg" movl 12(%4),%%edx\n"
32210+ "9: movl %%eax, 8(%3)\n"
32211+ "10: movl %%edx, 12(%3)\n"
32212+ "11: "__copyuser_seg" movl 16(%4), %%eax\n"
32213+ "12: "__copyuser_seg" movl 20(%4), %%edx\n"
32214+ "13: movl %%eax, 16(%3)\n"
32215+ "14: movl %%edx, 20(%3)\n"
32216+ "15: "__copyuser_seg" movl 24(%4), %%eax\n"
32217+ "16: "__copyuser_seg" movl 28(%4), %%edx\n"
32218+ "17: movl %%eax, 24(%3)\n"
32219+ "18: movl %%edx, 28(%3)\n"
32220+ "19: "__copyuser_seg" movl 32(%4), %%eax\n"
32221+ "20: "__copyuser_seg" movl 36(%4), %%edx\n"
32222+ "21: movl %%eax, 32(%3)\n"
32223+ "22: movl %%edx, 36(%3)\n"
32224+ "23: "__copyuser_seg" movl 40(%4), %%eax\n"
32225+ "24: "__copyuser_seg" movl 44(%4), %%edx\n"
32226+ "25: movl %%eax, 40(%3)\n"
32227+ "26: movl %%edx, 44(%3)\n"
32228+ "27: "__copyuser_seg" movl 48(%4), %%eax\n"
32229+ "28: "__copyuser_seg" movl 52(%4), %%edx\n"
32230+ "29: movl %%eax, 48(%3)\n"
32231+ "30: movl %%edx, 52(%3)\n"
32232+ "31: "__copyuser_seg" movl 56(%4), %%eax\n"
32233+ "32: "__copyuser_seg" movl 60(%4), %%edx\n"
32234+ "33: movl %%eax, 56(%3)\n"
32235+ "34: movl %%edx, 60(%3)\n"
32236+ " addl $-64, %0\n"
32237+ " addl $64, %4\n"
32238+ " addl $64, %3\n"
32239+ " cmpl $63, %0\n"
32240+ " ja 1b\n"
32241+ "35: movl %0, %%eax\n"
32242+ " shrl $2, %0\n"
32243+ " andl $3, %%eax\n"
32244+ " cld\n"
32245+ "99: rep; "__copyuser_seg" movsl\n"
32246+ "36: movl %%eax, %0\n"
32247+ "37: rep; "__copyuser_seg" movsb\n"
32248+ "100:\n"
32249 ".section .fixup,\"ax\"\n"
32250 "101: lea 0(%%eax,%0,4),%0\n"
32251 " jmp 100b\n"
32252@@ -207,41 +315,41 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
32253 int d0, d1;
32254 __asm__ __volatile__(
32255 " .align 2,0x90\n"
32256- "0: movl 32(%4), %%eax\n"
32257+ "0: "__copyuser_seg" movl 32(%4), %%eax\n"
32258 " cmpl $67, %0\n"
32259 " jbe 2f\n"
32260- "1: movl 64(%4), %%eax\n"
32261+ "1: "__copyuser_seg" movl 64(%4), %%eax\n"
32262 " .align 2,0x90\n"
32263- "2: movl 0(%4), %%eax\n"
32264- "21: movl 4(%4), %%edx\n"
32265+ "2: "__copyuser_seg" movl 0(%4), %%eax\n"
32266+ "21: "__copyuser_seg" movl 4(%4), %%edx\n"
32267 " movl %%eax, 0(%3)\n"
32268 " movl %%edx, 4(%3)\n"
32269- "3: movl 8(%4), %%eax\n"
32270- "31: movl 12(%4),%%edx\n"
32271+ "3: "__copyuser_seg" movl 8(%4), %%eax\n"
32272+ "31: "__copyuser_seg" movl 12(%4),%%edx\n"
32273 " movl %%eax, 8(%3)\n"
32274 " movl %%edx, 12(%3)\n"
32275- "4: movl 16(%4), %%eax\n"
32276- "41: movl 20(%4), %%edx\n"
32277+ "4: "__copyuser_seg" movl 16(%4), %%eax\n"
32278+ "41: "__copyuser_seg" movl 20(%4), %%edx\n"
32279 " movl %%eax, 16(%3)\n"
32280 " movl %%edx, 20(%3)\n"
32281- "10: movl 24(%4), %%eax\n"
32282- "51: movl 28(%4), %%edx\n"
32283+ "10: "__copyuser_seg" movl 24(%4), %%eax\n"
32284+ "51: "__copyuser_seg" movl 28(%4), %%edx\n"
32285 " movl %%eax, 24(%3)\n"
32286 " movl %%edx, 28(%3)\n"
32287- "11: movl 32(%4), %%eax\n"
32288- "61: movl 36(%4), %%edx\n"
32289+ "11: "__copyuser_seg" movl 32(%4), %%eax\n"
32290+ "61: "__copyuser_seg" movl 36(%4), %%edx\n"
32291 " movl %%eax, 32(%3)\n"
32292 " movl %%edx, 36(%3)\n"
32293- "12: movl 40(%4), %%eax\n"
32294- "71: movl 44(%4), %%edx\n"
32295+ "12: "__copyuser_seg" movl 40(%4), %%eax\n"
32296+ "71: "__copyuser_seg" movl 44(%4), %%edx\n"
32297 " movl %%eax, 40(%3)\n"
32298 " movl %%edx, 44(%3)\n"
32299- "13: movl 48(%4), %%eax\n"
32300- "81: movl 52(%4), %%edx\n"
32301+ "13: "__copyuser_seg" movl 48(%4), %%eax\n"
32302+ "81: "__copyuser_seg" movl 52(%4), %%edx\n"
32303 " movl %%eax, 48(%3)\n"
32304 " movl %%edx, 52(%3)\n"
32305- "14: movl 56(%4), %%eax\n"
32306- "91: movl 60(%4), %%edx\n"
32307+ "14: "__copyuser_seg" movl 56(%4), %%eax\n"
32308+ "91: "__copyuser_seg" movl 60(%4), %%edx\n"
32309 " movl %%eax, 56(%3)\n"
32310 " movl %%edx, 60(%3)\n"
32311 " addl $-64, %0\n"
32312@@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
32313 " shrl $2, %0\n"
32314 " andl $3, %%eax\n"
32315 " cld\n"
32316- "6: rep; movsl\n"
32317+ "6: rep; "__copyuser_seg" movsl\n"
32318 " movl %%eax,%0\n"
32319- "7: rep; movsb\n"
32320+ "7: rep; "__copyuser_seg" movsb\n"
32321 "8:\n"
32322 ".section .fixup,\"ax\"\n"
32323 "9: lea 0(%%eax,%0,4),%0\n"
32324@@ -305,41 +413,41 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
32325
32326 __asm__ __volatile__(
32327 " .align 2,0x90\n"
32328- "0: movl 32(%4), %%eax\n"
32329+ "0: "__copyuser_seg" movl 32(%4), %%eax\n"
32330 " cmpl $67, %0\n"
32331 " jbe 2f\n"
32332- "1: movl 64(%4), %%eax\n"
32333+ "1: "__copyuser_seg" movl 64(%4), %%eax\n"
32334 " .align 2,0x90\n"
32335- "2: movl 0(%4), %%eax\n"
32336- "21: movl 4(%4), %%edx\n"
32337+ "2: "__copyuser_seg" movl 0(%4), %%eax\n"
32338+ "21: "__copyuser_seg" movl 4(%4), %%edx\n"
32339 " movnti %%eax, 0(%3)\n"
32340 " movnti %%edx, 4(%3)\n"
32341- "3: movl 8(%4), %%eax\n"
32342- "31: movl 12(%4),%%edx\n"
32343+ "3: "__copyuser_seg" movl 8(%4), %%eax\n"
32344+ "31: "__copyuser_seg" movl 12(%4),%%edx\n"
32345 " movnti %%eax, 8(%3)\n"
32346 " movnti %%edx, 12(%3)\n"
32347- "4: movl 16(%4), %%eax\n"
32348- "41: movl 20(%4), %%edx\n"
32349+ "4: "__copyuser_seg" movl 16(%4), %%eax\n"
32350+ "41: "__copyuser_seg" movl 20(%4), %%edx\n"
32351 " movnti %%eax, 16(%3)\n"
32352 " movnti %%edx, 20(%3)\n"
32353- "10: movl 24(%4), %%eax\n"
32354- "51: movl 28(%4), %%edx\n"
32355+ "10: "__copyuser_seg" movl 24(%4), %%eax\n"
32356+ "51: "__copyuser_seg" movl 28(%4), %%edx\n"
32357 " movnti %%eax, 24(%3)\n"
32358 " movnti %%edx, 28(%3)\n"
32359- "11: movl 32(%4), %%eax\n"
32360- "61: movl 36(%4), %%edx\n"
32361+ "11: "__copyuser_seg" movl 32(%4), %%eax\n"
32362+ "61: "__copyuser_seg" movl 36(%4), %%edx\n"
32363 " movnti %%eax, 32(%3)\n"
32364 " movnti %%edx, 36(%3)\n"
32365- "12: movl 40(%4), %%eax\n"
32366- "71: movl 44(%4), %%edx\n"
32367+ "12: "__copyuser_seg" movl 40(%4), %%eax\n"
32368+ "71: "__copyuser_seg" movl 44(%4), %%edx\n"
32369 " movnti %%eax, 40(%3)\n"
32370 " movnti %%edx, 44(%3)\n"
32371- "13: movl 48(%4), %%eax\n"
32372- "81: movl 52(%4), %%edx\n"
32373+ "13: "__copyuser_seg" movl 48(%4), %%eax\n"
32374+ "81: "__copyuser_seg" movl 52(%4), %%edx\n"
32375 " movnti %%eax, 48(%3)\n"
32376 " movnti %%edx, 52(%3)\n"
32377- "14: movl 56(%4), %%eax\n"
32378- "91: movl 60(%4), %%edx\n"
32379+ "14: "__copyuser_seg" movl 56(%4), %%eax\n"
32380+ "91: "__copyuser_seg" movl 60(%4), %%edx\n"
32381 " movnti %%eax, 56(%3)\n"
32382 " movnti %%edx, 60(%3)\n"
32383 " addl $-64, %0\n"
32384@@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
32385 " shrl $2, %0\n"
32386 " andl $3, %%eax\n"
32387 " cld\n"
32388- "6: rep; movsl\n"
32389+ "6: rep; "__copyuser_seg" movsl\n"
32390 " movl %%eax,%0\n"
32391- "7: rep; movsb\n"
32392+ "7: rep; "__copyuser_seg" movsb\n"
32393 "8:\n"
32394 ".section .fixup,\"ax\"\n"
32395 "9: lea 0(%%eax,%0,4),%0\n"
32396@@ -399,41 +507,41 @@ static unsigned long __copy_user_intel_nocache(void *to,
32397
32398 __asm__ __volatile__(
32399 " .align 2,0x90\n"
32400- "0: movl 32(%4), %%eax\n"
32401+ "0: "__copyuser_seg" movl 32(%4), %%eax\n"
32402 " cmpl $67, %0\n"
32403 " jbe 2f\n"
32404- "1: movl 64(%4), %%eax\n"
32405+ "1: "__copyuser_seg" movl 64(%4), %%eax\n"
32406 " .align 2,0x90\n"
32407- "2: movl 0(%4), %%eax\n"
32408- "21: movl 4(%4), %%edx\n"
32409+ "2: "__copyuser_seg" movl 0(%4), %%eax\n"
32410+ "21: "__copyuser_seg" movl 4(%4), %%edx\n"
32411 " movnti %%eax, 0(%3)\n"
32412 " movnti %%edx, 4(%3)\n"
32413- "3: movl 8(%4), %%eax\n"
32414- "31: movl 12(%4),%%edx\n"
32415+ "3: "__copyuser_seg" movl 8(%4), %%eax\n"
32416+ "31: "__copyuser_seg" movl 12(%4),%%edx\n"
32417 " movnti %%eax, 8(%3)\n"
32418 " movnti %%edx, 12(%3)\n"
32419- "4: movl 16(%4), %%eax\n"
32420- "41: movl 20(%4), %%edx\n"
32421+ "4: "__copyuser_seg" movl 16(%4), %%eax\n"
32422+ "41: "__copyuser_seg" movl 20(%4), %%edx\n"
32423 " movnti %%eax, 16(%3)\n"
32424 " movnti %%edx, 20(%3)\n"
32425- "10: movl 24(%4), %%eax\n"
32426- "51: movl 28(%4), %%edx\n"
32427+ "10: "__copyuser_seg" movl 24(%4), %%eax\n"
32428+ "51: "__copyuser_seg" movl 28(%4), %%edx\n"
32429 " movnti %%eax, 24(%3)\n"
32430 " movnti %%edx, 28(%3)\n"
32431- "11: movl 32(%4), %%eax\n"
32432- "61: movl 36(%4), %%edx\n"
32433+ "11: "__copyuser_seg" movl 32(%4), %%eax\n"
32434+ "61: "__copyuser_seg" movl 36(%4), %%edx\n"
32435 " movnti %%eax, 32(%3)\n"
32436 " movnti %%edx, 36(%3)\n"
32437- "12: movl 40(%4), %%eax\n"
32438- "71: movl 44(%4), %%edx\n"
32439+ "12: "__copyuser_seg" movl 40(%4), %%eax\n"
32440+ "71: "__copyuser_seg" movl 44(%4), %%edx\n"
32441 " movnti %%eax, 40(%3)\n"
32442 " movnti %%edx, 44(%3)\n"
32443- "13: movl 48(%4), %%eax\n"
32444- "81: movl 52(%4), %%edx\n"
32445+ "13: "__copyuser_seg" movl 48(%4), %%eax\n"
32446+ "81: "__copyuser_seg" movl 52(%4), %%edx\n"
32447 " movnti %%eax, 48(%3)\n"
32448 " movnti %%edx, 52(%3)\n"
32449- "14: movl 56(%4), %%eax\n"
32450- "91: movl 60(%4), %%edx\n"
32451+ "14: "__copyuser_seg" movl 56(%4), %%eax\n"
32452+ "91: "__copyuser_seg" movl 60(%4), %%edx\n"
32453 " movnti %%eax, 56(%3)\n"
32454 " movnti %%edx, 60(%3)\n"
32455 " addl $-64, %0\n"
32456@@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
32457 " shrl $2, %0\n"
32458 " andl $3, %%eax\n"
32459 " cld\n"
32460- "6: rep; movsl\n"
32461+ "6: rep; "__copyuser_seg" movsl\n"
32462 " movl %%eax,%0\n"
32463- "7: rep; movsb\n"
32464+ "7: rep; "__copyuser_seg" movsb\n"
32465 "8:\n"
32466 ".section .fixup,\"ax\"\n"
32467 "9: lea 0(%%eax,%0,4),%0\n"
32468@@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
32469 */
32470 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
32471 unsigned long size);
32472-unsigned long __copy_user_intel(void __user *to, const void *from,
32473+unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
32474+ unsigned long size);
32475+unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
32476 unsigned long size);
32477 unsigned long __copy_user_zeroing_intel_nocache(void *to,
32478 const void __user *from, unsigned long size);
32479 #endif /* CONFIG_X86_INTEL_USERCOPY */
32480
32481 /* Generic arbitrary sized copy. */
32482-#define __copy_user(to, from, size) \
32483+#define __copy_user(to, from, size, prefix, set, restore) \
32484 do { \
32485 int __d0, __d1, __d2; \
32486 __asm__ __volatile__( \
32487+ set \
32488 " cmp $7,%0\n" \
32489 " jbe 1f\n" \
32490 " movl %1,%0\n" \
32491 " negl %0\n" \
32492 " andl $7,%0\n" \
32493 " subl %0,%3\n" \
32494- "4: rep; movsb\n" \
32495+ "4: rep; "prefix"movsb\n" \
32496 " movl %3,%0\n" \
32497 " shrl $2,%0\n" \
32498 " andl $3,%3\n" \
32499 " .align 2,0x90\n" \
32500- "0: rep; movsl\n" \
32501+ "0: rep; "prefix"movsl\n" \
32502 " movl %3,%0\n" \
32503- "1: rep; movsb\n" \
32504+ "1: rep; "prefix"movsb\n" \
32505 "2:\n" \
32506+ restore \
32507 ".section .fixup,\"ax\"\n" \
32508 "5: addl %3,%0\n" \
32509 " jmp 2b\n" \
32510@@ -538,14 +650,14 @@ do { \
32511 " negl %0\n" \
32512 " andl $7,%0\n" \
32513 " subl %0,%3\n" \
32514- "4: rep; movsb\n" \
32515+ "4: rep; "__copyuser_seg"movsb\n" \
32516 " movl %3,%0\n" \
32517 " shrl $2,%0\n" \
32518 " andl $3,%3\n" \
32519 " .align 2,0x90\n" \
32520- "0: rep; movsl\n" \
32521+ "0: rep; "__copyuser_seg"movsl\n" \
32522 " movl %3,%0\n" \
32523- "1: rep; movsb\n" \
32524+ "1: rep; "__copyuser_seg"movsb\n" \
32525 "2:\n" \
32526 ".section .fixup,\"ax\"\n" \
32527 "5: addl %3,%0\n" \
32528@@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
32529 {
32530 stac();
32531 if (movsl_is_ok(to, from, n))
32532- __copy_user(to, from, n);
32533+ __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
32534 else
32535- n = __copy_user_intel(to, from, n);
32536+ n = __generic_copy_to_user_intel(to, from, n);
32537 clac();
32538 return n;
32539 }
32540@@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
32541 {
32542 stac();
32543 if (movsl_is_ok(to, from, n))
32544- __copy_user(to, from, n);
32545+ __copy_user(to, from, n, __copyuser_seg, "", "");
32546 else
32547- n = __copy_user_intel((void __user *)to,
32548- (const void *)from, n);
32549+ n = __generic_copy_from_user_intel(to, from, n);
32550 clac();
32551 return n;
32552 }
32553@@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
32554 if (n > 64 && cpu_has_xmm2)
32555 n = __copy_user_intel_nocache(to, from, n);
32556 else
32557- __copy_user(to, from, n);
32558+ __copy_user(to, from, n, __copyuser_seg, "", "");
32559 #else
32560- __copy_user(to, from, n);
32561+ __copy_user(to, from, n, __copyuser_seg, "", "");
32562 #endif
32563 clac();
32564 return n;
32565 }
32566 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
32567
32568-/**
32569- * copy_to_user: - Copy a block of data into user space.
32570- * @to: Destination address, in user space.
32571- * @from: Source address, in kernel space.
32572- * @n: Number of bytes to copy.
32573- *
32574- * Context: User context only. This function may sleep if pagefaults are
32575- * enabled.
32576- *
32577- * Copy data from kernel space to user space.
32578- *
32579- * Returns number of bytes that could not be copied.
32580- * On success, this will be zero.
32581- */
32582-unsigned long _copy_to_user(void __user *to, const void *from, unsigned n)
32583+#ifdef CONFIG_PAX_MEMORY_UDEREF
32584+void __set_fs(mm_segment_t x)
32585 {
32586- if (access_ok(VERIFY_WRITE, to, n))
32587- n = __copy_to_user(to, from, n);
32588- return n;
32589+ switch (x.seg) {
32590+ case 0:
32591+ loadsegment(gs, 0);
32592+ break;
32593+ case TASK_SIZE_MAX:
32594+ loadsegment(gs, __USER_DS);
32595+ break;
32596+ case -1UL:
32597+ loadsegment(gs, __KERNEL_DS);
32598+ break;
32599+ default:
32600+ BUG();
32601+ }
32602 }
32603-EXPORT_SYMBOL(_copy_to_user);
32604+EXPORT_SYMBOL(__set_fs);
32605
32606-/**
32607- * copy_from_user: - Copy a block of data from user space.
32608- * @to: Destination address, in kernel space.
32609- * @from: Source address, in user space.
32610- * @n: Number of bytes to copy.
32611- *
32612- * Context: User context only. This function may sleep if pagefaults are
32613- * enabled.
32614- *
32615- * Copy data from user space to kernel space.
32616- *
32617- * Returns number of bytes that could not be copied.
32618- * On success, this will be zero.
32619- *
32620- * If some data could not be copied, this function will pad the copied
32621- * data to the requested size using zero bytes.
32622- */
32623-unsigned long _copy_from_user(void *to, const void __user *from, unsigned n)
32624+void set_fs(mm_segment_t x)
32625 {
32626- if (access_ok(VERIFY_READ, from, n))
32627- n = __copy_from_user(to, from, n);
32628- else
32629- memset(to, 0, n);
32630- return n;
32631+ current_thread_info()->addr_limit = x;
32632+ __set_fs(x);
32633 }
32634-EXPORT_SYMBOL(_copy_from_user);
32635+EXPORT_SYMBOL(set_fs);
32636+#endif
32637diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
32638index 0a42327..7a82465 100644
32639--- a/arch/x86/lib/usercopy_64.c
32640+++ b/arch/x86/lib/usercopy_64.c
32641@@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
32642 might_fault();
32643 /* no memory constraint because it doesn't change any memory gcc knows
32644 about */
32645+ pax_open_userland();
32646 stac();
32647 asm volatile(
32648 " testq %[size8],%[size8]\n"
32649@@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
32650 _ASM_EXTABLE(0b,3b)
32651 _ASM_EXTABLE(1b,2b)
32652 : [size8] "=&c"(size), [dst] "=&D" (__d0)
32653- : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
32654+ : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
32655 [zero] "r" (0UL), [eight] "r" (8UL));
32656 clac();
32657+ pax_close_userland();
32658 return size;
32659 }
32660 EXPORT_SYMBOL(__clear_user);
32661@@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
32662 }
32663 EXPORT_SYMBOL(clear_user);
32664
32665-unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
32666+unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
32667 {
32668- if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
32669- return copy_user_generic((__force void *)to, (__force void *)from, len);
32670- }
32671- return len;
32672+ if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
32673+ return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
32674+ return len;
32675 }
32676 EXPORT_SYMBOL(copy_in_user);
32677
32678@@ -69,8 +70,10 @@ EXPORT_SYMBOL(copy_in_user);
32679 * it is not necessary to optimize tail handling.
32680 */
32681 __visible unsigned long
32682-copy_user_handle_tail(char *to, char *from, unsigned len)
32683+copy_user_handle_tail(char __user *to, char __user *from, unsigned long len)
32684 {
32685+ clac();
32686+ pax_close_userland();
32687 for (; len; --len, to++) {
32688 char c;
32689
32690@@ -79,10 +82,9 @@ copy_user_handle_tail(char *to, char *from, unsigned len)
32691 if (__put_user_nocheck(c, to, sizeof(char)))
32692 break;
32693 }
32694- clac();
32695
32696 /* If the destination is a kernel buffer, we always clear the end */
32697- if (!__addr_ok(to))
32698+ if (!__addr_ok(to) && (unsigned long)to >= TASK_SIZE_MAX + pax_user_shadow_base)
32699 memset(to, 0, len);
32700 return len;
32701 }
32702diff --git a/arch/x86/math-emu/fpu_aux.c b/arch/x86/math-emu/fpu_aux.c
32703index dd76a05..df65688 100644
32704--- a/arch/x86/math-emu/fpu_aux.c
32705+++ b/arch/x86/math-emu/fpu_aux.c
32706@@ -52,7 +52,7 @@ void fpstate_init_soft(struct swregs_state *soft)
32707
32708 void finit(void)
32709 {
32710- fpstate_init_soft(&current->thread.fpu.state.soft);
32711+ fpstate_init_soft(&current->thread.fpu.state->soft);
32712 }
32713
32714 /*
32715diff --git a/arch/x86/math-emu/fpu_entry.c b/arch/x86/math-emu/fpu_entry.c
32716index 3d8f2e4..ef7cf4e 100644
32717--- a/arch/x86/math-emu/fpu_entry.c
32718+++ b/arch/x86/math-emu/fpu_entry.c
32719@@ -677,7 +677,7 @@ int fpregs_soft_set(struct task_struct *target,
32720 unsigned int pos, unsigned int count,
32721 const void *kbuf, const void __user *ubuf)
32722 {
32723- struct swregs_state *s387 = &target->thread.fpu.state.soft;
32724+ struct swregs_state *s387 = &target->thread.fpu.state->soft;
32725 void *space = s387->st_space;
32726 int ret;
32727 int offset, other, i, tags, regnr, tag, newtop;
32728@@ -729,7 +729,7 @@ int fpregs_soft_get(struct task_struct *target,
32729 unsigned int pos, unsigned int count,
32730 void *kbuf, void __user *ubuf)
32731 {
32732- struct swregs_state *s387 = &target->thread.fpu.state.soft;
32733+ struct swregs_state *s387 = &target->thread.fpu.state->soft;
32734 const void *space = s387->st_space;
32735 int ret;
32736 int offset = (S387->ftop & 7) * 10, other = 80 - offset;
32737diff --git a/arch/x86/math-emu/fpu_system.h b/arch/x86/math-emu/fpu_system.h
32738index 5e044d5..d342fce 100644
32739--- a/arch/x86/math-emu/fpu_system.h
32740+++ b/arch/x86/math-emu/fpu_system.h
32741@@ -46,7 +46,7 @@ static inline struct desc_struct FPU_get_ldt_descriptor(unsigned seg)
32742 #define SEG_EXPAND_DOWN(s) (((s).b & ((1 << 11) | (1 << 10))) \
32743 == (1 << 10))
32744
32745-#define I387 (&current->thread.fpu.state)
32746+#define I387 (current->thread.fpu.state)
32747 #define FPU_info (I387->soft.info)
32748
32749 #define FPU_CS (*(unsigned short *) &(FPU_info->regs->cs))
32750diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
32751index a482d10..1a6edb5 100644
32752--- a/arch/x86/mm/Makefile
32753+++ b/arch/x86/mm/Makefile
32754@@ -33,3 +33,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
32755 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
32756
32757 obj-$(CONFIG_X86_INTEL_MPX) += mpx.o
32758+
32759+quote:="
32760+obj-$(CONFIG_X86_64) += uderef_64.o
32761+CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS)) -fcall-saved-rax
32762diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
32763index 903ec1e..41b4708 100644
32764--- a/arch/x86/mm/extable.c
32765+++ b/arch/x86/mm/extable.c
32766@@ -2,16 +2,29 @@
32767 #include <linux/spinlock.h>
32768 #include <linux/sort.h>
32769 #include <asm/uaccess.h>
32770+#include <asm/boot.h>
32771
32772 static inline unsigned long
32773 ex_insn_addr(const struct exception_table_entry *x)
32774 {
32775- return (unsigned long)&x->insn + x->insn;
32776+ unsigned long reloc = 0;
32777+
32778+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
32779+ reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32780+#endif
32781+
32782+ return (unsigned long)&x->insn + x->insn + reloc;
32783 }
32784 static inline unsigned long
32785 ex_fixup_addr(const struct exception_table_entry *x)
32786 {
32787- return (unsigned long)&x->fixup + x->fixup;
32788+ unsigned long reloc = 0;
32789+
32790+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
32791+ reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32792+#endif
32793+
32794+ return (unsigned long)&x->fixup + x->fixup + reloc;
32795 }
32796
32797 int fixup_exception(struct pt_regs *regs)
32798@@ -20,7 +33,7 @@ int fixup_exception(struct pt_regs *regs)
32799 unsigned long new_ip;
32800
32801 #ifdef CONFIG_PNPBIOS
32802- if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
32803+ if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
32804 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
32805 extern u32 pnp_bios_is_utter_crap;
32806 pnp_bios_is_utter_crap = 1;
32807@@ -145,6 +158,13 @@ void sort_extable(struct exception_table_entry *start,
32808 i += 4;
32809 p->fixup -= i;
32810 i += 4;
32811+
32812+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
32813+ BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
32814+ p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32815+ p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32816+#endif
32817+
32818 }
32819 }
32820
32821diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
32822index 9dc9098..938251a 100644
32823--- a/arch/x86/mm/fault.c
32824+++ b/arch/x86/mm/fault.c
32825@@ -14,12 +14,19 @@
32826 #include <linux/prefetch.h> /* prefetchw */
32827 #include <linux/context_tracking.h> /* exception_enter(), ... */
32828 #include <linux/uaccess.h> /* faulthandler_disabled() */
32829+#include <linux/unistd.h>
32830+#include <linux/compiler.h>
32831
32832 #include <asm/traps.h> /* dotraplinkage, ... */
32833 #include <asm/pgalloc.h> /* pgd_*(), ... */
32834 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
32835 #include <asm/fixmap.h> /* VSYSCALL_ADDR */
32836 #include <asm/vsyscall.h> /* emulate_vsyscall */
32837+#include <asm/tlbflush.h>
32838+
32839+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32840+#include <asm/stacktrace.h>
32841+#endif
32842
32843 #define CREATE_TRACE_POINTS
32844 #include <asm/trace/exceptions.h>
32845@@ -121,7 +128,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
32846 return !instr_lo || (instr_lo>>1) == 1;
32847 case 0x00:
32848 /* Prefetch instruction is 0x0F0D or 0x0F18 */
32849- if (probe_kernel_address(instr, opcode))
32850+ if (user_mode(regs)) {
32851+ if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
32852+ return 0;
32853+ } else if (probe_kernel_address(instr, opcode))
32854 return 0;
32855
32856 *prefetch = (instr_lo == 0xF) &&
32857@@ -155,7 +165,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
32858 while (instr < max_instr) {
32859 unsigned char opcode;
32860
32861- if (probe_kernel_address(instr, opcode))
32862+ if (user_mode(regs)) {
32863+ if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
32864+ break;
32865+ } else if (probe_kernel_address(instr, opcode))
32866 break;
32867
32868 instr++;
32869@@ -186,6 +199,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
32870 force_sig_info(si_signo, &info, tsk);
32871 }
32872
32873+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
32874+static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
32875+#endif
32876+
32877+#ifdef CONFIG_PAX_EMUTRAMP
32878+static int pax_handle_fetch_fault(struct pt_regs *regs);
32879+#endif
32880+
32881+#ifdef CONFIG_PAX_PAGEEXEC
32882+static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
32883+{
32884+ pgd_t *pgd;
32885+ pud_t *pud;
32886+ pmd_t *pmd;
32887+
32888+ pgd = pgd_offset(mm, address);
32889+ if (!pgd_present(*pgd))
32890+ return NULL;
32891+ pud = pud_offset(pgd, address);
32892+ if (!pud_present(*pud))
32893+ return NULL;
32894+ pmd = pmd_offset(pud, address);
32895+ if (!pmd_present(*pmd))
32896+ return NULL;
32897+ return pmd;
32898+}
32899+#endif
32900+
32901 DEFINE_SPINLOCK(pgd_lock);
32902 LIST_HEAD(pgd_list);
32903
32904@@ -236,10 +277,27 @@ void vmalloc_sync_all(void)
32905 for (address = VMALLOC_START & PMD_MASK;
32906 address >= TASK_SIZE && address < FIXADDR_TOP;
32907 address += PMD_SIZE) {
32908+
32909+#ifdef CONFIG_PAX_PER_CPU_PGD
32910+ unsigned long cpu;
32911+#else
32912 struct page *page;
32913+#endif
32914
32915 spin_lock(&pgd_lock);
32916+
32917+#ifdef CONFIG_PAX_PER_CPU_PGD
32918+ for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
32919+ pgd_t *pgd = get_cpu_pgd(cpu, user);
32920+ pmd_t *ret;
32921+
32922+ ret = vmalloc_sync_one(pgd, address);
32923+ if (!ret)
32924+ break;
32925+ pgd = get_cpu_pgd(cpu, kernel);
32926+#else
32927 list_for_each_entry(page, &pgd_list, lru) {
32928+ pgd_t *pgd;
32929 spinlock_t *pgt_lock;
32930 pmd_t *ret;
32931
32932@@ -247,8 +305,14 @@ void vmalloc_sync_all(void)
32933 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
32934
32935 spin_lock(pgt_lock);
32936- ret = vmalloc_sync_one(page_address(page), address);
32937+ pgd = page_address(page);
32938+#endif
32939+
32940+ ret = vmalloc_sync_one(pgd, address);
32941+
32942+#ifndef CONFIG_PAX_PER_CPU_PGD
32943 spin_unlock(pgt_lock);
32944+#endif
32945
32946 if (!ret)
32947 break;
32948@@ -282,6 +346,12 @@ static noinline int vmalloc_fault(unsigned long address)
32949 * an interrupt in the middle of a task switch..
32950 */
32951 pgd_paddr = read_cr3();
32952+
32953+#ifdef CONFIG_PAX_PER_CPU_PGD
32954+ BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
32955+ vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
32956+#endif
32957+
32958 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
32959 if (!pmd_k)
32960 return -1;
32961@@ -378,11 +448,25 @@ static noinline int vmalloc_fault(unsigned long address)
32962 * happen within a race in page table update. In the later
32963 * case just flush:
32964 */
32965- pgd = pgd_offset(current->active_mm, address);
32966+
32967 pgd_ref = pgd_offset_k(address);
32968 if (pgd_none(*pgd_ref))
32969 return -1;
32970
32971+#ifdef CONFIG_PAX_PER_CPU_PGD
32972+ BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
32973+ pgd = pgd_offset_cpu(smp_processor_id(), user, address);
32974+ if (pgd_none(*pgd)) {
32975+ set_pgd(pgd, *pgd_ref);
32976+ arch_flush_lazy_mmu_mode();
32977+ } else {
32978+ BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
32979+ }
32980+ pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
32981+#else
32982+ pgd = pgd_offset(current->active_mm, address);
32983+#endif
32984+
32985 if (pgd_none(*pgd)) {
32986 set_pgd(pgd, *pgd_ref);
32987 arch_flush_lazy_mmu_mode();
32988@@ -549,7 +633,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
32989 static int is_errata100(struct pt_regs *regs, unsigned long address)
32990 {
32991 #ifdef CONFIG_X86_64
32992- if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
32993+ if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
32994 return 1;
32995 #endif
32996 return 0;
32997@@ -576,9 +660,9 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
32998 }
32999
33000 static const char nx_warning[] = KERN_CRIT
33001-"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
33002+"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
33003 static const char smep_warning[] = KERN_CRIT
33004-"unable to execute userspace code (SMEP?) (uid: %d)\n";
33005+"unable to execute userspace code (SMEP?) (uid: %d, task: %s, pid: %d)\n";
33006
33007 static void
33008 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
33009@@ -587,7 +671,7 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
33010 if (!oops_may_print())
33011 return;
33012
33013- if (error_code & PF_INSTR) {
33014+ if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
33015 unsigned int level;
33016 pgd_t *pgd;
33017 pte_t *pte;
33018@@ -598,13 +682,25 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
33019 pte = lookup_address_in_pgd(pgd, address, &level);
33020
33021 if (pte && pte_present(*pte) && !pte_exec(*pte))
33022- printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
33023+ printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
33024 if (pte && pte_present(*pte) && pte_exec(*pte) &&
33025 (pgd_flags(*pgd) & _PAGE_USER) &&
33026 (__read_cr4() & X86_CR4_SMEP))
33027- printk(smep_warning, from_kuid(&init_user_ns, current_uid()));
33028+ printk(smep_warning, from_kuid(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
33029 }
33030
33031+#ifdef CONFIG_PAX_KERNEXEC
33032+ if (init_mm.start_code <= address && address < init_mm.end_code) {
33033+ if (current->signal->curr_ip)
33034+ printk(KERN_EMERG "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
33035+ &current->signal->curr_ip, current->comm, task_pid_nr(current),
33036+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
33037+ else
33038+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
33039+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
33040+ }
33041+#endif
33042+
33043 printk(KERN_ALERT "BUG: unable to handle kernel ");
33044 if (address < PAGE_SIZE)
33045 printk(KERN_CONT "NULL pointer dereference");
33046@@ -783,6 +879,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
33047 return;
33048 }
33049 #endif
33050+
33051+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
33052+ if (pax_is_fetch_fault(regs, error_code, address)) {
33053+
33054+#ifdef CONFIG_PAX_EMUTRAMP
33055+ switch (pax_handle_fetch_fault(regs)) {
33056+ case 2:
33057+ return;
33058+ }
33059+#endif
33060+
33061+ pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
33062+ do_group_exit(SIGKILL);
33063+ }
33064+#endif
33065+
33066 /* Kernel addresses are always protection faults: */
33067 if (address >= TASK_SIZE)
33068 error_code |= PF_PROT;
33069@@ -865,7 +977,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
33070 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
33071 printk(KERN_ERR
33072 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
33073- tsk->comm, tsk->pid, address);
33074+ tsk->comm, task_pid_nr(tsk), address);
33075 code = BUS_MCEERR_AR;
33076 }
33077 #endif
33078@@ -917,6 +1029,107 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
33079 return 1;
33080 }
33081
33082+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
33083+static inline unsigned long get_limit(unsigned long segment)
33084+{
33085+ unsigned long __limit;
33086+
33087+ asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
33088+ return __limit + 1;
33089+}
33090+
33091+static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
33092+{
33093+ pte_t *pte;
33094+ pmd_t *pmd;
33095+ spinlock_t *ptl;
33096+ unsigned char pte_mask;
33097+
33098+ if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
33099+ !(mm->pax_flags & MF_PAX_PAGEEXEC))
33100+ return 0;
33101+
33102+ /* PaX: it's our fault, let's handle it if we can */
33103+
33104+ /* PaX: take a look at read faults before acquiring any locks */
33105+ if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
33106+ /* instruction fetch attempt from a protected page in user mode */
33107+ up_read(&mm->mmap_sem);
33108+
33109+#ifdef CONFIG_PAX_EMUTRAMP
33110+ switch (pax_handle_fetch_fault(regs)) {
33111+ case 2:
33112+ return 1;
33113+ }
33114+#endif
33115+
33116+ pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
33117+ do_group_exit(SIGKILL);
33118+ }
33119+
33120+ pmd = pax_get_pmd(mm, address);
33121+ if (unlikely(!pmd))
33122+ return 0;
33123+
33124+ pte = pte_offset_map_lock(mm, pmd, address, &ptl);
33125+ if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
33126+ pte_unmap_unlock(pte, ptl);
33127+ return 0;
33128+ }
33129+
33130+ if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
33131+ /* write attempt to a protected page in user mode */
33132+ pte_unmap_unlock(pte, ptl);
33133+ return 0;
33134+ }
33135+
33136+#ifdef CONFIG_SMP
33137+ if (likely(address > get_limit(regs->cs) && cpumask_test_cpu(smp_processor_id(), &mm->context.cpu_user_cs_mask)))
33138+#else
33139+ if (likely(address > get_limit(regs->cs)))
33140+#endif
33141+ {
33142+ set_pte(pte, pte_mkread(*pte));
33143+ __flush_tlb_one(address);
33144+ pte_unmap_unlock(pte, ptl);
33145+ up_read(&mm->mmap_sem);
33146+ return 1;
33147+ }
33148+
33149+ pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
33150+
33151+ /*
33152+ * PaX: fill DTLB with user rights and retry
33153+ */
33154+ __asm__ __volatile__ (
33155+ "orb %2,(%1)\n"
33156+#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
33157+/*
33158+ * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
33159+ * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
33160+ * page fault when examined during a TLB load attempt. this is true not only
33161+ * for PTEs holding a non-present entry but also present entries that will
33162+ * raise a page fault (such as those set up by PaX, or the copy-on-write
33163+ * mechanism). in effect it means that we do *not* need to flush the TLBs
33164+ * for our target pages since their PTEs are simply not in the TLBs at all.
33165+
33166+ * the best thing in omitting it is that we gain around 15-20% speed in the
33167+ * fast path of the page fault handler and can get rid of tracing since we
33168+ * can no longer flush unintended entries.
33169+ */
33170+ "invlpg (%0)\n"
33171+#endif
33172+ __copyuser_seg"testb $0,(%0)\n"
33173+ "xorb %3,(%1)\n"
33174+ :
33175+ : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
33176+ : "memory", "cc");
33177+ pte_unmap_unlock(pte, ptl);
33178+ up_read(&mm->mmap_sem);
33179+ return 1;
33180+}
33181+#endif
33182+
33183 /*
33184 * Handle a spurious fault caused by a stale TLB entry.
33185 *
33186@@ -1002,6 +1215,9 @@ int show_unhandled_signals = 1;
33187 static inline int
33188 access_error(unsigned long error_code, struct vm_area_struct *vma)
33189 {
33190+ if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
33191+ return 1;
33192+
33193 if (error_code & PF_WRITE) {
33194 /* write, present and write, not present: */
33195 if (unlikely(!(vma->vm_flags & VM_WRITE)))
33196@@ -1064,6 +1280,22 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
33197 tsk = current;
33198 mm = tsk->mm;
33199
33200+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
33201+ if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
33202+ if (!search_exception_tables(regs->ip)) {
33203+ printk(KERN_EMERG "PAX: please report this to pageexec@freemail.hu\n");
33204+ bad_area_nosemaphore(regs, error_code, address);
33205+ return;
33206+ }
33207+ if (address < pax_user_shadow_base) {
33208+ printk(KERN_EMERG "PAX: please report this to pageexec@freemail.hu\n");
33209+ printk(KERN_EMERG "PAX: faulting IP: %pS\n", (void *)regs->ip);
33210+ show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_EMERG);
33211+ } else
33212+ address -= pax_user_shadow_base;
33213+ }
33214+#endif
33215+
33216 /*
33217 * Detect and handle instructions that would cause a page fault for
33218 * both a tracked kernel page and a userspace page.
33219@@ -1188,6 +1420,11 @@ retry:
33220 might_sleep();
33221 }
33222
33223+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
33224+ if (pax_handle_pageexec_fault(regs, mm, address, error_code))
33225+ return;
33226+#endif
33227+
33228 vma = find_vma(mm, address);
33229 if (unlikely(!vma)) {
33230 bad_area(regs, error_code, address);
33231@@ -1199,18 +1436,24 @@ retry:
33232 bad_area(regs, error_code, address);
33233 return;
33234 }
33235- if (error_code & PF_USER) {
33236- /*
33237- * Accessing the stack below %sp is always a bug.
33238- * The large cushion allows instructions like enter
33239- * and pusha to work. ("enter $65535, $31" pushes
33240- * 32 pointers and then decrements %sp by 65535.)
33241- */
33242- if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
33243- bad_area(regs, error_code, address);
33244- return;
33245- }
33246+ /*
33247+ * Accessing the stack below %sp is always a bug.
33248+ * The large cushion allows instructions like enter
33249+ * and pusha to work. ("enter $65535, $31" pushes
33250+ * 32 pointers and then decrements %sp by 65535.)
33251+ */
33252+ if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
33253+ bad_area(regs, error_code, address);
33254+ return;
33255 }
33256+
33257+#ifdef CONFIG_PAX_SEGMEXEC
33258+ if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
33259+ bad_area(regs, error_code, address);
33260+ return;
33261+ }
33262+#endif
33263+
33264 if (unlikely(expand_stack(vma, address))) {
33265 bad_area(regs, error_code, address);
33266 return;
33267@@ -1330,3 +1573,292 @@ trace_do_page_fault(struct pt_regs *regs, unsigned long error_code)
33268 }
33269 NOKPROBE_SYMBOL(trace_do_page_fault);
33270 #endif /* CONFIG_TRACING */
33271+
33272+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
33273+static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
33274+{
33275+ struct mm_struct *mm = current->mm;
33276+ unsigned long ip = regs->ip;
33277+
33278+ if (v8086_mode(regs))
33279+ ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
33280+
33281+#ifdef CONFIG_PAX_PAGEEXEC
33282+ if (mm->pax_flags & MF_PAX_PAGEEXEC) {
33283+ if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
33284+ return true;
33285+ if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
33286+ return true;
33287+ return false;
33288+ }
33289+#endif
33290+
33291+#ifdef CONFIG_PAX_SEGMEXEC
33292+ if (mm->pax_flags & MF_PAX_SEGMEXEC) {
33293+ if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
33294+ return true;
33295+ return false;
33296+ }
33297+#endif
33298+
33299+ return false;
33300+}
33301+#endif
33302+
33303+#ifdef CONFIG_PAX_EMUTRAMP
33304+static int pax_handle_fetch_fault_32(struct pt_regs *regs)
33305+{
33306+ int err;
33307+
33308+ do { /* PaX: libffi trampoline emulation */
33309+ unsigned char mov, jmp;
33310+ unsigned int addr1, addr2;
33311+
33312+#ifdef CONFIG_X86_64
33313+ if ((regs->ip + 9) >> 32)
33314+ break;
33315+#endif
33316+
33317+ err = get_user(mov, (unsigned char __user *)regs->ip);
33318+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
33319+ err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
33320+ err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
33321+
33322+ if (err)
33323+ break;
33324+
33325+ if (mov == 0xB8 && jmp == 0xE9) {
33326+ regs->ax = addr1;
33327+ regs->ip = (unsigned int)(regs->ip + addr2 + 10);
33328+ return 2;
33329+ }
33330+ } while (0);
33331+
33332+ do { /* PaX: gcc trampoline emulation #1 */
33333+ unsigned char mov1, mov2;
33334+ unsigned short jmp;
33335+ unsigned int addr1, addr2;
33336+
33337+#ifdef CONFIG_X86_64
33338+ if ((regs->ip + 11) >> 32)
33339+ break;
33340+#endif
33341+
33342+ err = get_user(mov1, (unsigned char __user *)regs->ip);
33343+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
33344+ err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
33345+ err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
33346+ err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
33347+
33348+ if (err)
33349+ break;
33350+
33351+ if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
33352+ regs->cx = addr1;
33353+ regs->ax = addr2;
33354+ regs->ip = addr2;
33355+ return 2;
33356+ }
33357+ } while (0);
33358+
33359+ do { /* PaX: gcc trampoline emulation #2 */
33360+ unsigned char mov, jmp;
33361+ unsigned int addr1, addr2;
33362+
33363+#ifdef CONFIG_X86_64
33364+ if ((regs->ip + 9) >> 32)
33365+ break;
33366+#endif
33367+
33368+ err = get_user(mov, (unsigned char __user *)regs->ip);
33369+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
33370+ err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
33371+ err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
33372+
33373+ if (err)
33374+ break;
33375+
33376+ if (mov == 0xB9 && jmp == 0xE9) {
33377+ regs->cx = addr1;
33378+ regs->ip = (unsigned int)(regs->ip + addr2 + 10);
33379+ return 2;
33380+ }
33381+ } while (0);
33382+
33383+ return 1; /* PaX in action */
33384+}
33385+
33386+#ifdef CONFIG_X86_64
33387+static int pax_handle_fetch_fault_64(struct pt_regs *regs)
33388+{
33389+ int err;
33390+
33391+ do { /* PaX: libffi trampoline emulation */
33392+ unsigned short mov1, mov2, jmp1;
33393+ unsigned char stcclc, jmp2;
33394+ unsigned long addr1, addr2;
33395+
33396+ err = get_user(mov1, (unsigned short __user *)regs->ip);
33397+ err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
33398+ err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
33399+ err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
33400+ err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
33401+ err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
33402+ err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
33403+
33404+ if (err)
33405+ break;
33406+
33407+ if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
33408+ regs->r11 = addr1;
33409+ regs->r10 = addr2;
33410+ if (stcclc == 0xF8)
33411+ regs->flags &= ~X86_EFLAGS_CF;
33412+ else
33413+ regs->flags |= X86_EFLAGS_CF;
33414+ regs->ip = addr1;
33415+ return 2;
33416+ }
33417+ } while (0);
33418+
33419+ do { /* PaX: gcc trampoline emulation #1 */
33420+ unsigned short mov1, mov2, jmp1;
33421+ unsigned char jmp2;
33422+ unsigned int addr1;
33423+ unsigned long addr2;
33424+
33425+ err = get_user(mov1, (unsigned short __user *)regs->ip);
33426+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
33427+ err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
33428+ err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
33429+ err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
33430+ err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
33431+
33432+ if (err)
33433+ break;
33434+
33435+ if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
33436+ regs->r11 = addr1;
33437+ regs->r10 = addr2;
33438+ regs->ip = addr1;
33439+ return 2;
33440+ }
33441+ } while (0);
33442+
33443+ do { /* PaX: gcc trampoline emulation #2 */
33444+ unsigned short mov1, mov2, jmp1;
33445+ unsigned char jmp2;
33446+ unsigned long addr1, addr2;
33447+
33448+ err = get_user(mov1, (unsigned short __user *)regs->ip);
33449+ err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
33450+ err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
33451+ err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
33452+ err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
33453+ err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
33454+
33455+ if (err)
33456+ break;
33457+
33458+ if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
33459+ regs->r11 = addr1;
33460+ regs->r10 = addr2;
33461+ regs->ip = addr1;
33462+ return 2;
33463+ }
33464+ } while (0);
33465+
33466+ return 1; /* PaX in action */
33467+}
33468+#endif
33469+
33470+/*
33471+ * PaX: decide what to do with offenders (regs->ip = fault address)
33472+ *
33473+ * returns 1 when task should be killed
33474+ * 2 when gcc trampoline was detected
33475+ */
33476+static int pax_handle_fetch_fault(struct pt_regs *regs)
33477+{
33478+ if (v8086_mode(regs))
33479+ return 1;
33480+
33481+ if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
33482+ return 1;
33483+
33484+#ifdef CONFIG_X86_32
33485+ return pax_handle_fetch_fault_32(regs);
33486+#else
33487+ if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
33488+ return pax_handle_fetch_fault_32(regs);
33489+ else
33490+ return pax_handle_fetch_fault_64(regs);
33491+#endif
33492+}
33493+#endif
33494+
33495+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
33496+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
33497+{
33498+ long i;
33499+
33500+ printk(KERN_ERR "PAX: bytes at PC: ");
33501+ for (i = 0; i < 20; i++) {
33502+ unsigned char c;
33503+ if (get_user(c, (unsigned char __force_user *)pc+i))
33504+ printk(KERN_CONT "?? ");
33505+ else
33506+ printk(KERN_CONT "%02x ", c);
33507+ }
33508+ printk("\n");
33509+
33510+ printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
33511+ for (i = -1; i < 80 / (long)sizeof(long); i++) {
33512+ unsigned long c;
33513+ if (get_user(c, (unsigned long __force_user *)sp+i)) {
33514+#ifdef CONFIG_X86_32
33515+ printk(KERN_CONT "???????? ");
33516+#else
33517+ if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
33518+ printk(KERN_CONT "???????? ???????? ");
33519+ else
33520+ printk(KERN_CONT "???????????????? ");
33521+#endif
33522+ } else {
33523+#ifdef CONFIG_X86_64
33524+ if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
33525+ printk(KERN_CONT "%08x ", (unsigned int)c);
33526+ printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
33527+ } else
33528+#endif
33529+ printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
33530+ }
33531+ }
33532+ printk("\n");
33533+}
33534+#endif
33535+
33536+/**
33537+ * probe_kernel_write(): safely attempt to write to a location
33538+ * @dst: address to write to
33539+ * @src: pointer to the data that shall be written
33540+ * @size: size of the data chunk
33541+ *
33542+ * Safely write to address @dst from the buffer at @src. If a kernel fault
33543+ * happens, handle that and return -EFAULT.
33544+ */
33545+long notrace probe_kernel_write(void *dst, const void *src, size_t size)
33546+{
33547+ long ret;
33548+ mm_segment_t old_fs = get_fs();
33549+
33550+ set_fs(KERNEL_DS);
33551+ pagefault_disable();
33552+ pax_open_kernel();
33553+ ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
33554+ pax_close_kernel();
33555+ pagefault_enable();
33556+ set_fs(old_fs);
33557+
33558+ return ret ? -EFAULT : 0;
33559+}
33560diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
33561index 81bf3d2..7ef25c2 100644
33562--- a/arch/x86/mm/gup.c
33563+++ b/arch/x86/mm/gup.c
33564@@ -268,7 +268,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
33565 addr = start;
33566 len = (unsigned long) nr_pages << PAGE_SHIFT;
33567 end = start + len;
33568- if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
33569+ if (unlikely(!access_ok_noprefault(write ? VERIFY_WRITE : VERIFY_READ,
33570 (void __user *)start, len)))
33571 return 0;
33572
33573@@ -344,6 +344,10 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
33574 goto slow_irqon;
33575 #endif
33576
33577+ if (unlikely(!access_ok_noprefault(write ? VERIFY_WRITE : VERIFY_READ,
33578+ (void __user *)start, len)))
33579+ return 0;
33580+
33581 /*
33582 * XXX: batch / limit 'nr', to avoid large irq off latency
33583 * needs some instrumenting to determine the common sizes used by
33584diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
33585index eecb207a..e76b7f4 100644
33586--- a/arch/x86/mm/highmem_32.c
33587+++ b/arch/x86/mm/highmem_32.c
33588@@ -35,6 +35,8 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
33589 unsigned long vaddr;
33590 int idx, type;
33591
33592+ BUG_ON(pgprot_val(prot) & _PAGE_USER);
33593+
33594 preempt_disable();
33595 pagefault_disable();
33596
33597@@ -45,7 +47,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
33598 idx = type + KM_TYPE_NR*smp_processor_id();
33599 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
33600 BUG_ON(!pte_none(*(kmap_pte-idx)));
33601+
33602+ pax_open_kernel();
33603 set_pte(kmap_pte-idx, mk_pte(page, prot));
33604+ pax_close_kernel();
33605+
33606 arch_flush_lazy_mmu_mode();
33607
33608 return (void *)vaddr;
33609diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
33610index 42982b2..7168fc3 100644
33611--- a/arch/x86/mm/hugetlbpage.c
33612+++ b/arch/x86/mm/hugetlbpage.c
33613@@ -74,23 +74,24 @@ int pud_huge(pud_t pud)
33614 #ifdef CONFIG_HUGETLB_PAGE
33615 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
33616 unsigned long addr, unsigned long len,
33617- unsigned long pgoff, unsigned long flags)
33618+ unsigned long pgoff, unsigned long flags, unsigned long offset)
33619 {
33620 struct hstate *h = hstate_file(file);
33621 struct vm_unmapped_area_info info;
33622-
33623+
33624 info.flags = 0;
33625 info.length = len;
33626 info.low_limit = current->mm->mmap_legacy_base;
33627 info.high_limit = TASK_SIZE;
33628 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
33629 info.align_offset = 0;
33630+ info.threadstack_offset = offset;
33631 return vm_unmapped_area(&info);
33632 }
33633
33634 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
33635 unsigned long addr0, unsigned long len,
33636- unsigned long pgoff, unsigned long flags)
33637+ unsigned long pgoff, unsigned long flags, unsigned long offset)
33638 {
33639 struct hstate *h = hstate_file(file);
33640 struct vm_unmapped_area_info info;
33641@@ -102,6 +103,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
33642 info.high_limit = current->mm->mmap_base;
33643 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
33644 info.align_offset = 0;
33645+ info.threadstack_offset = offset;
33646 addr = vm_unmapped_area(&info);
33647
33648 /*
33649@@ -114,6 +116,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
33650 VM_BUG_ON(addr != -ENOMEM);
33651 info.flags = 0;
33652 info.low_limit = TASK_UNMAPPED_BASE;
33653+
33654+#ifdef CONFIG_PAX_RANDMMAP
33655+ if (current->mm->pax_flags & MF_PAX_RANDMMAP)
33656+ info.low_limit += current->mm->delta_mmap;
33657+#endif
33658+
33659 info.high_limit = TASK_SIZE;
33660 addr = vm_unmapped_area(&info);
33661 }
33662@@ -128,10 +136,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
33663 struct hstate *h = hstate_file(file);
33664 struct mm_struct *mm = current->mm;
33665 struct vm_area_struct *vma;
33666+ unsigned long pax_task_size = TASK_SIZE;
33667+ unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
33668
33669 if (len & ~huge_page_mask(h))
33670 return -EINVAL;
33671- if (len > TASK_SIZE)
33672+
33673+#ifdef CONFIG_PAX_SEGMEXEC
33674+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
33675+ pax_task_size = SEGMEXEC_TASK_SIZE;
33676+#endif
33677+
33678+ pax_task_size -= PAGE_SIZE;
33679+
33680+ if (len > pax_task_size)
33681 return -ENOMEM;
33682
33683 if (flags & MAP_FIXED) {
33684@@ -140,19 +158,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
33685 return addr;
33686 }
33687
33688+#ifdef CONFIG_PAX_RANDMMAP
33689+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33690+#endif
33691+
33692 if (addr) {
33693 addr = ALIGN(addr, huge_page_size(h));
33694 vma = find_vma(mm, addr);
33695- if (TASK_SIZE - len >= addr &&
33696- (!vma || addr + len <= vma->vm_start))
33697+ if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
33698 return addr;
33699 }
33700 if (mm->get_unmapped_area == arch_get_unmapped_area)
33701 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
33702- pgoff, flags);
33703+ pgoff, flags, offset);
33704 else
33705 return hugetlb_get_unmapped_area_topdown(file, addr, len,
33706- pgoff, flags);
33707+ pgoff, flags, offset);
33708 }
33709 #endif /* CONFIG_HUGETLB_PAGE */
33710
33711diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
33712index 8533b46..8c83176 100644
33713--- a/arch/x86/mm/init.c
33714+++ b/arch/x86/mm/init.c
33715@@ -4,6 +4,7 @@
33716 #include <linux/swap.h>
33717 #include <linux/memblock.h>
33718 #include <linux/bootmem.h> /* for max_low_pfn */
33719+#include <linux/tboot.h>
33720
33721 #include <asm/cacheflush.h>
33722 #include <asm/e820.h>
33723@@ -17,6 +18,8 @@
33724 #include <asm/proto.h>
33725 #include <asm/dma.h> /* for MAX_DMA_PFN */
33726 #include <asm/microcode.h>
33727+#include <asm/desc.h>
33728+#include <asm/bios_ebda.h>
33729
33730 /*
33731 * We need to define the tracepoints somewhere, and tlb.c
33732@@ -615,7 +618,18 @@ void __init init_mem_mapping(void)
33733 early_ioremap_page_table_range_init();
33734 #endif
33735
33736+#ifdef CONFIG_PAX_PER_CPU_PGD
33737+ clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
33738+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
33739+ KERNEL_PGD_PTRS);
33740+ clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
33741+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
33742+ KERNEL_PGD_PTRS);
33743+ load_cr3(get_cpu_pgd(0, kernel));
33744+#else
33745 load_cr3(swapper_pg_dir);
33746+#endif
33747+
33748 __flush_tlb_all();
33749
33750 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
33751@@ -631,10 +645,40 @@ void __init init_mem_mapping(void)
33752 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
33753 * mmio resources as well as potential bios/acpi data regions.
33754 */
33755+
33756+#ifdef CONFIG_GRKERNSEC_KMEM
33757+static unsigned int ebda_start __read_only;
33758+static unsigned int ebda_end __read_only;
33759+#endif
33760+
33761 int devmem_is_allowed(unsigned long pagenr)
33762 {
33763- if (pagenr < 256)
33764+#ifdef CONFIG_GRKERNSEC_KMEM
33765+ /* allow BDA */
33766+ if (!pagenr)
33767 return 1;
33768+ /* allow EBDA */
33769+ if (pagenr >= ebda_start && pagenr < ebda_end)
33770+ return 1;
33771+ /* if tboot is in use, allow access to its hardcoded serial log range */
33772+ if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
33773+ return 1;
33774+#else
33775+ if (!pagenr)
33776+ return 1;
33777+#ifdef CONFIG_VM86
33778+ if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
33779+ return 1;
33780+#endif
33781+#endif
33782+
33783+ if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
33784+ return 1;
33785+#ifdef CONFIG_GRKERNSEC_KMEM
33786+ /* throw out everything else below 1MB */
33787+ if (pagenr <= 256)
33788+ return 0;
33789+#endif
33790 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
33791 return 0;
33792 if (!page_is_ram(pagenr))
33793@@ -680,8 +724,127 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
33794 #endif
33795 }
33796
33797+#ifdef CONFIG_GRKERNSEC_KMEM
33798+static inline void gr_init_ebda(void)
33799+{
33800+ unsigned int ebda_addr;
33801+ unsigned int ebda_size = 0;
33802+
33803+ ebda_addr = get_bios_ebda();
33804+ if (ebda_addr) {
33805+ ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
33806+ ebda_size <<= 10;
33807+ }
33808+ if (ebda_addr && ebda_size) {
33809+ ebda_start = ebda_addr >> PAGE_SHIFT;
33810+ ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
33811+ } else {
33812+ ebda_start = 0x9f000 >> PAGE_SHIFT;
33813+ ebda_end = 0xa0000 >> PAGE_SHIFT;
33814+ }
33815+}
33816+#else
33817+static inline void gr_init_ebda(void) { }
33818+#endif
33819+
33820 void free_initmem(void)
33821 {
33822+#ifdef CONFIG_PAX_KERNEXEC
33823+#ifdef CONFIG_X86_32
33824+ /* PaX: limit KERNEL_CS to actual size */
33825+ unsigned long addr, limit;
33826+ struct desc_struct d;
33827+ int cpu;
33828+#else
33829+ pgd_t *pgd;
33830+ pud_t *pud;
33831+ pmd_t *pmd;
33832+ unsigned long addr, end;
33833+#endif
33834+#endif
33835+
33836+ gr_init_ebda();
33837+
33838+#ifdef CONFIG_PAX_KERNEXEC
33839+#ifdef CONFIG_X86_32
33840+ limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
33841+ limit = (limit - 1UL) >> PAGE_SHIFT;
33842+
33843+ memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
33844+ for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
33845+ pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
33846+ write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
33847+ write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
33848+ }
33849+
33850+ /* PaX: make KERNEL_CS read-only */
33851+ addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
33852+ if (!paravirt_enabled())
33853+ set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
33854+/*
33855+ for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
33856+ pgd = pgd_offset_k(addr);
33857+ pud = pud_offset(pgd, addr);
33858+ pmd = pmd_offset(pud, addr);
33859+ set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
33860+ }
33861+*/
33862+#ifdef CONFIG_X86_PAE
33863+ set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
33864+/*
33865+ for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
33866+ pgd = pgd_offset_k(addr);
33867+ pud = pud_offset(pgd, addr);
33868+ pmd = pmd_offset(pud, addr);
33869+ set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
33870+ }
33871+*/
33872+#endif
33873+
33874+#ifdef CONFIG_MODULES
33875+ set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
33876+#endif
33877+
33878+#else
33879+ /* PaX: make kernel code/rodata read-only, rest non-executable */
33880+ set_memory_ro((unsigned long)_text, ((unsigned long)(_sdata - _text) >> PAGE_SHIFT));
33881+ set_memory_nx((unsigned long)_sdata, (__START_KERNEL_map + KERNEL_IMAGE_SIZE - (unsigned long)_sdata) >> PAGE_SHIFT);
33882+
33883+ for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
33884+ pgd = pgd_offset_k(addr);
33885+ pud = pud_offset(pgd, addr);
33886+ pmd = pmd_offset(pud, addr);
33887+ if (!pmd_present(*pmd))
33888+ continue;
33889+ if (addr >= (unsigned long)_text)
33890+ BUG_ON(!pmd_large(*pmd));
33891+ if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
33892+ BUG_ON(pmd_write(*pmd));
33893+// set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
33894+ else
33895+ BUG_ON(!(pmd_flags(*pmd) & _PAGE_NX));
33896+// set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
33897+ }
33898+
33899+ addr = (unsigned long)__va(__pa(__START_KERNEL_map));
33900+ end = addr + KERNEL_IMAGE_SIZE;
33901+ for (; addr < end; addr += PMD_SIZE) {
33902+ pgd = pgd_offset_k(addr);
33903+ pud = pud_offset(pgd, addr);
33904+ pmd = pmd_offset(pud, addr);
33905+ if (!pmd_present(*pmd))
33906+ continue;
33907+ if (addr >= (unsigned long)_text)
33908+ BUG_ON(!pmd_large(*pmd));
33909+ if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
33910+ BUG_ON(pmd_write(*pmd));
33911+// set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
33912+ }
33913+#endif
33914+
33915+ flush_tlb_all();
33916+#endif
33917+
33918 free_init_pages("unused kernel",
33919 (unsigned long)(&__init_begin),
33920 (unsigned long)(&__init_end));
33921diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
33922index 68aec42..95ad5d3 100644
33923--- a/arch/x86/mm/init_32.c
33924+++ b/arch/x86/mm/init_32.c
33925@@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
33926 bool __read_mostly __vmalloc_start_set = false;
33927
33928 /*
33929- * Creates a middle page table and puts a pointer to it in the
33930- * given global directory entry. This only returns the gd entry
33931- * in non-PAE compilation mode, since the middle layer is folded.
33932- */
33933-static pmd_t * __init one_md_table_init(pgd_t *pgd)
33934-{
33935- pud_t *pud;
33936- pmd_t *pmd_table;
33937-
33938-#ifdef CONFIG_X86_PAE
33939- if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
33940- pmd_table = (pmd_t *)alloc_low_page();
33941- paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
33942- set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
33943- pud = pud_offset(pgd, 0);
33944- BUG_ON(pmd_table != pmd_offset(pud, 0));
33945-
33946- return pmd_table;
33947- }
33948-#endif
33949- pud = pud_offset(pgd, 0);
33950- pmd_table = pmd_offset(pud, 0);
33951-
33952- return pmd_table;
33953-}
33954-
33955-/*
33956 * Create a page table and place a pointer to it in a middle page
33957 * directory entry:
33958 */
33959@@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
33960 pte_t *page_table = (pte_t *)alloc_low_page();
33961
33962 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
33963+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
33964+ set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
33965+#else
33966 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
33967+#endif
33968 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
33969 }
33970
33971 return pte_offset_kernel(pmd, 0);
33972 }
33973
33974+static pmd_t * __init one_md_table_init(pgd_t *pgd)
33975+{
33976+ pud_t *pud;
33977+ pmd_t *pmd_table;
33978+
33979+ pud = pud_offset(pgd, 0);
33980+ pmd_table = pmd_offset(pud, 0);
33981+
33982+ return pmd_table;
33983+}
33984+
33985 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
33986 {
33987 int pgd_idx = pgd_index(vaddr);
33988@@ -209,6 +197,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
33989 int pgd_idx, pmd_idx;
33990 unsigned long vaddr;
33991 pgd_t *pgd;
33992+ pud_t *pud;
33993 pmd_t *pmd;
33994 pte_t *pte = NULL;
33995 unsigned long count = page_table_range_init_count(start, end);
33996@@ -223,8 +212,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
33997 pgd = pgd_base + pgd_idx;
33998
33999 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
34000- pmd = one_md_table_init(pgd);
34001- pmd = pmd + pmd_index(vaddr);
34002+ pud = pud_offset(pgd, vaddr);
34003+ pmd = pmd_offset(pud, vaddr);
34004+
34005+#ifdef CONFIG_X86_PAE
34006+ paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
34007+#endif
34008+
34009 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
34010 pmd++, pmd_idx++) {
34011 pte = page_table_kmap_check(one_page_table_init(pmd),
34012@@ -236,11 +230,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
34013 }
34014 }
34015
34016-static inline int is_kernel_text(unsigned long addr)
34017+static inline int is_kernel_text(unsigned long start, unsigned long end)
34018 {
34019- if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
34020- return 1;
34021- return 0;
34022+ if ((start >= ktla_ktva((unsigned long)_etext) ||
34023+ end <= ktla_ktva((unsigned long)_stext)) &&
34024+ (start >= ktla_ktva((unsigned long)_einittext) ||
34025+ end <= ktla_ktva((unsigned long)_sinittext)) &&
34026+
34027+#ifdef CONFIG_ACPI_SLEEP
34028+ (start >= (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
34029+#endif
34030+
34031+ (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
34032+ return 0;
34033+ return 1;
34034 }
34035
34036 /*
34037@@ -257,9 +260,10 @@ kernel_physical_mapping_init(unsigned long start,
34038 unsigned long last_map_addr = end;
34039 unsigned long start_pfn, end_pfn;
34040 pgd_t *pgd_base = swapper_pg_dir;
34041- int pgd_idx, pmd_idx, pte_ofs;
34042+ unsigned int pgd_idx, pmd_idx, pte_ofs;
34043 unsigned long pfn;
34044 pgd_t *pgd;
34045+ pud_t *pud;
34046 pmd_t *pmd;
34047 pte_t *pte;
34048 unsigned pages_2m, pages_4k;
34049@@ -292,8 +296,13 @@ repeat:
34050 pfn = start_pfn;
34051 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
34052 pgd = pgd_base + pgd_idx;
34053- for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
34054- pmd = one_md_table_init(pgd);
34055+ for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
34056+ pud = pud_offset(pgd, 0);
34057+ pmd = pmd_offset(pud, 0);
34058+
34059+#ifdef CONFIG_X86_PAE
34060+ paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
34061+#endif
34062
34063 if (pfn >= end_pfn)
34064 continue;
34065@@ -305,14 +314,13 @@ repeat:
34066 #endif
34067 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
34068 pmd++, pmd_idx++) {
34069- unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
34070+ unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
34071
34072 /*
34073 * Map with big pages if possible, otherwise
34074 * create normal page tables:
34075 */
34076 if (use_pse) {
34077- unsigned int addr2;
34078 pgprot_t prot = PAGE_KERNEL_LARGE;
34079 /*
34080 * first pass will use the same initial
34081@@ -323,11 +331,7 @@ repeat:
34082 _PAGE_PSE);
34083
34084 pfn &= PMD_MASK >> PAGE_SHIFT;
34085- addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
34086- PAGE_OFFSET + PAGE_SIZE-1;
34087-
34088- if (is_kernel_text(addr) ||
34089- is_kernel_text(addr2))
34090+ if (is_kernel_text(address, address + PMD_SIZE))
34091 prot = PAGE_KERNEL_LARGE_EXEC;
34092
34093 pages_2m++;
34094@@ -344,7 +348,7 @@ repeat:
34095 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
34096 pte += pte_ofs;
34097 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
34098- pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
34099+ pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
34100 pgprot_t prot = PAGE_KERNEL;
34101 /*
34102 * first pass will use the same initial
34103@@ -352,7 +356,7 @@ repeat:
34104 */
34105 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
34106
34107- if (is_kernel_text(addr))
34108+ if (is_kernel_text(address, address + PAGE_SIZE))
34109 prot = PAGE_KERNEL_EXEC;
34110
34111 pages_4k++;
34112@@ -475,7 +479,7 @@ void __init native_pagetable_init(void)
34113
34114 pud = pud_offset(pgd, va);
34115 pmd = pmd_offset(pud, va);
34116- if (!pmd_present(*pmd))
34117+ if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
34118 break;
34119
34120 /* should not be large page here */
34121@@ -533,12 +537,10 @@ void __init early_ioremap_page_table_range_init(void)
34122
34123 static void __init pagetable_init(void)
34124 {
34125- pgd_t *pgd_base = swapper_pg_dir;
34126-
34127- permanent_kmaps_init(pgd_base);
34128+ permanent_kmaps_init(swapper_pg_dir);
34129 }
34130
34131-pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL);
34132+pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL);
34133 EXPORT_SYMBOL_GPL(__supported_pte_mask);
34134
34135 /* user-defined highmem size */
34136@@ -788,10 +790,10 @@ void __init mem_init(void)
34137 ((unsigned long)&__init_end -
34138 (unsigned long)&__init_begin) >> 10,
34139
34140- (unsigned long)&_etext, (unsigned long)&_edata,
34141- ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
34142+ (unsigned long)&_sdata, (unsigned long)&_edata,
34143+ ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
34144
34145- (unsigned long)&_text, (unsigned long)&_etext,
34146+ ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
34147 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
34148
34149 /*
34150@@ -885,6 +887,7 @@ void set_kernel_text_rw(void)
34151 if (!kernel_set_to_readonly)
34152 return;
34153
34154+ start = ktla_ktva(start);
34155 pr_debug("Set kernel text: %lx - %lx for read write\n",
34156 start, start+size);
34157
34158@@ -899,6 +902,7 @@ void set_kernel_text_ro(void)
34159 if (!kernel_set_to_readonly)
34160 return;
34161
34162+ start = ktla_ktva(start);
34163 pr_debug("Set kernel text: %lx - %lx for read only\n",
34164 start, start+size);
34165
34166@@ -927,6 +931,7 @@ void mark_rodata_ro(void)
34167 unsigned long start = PFN_ALIGN(_text);
34168 unsigned long size = PFN_ALIGN(_etext) - start;
34169
34170+ start = ktla_ktva(start);
34171 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
34172 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
34173 size >> 10);
34174diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
34175index f9977a7..21a5082 100644
34176--- a/arch/x86/mm/init_64.c
34177+++ b/arch/x86/mm/init_64.c
34178@@ -136,7 +136,7 @@ int kernel_ident_mapping_init(struct x86_mapping_info *info, pgd_t *pgd_page,
34179 * around without checking the pgd every time.
34180 */
34181
34182-pteval_t __supported_pte_mask __read_mostly = ~0;
34183+pteval_t __supported_pte_mask __read_only = ~_PAGE_NX;
34184 EXPORT_SYMBOL_GPL(__supported_pte_mask);
34185
34186 int force_personality32;
34187@@ -169,7 +169,12 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
34188
34189 for (address = start; address <= end; address += PGDIR_SIZE) {
34190 const pgd_t *pgd_ref = pgd_offset_k(address);
34191+
34192+#ifdef CONFIG_PAX_PER_CPU_PGD
34193+ unsigned long cpu;
34194+#else
34195 struct page *page;
34196+#endif
34197
34198 /*
34199 * When it is called after memory hot remove, pgd_none()
34200@@ -180,6 +185,25 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
34201 continue;
34202
34203 spin_lock(&pgd_lock);
34204+
34205+#ifdef CONFIG_PAX_PER_CPU_PGD
34206+ for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
34207+ pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
34208+
34209+ if (!pgd_none(*pgd_ref) && !pgd_none(*pgd))
34210+ BUG_ON(pgd_page_vaddr(*pgd)
34211+ != pgd_page_vaddr(*pgd_ref));
34212+
34213+ if (removed) {
34214+ if (pgd_none(*pgd_ref) && !pgd_none(*pgd))
34215+ pgd_clear(pgd);
34216+ } else {
34217+ if (pgd_none(*pgd))
34218+ set_pgd(pgd, *pgd_ref);
34219+ }
34220+
34221+ pgd = pgd_offset_cpu(cpu, kernel, address);
34222+#else
34223 list_for_each_entry(page, &pgd_list, lru) {
34224 pgd_t *pgd;
34225 spinlock_t *pgt_lock;
34226@@ -188,6 +212,7 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
34227 /* the pgt_lock only for Xen */
34228 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
34229 spin_lock(pgt_lock);
34230+#endif
34231
34232 if (!pgd_none(*pgd_ref) && !pgd_none(*pgd))
34233 BUG_ON(pgd_page_vaddr(*pgd)
34234@@ -201,7 +226,10 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
34235 set_pgd(pgd, *pgd_ref);
34236 }
34237
34238+#ifndef CONFIG_PAX_PER_CPU_PGD
34239 spin_unlock(pgt_lock);
34240+#endif
34241+
34242 }
34243 spin_unlock(&pgd_lock);
34244 }
34245@@ -234,7 +262,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
34246 {
34247 if (pgd_none(*pgd)) {
34248 pud_t *pud = (pud_t *)spp_getpage();
34249- pgd_populate(&init_mm, pgd, pud);
34250+ pgd_populate_kernel(&init_mm, pgd, pud);
34251 if (pud != pud_offset(pgd, 0))
34252 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
34253 pud, pud_offset(pgd, 0));
34254@@ -246,7 +274,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
34255 {
34256 if (pud_none(*pud)) {
34257 pmd_t *pmd = (pmd_t *) spp_getpage();
34258- pud_populate(&init_mm, pud, pmd);
34259+ pud_populate_kernel(&init_mm, pud, pmd);
34260 if (pmd != pmd_offset(pud, 0))
34261 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
34262 pmd, pmd_offset(pud, 0));
34263@@ -275,7 +303,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
34264 pmd = fill_pmd(pud, vaddr);
34265 pte = fill_pte(pmd, vaddr);
34266
34267+ pax_open_kernel();
34268 set_pte(pte, new_pte);
34269+ pax_close_kernel();
34270
34271 /*
34272 * It's enough to flush this one mapping.
34273@@ -337,14 +367,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
34274 pgd = pgd_offset_k((unsigned long)__va(phys));
34275 if (pgd_none(*pgd)) {
34276 pud = (pud_t *) spp_getpage();
34277- set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
34278- _PAGE_USER));
34279+ set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
34280 }
34281 pud = pud_offset(pgd, (unsigned long)__va(phys));
34282 if (pud_none(*pud)) {
34283 pmd = (pmd_t *) spp_getpage();
34284- set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
34285- _PAGE_USER));
34286+ set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
34287 }
34288 pmd = pmd_offset(pud, phys);
34289 BUG_ON(!pmd_none(*pmd));
34290@@ -585,7 +613,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
34291 prot);
34292
34293 spin_lock(&init_mm.page_table_lock);
34294- pud_populate(&init_mm, pud, pmd);
34295+ pud_populate_kernel(&init_mm, pud, pmd);
34296 spin_unlock(&init_mm.page_table_lock);
34297 }
34298 __flush_tlb_all();
34299@@ -626,7 +654,7 @@ kernel_physical_mapping_init(unsigned long start,
34300 page_size_mask);
34301
34302 spin_lock(&init_mm.page_table_lock);
34303- pgd_populate(&init_mm, pgd, pud);
34304+ pgd_populate_kernel(&init_mm, pgd, pud);
34305 spin_unlock(&init_mm.page_table_lock);
34306 pgd_changed = true;
34307 }
34308diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
34309index 9c0ff04..9020d5f 100644
34310--- a/arch/x86/mm/iomap_32.c
34311+++ b/arch/x86/mm/iomap_32.c
34312@@ -65,7 +65,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
34313 type = kmap_atomic_idx_push();
34314 idx = type + KM_TYPE_NR * smp_processor_id();
34315 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
34316+
34317+ pax_open_kernel();
34318 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
34319+ pax_close_kernel();
34320+
34321 arch_flush_lazy_mmu_mode();
34322
34323 return (void *)vaddr;
34324diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
34325index b9c78f3..9ca7e24 100644
34326--- a/arch/x86/mm/ioremap.c
34327+++ b/arch/x86/mm/ioremap.c
34328@@ -59,8 +59,8 @@ static int __ioremap_check_ram(unsigned long start_pfn, unsigned long nr_pages,
34329 unsigned long i;
34330
34331 for (i = 0; i < nr_pages; ++i)
34332- if (pfn_valid(start_pfn + i) &&
34333- !PageReserved(pfn_to_page(start_pfn + i)))
34334+ if (pfn_valid(start_pfn + i) && (start_pfn + i >= 0x100 ||
34335+ !PageReserved(pfn_to_page(start_pfn + i))))
34336 return 1;
34337
34338 return 0;
34339@@ -332,7 +332,7 @@ EXPORT_SYMBOL(ioremap_prot);
34340 *
34341 * Caller must ensure there is only one unmapping for the same pointer.
34342 */
34343-void iounmap(volatile void __iomem *addr)
34344+void iounmap(const volatile void __iomem *addr)
34345 {
34346 struct vm_struct *p, *o;
34347
34348@@ -395,31 +395,37 @@ int __init arch_ioremap_pmd_supported(void)
34349 */
34350 void *xlate_dev_mem_ptr(phys_addr_t phys)
34351 {
34352- unsigned long start = phys & PAGE_MASK;
34353- unsigned long offset = phys & ~PAGE_MASK;
34354- void *vaddr;
34355+ phys_addr_t pfn = phys >> PAGE_SHIFT;
34356
34357- /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
34358- if (page_is_ram(start >> PAGE_SHIFT))
34359- return __va(phys);
34360+ if (page_is_ram(pfn)) {
34361+#ifdef CONFIG_HIGHMEM
34362+ if (pfn >= max_low_pfn)
34363+ return kmap_high(pfn_to_page(pfn));
34364+ else
34365+#endif
34366+ return __va(phys);
34367+ }
34368
34369- vaddr = ioremap_cache(start, PAGE_SIZE);
34370- /* Only add the offset on success and return NULL if the ioremap() failed: */
34371- if (vaddr)
34372- vaddr += offset;
34373-
34374- return vaddr;
34375+ return (void __force *)ioremap_cache(phys, 1);
34376 }
34377
34378 void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
34379 {
34380- if (page_is_ram(phys >> PAGE_SHIFT))
34381+ phys_addr_t pfn = phys >> PAGE_SHIFT;
34382+
34383+ if (page_is_ram(pfn)) {
34384+#ifdef CONFIG_HIGHMEM
34385+ if (pfn >= max_low_pfn)
34386+ kunmap_high(pfn_to_page(pfn));
34387+#endif
34388 return;
34389+ }
34390
34391- iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
34392+ iounmap((void __iomem __force *)addr);
34393 }
34394
34395-static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
34396+static pte_t __bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
34397+static pte_t *bm_pte __read_only = __bm_pte;
34398
34399 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
34400 {
34401@@ -455,8 +461,14 @@ void __init early_ioremap_init(void)
34402 early_ioremap_setup();
34403
34404 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
34405- memset(bm_pte, 0, sizeof(bm_pte));
34406- pmd_populate_kernel(&init_mm, pmd, bm_pte);
34407+ if (pmd_none(*pmd))
34408+#ifdef CONFIG_COMPAT_VDSO
34409+ pmd_populate_user(&init_mm, pmd, __bm_pte);
34410+#else
34411+ pmd_populate_kernel(&init_mm, pmd, __bm_pte);
34412+#endif
34413+ else
34414+ bm_pte = (pte_t *)pmd_page_vaddr(*pmd);
34415
34416 /*
34417 * The boot-ioremap range spans multiple pmds, for which
34418diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
34419index b4f2e7e..96c9c3e 100644
34420--- a/arch/x86/mm/kmemcheck/kmemcheck.c
34421+++ b/arch/x86/mm/kmemcheck/kmemcheck.c
34422@@ -628,9 +628,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
34423 * memory (e.g. tracked pages)? For now, we need this to avoid
34424 * invoking kmemcheck for PnP BIOS calls.
34425 */
34426- if (regs->flags & X86_VM_MASK)
34427+ if (v8086_mode(regs))
34428 return false;
34429- if (regs->cs != __KERNEL_CS)
34430+ if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
34431 return false;
34432
34433 pte = kmemcheck_pte_lookup(address);
34434diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
34435index 844b06d..f363c86 100644
34436--- a/arch/x86/mm/mmap.c
34437+++ b/arch/x86/mm/mmap.c
34438@@ -52,7 +52,7 @@ static unsigned long stack_maxrandom_size(void)
34439 * Leave an at least ~128 MB hole with possible stack randomization.
34440 */
34441 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
34442-#define MAX_GAP (TASK_SIZE/6*5)
34443+#define MAX_GAP (pax_task_size/6*5)
34444
34445 static int mmap_is_legacy(void)
34446 {
34447@@ -81,27 +81,40 @@ unsigned long arch_mmap_rnd(void)
34448 return rnd << PAGE_SHIFT;
34449 }
34450
34451-static unsigned long mmap_base(unsigned long rnd)
34452+static unsigned long mmap_base(struct mm_struct *mm, unsigned long rnd)
34453 {
34454 unsigned long gap = rlimit(RLIMIT_STACK);
34455+ unsigned long pax_task_size = TASK_SIZE;
34456+
34457+#ifdef CONFIG_PAX_SEGMEXEC
34458+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
34459+ pax_task_size = SEGMEXEC_TASK_SIZE;
34460+#endif
34461
34462 if (gap < MIN_GAP)
34463 gap = MIN_GAP;
34464 else if (gap > MAX_GAP)
34465 gap = MAX_GAP;
34466
34467- return PAGE_ALIGN(TASK_SIZE - gap - rnd);
34468+ return PAGE_ALIGN(pax_task_size - gap - rnd);
34469 }
34470
34471 /*
34472 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
34473 * does, but not when emulating X86_32
34474 */
34475-static unsigned long mmap_legacy_base(unsigned long rnd)
34476+static unsigned long mmap_legacy_base(struct mm_struct *mm, unsigned long rnd)
34477 {
34478- if (mmap_is_ia32())
34479+ if (mmap_is_ia32()) {
34480+
34481+#ifdef CONFIG_PAX_SEGMEXEC
34482+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
34483+ return SEGMEXEC_TASK_UNMAPPED_BASE;
34484+ else
34485+#endif
34486+
34487 return TASK_UNMAPPED_BASE;
34488- else
34489+ } else
34490 return TASK_UNMAPPED_BASE + rnd;
34491 }
34492
34493@@ -113,18 +126,29 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
34494 {
34495 unsigned long random_factor = 0UL;
34496
34497+#ifdef CONFIG_PAX_RANDMMAP
34498+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
34499+#endif
34500 if (current->flags & PF_RANDOMIZE)
34501 random_factor = arch_mmap_rnd();
34502
34503- mm->mmap_legacy_base = mmap_legacy_base(random_factor);
34504+ mm->mmap_legacy_base = mmap_legacy_base(mm, random_factor);
34505
34506 if (mmap_is_legacy()) {
34507 mm->mmap_base = mm->mmap_legacy_base;
34508 mm->get_unmapped_area = arch_get_unmapped_area;
34509 } else {
34510- mm->mmap_base = mmap_base(random_factor);
34511+ mm->mmap_base = mmap_base(mm, random_factor);
34512 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
34513 }
34514+
34515+#ifdef CONFIG_PAX_RANDMMAP
34516+ if (mm->pax_flags & MF_PAX_RANDMMAP) {
34517+ mm->mmap_legacy_base += mm->delta_mmap;
34518+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
34519+ }
34520+#endif
34521+
34522 }
34523
34524 const char *arch_vma_name(struct vm_area_struct *vma)
34525diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
34526index 0057a7a..95c7edd 100644
34527--- a/arch/x86/mm/mmio-mod.c
34528+++ b/arch/x86/mm/mmio-mod.c
34529@@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
34530 break;
34531 default:
34532 {
34533- unsigned char *ip = (unsigned char *)instptr;
34534+ unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
34535 my_trace->opcode = MMIO_UNKNOWN_OP;
34536 my_trace->width = 0;
34537 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
34538@@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
34539 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
34540 void __iomem *addr)
34541 {
34542- static atomic_t next_id;
34543+ static atomic_unchecked_t next_id;
34544 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
34545 /* These are page-unaligned. */
34546 struct mmiotrace_map map = {
34547@@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
34548 .private = trace
34549 },
34550 .phys = offset,
34551- .id = atomic_inc_return(&next_id)
34552+ .id = atomic_inc_return_unchecked(&next_id)
34553 };
34554 map.map_id = trace->id;
34555
34556@@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
34557 ioremap_trace_core(offset, size, addr);
34558 }
34559
34560-static void iounmap_trace_core(volatile void __iomem *addr)
34561+static void iounmap_trace_core(const volatile void __iomem *addr)
34562 {
34563 struct mmiotrace_map map = {
34564 .phys = 0,
34565@@ -328,7 +328,7 @@ not_enabled:
34566 }
34567 }
34568
34569-void mmiotrace_iounmap(volatile void __iomem *addr)
34570+void mmiotrace_iounmap(const volatile void __iomem *addr)
34571 {
34572 might_sleep();
34573 if (is_enabled()) /* recheck and proper locking in *_core() */
34574diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
34575index 4053bb5..b1ad3dc 100644
34576--- a/arch/x86/mm/numa.c
34577+++ b/arch/x86/mm/numa.c
34578@@ -506,7 +506,7 @@ static void __init numa_clear_kernel_node_hotplug(void)
34579 }
34580 }
34581
34582-static int __init numa_register_memblks(struct numa_meminfo *mi)
34583+static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
34584 {
34585 unsigned long uninitialized_var(pfn_align);
34586 int i, nid;
34587diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
34588index 727158c..54dd3ff 100644
34589--- a/arch/x86/mm/pageattr.c
34590+++ b/arch/x86/mm/pageattr.c
34591@@ -260,7 +260,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
34592 */
34593 #ifdef CONFIG_PCI_BIOS
34594 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
34595- pgprot_val(forbidden) |= _PAGE_NX;
34596+ pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
34597 #endif
34598
34599 /*
34600@@ -268,9 +268,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
34601 * Does not cover __inittext since that is gone later on. On
34602 * 64bit we do not enforce !NX on the low mapping
34603 */
34604- if (within(address, (unsigned long)_text, (unsigned long)_etext))
34605- pgprot_val(forbidden) |= _PAGE_NX;
34606+ if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
34607+ pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
34608
34609+#ifdef CONFIG_DEBUG_RODATA
34610 /*
34611 * The .rodata section needs to be read-only. Using the pfn
34612 * catches all aliases.
34613@@ -278,6 +279,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
34614 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
34615 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
34616 pgprot_val(forbidden) |= _PAGE_RW;
34617+#endif
34618
34619 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
34620 /*
34621@@ -316,6 +318,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
34622 }
34623 #endif
34624
34625+#ifdef CONFIG_PAX_KERNEXEC
34626+ if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
34627+ pgprot_val(forbidden) |= _PAGE_RW;
34628+ pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
34629+ }
34630+#endif
34631+
34632 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
34633
34634 return prot;
34635@@ -436,23 +445,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
34636 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
34637 {
34638 /* change init_mm */
34639+ pax_open_kernel();
34640 set_pte_atomic(kpte, pte);
34641+
34642 #ifdef CONFIG_X86_32
34643 if (!SHARED_KERNEL_PMD) {
34644+
34645+#ifdef CONFIG_PAX_PER_CPU_PGD
34646+ unsigned long cpu;
34647+#else
34648 struct page *page;
34649+#endif
34650
34651+#ifdef CONFIG_PAX_PER_CPU_PGD
34652+ for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
34653+ pgd_t *pgd = get_cpu_pgd(cpu, kernel);
34654+#else
34655 list_for_each_entry(page, &pgd_list, lru) {
34656- pgd_t *pgd;
34657+ pgd_t *pgd = (pgd_t *)page_address(page);
34658+#endif
34659+
34660 pud_t *pud;
34661 pmd_t *pmd;
34662
34663- pgd = (pgd_t *)page_address(page) + pgd_index(address);
34664+ pgd += pgd_index(address);
34665 pud = pud_offset(pgd, address);
34666 pmd = pmd_offset(pud, address);
34667 set_pte_atomic((pte_t *)pmd, pte);
34668 }
34669 }
34670 #endif
34671+ pax_close_kernel();
34672 }
34673
34674 static int
34675@@ -505,7 +528,8 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
34676 * up accordingly.
34677 */
34678 old_pte = *kpte;
34679- old_prot = req_prot = pgprot_large_2_4k(pte_pgprot(old_pte));
34680+ old_prot = pte_pgprot(old_pte);
34681+ req_prot = pgprot_large_2_4k(old_prot);
34682
34683 pgprot_val(req_prot) &= ~pgprot_val(cpa->mask_clr);
34684 pgprot_val(req_prot) |= pgprot_val(cpa->mask_set);
34685@@ -1176,7 +1200,9 @@ repeat:
34686 * Do we really change anything ?
34687 */
34688 if (pte_val(old_pte) != pte_val(new_pte)) {
34689+ pax_open_kernel();
34690 set_pte_atomic(kpte, new_pte);
34691+ pax_close_kernel();
34692 cpa->flags |= CPA_FLUSHTLB;
34693 }
34694 cpa->numpages = 1;
34695diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
34696index 188e3e0..5c75446 100644
34697--- a/arch/x86/mm/pat.c
34698+++ b/arch/x86/mm/pat.c
34699@@ -588,7 +588,7 @@ int free_memtype(u64 start, u64 end)
34700
34701 if (!entry) {
34702 pr_info("x86/PAT: %s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
34703- current->comm, current->pid, start, end - 1);
34704+ current->comm, task_pid_nr(current), start, end - 1);
34705 return -EINVAL;
34706 }
34707
34708@@ -711,8 +711,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34709
34710 while (cursor < to) {
34711 if (!devmem_is_allowed(pfn)) {
34712- pr_info("x86/PAT: Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx], PAT prevents it\n",
34713- current->comm, from, to - 1);
34714+ pr_info("x86/PAT: Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx), PAT prevents it\n",
34715+ current->comm, from, to - 1, cursor);
34716 return 0;
34717 }
34718 cursor += PAGE_SIZE;
34719@@ -782,7 +782,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size,
34720
34721 if (ioremap_change_attr((unsigned long)__va(base), id_sz, pcm) < 0) {
34722 pr_info("x86/PAT: %s:%d ioremap_change_attr failed %s for [mem %#010Lx-%#010Lx]\n",
34723- current->comm, current->pid,
34724+ current->comm, task_pid_nr(current),
34725 cattr_name(pcm),
34726 base, (unsigned long long)(base + size-1));
34727 return -EINVAL;
34728@@ -817,7 +817,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
34729 pcm = lookup_memtype(paddr);
34730 if (want_pcm != pcm) {
34731 pr_warn("x86/PAT: %s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
34732- current->comm, current->pid,
34733+ current->comm, task_pid_nr(current),
34734 cattr_name(want_pcm),
34735 (unsigned long long)paddr,
34736 (unsigned long long)(paddr + size - 1),
34737@@ -838,7 +838,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
34738 !is_new_memtype_allowed(paddr, size, want_pcm, pcm)) {
34739 free_memtype(paddr, paddr + size);
34740 pr_err("x86/PAT: %s:%d map pfn expected mapping type %s for [mem %#010Lx-%#010Lx], got %s\n",
34741- current->comm, current->pid,
34742+ current->comm, task_pid_nr(current),
34743 cattr_name(want_pcm),
34744 (unsigned long long)paddr,
34745 (unsigned long long)(paddr + size - 1),
34746diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
34747index 6393108..890adda 100644
34748--- a/arch/x86/mm/pat_rbtree.c
34749+++ b/arch/x86/mm/pat_rbtree.c
34750@@ -161,7 +161,7 @@ success:
34751
34752 failure:
34753 pr_info("x86/PAT: %s:%d conflicting memory types %Lx-%Lx %s<->%s\n",
34754- current->comm, current->pid, start, end,
34755+ current->comm, task_pid_nr(current), start, end,
34756 cattr_name(found_type), cattr_name(match->type));
34757 return -EBUSY;
34758 }
34759diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
34760index 9f0614d..92ae64a 100644
34761--- a/arch/x86/mm/pf_in.c
34762+++ b/arch/x86/mm/pf_in.c
34763@@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
34764 int i;
34765 enum reason_type rv = OTHERS;
34766
34767- p = (unsigned char *)ins_addr;
34768+ p = (unsigned char *)ktla_ktva(ins_addr);
34769 p += skip_prefix(p, &prf);
34770 p += get_opcode(p, &opcode);
34771
34772@@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
34773 struct prefix_bits prf;
34774 int i;
34775
34776- p = (unsigned char *)ins_addr;
34777+ p = (unsigned char *)ktla_ktva(ins_addr);
34778 p += skip_prefix(p, &prf);
34779 p += get_opcode(p, &opcode);
34780
34781@@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
34782 struct prefix_bits prf;
34783 int i;
34784
34785- p = (unsigned char *)ins_addr;
34786+ p = (unsigned char *)ktla_ktva(ins_addr);
34787 p += skip_prefix(p, &prf);
34788 p += get_opcode(p, &opcode);
34789
34790@@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
34791 struct prefix_bits prf;
34792 int i;
34793
34794- p = (unsigned char *)ins_addr;
34795+ p = (unsigned char *)ktla_ktva(ins_addr);
34796 p += skip_prefix(p, &prf);
34797 p += get_opcode(p, &opcode);
34798 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
34799@@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
34800 struct prefix_bits prf;
34801 int i;
34802
34803- p = (unsigned char *)ins_addr;
34804+ p = (unsigned char *)ktla_ktva(ins_addr);
34805 p += skip_prefix(p, &prf);
34806 p += get_opcode(p, &opcode);
34807 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
34808diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
34809index fb0a9dd..5ab49c4 100644
34810--- a/arch/x86/mm/pgtable.c
34811+++ b/arch/x86/mm/pgtable.c
34812@@ -98,10 +98,75 @@ static inline void pgd_list_del(pgd_t *pgd)
34813 list_del(&page->lru);
34814 }
34815
34816-#define UNSHARED_PTRS_PER_PGD \
34817- (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
34818+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
34819+pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
34820
34821+void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
34822+{
34823+ unsigned int count = USER_PGD_PTRS;
34824
34825+ if (!pax_user_shadow_base)
34826+ return;
34827+
34828+ while (count--)
34829+ *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
34830+}
34831+#endif
34832+
34833+#ifdef CONFIG_PAX_PER_CPU_PGD
34834+void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
34835+{
34836+ unsigned int count = USER_PGD_PTRS;
34837+
34838+ while (count--) {
34839+ pgd_t pgd;
34840+
34841+#ifdef CONFIG_X86_64
34842+ pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
34843+#else
34844+ pgd = *src++;
34845+#endif
34846+
34847+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
34848+ pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
34849+#endif
34850+
34851+ *dst++ = pgd;
34852+ }
34853+
34854+}
34855+#endif
34856+
34857+#ifdef CONFIG_X86_64
34858+#define pxd_t pud_t
34859+#define pyd_t pgd_t
34860+#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
34861+#define pgtable_pxd_page_ctor(page) true
34862+#define pgtable_pxd_page_dtor(page) do {} while (0)
34863+#define pxd_free(mm, pud) pud_free((mm), (pud))
34864+#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
34865+#define pyd_offset(mm, address) pgd_offset((mm), (address))
34866+#define PYD_SIZE PGDIR_SIZE
34867+#define mm_inc_nr_pxds(mm) do {} while (0)
34868+#define mm_dec_nr_pxds(mm) do {} while (0)
34869+#else
34870+#define pxd_t pmd_t
34871+#define pyd_t pud_t
34872+#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
34873+#define pgtable_pxd_page_ctor(page) pgtable_pmd_page_ctor(page)
34874+#define pgtable_pxd_page_dtor(page) pgtable_pmd_page_dtor(page)
34875+#define pxd_free(mm, pud) pmd_free((mm), (pud))
34876+#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
34877+#define pyd_offset(mm, address) pud_offset((mm), (address))
34878+#define PYD_SIZE PUD_SIZE
34879+#define mm_inc_nr_pxds(mm) mm_inc_nr_pmds(mm)
34880+#define mm_dec_nr_pxds(mm) mm_dec_nr_pmds(mm)
34881+#endif
34882+
34883+#ifdef CONFIG_PAX_PER_CPU_PGD
34884+static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
34885+static inline void pgd_dtor(pgd_t *pgd) {}
34886+#else
34887 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
34888 {
34889 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
34890@@ -142,6 +207,7 @@ static void pgd_dtor(pgd_t *pgd)
34891 pgd_list_del(pgd);
34892 spin_unlock(&pgd_lock);
34893 }
34894+#endif
34895
34896 /*
34897 * List of all pgd's needed for non-PAE so it can invalidate entries
34898@@ -154,7 +220,7 @@ static void pgd_dtor(pgd_t *pgd)
34899 * -- nyc
34900 */
34901
34902-#ifdef CONFIG_X86_PAE
34903+#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
34904 /*
34905 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
34906 * updating the top-level pagetable entries to guarantee the
34907@@ -166,7 +232,7 @@ static void pgd_dtor(pgd_t *pgd)
34908 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
34909 * and initialize the kernel pmds here.
34910 */
34911-#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
34912+#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
34913
34914 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
34915 {
34916@@ -184,46 +250,48 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
34917 */
34918 flush_tlb_mm(mm);
34919 }
34920+#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
34921+#define PREALLOCATED_PXDS USER_PGD_PTRS
34922 #else /* !CONFIG_X86_PAE */
34923
34924 /* No need to prepopulate any pagetable entries in non-PAE modes. */
34925-#define PREALLOCATED_PMDS 0
34926+#define PREALLOCATED_PXDS 0
34927
34928 #endif /* CONFIG_X86_PAE */
34929
34930-static void free_pmds(struct mm_struct *mm, pmd_t *pmds[])
34931+static void free_pxds(struct mm_struct *mm, pxd_t *pxds[])
34932 {
34933 int i;
34934
34935- for(i = 0; i < PREALLOCATED_PMDS; i++)
34936- if (pmds[i]) {
34937- pgtable_pmd_page_dtor(virt_to_page(pmds[i]));
34938- free_page((unsigned long)pmds[i]);
34939- mm_dec_nr_pmds(mm);
34940+ for(i = 0; i < PREALLOCATED_PXDS; i++)
34941+ if (pxds[i]) {
34942+ pgtable_pxd_page_dtor(virt_to_page(pxds[i]));
34943+ free_page((unsigned long)pxds[i]);
34944+ mm_dec_nr_pxds(mm);
34945 }
34946 }
34947
34948-static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[])
34949+static int preallocate_pxds(struct mm_struct *mm, pxd_t *pxds[])
34950 {
34951 int i;
34952 bool failed = false;
34953
34954- for(i = 0; i < PREALLOCATED_PMDS; i++) {
34955- pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
34956- if (!pmd)
34957+ for(i = 0; i < PREALLOCATED_PXDS; i++) {
34958+ pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
34959+ if (!pxd)
34960 failed = true;
34961- if (pmd && !pgtable_pmd_page_ctor(virt_to_page(pmd))) {
34962- free_page((unsigned long)pmd);
34963- pmd = NULL;
34964+ if (pxd && !pgtable_pxd_page_ctor(virt_to_page(pxd))) {
34965+ free_page((unsigned long)pxd);
34966+ pxd = NULL;
34967 failed = true;
34968 }
34969- if (pmd)
34970- mm_inc_nr_pmds(mm);
34971- pmds[i] = pmd;
34972+ if (pxd)
34973+ mm_inc_nr_pxds(mm);
34974+ pxds[i] = pxd;
34975 }
34976
34977 if (failed) {
34978- free_pmds(mm, pmds);
34979+ free_pxds(mm, pxds);
34980 return -ENOMEM;
34981 }
34982
34983@@ -236,43 +304,47 @@ static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[])
34984 * preallocate which never got a corresponding vma will need to be
34985 * freed manually.
34986 */
34987-static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
34988+static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
34989 {
34990 int i;
34991
34992- for(i = 0; i < PREALLOCATED_PMDS; i++) {
34993+ for(i = 0; i < PREALLOCATED_PXDS; i++) {
34994 pgd_t pgd = pgdp[i];
34995
34996 if (pgd_val(pgd) != 0) {
34997- pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
34998+ pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
34999
35000- pgdp[i] = native_make_pgd(0);
35001+ set_pgd(pgdp + i, native_make_pgd(0));
35002
35003- paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
35004- pmd_free(mm, pmd);
35005- mm_dec_nr_pmds(mm);
35006+ paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
35007+ pxd_free(mm, pxd);
35008+ mm_dec_nr_pxds(mm);
35009 }
35010 }
35011 }
35012
35013-static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
35014+static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
35015 {
35016- pud_t *pud;
35017+ pyd_t *pyd;
35018 int i;
35019
35020- if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
35021+ if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
35022 return;
35023
35024- pud = pud_offset(pgd, 0);
35025+#ifdef CONFIG_X86_64
35026+ pyd = pyd_offset(mm, 0L);
35027+#else
35028+ pyd = pyd_offset(pgd, 0L);
35029+#endif
35030
35031- for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
35032- pmd_t *pmd = pmds[i];
35033+ for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
35034+ pxd_t *pxd = pxds[i];
35035
35036 if (i >= KERNEL_PGD_BOUNDARY)
35037- memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
35038- sizeof(pmd_t) * PTRS_PER_PMD);
35039+ memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
35040+ sizeof(pxd_t) * PTRS_PER_PMD);
35041
35042- pud_populate(mm, pud, pmd);
35043+ pyd_populate(mm, pyd, pxd);
35044 }
35045 }
35046
35047@@ -354,7 +426,7 @@ static inline void _pgd_free(pgd_t *pgd)
35048 pgd_t *pgd_alloc(struct mm_struct *mm)
35049 {
35050 pgd_t *pgd;
35051- pmd_t *pmds[PREALLOCATED_PMDS];
35052+ pxd_t *pxds[PREALLOCATED_PXDS];
35053
35054 pgd = _pgd_alloc();
35055
35056@@ -363,11 +435,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
35057
35058 mm->pgd = pgd;
35059
35060- if (preallocate_pmds(mm, pmds) != 0)
35061+ if (preallocate_pxds(mm, pxds) != 0)
35062 goto out_free_pgd;
35063
35064 if (paravirt_pgd_alloc(mm) != 0)
35065- goto out_free_pmds;
35066+ goto out_free_pxds;
35067
35068 /*
35069 * Make sure that pre-populating the pmds is atomic with
35070@@ -377,14 +449,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
35071 spin_lock(&pgd_lock);
35072
35073 pgd_ctor(mm, pgd);
35074- pgd_prepopulate_pmd(mm, pgd, pmds);
35075+ pgd_prepopulate_pxd(mm, pgd, pxds);
35076
35077 spin_unlock(&pgd_lock);
35078
35079 return pgd;
35080
35081-out_free_pmds:
35082- free_pmds(mm, pmds);
35083+out_free_pxds:
35084+ free_pxds(mm, pxds);
35085 out_free_pgd:
35086 _pgd_free(pgd);
35087 out:
35088@@ -393,7 +465,7 @@ out:
35089
35090 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
35091 {
35092- pgd_mop_up_pmds(mm, pgd);
35093+ pgd_mop_up_pxds(mm, pgd);
35094 pgd_dtor(pgd);
35095 paravirt_pgd_free(mm, pgd);
35096 _pgd_free(pgd);
35097@@ -544,6 +616,55 @@ void __init reserve_top_address(unsigned long reserve)
35098
35099 int fixmaps_set;
35100
35101+static void fix_user_fixmap(enum fixed_addresses idx, unsigned long address)
35102+{
35103+#ifdef CONFIG_X86_64
35104+ pgd_t *pgd;
35105+ pud_t *pud;
35106+ pmd_t *pmd;
35107+
35108+ switch (idx) {
35109+ default:
35110+ return;
35111+
35112+#ifdef CONFIG_X86_VSYSCALL_EMULATION
35113+ case VSYSCALL_PAGE:
35114+ break;
35115+#endif
35116+
35117+#ifdef CONFIG_PARAVIRT_CLOCK
35118+ case PVCLOCK_FIXMAP_BEGIN ... PVCLOCK_FIXMAP_END:
35119+ break;
35120+#endif
35121+ }
35122+
35123+ pgd = pgd_offset_k(address);
35124+ if (!(pgd_val(*pgd) & _PAGE_USER)) {
35125+#ifdef CONFIG_PAX_PER_CPU_PGD
35126+ unsigned int cpu;
35127+ pgd_t *pgd_cpu;
35128+
35129+ for_each_possible_cpu(cpu) {
35130+ pgd_cpu = pgd_offset_cpu(cpu, kernel, address);
35131+ set_pgd(pgd_cpu, __pgd(pgd_val(*pgd_cpu) | _PAGE_USER));
35132+
35133+ pgd_cpu = pgd_offset_cpu(cpu, user, address);
35134+ set_pgd(pgd_cpu, __pgd(pgd_val(*pgd_cpu) | _PAGE_USER));
35135+ }
35136+#endif
35137+ set_pgd(pgd, __pgd(pgd_val(*pgd) | _PAGE_USER));
35138+ }
35139+
35140+ pud = pud_offset(pgd, address);
35141+ if (!(pud_val(*pud) & _PAGE_USER))
35142+ set_pud(pud, __pud(pud_val(*pud) | _PAGE_USER));
35143+
35144+ pmd = pmd_offset(pud, address);
35145+ if (!(pmd_val(*pmd) & _PAGE_USER))
35146+ set_pmd(pmd, __pmd(pmd_val(*pmd) | _PAGE_USER));
35147+#endif
35148+}
35149+
35150 void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
35151 {
35152 unsigned long address = __fix_to_virt(idx);
35153@@ -554,6 +675,7 @@ void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
35154 }
35155 set_pte_vaddr(address, pte);
35156 fixmaps_set++;
35157+ fix_user_fixmap(idx, address);
35158 }
35159
35160 void native_set_fixmap(enum fixed_addresses idx, phys_addr_t phys,
35161@@ -620,9 +742,11 @@ int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot)
35162
35163 prot = pgprot_4k_2_large(prot);
35164
35165+ pax_open_kernel();
35166 set_pte((pte_t *)pmd, pfn_pte(
35167 (u64)addr >> PAGE_SHIFT,
35168 __pgprot(pgprot_val(prot) | _PAGE_PSE)));
35169+ pax_close_kernel();
35170
35171 return 1;
35172 }
35173diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
35174index 75cc097..79a097f 100644
35175--- a/arch/x86/mm/pgtable_32.c
35176+++ b/arch/x86/mm/pgtable_32.c
35177@@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
35178 return;
35179 }
35180 pte = pte_offset_kernel(pmd, vaddr);
35181+
35182+ pax_open_kernel();
35183 if (pte_val(pteval))
35184 set_pte_at(&init_mm, vaddr, pte, pteval);
35185 else
35186 pte_clear(&init_mm, vaddr, pte);
35187+ pax_close_kernel();
35188
35189 /*
35190 * It's enough to flush this one mapping.
35191diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
35192index 90555bf..f5f1828 100644
35193--- a/arch/x86/mm/setup_nx.c
35194+++ b/arch/x86/mm/setup_nx.c
35195@@ -5,8 +5,10 @@
35196 #include <asm/pgtable.h>
35197 #include <asm/proto.h>
35198
35199+#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
35200 static int disable_nx;
35201
35202+#ifndef CONFIG_PAX_PAGEEXEC
35203 /*
35204 * noexec = on|off
35205 *
35206@@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
35207 return 0;
35208 }
35209 early_param("noexec", noexec_setup);
35210+#endif
35211+
35212+#endif
35213
35214 void x86_configure_nx(void)
35215 {
35216+#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
35217 if (cpu_has_nx && !disable_nx)
35218 __supported_pte_mask |= _PAGE_NX;
35219 else
35220+#endif
35221 __supported_pte_mask &= ~_PAGE_NX;
35222 }
35223
35224diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
35225index 90b924a..4197ac2 100644
35226--- a/arch/x86/mm/tlb.c
35227+++ b/arch/x86/mm/tlb.c
35228@@ -45,7 +45,11 @@ void leave_mm(int cpu)
35229 BUG();
35230 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
35231 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
35232+
35233+#ifndef CONFIG_PAX_PER_CPU_PGD
35234 load_cr3(swapper_pg_dir);
35235+#endif
35236+
35237 /*
35238 * This gets called in the idle path where RCU
35239 * functions differently. Tracing normally
35240diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
35241new file mode 100644
35242index 0000000..3fda3f3
35243--- /dev/null
35244+++ b/arch/x86/mm/uderef_64.c
35245@@ -0,0 +1,37 @@
35246+#include <linux/mm.h>
35247+#include <asm/pgtable.h>
35248+#include <asm/uaccess.h>
35249+
35250+#ifdef CONFIG_PAX_MEMORY_UDEREF
35251+/* PaX: due to the special call convention these functions must
35252+ * - remain leaf functions under all configurations,
35253+ * - never be called directly, only dereferenced from the wrappers.
35254+ */
35255+void __used __pax_open_userland(void)
35256+{
35257+ unsigned int cpu;
35258+
35259+ if (unlikely(!segment_eq(get_fs(), USER_DS)))
35260+ return;
35261+
35262+ cpu = raw_get_cpu();
35263+ BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
35264+ write_cr3(__pa_nodebug(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
35265+ raw_put_cpu_no_resched();
35266+}
35267+EXPORT_SYMBOL(__pax_open_userland);
35268+
35269+void __used __pax_close_userland(void)
35270+{
35271+ unsigned int cpu;
35272+
35273+ if (unlikely(!segment_eq(get_fs(), USER_DS)))
35274+ return;
35275+
35276+ cpu = raw_get_cpu();
35277+ BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
35278+ write_cr3(__pa_nodebug(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
35279+ raw_put_cpu_no_resched();
35280+}
35281+EXPORT_SYMBOL(__pax_close_userland);
35282+#endif
35283diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
35284index 4093216..44b6b83 100644
35285--- a/arch/x86/net/bpf_jit.S
35286+++ b/arch/x86/net/bpf_jit.S
35287@@ -8,6 +8,7 @@
35288 * of the License.
35289 */
35290 #include <linux/linkage.h>
35291+#include <asm/alternative-asm.h>
35292
35293 /*
35294 * Calling convention :
35295@@ -37,6 +38,7 @@ sk_load_word_positive_offset:
35296 jle bpf_slow_path_word
35297 mov (SKBDATA,%rsi),%eax
35298 bswap %eax /* ntohl() */
35299+ pax_force_retaddr
35300 ret
35301
35302 sk_load_half:
35303@@ -54,6 +56,7 @@ sk_load_half_positive_offset:
35304 jle bpf_slow_path_half
35305 movzwl (SKBDATA,%rsi),%eax
35306 rol $8,%ax # ntohs()
35307+ pax_force_retaddr
35308 ret
35309
35310 sk_load_byte:
35311@@ -68,6 +71,7 @@ sk_load_byte_positive_offset:
35312 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
35313 jle bpf_slow_path_byte
35314 movzbl (SKBDATA,%rsi),%eax
35315+ pax_force_retaddr
35316 ret
35317
35318 /* rsi contains offset and can be scratched */
35319@@ -89,6 +93,7 @@ bpf_slow_path_word:
35320 js bpf_error
35321 mov - MAX_BPF_STACK + 32(%rbp),%eax
35322 bswap %eax
35323+ pax_force_retaddr
35324 ret
35325
35326 bpf_slow_path_half:
35327@@ -97,12 +102,14 @@ bpf_slow_path_half:
35328 mov - MAX_BPF_STACK + 32(%rbp),%ax
35329 rol $8,%ax
35330 movzwl %ax,%eax
35331+ pax_force_retaddr
35332 ret
35333
35334 bpf_slow_path_byte:
35335 bpf_slow_path_common(1)
35336 js bpf_error
35337 movzbl - MAX_BPF_STACK + 32(%rbp),%eax
35338+ pax_force_retaddr
35339 ret
35340
35341 #define sk_negative_common(SIZE) \
35342@@ -125,6 +132,7 @@ sk_load_word_negative_offset:
35343 sk_negative_common(4)
35344 mov (%rax), %eax
35345 bswap %eax
35346+ pax_force_retaddr
35347 ret
35348
35349 bpf_slow_path_half_neg:
35350@@ -136,6 +144,7 @@ sk_load_half_negative_offset:
35351 mov (%rax),%ax
35352 rol $8,%ax
35353 movzwl %ax,%eax
35354+ pax_force_retaddr
35355 ret
35356
35357 bpf_slow_path_byte_neg:
35358@@ -145,6 +154,7 @@ sk_load_byte_negative_offset:
35359 .globl sk_load_byte_negative_offset
35360 sk_negative_common(1)
35361 movzbl (%rax), %eax
35362+ pax_force_retaddr
35363 ret
35364
35365 bpf_error:
35366@@ -155,4 +165,5 @@ bpf_error:
35367 mov - MAX_BPF_STACK + 16(%rbp),%r14
35368 mov - MAX_BPF_STACK + 24(%rbp),%r15
35369 leaveq
35370+ pax_force_retaddr
35371 ret
35372diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
35373index be2e7a2..e6960dd 100644
35374--- a/arch/x86/net/bpf_jit_comp.c
35375+++ b/arch/x86/net/bpf_jit_comp.c
35376@@ -14,7 +14,11 @@
35377 #include <asm/cacheflush.h>
35378 #include <linux/bpf.h>
35379
35380+#ifdef CONFIG_GRKERNSEC_BPF_HARDEN
35381+int bpf_jit_enable __read_only;
35382+#else
35383 int bpf_jit_enable __read_mostly;
35384+#endif
35385
35386 /*
35387 * assembly code in arch/x86/net/bpf_jit.S
35388@@ -176,7 +180,9 @@ static u8 add_2reg(u8 byte, u32 dst_reg, u32 src_reg)
35389 static void jit_fill_hole(void *area, unsigned int size)
35390 {
35391 /* fill whole space with int3 instructions */
35392+ pax_open_kernel();
35393 memset(area, 0xcc, size);
35394+ pax_close_kernel();
35395 }
35396
35397 struct jit_context {
35398@@ -1026,7 +1032,9 @@ common_load:
35399 pr_err("bpf_jit_compile fatal error\n");
35400 return -EFAULT;
35401 }
35402+ pax_open_kernel();
35403 memcpy(image + proglen, temp, ilen);
35404+ pax_close_kernel();
35405 }
35406 proglen += ilen;
35407 addrs[i] = proglen;
35408@@ -1103,7 +1111,6 @@ void bpf_int_jit_compile(struct bpf_prog *prog)
35409
35410 if (image) {
35411 bpf_flush_icache(header, image + proglen);
35412- set_memory_ro((unsigned long)header, header->pages);
35413 prog->bpf_func = (void *)image;
35414 prog->jited = true;
35415 }
35416@@ -1116,12 +1123,8 @@ void bpf_jit_free(struct bpf_prog *fp)
35417 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
35418 struct bpf_binary_header *header = (void *)addr;
35419
35420- if (!fp->jited)
35421- goto free_filter;
35422+ if (fp->jited)
35423+ bpf_jit_binary_free(header);
35424
35425- set_memory_rw(addr, header->pages);
35426- bpf_jit_binary_free(header);
35427-
35428-free_filter:
35429 bpf_prog_unlock_free(fp);
35430 }
35431diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
35432index 4e664bd..2beeaa2 100644
35433--- a/arch/x86/oprofile/backtrace.c
35434+++ b/arch/x86/oprofile/backtrace.c
35435@@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
35436 struct stack_frame_ia32 *fp;
35437 unsigned long bytes;
35438
35439- bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
35440+ bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
35441 if (bytes != 0)
35442 return NULL;
35443
35444- fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
35445+ fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
35446
35447 oprofile_add_trace(bufhead[0].return_address);
35448
35449@@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
35450 struct stack_frame bufhead[2];
35451 unsigned long bytes;
35452
35453- bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
35454+ bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
35455 if (bytes != 0)
35456 return NULL;
35457
35458diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
35459index 1d2e639..f6ef82a 100644
35460--- a/arch/x86/oprofile/nmi_int.c
35461+++ b/arch/x86/oprofile/nmi_int.c
35462@@ -23,6 +23,7 @@
35463 #include <asm/nmi.h>
35464 #include <asm/msr.h>
35465 #include <asm/apic.h>
35466+#include <asm/pgtable.h>
35467
35468 #include "op_counter.h"
35469 #include "op_x86_model.h"
35470@@ -785,8 +786,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
35471 if (ret)
35472 return ret;
35473
35474- if (!model->num_virt_counters)
35475- model->num_virt_counters = model->num_counters;
35476+ if (!model->num_virt_counters) {
35477+ pax_open_kernel();
35478+ *(unsigned int *)&model->num_virt_counters = model->num_counters;
35479+ pax_close_kernel();
35480+ }
35481
35482 mux_init(ops);
35483
35484diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
35485index 50d86c0..7985318 100644
35486--- a/arch/x86/oprofile/op_model_amd.c
35487+++ b/arch/x86/oprofile/op_model_amd.c
35488@@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
35489 num_counters = AMD64_NUM_COUNTERS;
35490 }
35491
35492- op_amd_spec.num_counters = num_counters;
35493- op_amd_spec.num_controls = num_counters;
35494- op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
35495+ pax_open_kernel();
35496+ *(unsigned int *)&op_amd_spec.num_counters = num_counters;
35497+ *(unsigned int *)&op_amd_spec.num_controls = num_counters;
35498+ *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
35499+ pax_close_kernel();
35500
35501 return 0;
35502 }
35503diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
35504index d90528e..0127e2b 100644
35505--- a/arch/x86/oprofile/op_model_ppro.c
35506+++ b/arch/x86/oprofile/op_model_ppro.c
35507@@ -19,6 +19,7 @@
35508 #include <asm/msr.h>
35509 #include <asm/apic.h>
35510 #include <asm/nmi.h>
35511+#include <asm/pgtable.h>
35512
35513 #include "op_x86_model.h"
35514 #include "op_counter.h"
35515@@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
35516
35517 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
35518
35519- op_arch_perfmon_spec.num_counters = num_counters;
35520- op_arch_perfmon_spec.num_controls = num_counters;
35521+ pax_open_kernel();
35522+ *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
35523+ *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
35524+ pax_close_kernel();
35525 }
35526
35527 static int arch_perfmon_init(struct oprofile_operations *ignore)
35528diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
35529index 71e8a67..6a313bb 100644
35530--- a/arch/x86/oprofile/op_x86_model.h
35531+++ b/arch/x86/oprofile/op_x86_model.h
35532@@ -52,7 +52,7 @@ struct op_x86_model_spec {
35533 void (*switch_ctrl)(struct op_x86_model_spec const *model,
35534 struct op_msrs const * const msrs);
35535 #endif
35536-};
35537+} __do_const;
35538
35539 struct op_counter_config;
35540
35541diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c
35542index 7553921..d631bd4 100644
35543--- a/arch/x86/pci/intel_mid_pci.c
35544+++ b/arch/x86/pci/intel_mid_pci.c
35545@@ -278,7 +278,7 @@ int __init intel_mid_pci_init(void)
35546 pci_mmcfg_late_init();
35547 pcibios_enable_irq = intel_mid_pci_irq_enable;
35548 pcibios_disable_irq = intel_mid_pci_irq_disable;
35549- pci_root_ops = intel_mid_pci_ops;
35550+ memcpy((void *)&pci_root_ops, &intel_mid_pci_ops, sizeof pci_root_ops);
35551 pci_soc_mode = 1;
35552 /* Continue with standard init */
35553 return 1;
35554diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
35555index 9bd1154..e9d4656 100644
35556--- a/arch/x86/pci/irq.c
35557+++ b/arch/x86/pci/irq.c
35558@@ -51,7 +51,7 @@ struct irq_router {
35559 struct irq_router_handler {
35560 u16 vendor;
35561 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
35562-};
35563+} __do_const;
35564
35565 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
35566 void (*pcibios_disable_irq)(struct pci_dev *dev) = pirq_disable_irq;
35567@@ -792,7 +792,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
35568 return 0;
35569 }
35570
35571-static __initdata struct irq_router_handler pirq_routers[] = {
35572+static __initconst const struct irq_router_handler pirq_routers[] = {
35573 { PCI_VENDOR_ID_INTEL, intel_router_probe },
35574 { PCI_VENDOR_ID_AL, ali_router_probe },
35575 { PCI_VENDOR_ID_ITE, ite_router_probe },
35576@@ -819,7 +819,7 @@ static struct pci_dev *pirq_router_dev;
35577 static void __init pirq_find_router(struct irq_router *r)
35578 {
35579 struct irq_routing_table *rt = pirq_table;
35580- struct irq_router_handler *h;
35581+ const struct irq_router_handler *h;
35582
35583 #ifdef CONFIG_PCI_BIOS
35584 if (!rt->signature) {
35585@@ -1092,7 +1092,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
35586 return 0;
35587 }
35588
35589-static struct dmi_system_id __initdata pciirq_dmi_table[] = {
35590+static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
35591 {
35592 .callback = fix_broken_hp_bios_irq9,
35593 .ident = "HP Pavilion N5400 Series Laptop",
35594diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
35595index 9b83b90..2c256c5 100644
35596--- a/arch/x86/pci/pcbios.c
35597+++ b/arch/x86/pci/pcbios.c
35598@@ -79,7 +79,7 @@ union bios32 {
35599 static struct {
35600 unsigned long address;
35601 unsigned short segment;
35602-} bios32_indirect __initdata = { 0, __KERNEL_CS };
35603+} bios32_indirect __initdata = { 0, __PCIBIOS_CS };
35604
35605 /*
35606 * Returns the entry point for the given service, NULL on error
35607@@ -92,37 +92,80 @@ static unsigned long __init bios32_service(unsigned long service)
35608 unsigned long length; /* %ecx */
35609 unsigned long entry; /* %edx */
35610 unsigned long flags;
35611+ struct desc_struct d, *gdt;
35612
35613 local_irq_save(flags);
35614- __asm__("lcall *(%%edi); cld"
35615+
35616+ gdt = get_cpu_gdt_table(smp_processor_id());
35617+
35618+ pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
35619+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
35620+ pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
35621+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
35622+
35623+ __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
35624 : "=a" (return_code),
35625 "=b" (address),
35626 "=c" (length),
35627 "=d" (entry)
35628 : "0" (service),
35629 "1" (0),
35630- "D" (&bios32_indirect));
35631+ "D" (&bios32_indirect),
35632+ "r"(__PCIBIOS_DS)
35633+ : "memory");
35634+
35635+ pax_open_kernel();
35636+ gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
35637+ gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
35638+ gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
35639+ gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
35640+ pax_close_kernel();
35641+
35642 local_irq_restore(flags);
35643
35644 switch (return_code) {
35645- case 0:
35646- return address + entry;
35647- case 0x80: /* Not present */
35648- printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
35649- return 0;
35650- default: /* Shouldn't happen */
35651- printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
35652- service, return_code);
35653+ case 0: {
35654+ int cpu;
35655+ unsigned char flags;
35656+
35657+ printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
35658+ if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
35659+ printk(KERN_WARNING "bios32_service: not valid\n");
35660 return 0;
35661+ }
35662+ address = address + PAGE_OFFSET;
35663+ length += 16UL; /* some BIOSs underreport this... */
35664+ flags = 4;
35665+ if (length >= 64*1024*1024) {
35666+ length >>= PAGE_SHIFT;
35667+ flags |= 8;
35668+ }
35669+
35670+ for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
35671+ gdt = get_cpu_gdt_table(cpu);
35672+ pack_descriptor(&d, address, length, 0x9b, flags);
35673+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
35674+ pack_descriptor(&d, address, length, 0x93, flags);
35675+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
35676+ }
35677+ return entry;
35678+ }
35679+ case 0x80: /* Not present */
35680+ printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
35681+ return 0;
35682+ default: /* Shouldn't happen */
35683+ printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
35684+ service, return_code);
35685+ return 0;
35686 }
35687 }
35688
35689 static struct {
35690 unsigned long address;
35691 unsigned short segment;
35692-} pci_indirect = { 0, __KERNEL_CS };
35693+} pci_indirect __read_only = { 0, __PCIBIOS_CS };
35694
35695-static int pci_bios_present;
35696+static int pci_bios_present __read_only;
35697
35698 static int __init check_pcibios(void)
35699 {
35700@@ -131,11 +174,13 @@ static int __init check_pcibios(void)
35701 unsigned long flags, pcibios_entry;
35702
35703 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
35704- pci_indirect.address = pcibios_entry + PAGE_OFFSET;
35705+ pci_indirect.address = pcibios_entry;
35706
35707 local_irq_save(flags);
35708- __asm__(
35709- "lcall *(%%edi); cld\n\t"
35710+ __asm__("movw %w6, %%ds\n\t"
35711+ "lcall *%%ss:(%%edi); cld\n\t"
35712+ "push %%ss\n\t"
35713+ "pop %%ds\n\t"
35714 "jc 1f\n\t"
35715 "xor %%ah, %%ah\n"
35716 "1:"
35717@@ -144,7 +189,8 @@ static int __init check_pcibios(void)
35718 "=b" (ebx),
35719 "=c" (ecx)
35720 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
35721- "D" (&pci_indirect)
35722+ "D" (&pci_indirect),
35723+ "r" (__PCIBIOS_DS)
35724 : "memory");
35725 local_irq_restore(flags);
35726
35727@@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35728
35729 switch (len) {
35730 case 1:
35731- __asm__("lcall *(%%esi); cld\n\t"
35732+ __asm__("movw %w6, %%ds\n\t"
35733+ "lcall *%%ss:(%%esi); cld\n\t"
35734+ "push %%ss\n\t"
35735+ "pop %%ds\n\t"
35736 "jc 1f\n\t"
35737 "xor %%ah, %%ah\n"
35738 "1:"
35739@@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35740 : "1" (PCIBIOS_READ_CONFIG_BYTE),
35741 "b" (bx),
35742 "D" ((long)reg),
35743- "S" (&pci_indirect));
35744+ "S" (&pci_indirect),
35745+ "r" (__PCIBIOS_DS));
35746 /*
35747 * Zero-extend the result beyond 8 bits, do not trust the
35748 * BIOS having done it:
35749@@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35750 *value &= 0xff;
35751 break;
35752 case 2:
35753- __asm__("lcall *(%%esi); cld\n\t"
35754+ __asm__("movw %w6, %%ds\n\t"
35755+ "lcall *%%ss:(%%esi); cld\n\t"
35756+ "push %%ss\n\t"
35757+ "pop %%ds\n\t"
35758 "jc 1f\n\t"
35759 "xor %%ah, %%ah\n"
35760 "1:"
35761@@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35762 : "1" (PCIBIOS_READ_CONFIG_WORD),
35763 "b" (bx),
35764 "D" ((long)reg),
35765- "S" (&pci_indirect));
35766+ "S" (&pci_indirect),
35767+ "r" (__PCIBIOS_DS));
35768 /*
35769 * Zero-extend the result beyond 16 bits, do not trust the
35770 * BIOS having done it:
35771@@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35772 *value &= 0xffff;
35773 break;
35774 case 4:
35775- __asm__("lcall *(%%esi); cld\n\t"
35776+ __asm__("movw %w6, %%ds\n\t"
35777+ "lcall *%%ss:(%%esi); cld\n\t"
35778+ "push %%ss\n\t"
35779+ "pop %%ds\n\t"
35780 "jc 1f\n\t"
35781 "xor %%ah, %%ah\n"
35782 "1:"
35783@@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35784 : "1" (PCIBIOS_READ_CONFIG_DWORD),
35785 "b" (bx),
35786 "D" ((long)reg),
35787- "S" (&pci_indirect));
35788+ "S" (&pci_indirect),
35789+ "r" (__PCIBIOS_DS));
35790 break;
35791 }
35792
35793@@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35794
35795 switch (len) {
35796 case 1:
35797- __asm__("lcall *(%%esi); cld\n\t"
35798+ __asm__("movw %w6, %%ds\n\t"
35799+ "lcall *%%ss:(%%esi); cld\n\t"
35800+ "push %%ss\n\t"
35801+ "pop %%ds\n\t"
35802 "jc 1f\n\t"
35803 "xor %%ah, %%ah\n"
35804 "1:"
35805@@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35806 "c" (value),
35807 "b" (bx),
35808 "D" ((long)reg),
35809- "S" (&pci_indirect));
35810+ "S" (&pci_indirect),
35811+ "r" (__PCIBIOS_DS));
35812 break;
35813 case 2:
35814- __asm__("lcall *(%%esi); cld\n\t"
35815+ __asm__("movw %w6, %%ds\n\t"
35816+ "lcall *%%ss:(%%esi); cld\n\t"
35817+ "push %%ss\n\t"
35818+ "pop %%ds\n\t"
35819 "jc 1f\n\t"
35820 "xor %%ah, %%ah\n"
35821 "1:"
35822@@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35823 "c" (value),
35824 "b" (bx),
35825 "D" ((long)reg),
35826- "S" (&pci_indirect));
35827+ "S" (&pci_indirect),
35828+ "r" (__PCIBIOS_DS));
35829 break;
35830 case 4:
35831- __asm__("lcall *(%%esi); cld\n\t"
35832+ __asm__("movw %w6, %%ds\n\t"
35833+ "lcall *%%ss:(%%esi); cld\n\t"
35834+ "push %%ss\n\t"
35835+ "pop %%ds\n\t"
35836 "jc 1f\n\t"
35837 "xor %%ah, %%ah\n"
35838 "1:"
35839@@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35840 "c" (value),
35841 "b" (bx),
35842 "D" ((long)reg),
35843- "S" (&pci_indirect));
35844+ "S" (&pci_indirect),
35845+ "r" (__PCIBIOS_DS));
35846 break;
35847 }
35848
35849@@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
35850
35851 DBG("PCI: Fetching IRQ routing table... ");
35852 __asm__("push %%es\n\t"
35853+ "movw %w8, %%ds\n\t"
35854 "push %%ds\n\t"
35855 "pop %%es\n\t"
35856- "lcall *(%%esi); cld\n\t"
35857+ "lcall *%%ss:(%%esi); cld\n\t"
35858 "pop %%es\n\t"
35859+ "push %%ss\n\t"
35860+ "pop %%ds\n"
35861 "jc 1f\n\t"
35862 "xor %%ah, %%ah\n"
35863 "1:"
35864@@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
35865 "1" (0),
35866 "D" ((long) &opt),
35867 "S" (&pci_indirect),
35868- "m" (opt)
35869+ "m" (opt),
35870+ "r" (__PCIBIOS_DS)
35871 : "memory");
35872 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
35873 if (ret & 0xff00)
35874@@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
35875 {
35876 int ret;
35877
35878- __asm__("lcall *(%%esi); cld\n\t"
35879+ __asm__("movw %w5, %%ds\n\t"
35880+ "lcall *%%ss:(%%esi); cld\n\t"
35881+ "push %%ss\n\t"
35882+ "pop %%ds\n"
35883 "jc 1f\n\t"
35884 "xor %%ah, %%ah\n"
35885 "1:"
35886@@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
35887 : "0" (PCIBIOS_SET_PCI_HW_INT),
35888 "b" ((dev->bus->number << 8) | dev->devfn),
35889 "c" ((irq << 8) | (pin + 10)),
35890- "S" (&pci_indirect));
35891+ "S" (&pci_indirect),
35892+ "r" (__PCIBIOS_DS));
35893 return !(ret & 0xff00);
35894 }
35895 EXPORT_SYMBOL(pcibios_set_irq_routing);
35896diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
35897index ed5b673..24d2d53 100644
35898--- a/arch/x86/platform/efi/efi_32.c
35899+++ b/arch/x86/platform/efi/efi_32.c
35900@@ -61,11 +61,27 @@ pgd_t * __init efi_call_phys_prolog(void)
35901 struct desc_ptr gdt_descr;
35902 pgd_t *save_pgd;
35903
35904+#ifdef CONFIG_PAX_KERNEXEC
35905+ struct desc_struct d;
35906+#endif
35907+
35908 /* Current pgd is swapper_pg_dir, we'll restore it later: */
35909+#ifdef CONFIG_PAX_PER_CPU_PGD
35910+ save_pgd = get_cpu_pgd(smp_processor_id(), kernel);
35911+#else
35912 save_pgd = swapper_pg_dir;
35913+#endif
35914+
35915 load_cr3(initial_page_table);
35916 __flush_tlb_all();
35917
35918+#ifdef CONFIG_PAX_KERNEXEC
35919+ pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
35920+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
35921+ pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
35922+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
35923+#endif
35924+
35925 gdt_descr.address = __pa(get_cpu_gdt_table(0));
35926 gdt_descr.size = GDT_SIZE - 1;
35927 load_gdt(&gdt_descr);
35928@@ -77,6 +93,14 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
35929 {
35930 struct desc_ptr gdt_descr;
35931
35932+#ifdef CONFIG_PAX_KERNEXEC
35933+ struct desc_struct d;
35934+
35935+ memset(&d, 0, sizeof d);
35936+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
35937+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
35938+#endif
35939+
35940 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
35941 gdt_descr.size = GDT_SIZE - 1;
35942 load_gdt(&gdt_descr);
35943diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
35944index a0ac0f9..f41d324 100644
35945--- a/arch/x86/platform/efi/efi_64.c
35946+++ b/arch/x86/platform/efi/efi_64.c
35947@@ -96,6 +96,11 @@ pgd_t * __init efi_call_phys_prolog(void)
35948 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
35949 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
35950 }
35951+
35952+#ifdef CONFIG_PAX_PER_CPU_PGD
35953+ load_cr3(swapper_pg_dir);
35954+#endif
35955+
35956 __flush_tlb_all();
35957
35958 return save_pgd;
35959@@ -119,6 +124,10 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
35960
35961 kfree(save_pgd);
35962
35963+#ifdef CONFIG_PAX_PER_CPU_PGD
35964+ load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
35965+#endif
35966+
35967 __flush_tlb_all();
35968 early_code_mapping_set_exec(0);
35969 }
35970@@ -148,8 +157,23 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
35971 unsigned npages;
35972 pgd_t *pgd;
35973
35974- if (efi_enabled(EFI_OLD_MEMMAP))
35975+ if (efi_enabled(EFI_OLD_MEMMAP)) {
35976+ /* PaX: We need to disable the NX bit in the PGD, otherwise we won't be
35977+ * able to execute the EFI services.
35978+ */
35979+ if (__supported_pte_mask & _PAGE_NX) {
35980+ unsigned long addr = (unsigned long) __va(0);
35981+ pgd_t pe = __pgd(pgd_val(*pgd_offset_k(addr)) & ~_PAGE_NX);
35982+
35983+ pr_alert("PAX: Disabling NX protection for low memory map. Try booting without \"efi=old_map\"\n");
35984+#ifdef CONFIG_PAX_PER_CPU_PGD
35985+ set_pgd(pgd_offset_cpu(0, kernel, addr), pe);
35986+#endif
35987+ set_pgd(pgd_offset_k(addr), pe);
35988+ }
35989+
35990 return 0;
35991+ }
35992
35993 efi_scratch.efi_pgt = (pgd_t *)(unsigned long)real_mode_header->trampoline_pgd;
35994 pgd = __va(efi_scratch.efi_pgt);
35995diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
35996index 040192b..7d3300f 100644
35997--- a/arch/x86/platform/efi/efi_stub_32.S
35998+++ b/arch/x86/platform/efi/efi_stub_32.S
35999@@ -6,7 +6,9 @@
36000 */
36001
36002 #include <linux/linkage.h>
36003+#include <linux/init.h>
36004 #include <asm/page_types.h>
36005+#include <asm/segment.h>
36006
36007 /*
36008 * efi_call_phys(void *, ...) is a function with variable parameters.
36009@@ -20,7 +22,7 @@
36010 * service functions will comply with gcc calling convention, too.
36011 */
36012
36013-.text
36014+__INIT
36015 ENTRY(efi_call_phys)
36016 /*
36017 * 0. The function can only be called in Linux kernel. So CS has been
36018@@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
36019 * The mapping of lower virtual memory has been created in prolog and
36020 * epilog.
36021 */
36022- movl $1f, %edx
36023- subl $__PAGE_OFFSET, %edx
36024- jmp *%edx
36025+#ifdef CONFIG_PAX_KERNEXEC
36026+ movl $(__KERNEXEC_EFI_DS), %edx
36027+ mov %edx, %ds
36028+ mov %edx, %es
36029+ mov %edx, %ss
36030+ addl $2f,(1f)
36031+ ljmp *(1f)
36032+
36033+__INITDATA
36034+1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
36035+.previous
36036+
36037+2:
36038+ subl $2b,(1b)
36039+#else
36040+ jmp 1f-__PAGE_OFFSET
36041 1:
36042+#endif
36043
36044 /*
36045 * 2. Now on the top of stack is the return
36046@@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
36047 * parameter 2, ..., param n. To make things easy, we save the return
36048 * address of efi_call_phys in a global variable.
36049 */
36050- popl %edx
36051- movl %edx, saved_return_addr
36052- /* get the function pointer into ECX*/
36053- popl %ecx
36054- movl %ecx, efi_rt_function_ptr
36055- movl $2f, %edx
36056- subl $__PAGE_OFFSET, %edx
36057- pushl %edx
36058+ popl (saved_return_addr)
36059+ popl (efi_rt_function_ptr)
36060
36061 /*
36062 * 3. Clear PG bit in %CR0.
36063@@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
36064 /*
36065 * 5. Call the physical function.
36066 */
36067- jmp *%ecx
36068+ call *(efi_rt_function_ptr-__PAGE_OFFSET)
36069
36070-2:
36071 /*
36072 * 6. After EFI runtime service returns, control will return to
36073 * following instruction. We'd better readjust stack pointer first.
36074@@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
36075 movl %cr0, %edx
36076 orl $0x80000000, %edx
36077 movl %edx, %cr0
36078- jmp 1f
36079-1:
36080+
36081 /*
36082 * 8. Now restore the virtual mode from flat mode by
36083 * adding EIP with PAGE_OFFSET.
36084 */
36085- movl $1f, %edx
36086- jmp *%edx
36087+#ifdef CONFIG_PAX_KERNEXEC
36088+ movl $(__KERNEL_DS), %edx
36089+ mov %edx, %ds
36090+ mov %edx, %es
36091+ mov %edx, %ss
36092+ ljmp $(__KERNEL_CS),$1f
36093+#else
36094+ jmp 1f+__PAGE_OFFSET
36095+#endif
36096 1:
36097
36098 /*
36099 * 9. Balance the stack. And because EAX contain the return value,
36100 * we'd better not clobber it.
36101 */
36102- leal efi_rt_function_ptr, %edx
36103- movl (%edx), %ecx
36104- pushl %ecx
36105+ pushl (efi_rt_function_ptr)
36106
36107 /*
36108- * 10. Push the saved return address onto the stack and return.
36109+ * 10. Return to the saved return address.
36110 */
36111- leal saved_return_addr, %edx
36112- movl (%edx), %ecx
36113- pushl %ecx
36114- ret
36115+ jmpl *(saved_return_addr)
36116 ENDPROC(efi_call_phys)
36117 .previous
36118
36119-.data
36120+__INITDATA
36121 saved_return_addr:
36122 .long 0
36123 efi_rt_function_ptr:
36124diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
36125index 86d0f9e..6d499f4 100644
36126--- a/arch/x86/platform/efi/efi_stub_64.S
36127+++ b/arch/x86/platform/efi/efi_stub_64.S
36128@@ -11,6 +11,7 @@
36129 #include <asm/msr.h>
36130 #include <asm/processor-flags.h>
36131 #include <asm/page_types.h>
36132+#include <asm/alternative-asm.h>
36133
36134 #define SAVE_XMM \
36135 mov %rsp, %rax; \
36136@@ -88,6 +89,7 @@ ENTRY(efi_call)
36137 RESTORE_PGT
36138 addq $48, %rsp
36139 RESTORE_XMM
36140+ pax_force_retaddr 0, 1
36141 ret
36142 ENDPROC(efi_call)
36143
36144diff --git a/arch/x86/platform/intel-mid/intel-mid.c b/arch/x86/platform/intel-mid/intel-mid.c
36145index 01d54ea..ba1d71c 100644
36146--- a/arch/x86/platform/intel-mid/intel-mid.c
36147+++ b/arch/x86/platform/intel-mid/intel-mid.c
36148@@ -63,7 +63,7 @@ enum intel_mid_timer_options intel_mid_timer_options;
36149 /* intel_mid_ops to store sub arch ops */
36150 struct intel_mid_ops *intel_mid_ops;
36151 /* getter function for sub arch ops*/
36152-static void *(*get_intel_mid_ops[])(void) = INTEL_MID_OPS_INIT;
36153+static const void *(*get_intel_mid_ops[])(void) = INTEL_MID_OPS_INIT;
36154 enum intel_mid_cpu_type __intel_mid_cpu_chip;
36155 EXPORT_SYMBOL_GPL(__intel_mid_cpu_chip);
36156
36157@@ -71,9 +71,10 @@ static void intel_mid_power_off(void)
36158 {
36159 };
36160
36161-static void intel_mid_reboot(void)
36162+static void __noreturn intel_mid_reboot(void)
36163 {
36164 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
36165+ BUG();
36166 }
36167
36168 static unsigned long __init intel_mid_calibrate_tsc(void)
36169diff --git a/arch/x86/platform/intel-mid/intel_mid_weak_decls.h b/arch/x86/platform/intel-mid/intel_mid_weak_decls.h
36170index 3c1c386..59a68ed 100644
36171--- a/arch/x86/platform/intel-mid/intel_mid_weak_decls.h
36172+++ b/arch/x86/platform/intel-mid/intel_mid_weak_decls.h
36173@@ -13,6 +13,6 @@
36174 /* For every CPU addition a new get_<cpuname>_ops interface needs
36175 * to be added.
36176 */
36177-extern void *get_penwell_ops(void);
36178-extern void *get_cloverview_ops(void);
36179-extern void *get_tangier_ops(void);
36180+extern const void *get_penwell_ops(void);
36181+extern const void *get_cloverview_ops(void);
36182+extern const void *get_tangier_ops(void);
36183diff --git a/arch/x86/platform/intel-mid/mfld.c b/arch/x86/platform/intel-mid/mfld.c
36184index 23381d2..8ddc10e 100644
36185--- a/arch/x86/platform/intel-mid/mfld.c
36186+++ b/arch/x86/platform/intel-mid/mfld.c
36187@@ -64,12 +64,12 @@ static void __init penwell_arch_setup(void)
36188 pm_power_off = mfld_power_off;
36189 }
36190
36191-void *get_penwell_ops(void)
36192+const void *get_penwell_ops(void)
36193 {
36194 return &penwell_ops;
36195 }
36196
36197-void *get_cloverview_ops(void)
36198+const void *get_cloverview_ops(void)
36199 {
36200 return &penwell_ops;
36201 }
36202diff --git a/arch/x86/platform/intel-mid/mrfl.c b/arch/x86/platform/intel-mid/mrfl.c
36203index aaca917..66eadbc 100644
36204--- a/arch/x86/platform/intel-mid/mrfl.c
36205+++ b/arch/x86/platform/intel-mid/mrfl.c
36206@@ -97,7 +97,7 @@ static struct intel_mid_ops tangier_ops = {
36207 .arch_setup = tangier_arch_setup,
36208 };
36209
36210-void *get_tangier_ops(void)
36211+const void *get_tangier_ops(void)
36212 {
36213 return &tangier_ops;
36214 }
36215diff --git a/arch/x86/platform/intel-quark/imr_selftest.c b/arch/x86/platform/intel-quark/imr_selftest.c
36216index 278e4da..35db1a9 100644
36217--- a/arch/x86/platform/intel-quark/imr_selftest.c
36218+++ b/arch/x86/platform/intel-quark/imr_selftest.c
36219@@ -55,7 +55,7 @@ static void __init imr_self_test_result(int res, const char *fmt, ...)
36220 */
36221 static void __init imr_self_test(void)
36222 {
36223- phys_addr_t base = virt_to_phys(&_text);
36224+ phys_addr_t base = virt_to_phys((void *)ktla_ktva((unsigned long)_text));
36225 size_t size = virt_to_phys(&__end_rodata) - base;
36226 const char *fmt_over = "overlapped IMR @ (0x%08lx - 0x%08lx)\n";
36227 int ret;
36228diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
36229index d6ee929..3637cb5 100644
36230--- a/arch/x86/platform/olpc/olpc_dt.c
36231+++ b/arch/x86/platform/olpc/olpc_dt.c
36232@@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
36233 return res;
36234 }
36235
36236-static struct of_pdt_ops prom_olpc_ops __initdata = {
36237+static struct of_pdt_ops prom_olpc_ops __initconst = {
36238 .nextprop = olpc_dt_nextprop,
36239 .getproplen = olpc_dt_getproplen,
36240 .getproperty = olpc_dt_getproperty,
36241diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
36242index 9ab5279..8ba4611 100644
36243--- a/arch/x86/power/cpu.c
36244+++ b/arch/x86/power/cpu.c
36245@@ -134,11 +134,8 @@ static void do_fpu_end(void)
36246 static void fix_processor_context(void)
36247 {
36248 int cpu = smp_processor_id();
36249- struct tss_struct *t = &per_cpu(cpu_tss, cpu);
36250-#ifdef CONFIG_X86_64
36251- struct desc_struct *desc = get_cpu_gdt_table(cpu);
36252- tss_desc tss;
36253-#endif
36254+ struct tss_struct *t = cpu_tss + cpu;
36255+
36256 set_tss_desc(cpu, t); /*
36257 * This just modifies memory; should not be
36258 * necessary. But... This is necessary, because
36259@@ -147,10 +144,6 @@ static void fix_processor_context(void)
36260 */
36261
36262 #ifdef CONFIG_X86_64
36263- memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
36264- tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
36265- write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
36266-
36267 syscall_init(); /* This sets MSR_*STAR and related */
36268 #endif
36269 load_TR_desc(); /* This does ltr */
36270diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
36271index 0b7a63d..dff2199 100644
36272--- a/arch/x86/realmode/init.c
36273+++ b/arch/x86/realmode/init.c
36274@@ -68,7 +68,13 @@ void __init setup_real_mode(void)
36275 __va(real_mode_header->trampoline_header);
36276
36277 #ifdef CONFIG_X86_32
36278- trampoline_header->start = __pa_symbol(startup_32_smp);
36279+ trampoline_header->start = __pa_symbol(ktla_ktva((unsigned long)startup_32_smp));
36280+
36281+#ifdef CONFIG_PAX_KERNEXEC
36282+ trampoline_header->start -= LOAD_PHYSICAL_ADDR;
36283+#endif
36284+
36285+ trampoline_header->boot_cs = __BOOT_CS;
36286 trampoline_header->gdt_limit = __BOOT_DS + 7;
36287 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
36288 #else
36289@@ -84,7 +90,7 @@ void __init setup_real_mode(void)
36290 *trampoline_cr4_features = __read_cr4();
36291
36292 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
36293- trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
36294+ trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
36295 trampoline_pgd[511] = init_level4_pgt[511].pgd;
36296 #endif
36297 }
36298diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
36299index 2730d77..2e4cd19 100644
36300--- a/arch/x86/realmode/rm/Makefile
36301+++ b/arch/x86/realmode/rm/Makefile
36302@@ -68,5 +68,8 @@ $(obj)/realmode.relocs: $(obj)/realmode.elf FORCE
36303
36304 KBUILD_CFLAGS := $(LINUXINCLUDE) $(REALMODE_CFLAGS) -D_SETUP -D_WAKEUP \
36305 -I$(srctree)/arch/x86/boot
36306+ifdef CONSTIFY_PLUGIN
36307+KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
36308+endif
36309 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
36310 GCOV_PROFILE := n
36311diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
36312index a28221d..93c40f1 100644
36313--- a/arch/x86/realmode/rm/header.S
36314+++ b/arch/x86/realmode/rm/header.S
36315@@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
36316 #endif
36317 /* APM/BIOS reboot */
36318 .long pa_machine_real_restart_asm
36319-#ifdef CONFIG_X86_64
36320+#ifdef CONFIG_X86_32
36321+ .long __KERNEL_CS
36322+#else
36323 .long __KERNEL32_CS
36324 #endif
36325 END(real_mode_header)
36326diff --git a/arch/x86/realmode/rm/reboot.S b/arch/x86/realmode/rm/reboot.S
36327index d66c607..3def845 100644
36328--- a/arch/x86/realmode/rm/reboot.S
36329+++ b/arch/x86/realmode/rm/reboot.S
36330@@ -27,6 +27,10 @@ ENTRY(machine_real_restart_asm)
36331 lgdtl pa_tr_gdt
36332
36333 /* Disable paging to drop us out of long mode */
36334+ movl %cr4, %eax
36335+ andl $~X86_CR4_PCIDE, %eax
36336+ movl %eax, %cr4
36337+
36338 movl %cr0, %eax
36339 andl $~X86_CR0_PG, %eax
36340 movl %eax, %cr0
36341diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
36342index 48ddd76..c26749f 100644
36343--- a/arch/x86/realmode/rm/trampoline_32.S
36344+++ b/arch/x86/realmode/rm/trampoline_32.S
36345@@ -24,6 +24,12 @@
36346 #include <asm/page_types.h>
36347 #include "realmode.h"
36348
36349+#ifdef CONFIG_PAX_KERNEXEC
36350+#define ta(X) (X)
36351+#else
36352+#define ta(X) (pa_ ## X)
36353+#endif
36354+
36355 .text
36356 .code16
36357
36358@@ -38,8 +44,6 @@ ENTRY(trampoline_start)
36359
36360 cli # We should be safe anyway
36361
36362- movl tr_start, %eax # where we need to go
36363-
36364 movl $0xA5A5A5A5, trampoline_status
36365 # write marker for master knows we're running
36366
36367@@ -55,7 +59,7 @@ ENTRY(trampoline_start)
36368 movw $1, %dx # protected mode (PE) bit
36369 lmsw %dx # into protected mode
36370
36371- ljmpl $__BOOT_CS, $pa_startup_32
36372+ ljmpl *(trampoline_header)
36373
36374 .section ".text32","ax"
36375 .code32
36376@@ -66,7 +70,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
36377 .balign 8
36378 GLOBAL(trampoline_header)
36379 tr_start: .space 4
36380- tr_gdt_pad: .space 2
36381+ tr_boot_cs: .space 2
36382 tr_gdt: .space 6
36383 END(trampoline_header)
36384
36385diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
36386index dac7b20..72dbaca 100644
36387--- a/arch/x86/realmode/rm/trampoline_64.S
36388+++ b/arch/x86/realmode/rm/trampoline_64.S
36389@@ -93,6 +93,7 @@ ENTRY(startup_32)
36390 movl %edx, %gs
36391
36392 movl pa_tr_cr4, %eax
36393+ andl $~X86_CR4_PCIDE, %eax
36394 movl %eax, %cr4 # Enable PAE mode
36395
36396 # Setup trampoline 4 level pagetables
36397@@ -106,7 +107,7 @@ ENTRY(startup_32)
36398 wrmsr
36399
36400 # Enable paging and in turn activate Long Mode
36401- movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
36402+ movl $(X86_CR0_PG | X86_CR0_PE), %eax
36403 movl %eax, %cr0
36404
36405 /*
36406diff --git a/arch/x86/realmode/rm/wakeup_asm.S b/arch/x86/realmode/rm/wakeup_asm.S
36407index 9e7e147..25a4158 100644
36408--- a/arch/x86/realmode/rm/wakeup_asm.S
36409+++ b/arch/x86/realmode/rm/wakeup_asm.S
36410@@ -126,11 +126,10 @@ ENTRY(wakeup_start)
36411 lgdtl pmode_gdt
36412
36413 /* This really couldn't... */
36414- movl pmode_entry, %eax
36415 movl pmode_cr0, %ecx
36416 movl %ecx, %cr0
36417- ljmpl $__KERNEL_CS, $pa_startup_32
36418- /* -> jmp *%eax in trampoline_32.S */
36419+
36420+ ljmpl *pmode_entry
36421 #else
36422 jmp trampoline_start
36423 #endif
36424diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
36425index 604a37e..e49702a 100644
36426--- a/arch/x86/tools/Makefile
36427+++ b/arch/x86/tools/Makefile
36428@@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
36429
36430 $(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
36431
36432-HOST_EXTRACFLAGS += -I$(srctree)/tools/include
36433+HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
36434 hostprogs-y += relocs
36435 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
36436 PHONY += relocs
36437diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
36438index 0c2fae8..88d7719 100644
36439--- a/arch/x86/tools/relocs.c
36440+++ b/arch/x86/tools/relocs.c
36441@@ -1,5 +1,7 @@
36442 /* This is included from relocs_32/64.c */
36443
36444+#include "../../../include/generated/autoconf.h"
36445+
36446 #define ElfW(type) _ElfW(ELF_BITS, type)
36447 #define _ElfW(bits, type) __ElfW(bits, type)
36448 #define __ElfW(bits, type) Elf##bits##_##type
36449@@ -11,6 +13,7 @@
36450 #define Elf_Sym ElfW(Sym)
36451
36452 static Elf_Ehdr ehdr;
36453+static Elf_Phdr *phdr;
36454
36455 struct relocs {
36456 uint32_t *offset;
36457@@ -386,9 +389,39 @@ static void read_ehdr(FILE *fp)
36458 }
36459 }
36460
36461+static void read_phdrs(FILE *fp)
36462+{
36463+ unsigned int i;
36464+
36465+ phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
36466+ if (!phdr) {
36467+ die("Unable to allocate %d program headers\n",
36468+ ehdr.e_phnum);
36469+ }
36470+ if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
36471+ die("Seek to %d failed: %s\n",
36472+ ehdr.e_phoff, strerror(errno));
36473+ }
36474+ if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
36475+ die("Cannot read ELF program headers: %s\n",
36476+ strerror(errno));
36477+ }
36478+ for(i = 0; i < ehdr.e_phnum; i++) {
36479+ phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
36480+ phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
36481+ phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
36482+ phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
36483+ phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
36484+ phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
36485+ phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
36486+ phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
36487+ }
36488+
36489+}
36490+
36491 static void read_shdrs(FILE *fp)
36492 {
36493- int i;
36494+ unsigned int i;
36495 Elf_Shdr shdr;
36496
36497 secs = calloc(ehdr.e_shnum, sizeof(struct section));
36498@@ -423,7 +456,7 @@ static void read_shdrs(FILE *fp)
36499
36500 static void read_strtabs(FILE *fp)
36501 {
36502- int i;
36503+ unsigned int i;
36504 for (i = 0; i < ehdr.e_shnum; i++) {
36505 struct section *sec = &secs[i];
36506 if (sec->shdr.sh_type != SHT_STRTAB) {
36507@@ -448,7 +481,7 @@ static void read_strtabs(FILE *fp)
36508
36509 static void read_symtabs(FILE *fp)
36510 {
36511- int i,j;
36512+ unsigned int i,j;
36513 for (i = 0; i < ehdr.e_shnum; i++) {
36514 struct section *sec = &secs[i];
36515 if (sec->shdr.sh_type != SHT_SYMTAB) {
36516@@ -479,9 +512,11 @@ static void read_symtabs(FILE *fp)
36517 }
36518
36519
36520-static void read_relocs(FILE *fp)
36521+static void read_relocs(FILE *fp, int use_real_mode)
36522 {
36523- int i,j;
36524+ unsigned int i,j;
36525+ uint32_t base;
36526+
36527 for (i = 0; i < ehdr.e_shnum; i++) {
36528 struct section *sec = &secs[i];
36529 if (sec->shdr.sh_type != SHT_REL_TYPE) {
36530@@ -501,9 +536,22 @@ static void read_relocs(FILE *fp)
36531 die("Cannot read symbol table: %s\n",
36532 strerror(errno));
36533 }
36534+ base = 0;
36535+
36536+#ifdef CONFIG_X86_32
36537+ for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
36538+ if (phdr[j].p_type != PT_LOAD )
36539+ continue;
36540+ 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)
36541+ continue;
36542+ base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
36543+ break;
36544+ }
36545+#endif
36546+
36547 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
36548 Elf_Rel *rel = &sec->reltab[j];
36549- rel->r_offset = elf_addr_to_cpu(rel->r_offset);
36550+ rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
36551 rel->r_info = elf_xword_to_cpu(rel->r_info);
36552 #if (SHT_REL_TYPE == SHT_RELA)
36553 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
36554@@ -515,7 +563,7 @@ static void read_relocs(FILE *fp)
36555
36556 static void print_absolute_symbols(void)
36557 {
36558- int i;
36559+ unsigned int i;
36560 const char *format;
36561
36562 if (ELF_BITS == 64)
36563@@ -528,7 +576,7 @@ static void print_absolute_symbols(void)
36564 for (i = 0; i < ehdr.e_shnum; i++) {
36565 struct section *sec = &secs[i];
36566 char *sym_strtab;
36567- int j;
36568+ unsigned int j;
36569
36570 if (sec->shdr.sh_type != SHT_SYMTAB) {
36571 continue;
36572@@ -555,7 +603,7 @@ static void print_absolute_symbols(void)
36573
36574 static void print_absolute_relocs(void)
36575 {
36576- int i, printed = 0;
36577+ unsigned int i, printed = 0;
36578 const char *format;
36579
36580 if (ELF_BITS == 64)
36581@@ -568,7 +616,7 @@ static void print_absolute_relocs(void)
36582 struct section *sec_applies, *sec_symtab;
36583 char *sym_strtab;
36584 Elf_Sym *sh_symtab;
36585- int j;
36586+ unsigned int j;
36587 if (sec->shdr.sh_type != SHT_REL_TYPE) {
36588 continue;
36589 }
36590@@ -645,13 +693,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
36591 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
36592 Elf_Sym *sym, const char *symname))
36593 {
36594- int i;
36595+ unsigned int i;
36596 /* Walk through the relocations */
36597 for (i = 0; i < ehdr.e_shnum; i++) {
36598 char *sym_strtab;
36599 Elf_Sym *sh_symtab;
36600 struct section *sec_applies, *sec_symtab;
36601- int j;
36602+ unsigned int j;
36603 struct section *sec = &secs[i];
36604
36605 if (sec->shdr.sh_type != SHT_REL_TYPE) {
36606@@ -697,7 +745,7 @@ static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
36607 * kernel data and does not require special treatment.
36608 *
36609 */
36610-static int per_cpu_shndx = -1;
36611+static unsigned int per_cpu_shndx = ~0;
36612 static Elf_Addr per_cpu_load_addr;
36613
36614 static void percpu_init(void)
36615@@ -830,6 +878,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
36616 {
36617 unsigned r_type = ELF32_R_TYPE(rel->r_info);
36618 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
36619+ char *sym_strtab = sec->link->link->strtab;
36620+
36621+ /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
36622+ if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
36623+ return 0;
36624+
36625+#ifdef CONFIG_PAX_KERNEXEC
36626+ /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
36627+ if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
36628+ return 0;
36629+ if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
36630+ return 0;
36631+ if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
36632+ return 0;
36633+ if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
36634+ return 0;
36635+#endif
36636
36637 switch (r_type) {
36638 case R_386_NONE:
36639@@ -968,7 +1033,7 @@ static int write32_as_text(uint32_t v, FILE *f)
36640
36641 static void emit_relocs(int as_text, int use_real_mode)
36642 {
36643- int i;
36644+ unsigned int i;
36645 int (*write_reloc)(uint32_t, FILE *) = write32;
36646 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
36647 const char *symname);
36648@@ -1078,10 +1143,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
36649 {
36650 regex_init(use_real_mode);
36651 read_ehdr(fp);
36652+ read_phdrs(fp);
36653 read_shdrs(fp);
36654 read_strtabs(fp);
36655 read_symtabs(fp);
36656- read_relocs(fp);
36657+ read_relocs(fp, use_real_mode);
36658 if (ELF_BITS == 64)
36659 percpu_init();
36660 if (show_absolute_syms) {
36661diff --git a/arch/x86/um/mem_32.c b/arch/x86/um/mem_32.c
36662index 744afdc..a0b8a0d 100644
36663--- a/arch/x86/um/mem_32.c
36664+++ b/arch/x86/um/mem_32.c
36665@@ -20,7 +20,7 @@ static int __init gate_vma_init(void)
36666 gate_vma.vm_start = FIXADDR_USER_START;
36667 gate_vma.vm_end = FIXADDR_USER_END;
36668 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
36669- gate_vma.vm_page_prot = __P101;
36670+ gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
36671
36672 return 0;
36673 }
36674diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
36675index 48e3858..ab4458c 100644
36676--- a/arch/x86/um/tls_32.c
36677+++ b/arch/x86/um/tls_32.c
36678@@ -261,7 +261,7 @@ out:
36679 if (unlikely(task == current &&
36680 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
36681 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
36682- "without flushed TLS.", current->pid);
36683+ "without flushed TLS.", task_pid_nr(current));
36684 }
36685
36686 return 0;
36687diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
36688index 4841453..d59a203 100644
36689--- a/arch/x86/xen/Kconfig
36690+++ b/arch/x86/xen/Kconfig
36691@@ -9,6 +9,7 @@ config XEN
36692 select XEN_HAVE_PVMMU
36693 depends on X86_64 || (X86_32 && X86_PAE)
36694 depends on X86_LOCAL_APIC && X86_TSC
36695+ depends on !GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_VIRT_XEN
36696 help
36697 This is the Linux Xen port. Enabling this will allow the
36698 kernel to boot in a paravirtualized environment under the
36699diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
36700index 777ad2f..fa43e03 100644
36701--- a/arch/x86/xen/enlighten.c
36702+++ b/arch/x86/xen/enlighten.c
36703@@ -129,8 +129,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
36704
36705 struct shared_info xen_dummy_shared_info;
36706
36707-void *xen_initial_gdt;
36708-
36709 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
36710 __read_mostly int xen_have_vector_callback;
36711 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
36712@@ -588,8 +586,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
36713 {
36714 unsigned long va = dtr->address;
36715 unsigned int size = dtr->size + 1;
36716- unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
36717- unsigned long frames[pages];
36718+ unsigned long frames[65536 / PAGE_SIZE];
36719 int f;
36720
36721 /*
36722@@ -637,8 +634,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
36723 {
36724 unsigned long va = dtr->address;
36725 unsigned int size = dtr->size + 1;
36726- unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
36727- unsigned long frames[pages];
36728+ unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
36729 int f;
36730
36731 /*
36732@@ -646,7 +642,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
36733 * 8-byte entries, or 16 4k pages..
36734 */
36735
36736- BUG_ON(size > 65536);
36737+ BUG_ON(size > GDT_SIZE);
36738 BUG_ON(va & ~PAGE_MASK);
36739
36740 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
36741@@ -1268,30 +1264,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
36742 #endif
36743 };
36744
36745-static void xen_reboot(int reason)
36746+static __noreturn void xen_reboot(int reason)
36747 {
36748 struct sched_shutdown r = { .reason = reason };
36749
36750- if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
36751- BUG();
36752+ HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
36753+ BUG();
36754 }
36755
36756-static void xen_restart(char *msg)
36757+static __noreturn void xen_restart(char *msg)
36758 {
36759 xen_reboot(SHUTDOWN_reboot);
36760 }
36761
36762-static void xen_emergency_restart(void)
36763+static __noreturn void xen_emergency_restart(void)
36764 {
36765 xen_reboot(SHUTDOWN_reboot);
36766 }
36767
36768-static void xen_machine_halt(void)
36769+static __noreturn void xen_machine_halt(void)
36770 {
36771 xen_reboot(SHUTDOWN_poweroff);
36772 }
36773
36774-static void xen_machine_power_off(void)
36775+static __noreturn void xen_machine_power_off(void)
36776 {
36777 if (pm_power_off)
36778 pm_power_off();
36779@@ -1444,8 +1440,11 @@ static void __ref xen_setup_gdt(int cpu)
36780 pv_cpu_ops.write_gdt_entry = xen_write_gdt_entry_boot;
36781 pv_cpu_ops.load_gdt = xen_load_gdt_boot;
36782
36783- setup_stack_canary_segment(0);
36784- switch_to_new_gdt(0);
36785+ setup_stack_canary_segment(cpu);
36786+#ifdef CONFIG_X86_64
36787+ load_percpu_segment(cpu);
36788+#endif
36789+ switch_to_new_gdt(cpu);
36790
36791 pv_cpu_ops.write_gdt_entry = xen_write_gdt_entry;
36792 pv_cpu_ops.load_gdt = xen_load_gdt;
36793@@ -1561,7 +1560,17 @@ asmlinkage __visible void __init xen_start_kernel(void)
36794 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
36795
36796 /* Work out if we support NX */
36797- x86_configure_nx();
36798+#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
36799+ if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
36800+ (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
36801+ unsigned l, h;
36802+
36803+ __supported_pte_mask |= _PAGE_NX;
36804+ rdmsr(MSR_EFER, l, h);
36805+ l |= EFER_NX;
36806+ wrmsr(MSR_EFER, l, h);
36807+ }
36808+#endif
36809
36810 /* Get mfn list */
36811 xen_build_dynamic_phys_to_machine();
36812@@ -1589,13 +1598,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
36813
36814 machine_ops = xen_machine_ops;
36815
36816- /*
36817- * The only reliable way to retain the initial address of the
36818- * percpu gdt_page is to remember it here, so we can go and
36819- * mark it RW later, when the initial percpu area is freed.
36820- */
36821- xen_initial_gdt = &per_cpu(gdt_page, 0);
36822-
36823 xen_smp_init();
36824
36825 #ifdef CONFIG_ACPI_NUMA
36826diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
36827index dd151b2..3291e38 100644
36828--- a/arch/x86/xen/mmu.c
36829+++ b/arch/x86/xen/mmu.c
36830@@ -1835,7 +1835,11 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
36831 * L3_k[511] -> level2_fixmap_pgt */
36832 convert_pfn_mfn(level3_kernel_pgt);
36833
36834+ convert_pfn_mfn(level3_vmalloc_start_pgt);
36835+ convert_pfn_mfn(level3_vmalloc_end_pgt);
36836+ convert_pfn_mfn(level3_vmemmap_pgt);
36837 /* L3_k[511][506] -> level1_fixmap_pgt */
36838+ /* L3_k[511][507] -> level1_vsyscall_pgt */
36839 convert_pfn_mfn(level2_fixmap_pgt);
36840 }
36841 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
36842@@ -1860,11 +1864,22 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
36843 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
36844 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
36845 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
36846+ set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
36847+ set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
36848+ set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
36849 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
36850 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
36851+ set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
36852 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
36853 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
36854- set_page_prot(level1_fixmap_pgt, PAGE_KERNEL_RO);
36855+ set_page_prot(level1_modules_pgt[0], PAGE_KERNEL_RO);
36856+ set_page_prot(level1_modules_pgt[1], PAGE_KERNEL_RO);
36857+ set_page_prot(level1_modules_pgt[2], PAGE_KERNEL_RO);
36858+ set_page_prot(level1_modules_pgt[3], PAGE_KERNEL_RO);
36859+ set_page_prot(level1_fixmap_pgt[0], PAGE_KERNEL_RO);
36860+ set_page_prot(level1_fixmap_pgt[1], PAGE_KERNEL_RO);
36861+ set_page_prot(level1_fixmap_pgt[2], PAGE_KERNEL_RO);
36862+ set_page_prot(level1_vsyscall_pgt, PAGE_KERNEL_RO);
36863
36864 /* Pin down new L4 */
36865 pin_pagetable_pfn(MMUEXT_PIN_L4_TABLE,
36866@@ -2048,6 +2063,7 @@ static void __init xen_post_allocator_init(void)
36867 pv_mmu_ops.set_pud = xen_set_pud;
36868 #if CONFIG_PGTABLE_LEVELS == 4
36869 pv_mmu_ops.set_pgd = xen_set_pgd;
36870+ pv_mmu_ops.set_pgd_batched = xen_set_pgd;
36871 #endif
36872
36873 /* This will work as long as patching hasn't happened yet
36874@@ -2126,6 +2142,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
36875 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
36876 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
36877 .set_pgd = xen_set_pgd_hyper,
36878+ .set_pgd_batched = xen_set_pgd_hyper,
36879
36880 .alloc_pud = xen_alloc_pmd_init,
36881 .release_pud = xen_release_pmd_init,
36882diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
36883index 8648438..18bac20 100644
36884--- a/arch/x86/xen/smp.c
36885+++ b/arch/x86/xen/smp.c
36886@@ -284,17 +284,13 @@ static void __init xen_smp_prepare_boot_cpu(void)
36887
36888 if (xen_pv_domain()) {
36889 if (!xen_feature(XENFEAT_writable_page_tables))
36890- /* We've switched to the "real" per-cpu gdt, so make
36891- * sure the old memory can be recycled. */
36892- make_lowmem_page_readwrite(xen_initial_gdt);
36893-
36894 #ifdef CONFIG_X86_32
36895 /*
36896 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
36897 * expects __USER_DS
36898 */
36899- loadsegment(ds, __USER_DS);
36900- loadsegment(es, __USER_DS);
36901+ loadsegment(ds, __KERNEL_DS);
36902+ loadsegment(es, __KERNEL_DS);
36903 #endif
36904
36905 xen_filter_cpu_maps();
36906@@ -375,7 +371,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
36907 #ifdef CONFIG_X86_32
36908 /* Note: PVH is not yet supported on x86_32. */
36909 ctxt->user_regs.fs = __KERNEL_PERCPU;
36910- ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
36911+ savesegment(gs, ctxt->user_regs.gs);
36912 #endif
36913 memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
36914
36915@@ -383,8 +379,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
36916 ctxt->user_regs.eip = (unsigned long)cpu_bringup_and_idle;
36917 ctxt->flags = VGCF_IN_KERNEL;
36918 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
36919- ctxt->user_regs.ds = __USER_DS;
36920- ctxt->user_regs.es = __USER_DS;
36921+ ctxt->user_regs.ds = __KERNEL_DS;
36922+ ctxt->user_regs.es = __KERNEL_DS;
36923 ctxt->user_regs.ss = __KERNEL_DS;
36924
36925 xen_copy_trap_info(ctxt->trap_ctxt);
36926@@ -720,7 +716,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
36927
36928 void __init xen_smp_init(void)
36929 {
36930- smp_ops = xen_smp_ops;
36931+ memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
36932 xen_fill_possible_map();
36933 }
36934
36935diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
36936index fd92a64..1f72641 100644
36937--- a/arch/x86/xen/xen-asm_32.S
36938+++ b/arch/x86/xen/xen-asm_32.S
36939@@ -99,7 +99,7 @@ ENTRY(xen_iret)
36940 pushw %fs
36941 movl $(__KERNEL_PERCPU), %eax
36942 movl %eax, %fs
36943- movl %fs:xen_vcpu, %eax
36944+ mov PER_CPU_VAR(xen_vcpu), %eax
36945 POP_FS
36946 #else
36947 movl %ss:xen_vcpu, %eax
36948diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
36949index 8afdfcc..79239db 100644
36950--- a/arch/x86/xen/xen-head.S
36951+++ b/arch/x86/xen/xen-head.S
36952@@ -41,6 +41,17 @@ ENTRY(startup_xen)
36953 #ifdef CONFIG_X86_32
36954 mov %esi,xen_start_info
36955 mov $init_thread_union+THREAD_SIZE,%esp
36956+#ifdef CONFIG_SMP
36957+ movl $cpu_gdt_table,%edi
36958+ movl $__per_cpu_load,%eax
36959+ movw %ax,__KERNEL_PERCPU + 2(%edi)
36960+ rorl $16,%eax
36961+ movb %al,__KERNEL_PERCPU + 4(%edi)
36962+ movb %ah,__KERNEL_PERCPU + 7(%edi)
36963+ movl $__per_cpu_end - 1,%eax
36964+ subl $__per_cpu_start,%eax
36965+ movw %ax,__KERNEL_PERCPU + 0(%edi)
36966+#endif
36967 #else
36968 mov %rsi,xen_start_info
36969 mov $init_thread_union+THREAD_SIZE,%rsp
36970diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
36971index 2292721..a9bb18e 100644
36972--- a/arch/x86/xen/xen-ops.h
36973+++ b/arch/x86/xen/xen-ops.h
36974@@ -16,8 +16,6 @@ void xen_syscall_target(void);
36975 void xen_syscall32_target(void);
36976 #endif
36977
36978-extern void *xen_initial_gdt;
36979-
36980 struct trap_info;
36981 void xen_copy_trap_info(struct trap_info *traps);
36982
36983diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
36984index 525bd3d..ef888b1 100644
36985--- a/arch/xtensa/variants/dc232b/include/variant/core.h
36986+++ b/arch/xtensa/variants/dc232b/include/variant/core.h
36987@@ -119,9 +119,9 @@
36988 ----------------------------------------------------------------------*/
36989
36990 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
36991-#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
36992 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
36993 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
36994+#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
36995
36996 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
36997 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
36998diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
36999index 2f33760..835e50a 100644
37000--- a/arch/xtensa/variants/fsf/include/variant/core.h
37001+++ b/arch/xtensa/variants/fsf/include/variant/core.h
37002@@ -11,6 +11,7 @@
37003 #ifndef _XTENSA_CORE_H
37004 #define _XTENSA_CORE_H
37005
37006+#include <linux/const.h>
37007
37008 /****************************************************************************
37009 Parameters Useful for Any Code, USER or PRIVILEGED
37010@@ -112,9 +113,9 @@
37011 ----------------------------------------------------------------------*/
37012
37013 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
37014-#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
37015 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
37016 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
37017+#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
37018
37019 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
37020 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
37021diff --git a/block/bio.c b/block/bio.c
37022index d6e5ba3..2bb142c 100644
37023--- a/block/bio.c
37024+++ b/block/bio.c
37025@@ -1187,7 +1187,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
37026 /*
37027 * Overflow, abort
37028 */
37029- if (end < start)
37030+ if (end < start || end - start > INT_MAX - nr_pages)
37031 return ERR_PTR(-EINVAL);
37032
37033 nr_pages += end - start;
37034@@ -1312,7 +1312,7 @@ struct bio *bio_map_user_iov(struct request_queue *q,
37035 /*
37036 * Overflow, abort
37037 */
37038- if (end < start)
37039+ if (end < start || end - start > INT_MAX - nr_pages)
37040 return ERR_PTR(-EINVAL);
37041
37042 nr_pages += end - start;
37043diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
37044index 0736729..2ec3b48 100644
37045--- a/block/blk-iopoll.c
37046+++ b/block/blk-iopoll.c
37047@@ -74,7 +74,7 @@ void blk_iopoll_complete(struct blk_iopoll *iop)
37048 }
37049 EXPORT_SYMBOL(blk_iopoll_complete);
37050
37051-static void blk_iopoll_softirq(struct softirq_action *h)
37052+static __latent_entropy void blk_iopoll_softirq(void)
37053 {
37054 struct list_head *list = this_cpu_ptr(&blk_cpu_iopoll);
37055 int rearm = 0, budget = blk_iopoll_budget;
37056diff --git a/block/blk-map.c b/block/blk-map.c
37057index da310a1..213b5c9 100644
37058--- a/block/blk-map.c
37059+++ b/block/blk-map.c
37060@@ -192,7 +192,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
37061 if (!len || !kbuf)
37062 return -EINVAL;
37063
37064- do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
37065+ do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
37066 if (do_copy)
37067 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
37068 else
37069diff --git a/block/blk-softirq.c b/block/blk-softirq.c
37070index 53b1737..08177d2e 100644
37071--- a/block/blk-softirq.c
37072+++ b/block/blk-softirq.c
37073@@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
37074 * Softirq action handler - move entries to local list and loop over them
37075 * while passing them to the queue registered handler.
37076 */
37077-static void blk_done_softirq(struct softirq_action *h)
37078+static __latent_entropy void blk_done_softirq(void)
37079 {
37080 struct list_head *cpu_list, local_list;
37081
37082diff --git a/block/bsg.c b/block/bsg.c
37083index d214e92..9649863 100644
37084--- a/block/bsg.c
37085+++ b/block/bsg.c
37086@@ -140,16 +140,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
37087 struct sg_io_v4 *hdr, struct bsg_device *bd,
37088 fmode_t has_write_perm)
37089 {
37090+ unsigned char tmpcmd[sizeof(rq->__cmd)];
37091+ unsigned char *cmdptr;
37092+
37093 if (hdr->request_len > BLK_MAX_CDB) {
37094 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
37095 if (!rq->cmd)
37096 return -ENOMEM;
37097- }
37098+ cmdptr = rq->cmd;
37099+ } else
37100+ cmdptr = tmpcmd;
37101
37102- if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
37103+ if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
37104 hdr->request_len))
37105 return -EFAULT;
37106
37107+ if (cmdptr != rq->cmd)
37108+ memcpy(rq->cmd, cmdptr, hdr->request_len);
37109+
37110 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
37111 if (blk_verify_command(rq->cmd, has_write_perm))
37112 return -EPERM;
37113diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
37114index f678c73..f35aa18 100644
37115--- a/block/compat_ioctl.c
37116+++ b/block/compat_ioctl.c
37117@@ -156,7 +156,7 @@ static int compat_cdrom_generic_command(struct block_device *bdev, fmode_t mode,
37118 cgc = compat_alloc_user_space(sizeof(*cgc));
37119 cgc32 = compat_ptr(arg);
37120
37121- if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) ||
37122+ if (copy_in_user(cgc->cmd, cgc32->cmd, sizeof(cgc->cmd)) ||
37123 get_user(data, &cgc32->buffer) ||
37124 put_user(compat_ptr(data), &cgc->buffer) ||
37125 copy_in_user(&cgc->buflen, &cgc32->buflen,
37126@@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
37127 err |= __get_user(f->spec1, &uf->spec1);
37128 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
37129 err |= __get_user(name, &uf->name);
37130- f->name = compat_ptr(name);
37131+ f->name = (void __force_kernel *)compat_ptr(name);
37132 if (err) {
37133 err = -EFAULT;
37134 goto out;
37135diff --git a/block/genhd.c b/block/genhd.c
37136index 59a1395..54ff187 100644
37137--- a/block/genhd.c
37138+++ b/block/genhd.c
37139@@ -470,21 +470,24 @@ static char *bdevt_str(dev_t devt, char *buf)
37140
37141 /*
37142 * Register device numbers dev..(dev+range-1)
37143- * range must be nonzero
37144+ * Noop if @range is zero.
37145 * The hash chain is sorted on range, so that subranges can override.
37146 */
37147 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
37148 struct kobject *(*probe)(dev_t, int *, void *),
37149 int (*lock)(dev_t, void *), void *data)
37150 {
37151- kobj_map(bdev_map, devt, range, module, probe, lock, data);
37152+ if (range)
37153+ kobj_map(bdev_map, devt, range, module, probe, lock, data);
37154 }
37155
37156 EXPORT_SYMBOL(blk_register_region);
37157
37158+/* undo blk_register_region(), noop if @range is zero */
37159 void blk_unregister_region(dev_t devt, unsigned long range)
37160 {
37161- kobj_unmap(bdev_map, devt, range);
37162+ if (range)
37163+ kobj_unmap(bdev_map, devt, range);
37164 }
37165
37166 EXPORT_SYMBOL(blk_unregister_region);
37167diff --git a/block/partitions/efi.c b/block/partitions/efi.c
37168index 26cb624..a49c3a5 100644
37169--- a/block/partitions/efi.c
37170+++ b/block/partitions/efi.c
37171@@ -293,14 +293,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
37172 if (!gpt)
37173 return NULL;
37174
37175+ if (!le32_to_cpu(gpt->num_partition_entries))
37176+ return NULL;
37177+ pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
37178+ if (!pte)
37179+ return NULL;
37180+
37181 count = le32_to_cpu(gpt->num_partition_entries) *
37182 le32_to_cpu(gpt->sizeof_partition_entry);
37183- if (!count)
37184- return NULL;
37185- pte = kmalloc(count, GFP_KERNEL);
37186- if (!pte)
37187- return NULL;
37188-
37189 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
37190 (u8 *) pte, count) < count) {
37191 kfree(pte);
37192diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
37193index dda653c..028a13ee 100644
37194--- a/block/scsi_ioctl.c
37195+++ b/block/scsi_ioctl.c
37196@@ -67,7 +67,7 @@ static int scsi_get_bus(struct request_queue *q, int __user *p)
37197 return put_user(0, p);
37198 }
37199
37200-static int sg_get_timeout(struct request_queue *q)
37201+static int __intentional_overflow(-1) sg_get_timeout(struct request_queue *q)
37202 {
37203 return jiffies_to_clock_t(q->sg_timeout);
37204 }
37205@@ -227,8 +227,20 @@ EXPORT_SYMBOL(blk_verify_command);
37206 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
37207 struct sg_io_hdr *hdr, fmode_t mode)
37208 {
37209- if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
37210+ unsigned char tmpcmd[sizeof(rq->__cmd)];
37211+ unsigned char *cmdptr;
37212+
37213+ if (rq->cmd != rq->__cmd)
37214+ cmdptr = rq->cmd;
37215+ else
37216+ cmdptr = tmpcmd;
37217+
37218+ if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
37219 return -EFAULT;
37220+
37221+ if (cmdptr != rq->cmd)
37222+ memcpy(rq->cmd, cmdptr, hdr->cmd_len);
37223+
37224 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
37225 return -EPERM;
37226
37227@@ -420,6 +432,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
37228 int err;
37229 unsigned int in_len, out_len, bytes, opcode, cmdlen;
37230 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
37231+ unsigned char tmpcmd[sizeof(rq->__cmd)];
37232+ unsigned char *cmdptr;
37233
37234 if (!sic)
37235 return -EINVAL;
37236@@ -458,9 +472,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
37237 */
37238 err = -EFAULT;
37239 rq->cmd_len = cmdlen;
37240- if (copy_from_user(rq->cmd, sic->data, cmdlen))
37241+
37242+ if (rq->cmd != rq->__cmd)
37243+ cmdptr = rq->cmd;
37244+ else
37245+ cmdptr = tmpcmd;
37246+
37247+ if (copy_from_user(cmdptr, sic->data, cmdlen))
37248 goto error;
37249
37250+ if (rq->cmd != cmdptr)
37251+ memcpy(rq->cmd, cmdptr, cmdlen);
37252+
37253 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
37254 goto error;
37255
37256diff --git a/crypto/cryptd.c b/crypto/cryptd.c
37257index 22ba81f..1acac67 100644
37258--- a/crypto/cryptd.c
37259+++ b/crypto/cryptd.c
37260@@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
37261
37262 struct cryptd_blkcipher_request_ctx {
37263 crypto_completion_t complete;
37264-};
37265+} __no_const;
37266
37267 struct cryptd_hash_ctx {
37268 struct crypto_shash *child;
37269@@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
37270
37271 struct cryptd_aead_request_ctx {
37272 crypto_completion_t complete;
37273-};
37274+} __no_const;
37275
37276 static void cryptd_queue_worker(struct work_struct *work);
37277
37278diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
37279index 45e7d51..2967121 100644
37280--- a/crypto/pcrypt.c
37281+++ b/crypto/pcrypt.c
37282@@ -385,7 +385,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
37283 int ret;
37284
37285 pinst->kobj.kset = pcrypt_kset;
37286- ret = kobject_add(&pinst->kobj, NULL, name);
37287+ ret = kobject_add(&pinst->kobj, NULL, "%s", name);
37288 if (!ret)
37289 kobject_uevent(&pinst->kobj, KOBJ_ADD);
37290
37291diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c
37292index ea5815c..5880da6 100644
37293--- a/crypto/scatterwalk.c
37294+++ b/crypto/scatterwalk.c
37295@@ -109,14 +109,20 @@ void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg,
37296 {
37297 struct scatter_walk walk;
37298 struct scatterlist tmp[2];
37299+ void *realbuf = buf;
37300
37301 if (!nbytes)
37302 return;
37303
37304 sg = scatterwalk_ffwd(tmp, sg, start);
37305
37306- if (sg_page(sg) == virt_to_page(buf) &&
37307- sg->offset == offset_in_page(buf))
37308+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
37309+ if (object_starts_on_stack(buf))
37310+ realbuf = buf - current->stack + current->lowmem_stack;
37311+#endif
37312+
37313+ if (sg_page(sg) == virt_to_page(realbuf) &&
37314+ sg->offset == offset_in_page(realbuf))
37315 return;
37316
37317 scatterwalk_start(&walk, sg);
37318diff --git a/crypto/zlib.c b/crypto/zlib.c
37319index d51a30a..fb1f8af 100644
37320--- a/crypto/zlib.c
37321+++ b/crypto/zlib.c
37322@@ -95,10 +95,10 @@ static int zlib_compress_setup(struct crypto_pcomp *tfm, const void *params,
37323 zlib_comp_exit(ctx);
37324
37325 window_bits = tb[ZLIB_COMP_WINDOWBITS]
37326- ? nla_get_u32(tb[ZLIB_COMP_WINDOWBITS])
37327+ ? nla_get_s32(tb[ZLIB_COMP_WINDOWBITS])
37328 : MAX_WBITS;
37329 mem_level = tb[ZLIB_COMP_MEMLEVEL]
37330- ? nla_get_u32(tb[ZLIB_COMP_MEMLEVEL])
37331+ ? nla_get_s32(tb[ZLIB_COMP_MEMLEVEL])
37332 : DEF_MEM_LEVEL;
37333
37334 workspacesize = zlib_deflate_workspacesize(window_bits, mem_level);
37335diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
37336index 8c2fe2f..fc47c12 100644
37337--- a/drivers/acpi/acpi_video.c
37338+++ b/drivers/acpi/acpi_video.c
37339@@ -398,7 +398,7 @@ static int video_disable_backlight_sysfs_if(
37340 return 0;
37341 }
37342
37343-static struct dmi_system_id video_dmi_table[] = {
37344+static const struct dmi_system_id video_dmi_table[] = {
37345 /*
37346 * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121
37347 */
37348diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
37349index 52dfd0d..8386baf 100644
37350--- a/drivers/acpi/acpica/hwxfsleep.c
37351+++ b/drivers/acpi/acpica/hwxfsleep.c
37352@@ -70,11 +70,12 @@ static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id);
37353 /* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */
37354
37355 static struct acpi_sleep_functions acpi_sleep_dispatch[] = {
37356- {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
37357- acpi_hw_extended_sleep},
37358- {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
37359- acpi_hw_extended_wake_prep},
37360- {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake), acpi_hw_extended_wake}
37361+ {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
37362+ .extended_function = acpi_hw_extended_sleep},
37363+ {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
37364+ .extended_function = acpi_hw_extended_wake_prep},
37365+ {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake),
37366+ .extended_function = acpi_hw_extended_wake}
37367 };
37368
37369 /*
37370diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
37371index 16129c7..8b675cd 100644
37372--- a/drivers/acpi/apei/apei-internal.h
37373+++ b/drivers/acpi/apei/apei-internal.h
37374@@ -19,7 +19,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
37375 struct apei_exec_ins_type {
37376 u32 flags;
37377 apei_exec_ins_func_t run;
37378-};
37379+} __do_const;
37380
37381 struct apei_exec_context {
37382 u32 ip;
37383diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
37384index 2bfd53c..391e9a4 100644
37385--- a/drivers/acpi/apei/ghes.c
37386+++ b/drivers/acpi/apei/ghes.c
37387@@ -478,7 +478,7 @@ static void __ghes_print_estatus(const char *pfx,
37388 const struct acpi_hest_generic *generic,
37389 const struct acpi_hest_generic_status *estatus)
37390 {
37391- static atomic_t seqno;
37392+ static atomic_unchecked_t seqno;
37393 unsigned int curr_seqno;
37394 char pfx_seq[64];
37395
37396@@ -489,7 +489,7 @@ static void __ghes_print_estatus(const char *pfx,
37397 else
37398 pfx = KERN_ERR;
37399 }
37400- curr_seqno = atomic_inc_return(&seqno);
37401+ curr_seqno = atomic_inc_return_unchecked(&seqno);
37402 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
37403 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
37404 pfx_seq, generic->header.source_id);
37405diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
37406index a83e3c6..c3d617f 100644
37407--- a/drivers/acpi/bgrt.c
37408+++ b/drivers/acpi/bgrt.c
37409@@ -86,8 +86,10 @@ static int __init bgrt_init(void)
37410 if (!bgrt_image)
37411 return -ENODEV;
37412
37413- bin_attr_image.private = bgrt_image;
37414- bin_attr_image.size = bgrt_image_size;
37415+ pax_open_kernel();
37416+ *(void **)&bin_attr_image.private = bgrt_image;
37417+ *(size_t *)&bin_attr_image.size = bgrt_image_size;
37418+ pax_close_kernel();
37419
37420 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
37421 if (!bgrt_kobj)
37422diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
37423index 278dc4b..976433d 100644
37424--- a/drivers/acpi/blacklist.c
37425+++ b/drivers/acpi/blacklist.c
37426@@ -51,7 +51,7 @@ struct acpi_blacklist_item {
37427 u32 is_critical_error;
37428 };
37429
37430-static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
37431+static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
37432
37433 /*
37434 * POLICY: If *anything* doesn't work, put it on the blacklist.
37435@@ -172,7 +172,7 @@ static int __init dmi_enable_rev_override(const struct dmi_system_id *d)
37436 }
37437 #endif
37438
37439-static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
37440+static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
37441 {
37442 .callback = dmi_disable_osi_vista,
37443 .ident = "Fujitsu Siemens",
37444diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
37445index 513e7230e..802015a 100644
37446--- a/drivers/acpi/bus.c
37447+++ b/drivers/acpi/bus.c
37448@@ -67,7 +67,7 @@ static int set_copy_dsdt(const struct dmi_system_id *id)
37449 }
37450 #endif
37451
37452-static struct dmi_system_id dsdt_dmi_table[] __initdata = {
37453+static const struct dmi_system_id dsdt_dmi_table[] __initconst = {
37454 /*
37455 * Invoke DSDT corruption work-around on all Toshiba Satellite.
37456 * https://bugzilla.kernel.org/show_bug.cgi?id=14679
37457@@ -83,7 +83,7 @@ static struct dmi_system_id dsdt_dmi_table[] __initdata = {
37458 {}
37459 };
37460 #else
37461-static struct dmi_system_id dsdt_dmi_table[] __initdata = {
37462+static const struct dmi_system_id dsdt_dmi_table[] __initconst = {
37463 {}
37464 };
37465 #endif
37466diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
37467index c68e724..e863008 100644
37468--- a/drivers/acpi/custom_method.c
37469+++ b/drivers/acpi/custom_method.c
37470@@ -29,6 +29,10 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
37471 struct acpi_table_header table;
37472 acpi_status status;
37473
37474+#ifdef CONFIG_GRKERNSEC_KMEM
37475+ return -EPERM;
37476+#endif
37477+
37478 if (!(*ppos)) {
37479 /* parse the table header to get the table length */
37480 if (count <= sizeof(struct acpi_table_header))
37481diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
37482index 88dbbb1..90714c0 100644
37483--- a/drivers/acpi/device_pm.c
37484+++ b/drivers/acpi/device_pm.c
37485@@ -1045,6 +1045,8 @@ EXPORT_SYMBOL_GPL(acpi_subsys_freeze);
37486
37487 #endif /* CONFIG_PM_SLEEP */
37488
37489+static void acpi_dev_pm_detach(struct device *dev, bool power_off);
37490+
37491 static struct dev_pm_domain acpi_general_pm_domain = {
37492 .ops = {
37493 .runtime_suspend = acpi_subsys_runtime_suspend,
37494@@ -1061,6 +1063,7 @@ static struct dev_pm_domain acpi_general_pm_domain = {
37495 .restore_early = acpi_subsys_resume_early,
37496 #endif
37497 },
37498+ .detach = acpi_dev_pm_detach
37499 };
37500
37501 /**
37502@@ -1130,7 +1133,6 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
37503 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
37504 }
37505
37506- dev->pm_domain->detach = acpi_dev_pm_detach;
37507 return 0;
37508 }
37509 EXPORT_SYMBOL_GPL(acpi_dev_pm_attach);
37510diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
37511index 9d4761d..ece2163 100644
37512--- a/drivers/acpi/ec.c
37513+++ b/drivers/acpi/ec.c
37514@@ -1434,7 +1434,7 @@ static int ec_clear_on_resume(const struct dmi_system_id *id)
37515 return 0;
37516 }
37517
37518-static struct dmi_system_id ec_dmi_table[] __initdata = {
37519+static const struct dmi_system_id ec_dmi_table[] __initconst = {
37520 {
37521 ec_skip_dsdt_scan, "Compal JFL92", {
37522 DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
37523diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
37524index 139d9e4..9a9d799 100644
37525--- a/drivers/acpi/pci_slot.c
37526+++ b/drivers/acpi/pci_slot.c
37527@@ -195,7 +195,7 @@ static int do_sta_before_sun(const struct dmi_system_id *d)
37528 return 0;
37529 }
37530
37531-static struct dmi_system_id acpi_pci_slot_dmi_table[] __initdata = {
37532+static const struct dmi_system_id acpi_pci_slot_dmi_table[] __initconst = {
37533 /*
37534 * Fujitsu Primequest machines will return 1023 to indicate an
37535 * error if the _SUN method is evaluated on SxFy objects that
37536diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
37537index d9f7158..168e742 100644
37538--- a/drivers/acpi/processor_driver.c
37539+++ b/drivers/acpi/processor_driver.c
37540@@ -159,7 +159,7 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
37541 return NOTIFY_OK;
37542 }
37543
37544-static struct notifier_block __refdata acpi_cpu_notifier = {
37545+static struct notifier_block __refconst acpi_cpu_notifier = {
37546 .notifier_call = acpi_cpu_soft_notify,
37547 };
37548
37549diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
37550index d540f42..d5b32ac 100644
37551--- a/drivers/acpi/processor_idle.c
37552+++ b/drivers/acpi/processor_idle.c
37553@@ -910,7 +910,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
37554 {
37555 int i, count = CPUIDLE_DRIVER_STATE_START;
37556 struct acpi_processor_cx *cx;
37557- struct cpuidle_state *state;
37558+ cpuidle_state_no_const *state;
37559 struct cpuidle_driver *drv = &acpi_idle_driver;
37560
37561 if (!pr->flags.power_setup_done)
37562diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c
37563index 7cfbda4..74f738c 100644
37564--- a/drivers/acpi/processor_pdc.c
37565+++ b/drivers/acpi/processor_pdc.c
37566@@ -173,7 +173,7 @@ static int __init set_no_mwait(const struct dmi_system_id *id)
37567 return 0;
37568 }
37569
37570-static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
37571+static const struct dmi_system_id processor_idle_dmi_table[] __initconst = {
37572 {
37573 set_no_mwait, "Extensa 5220", {
37574 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
37575diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
37576index 2f0d4db..b9e9b15 100644
37577--- a/drivers/acpi/sleep.c
37578+++ b/drivers/acpi/sleep.c
37579@@ -148,7 +148,7 @@ static int __init init_nvs_nosave(const struct dmi_system_id *d)
37580 return 0;
37581 }
37582
37583-static struct dmi_system_id acpisleep_dmi_table[] __initdata = {
37584+static const struct dmi_system_id acpisleep_dmi_table[] __initconst = {
37585 {
37586 .callback = init_old_suspend_ordering,
37587 .ident = "Abit KN9 (nForce4 variant)",
37588diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
37589index 0876d77b..3ba0127 100644
37590--- a/drivers/acpi/sysfs.c
37591+++ b/drivers/acpi/sysfs.c
37592@@ -423,11 +423,11 @@ static u32 num_counters;
37593 static struct attribute **all_attrs;
37594 static u32 acpi_gpe_count;
37595
37596-static struct attribute_group interrupt_stats_attr_group = {
37597+static attribute_group_no_const interrupt_stats_attr_group = {
37598 .name = "interrupts",
37599 };
37600
37601-static struct kobj_attribute *counter_attrs;
37602+static kobj_attribute_no_const *counter_attrs;
37603
37604 static void delete_gpe_attr_array(void)
37605 {
37606diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
37607index 6d4e44e..44fb839 100644
37608--- a/drivers/acpi/thermal.c
37609+++ b/drivers/acpi/thermal.c
37610@@ -1212,7 +1212,7 @@ static int thermal_psv(const struct dmi_system_id *d) {
37611 return 0;
37612 }
37613
37614-static struct dmi_system_id thermal_dmi_table[] __initdata = {
37615+static const struct dmi_system_id thermal_dmi_table[] __initconst = {
37616 /*
37617 * Award BIOS on this AOpen makes thermal control almost worthless.
37618 * http://bugzilla.kernel.org/show_bug.cgi?id=8842
37619diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
37620index 2922f1f..26b0c03 100644
37621--- a/drivers/acpi/video_detect.c
37622+++ b/drivers/acpi/video_detect.c
37623@@ -41,7 +41,6 @@ ACPI_MODULE_NAME("video");
37624 void acpi_video_unregister_backlight(void);
37625
37626 static bool backlight_notifier_registered;
37627-static struct notifier_block backlight_nb;
37628 static struct work_struct backlight_notify_work;
37629
37630 static enum acpi_backlight_type acpi_backlight_cmdline = acpi_backlight_undef;
37631@@ -284,6 +283,10 @@ static int acpi_video_backlight_notify(struct notifier_block *nb,
37632 return NOTIFY_OK;
37633 }
37634
37635+static const struct notifier_block backlight_nb = {
37636+ .notifier_call = acpi_video_backlight_notify,
37637+};
37638+
37639 /*
37640 * Determine which type of backlight interface to use on this system,
37641 * First check cmdline, then dmi quirks, then do autodetect.
37642@@ -314,8 +317,6 @@ enum acpi_backlight_type acpi_video_get_backlight_type(void)
37643 &video_caps, NULL);
37644 INIT_WORK(&backlight_notify_work,
37645 acpi_video_backlight_notify_work);
37646- backlight_nb.notifier_call = acpi_video_backlight_notify;
37647- backlight_nb.priority = 0;
37648 if (backlight_register_notifier(&backlight_nb) == 0)
37649 backlight_notifier_registered = true;
37650 init_done = true;
37651diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
37652index 790e0de..6bae378 100644
37653--- a/drivers/ata/libata-core.c
37654+++ b/drivers/ata/libata-core.c
37655@@ -102,7 +102,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
37656 static void ata_dev_xfermask(struct ata_device *dev);
37657 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
37658
37659-atomic_t ata_print_id = ATOMIC_INIT(0);
37660+atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
37661
37662 struct ata_force_param {
37663 const char *name;
37664@@ -4800,7 +4800,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
37665 struct ata_port *ap;
37666 unsigned int tag;
37667
37668- WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37669+ BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37670 ap = qc->ap;
37671
37672 qc->flags = 0;
37673@@ -4817,7 +4817,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
37674 struct ata_port *ap;
37675 struct ata_link *link;
37676
37677- WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37678+ BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37679 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
37680 ap = qc->ap;
37681 link = qc->dev->link;
37682@@ -5924,6 +5924,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
37683 return;
37684
37685 spin_lock(&lock);
37686+ pax_open_kernel();
37687
37688 for (cur = ops->inherits; cur; cur = cur->inherits) {
37689 void **inherit = (void **)cur;
37690@@ -5937,8 +5938,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
37691 if (IS_ERR(*pp))
37692 *pp = NULL;
37693
37694- ops->inherits = NULL;
37695+ *(struct ata_port_operations **)&ops->inherits = NULL;
37696
37697+ pax_close_kernel();
37698 spin_unlock(&lock);
37699 }
37700
37701@@ -6134,7 +6136,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
37702
37703 /* give ports names and add SCSI hosts */
37704 for (i = 0; i < host->n_ports; i++) {
37705- host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
37706+ host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
37707 host->ports[i]->local_port_no = i + 1;
37708 }
37709
37710diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
37711index 0d7f0da..bc20aa6 100644
37712--- a/drivers/ata/libata-scsi.c
37713+++ b/drivers/ata/libata-scsi.c
37714@@ -4193,7 +4193,7 @@ int ata_sas_port_init(struct ata_port *ap)
37715
37716 if (rc)
37717 return rc;
37718- ap->print_id = atomic_inc_return(&ata_print_id);
37719+ ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
37720 return 0;
37721 }
37722 EXPORT_SYMBOL_GPL(ata_sas_port_init);
37723diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
37724index f840ca1..edd6ef3 100644
37725--- a/drivers/ata/libata.h
37726+++ b/drivers/ata/libata.h
37727@@ -53,7 +53,7 @@ enum {
37728 ATA_DNXFER_QUIET = (1 << 31),
37729 };
37730
37731-extern atomic_t ata_print_id;
37732+extern atomic_unchecked_t ata_print_id;
37733 extern int atapi_passthru16;
37734 extern int libata_fua;
37735 extern int libata_noacpi;
37736diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
37737index 5d9ee99..8fa2585 100644
37738--- a/drivers/ata/pata_arasan_cf.c
37739+++ b/drivers/ata/pata_arasan_cf.c
37740@@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
37741 /* Handle platform specific quirks */
37742 if (quirk) {
37743 if (quirk & CF_BROKEN_PIO) {
37744- ap->ops->set_piomode = NULL;
37745+ pax_open_kernel();
37746+ *(void **)&ap->ops->set_piomode = NULL;
37747+ pax_close_kernel();
37748 ap->pio_mask = 0;
37749 }
37750 if (quirk & CF_BROKEN_MWDMA)
37751diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
37752index f9b983a..887b9d8 100644
37753--- a/drivers/atm/adummy.c
37754+++ b/drivers/atm/adummy.c
37755@@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
37756 vcc->pop(vcc, skb);
37757 else
37758 dev_kfree_skb_any(skb);
37759- atomic_inc(&vcc->stats->tx);
37760+ atomic_inc_unchecked(&vcc->stats->tx);
37761
37762 return 0;
37763 }
37764diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
37765index f1a9198..f466a4a 100644
37766--- a/drivers/atm/ambassador.c
37767+++ b/drivers/atm/ambassador.c
37768@@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
37769 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
37770
37771 // VC layer stats
37772- atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
37773+ atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
37774
37775 // free the descriptor
37776 kfree (tx_descr);
37777@@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
37778 dump_skb ("<<<", vc, skb);
37779
37780 // VC layer stats
37781- atomic_inc(&atm_vcc->stats->rx);
37782+ atomic_inc_unchecked(&atm_vcc->stats->rx);
37783 __net_timestamp(skb);
37784 // end of our responsibility
37785 atm_vcc->push (atm_vcc, skb);
37786@@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
37787 } else {
37788 PRINTK (KERN_INFO, "dropped over-size frame");
37789 // should we count this?
37790- atomic_inc(&atm_vcc->stats->rx_drop);
37791+ atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
37792 }
37793
37794 } else {
37795@@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
37796 }
37797
37798 if (check_area (skb->data, skb->len)) {
37799- atomic_inc(&atm_vcc->stats->tx_err);
37800+ atomic_inc_unchecked(&atm_vcc->stats->tx_err);
37801 return -ENOMEM; // ?
37802 }
37803
37804diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
37805index 480fa6f..947067c 100644
37806--- a/drivers/atm/atmtcp.c
37807+++ b/drivers/atm/atmtcp.c
37808@@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
37809 if (vcc->pop) vcc->pop(vcc,skb);
37810 else dev_kfree_skb(skb);
37811 if (dev_data) return 0;
37812- atomic_inc(&vcc->stats->tx_err);
37813+ atomic_inc_unchecked(&vcc->stats->tx_err);
37814 return -ENOLINK;
37815 }
37816 size = skb->len+sizeof(struct atmtcp_hdr);
37817@@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
37818 if (!new_skb) {
37819 if (vcc->pop) vcc->pop(vcc,skb);
37820 else dev_kfree_skb(skb);
37821- atomic_inc(&vcc->stats->tx_err);
37822+ atomic_inc_unchecked(&vcc->stats->tx_err);
37823 return -ENOBUFS;
37824 }
37825 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
37826@@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
37827 if (vcc->pop) vcc->pop(vcc,skb);
37828 else dev_kfree_skb(skb);
37829 out_vcc->push(out_vcc,new_skb);
37830- atomic_inc(&vcc->stats->tx);
37831- atomic_inc(&out_vcc->stats->rx);
37832+ atomic_inc_unchecked(&vcc->stats->tx);
37833+ atomic_inc_unchecked(&out_vcc->stats->rx);
37834 return 0;
37835 }
37836
37837@@ -300,7 +300,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
37838 read_unlock(&vcc_sklist_lock);
37839 if (!out_vcc) {
37840 result = -EUNATCH;
37841- atomic_inc(&vcc->stats->tx_err);
37842+ atomic_inc_unchecked(&vcc->stats->tx_err);
37843 goto done;
37844 }
37845 skb_pull(skb,sizeof(struct atmtcp_hdr));
37846@@ -312,8 +312,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
37847 __net_timestamp(new_skb);
37848 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
37849 out_vcc->push(out_vcc,new_skb);
37850- atomic_inc(&vcc->stats->tx);
37851- atomic_inc(&out_vcc->stats->rx);
37852+ atomic_inc_unchecked(&vcc->stats->tx);
37853+ atomic_inc_unchecked(&out_vcc->stats->rx);
37854 done:
37855 if (vcc->pop) vcc->pop(vcc,skb);
37856 else dev_kfree_skb(skb);
37857diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
37858index 6339efd..2b441d5 100644
37859--- a/drivers/atm/eni.c
37860+++ b/drivers/atm/eni.c
37861@@ -525,7 +525,7 @@ static int rx_aal0(struct atm_vcc *vcc)
37862 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
37863 vcc->dev->number);
37864 length = 0;
37865- atomic_inc(&vcc->stats->rx_err);
37866+ atomic_inc_unchecked(&vcc->stats->rx_err);
37867 }
37868 else {
37869 length = ATM_CELL_SIZE-1; /* no HEC */
37870@@ -580,7 +580,7 @@ static int rx_aal5(struct atm_vcc *vcc)
37871 size);
37872 }
37873 eff = length = 0;
37874- atomic_inc(&vcc->stats->rx_err);
37875+ atomic_inc_unchecked(&vcc->stats->rx_err);
37876 }
37877 else {
37878 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
37879@@ -597,7 +597,7 @@ static int rx_aal5(struct atm_vcc *vcc)
37880 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
37881 vcc->dev->number,vcc->vci,length,size << 2,descr);
37882 length = eff = 0;
37883- atomic_inc(&vcc->stats->rx_err);
37884+ atomic_inc_unchecked(&vcc->stats->rx_err);
37885 }
37886 }
37887 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
37888@@ -770,7 +770,7 @@ rx_dequeued++;
37889 vcc->push(vcc,skb);
37890 pushed++;
37891 }
37892- atomic_inc(&vcc->stats->rx);
37893+ atomic_inc_unchecked(&vcc->stats->rx);
37894 }
37895 wake_up(&eni_dev->rx_wait);
37896 }
37897@@ -1230,7 +1230,7 @@ static void dequeue_tx(struct atm_dev *dev)
37898 DMA_TO_DEVICE);
37899 if (vcc->pop) vcc->pop(vcc,skb);
37900 else dev_kfree_skb_irq(skb);
37901- atomic_inc(&vcc->stats->tx);
37902+ atomic_inc_unchecked(&vcc->stats->tx);
37903 wake_up(&eni_dev->tx_wait);
37904 dma_complete++;
37905 }
37906diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
37907index 82f2ae0..f205c02 100644
37908--- a/drivers/atm/firestream.c
37909+++ b/drivers/atm/firestream.c
37910@@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
37911 }
37912 }
37913
37914- atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
37915+ atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
37916
37917 fs_dprintk (FS_DEBUG_TXMEM, "i");
37918 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
37919@@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
37920 #endif
37921 skb_put (skb, qe->p1 & 0xffff);
37922 ATM_SKB(skb)->vcc = atm_vcc;
37923- atomic_inc(&atm_vcc->stats->rx);
37924+ atomic_inc_unchecked(&atm_vcc->stats->rx);
37925 __net_timestamp(skb);
37926 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
37927 atm_vcc->push (atm_vcc, skb);
37928@@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
37929 kfree (pe);
37930 }
37931 if (atm_vcc)
37932- atomic_inc(&atm_vcc->stats->rx_drop);
37933+ atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
37934 break;
37935 case 0x1f: /* Reassembly abort: no buffers. */
37936 /* Silently increment error counter. */
37937 if (atm_vcc)
37938- atomic_inc(&atm_vcc->stats->rx_drop);
37939+ atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
37940 break;
37941 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
37942 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
37943diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
37944index 75dde90..4309ead 100644
37945--- a/drivers/atm/fore200e.c
37946+++ b/drivers/atm/fore200e.c
37947@@ -932,9 +932,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
37948 #endif
37949 /* check error condition */
37950 if (*entry->status & STATUS_ERROR)
37951- atomic_inc(&vcc->stats->tx_err);
37952+ atomic_inc_unchecked(&vcc->stats->tx_err);
37953 else
37954- atomic_inc(&vcc->stats->tx);
37955+ atomic_inc_unchecked(&vcc->stats->tx);
37956 }
37957 }
37958
37959@@ -1083,7 +1083,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
37960 if (skb == NULL) {
37961 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
37962
37963- atomic_inc(&vcc->stats->rx_drop);
37964+ atomic_inc_unchecked(&vcc->stats->rx_drop);
37965 return -ENOMEM;
37966 }
37967
37968@@ -1126,14 +1126,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
37969
37970 dev_kfree_skb_any(skb);
37971
37972- atomic_inc(&vcc->stats->rx_drop);
37973+ atomic_inc_unchecked(&vcc->stats->rx_drop);
37974 return -ENOMEM;
37975 }
37976
37977 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
37978
37979 vcc->push(vcc, skb);
37980- atomic_inc(&vcc->stats->rx);
37981+ atomic_inc_unchecked(&vcc->stats->rx);
37982
37983 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
37984
37985@@ -1211,7 +1211,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
37986 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
37987 fore200e->atm_dev->number,
37988 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
37989- atomic_inc(&vcc->stats->rx_err);
37990+ atomic_inc_unchecked(&vcc->stats->rx_err);
37991 }
37992 }
37993
37994@@ -1656,7 +1656,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
37995 goto retry_here;
37996 }
37997
37998- atomic_inc(&vcc->stats->tx_err);
37999+ atomic_inc_unchecked(&vcc->stats->tx_err);
38000
38001 fore200e->tx_sat++;
38002 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
38003diff --git a/drivers/atm/he.c b/drivers/atm/he.c
38004index a8da3a5..67cf6c2 100644
38005--- a/drivers/atm/he.c
38006+++ b/drivers/atm/he.c
38007@@ -1692,7 +1692,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
38008
38009 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
38010 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
38011- atomic_inc(&vcc->stats->rx_drop);
38012+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38013 goto return_host_buffers;
38014 }
38015
38016@@ -1719,7 +1719,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
38017 RBRQ_LEN_ERR(he_dev->rbrq_head)
38018 ? "LEN_ERR" : "",
38019 vcc->vpi, vcc->vci);
38020- atomic_inc(&vcc->stats->rx_err);
38021+ atomic_inc_unchecked(&vcc->stats->rx_err);
38022 goto return_host_buffers;
38023 }
38024
38025@@ -1771,7 +1771,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
38026 vcc->push(vcc, skb);
38027 spin_lock(&he_dev->global_lock);
38028
38029- atomic_inc(&vcc->stats->rx);
38030+ atomic_inc_unchecked(&vcc->stats->rx);
38031
38032 return_host_buffers:
38033 ++pdus_assembled;
38034@@ -2097,7 +2097,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
38035 tpd->vcc->pop(tpd->vcc, tpd->skb);
38036 else
38037 dev_kfree_skb_any(tpd->skb);
38038- atomic_inc(&tpd->vcc->stats->tx_err);
38039+ atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
38040 }
38041 dma_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
38042 return;
38043@@ -2509,7 +2509,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38044 vcc->pop(vcc, skb);
38045 else
38046 dev_kfree_skb_any(skb);
38047- atomic_inc(&vcc->stats->tx_err);
38048+ atomic_inc_unchecked(&vcc->stats->tx_err);
38049 return -EINVAL;
38050 }
38051
38052@@ -2520,7 +2520,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38053 vcc->pop(vcc, skb);
38054 else
38055 dev_kfree_skb_any(skb);
38056- atomic_inc(&vcc->stats->tx_err);
38057+ atomic_inc_unchecked(&vcc->stats->tx_err);
38058 return -EINVAL;
38059 }
38060 #endif
38061@@ -2532,7 +2532,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38062 vcc->pop(vcc, skb);
38063 else
38064 dev_kfree_skb_any(skb);
38065- atomic_inc(&vcc->stats->tx_err);
38066+ atomic_inc_unchecked(&vcc->stats->tx_err);
38067 spin_unlock_irqrestore(&he_dev->global_lock, flags);
38068 return -ENOMEM;
38069 }
38070@@ -2574,7 +2574,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38071 vcc->pop(vcc, skb);
38072 else
38073 dev_kfree_skb_any(skb);
38074- atomic_inc(&vcc->stats->tx_err);
38075+ atomic_inc_unchecked(&vcc->stats->tx_err);
38076 spin_unlock_irqrestore(&he_dev->global_lock, flags);
38077 return -ENOMEM;
38078 }
38079@@ -2605,7 +2605,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38080 __enqueue_tpd(he_dev, tpd, cid);
38081 spin_unlock_irqrestore(&he_dev->global_lock, flags);
38082
38083- atomic_inc(&vcc->stats->tx);
38084+ atomic_inc_unchecked(&vcc->stats->tx);
38085
38086 return 0;
38087 }
38088diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
38089index 527bbd5..96570c8 100644
38090--- a/drivers/atm/horizon.c
38091+++ b/drivers/atm/horizon.c
38092@@ -1018,7 +1018,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
38093 {
38094 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
38095 // VC layer stats
38096- atomic_inc(&vcc->stats->rx);
38097+ atomic_inc_unchecked(&vcc->stats->rx);
38098 __net_timestamp(skb);
38099 // end of our responsibility
38100 vcc->push (vcc, skb);
38101@@ -1170,7 +1170,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
38102 dev->tx_iovec = NULL;
38103
38104 // VC layer stats
38105- atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
38106+ atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
38107
38108 // free the skb
38109 hrz_kfree_skb (skb);
38110diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
38111index 074616b..d6b3d5f 100644
38112--- a/drivers/atm/idt77252.c
38113+++ b/drivers/atm/idt77252.c
38114@@ -811,7 +811,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
38115 else
38116 dev_kfree_skb(skb);
38117
38118- atomic_inc(&vcc->stats->tx);
38119+ atomic_inc_unchecked(&vcc->stats->tx);
38120 }
38121
38122 atomic_dec(&scq->used);
38123@@ -1073,13 +1073,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38124 if ((sb = dev_alloc_skb(64)) == NULL) {
38125 printk("%s: Can't allocate buffers for aal0.\n",
38126 card->name);
38127- atomic_add(i, &vcc->stats->rx_drop);
38128+ atomic_add_unchecked(i, &vcc->stats->rx_drop);
38129 break;
38130 }
38131 if (!atm_charge(vcc, sb->truesize)) {
38132 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
38133 card->name);
38134- atomic_add(i - 1, &vcc->stats->rx_drop);
38135+ atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
38136 dev_kfree_skb(sb);
38137 break;
38138 }
38139@@ -1096,7 +1096,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38140 ATM_SKB(sb)->vcc = vcc;
38141 __net_timestamp(sb);
38142 vcc->push(vcc, sb);
38143- atomic_inc(&vcc->stats->rx);
38144+ atomic_inc_unchecked(&vcc->stats->rx);
38145
38146 cell += ATM_CELL_PAYLOAD;
38147 }
38148@@ -1133,13 +1133,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38149 "(CDC: %08x)\n",
38150 card->name, len, rpp->len, readl(SAR_REG_CDC));
38151 recycle_rx_pool_skb(card, rpp);
38152- atomic_inc(&vcc->stats->rx_err);
38153+ atomic_inc_unchecked(&vcc->stats->rx_err);
38154 return;
38155 }
38156 if (stat & SAR_RSQE_CRC) {
38157 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
38158 recycle_rx_pool_skb(card, rpp);
38159- atomic_inc(&vcc->stats->rx_err);
38160+ atomic_inc_unchecked(&vcc->stats->rx_err);
38161 return;
38162 }
38163 if (skb_queue_len(&rpp->queue) > 1) {
38164@@ -1150,7 +1150,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38165 RXPRINTK("%s: Can't alloc RX skb.\n",
38166 card->name);
38167 recycle_rx_pool_skb(card, rpp);
38168- atomic_inc(&vcc->stats->rx_err);
38169+ atomic_inc_unchecked(&vcc->stats->rx_err);
38170 return;
38171 }
38172 if (!atm_charge(vcc, skb->truesize)) {
38173@@ -1169,7 +1169,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38174 __net_timestamp(skb);
38175
38176 vcc->push(vcc, skb);
38177- atomic_inc(&vcc->stats->rx);
38178+ atomic_inc_unchecked(&vcc->stats->rx);
38179
38180 return;
38181 }
38182@@ -1191,7 +1191,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38183 __net_timestamp(skb);
38184
38185 vcc->push(vcc, skb);
38186- atomic_inc(&vcc->stats->rx);
38187+ atomic_inc_unchecked(&vcc->stats->rx);
38188
38189 if (skb->truesize > SAR_FB_SIZE_3)
38190 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
38191@@ -1302,14 +1302,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
38192 if (vcc->qos.aal != ATM_AAL0) {
38193 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
38194 card->name, vpi, vci);
38195- atomic_inc(&vcc->stats->rx_drop);
38196+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38197 goto drop;
38198 }
38199
38200 if ((sb = dev_alloc_skb(64)) == NULL) {
38201 printk("%s: Can't allocate buffers for AAL0.\n",
38202 card->name);
38203- atomic_inc(&vcc->stats->rx_err);
38204+ atomic_inc_unchecked(&vcc->stats->rx_err);
38205 goto drop;
38206 }
38207
38208@@ -1328,7 +1328,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
38209 ATM_SKB(sb)->vcc = vcc;
38210 __net_timestamp(sb);
38211 vcc->push(vcc, sb);
38212- atomic_inc(&vcc->stats->rx);
38213+ atomic_inc_unchecked(&vcc->stats->rx);
38214
38215 drop:
38216 skb_pull(queue, 64);
38217@@ -1953,13 +1953,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
38218
38219 if (vc == NULL) {
38220 printk("%s: NULL connection in send().\n", card->name);
38221- atomic_inc(&vcc->stats->tx_err);
38222+ atomic_inc_unchecked(&vcc->stats->tx_err);
38223 dev_kfree_skb(skb);
38224 return -EINVAL;
38225 }
38226 if (!test_bit(VCF_TX, &vc->flags)) {
38227 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
38228- atomic_inc(&vcc->stats->tx_err);
38229+ atomic_inc_unchecked(&vcc->stats->tx_err);
38230 dev_kfree_skb(skb);
38231 return -EINVAL;
38232 }
38233@@ -1971,14 +1971,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
38234 break;
38235 default:
38236 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
38237- atomic_inc(&vcc->stats->tx_err);
38238+ atomic_inc_unchecked(&vcc->stats->tx_err);
38239 dev_kfree_skb(skb);
38240 return -EINVAL;
38241 }
38242
38243 if (skb_shinfo(skb)->nr_frags != 0) {
38244 printk("%s: No scatter-gather yet.\n", card->name);
38245- atomic_inc(&vcc->stats->tx_err);
38246+ atomic_inc_unchecked(&vcc->stats->tx_err);
38247 dev_kfree_skb(skb);
38248 return -EINVAL;
38249 }
38250@@ -1986,7 +1986,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
38251
38252 err = queue_skb(card, vc, skb, oam);
38253 if (err) {
38254- atomic_inc(&vcc->stats->tx_err);
38255+ atomic_inc_unchecked(&vcc->stats->tx_err);
38256 dev_kfree_skb(skb);
38257 return err;
38258 }
38259@@ -2009,7 +2009,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
38260 skb = dev_alloc_skb(64);
38261 if (!skb) {
38262 printk("%s: Out of memory in send_oam().\n", card->name);
38263- atomic_inc(&vcc->stats->tx_err);
38264+ atomic_inc_unchecked(&vcc->stats->tx_err);
38265 return -ENOMEM;
38266 }
38267 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
38268diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
38269index 65e6590..df77d04 100644
38270--- a/drivers/atm/iphase.c
38271+++ b/drivers/atm/iphase.c
38272@@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
38273 status = (u_short) (buf_desc_ptr->desc_mode);
38274 if (status & (RX_CER | RX_PTE | RX_OFL))
38275 {
38276- atomic_inc(&vcc->stats->rx_err);
38277+ atomic_inc_unchecked(&vcc->stats->rx_err);
38278 IF_ERR(printk("IA: bad packet, dropping it");)
38279 if (status & RX_CER) {
38280 IF_ERR(printk(" cause: packet CRC error\n");)
38281@@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
38282 len = dma_addr - buf_addr;
38283 if (len > iadev->rx_buf_sz) {
38284 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
38285- atomic_inc(&vcc->stats->rx_err);
38286+ atomic_inc_unchecked(&vcc->stats->rx_err);
38287 goto out_free_desc;
38288 }
38289
38290@@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
38291 ia_vcc = INPH_IA_VCC(vcc);
38292 if (ia_vcc == NULL)
38293 {
38294- atomic_inc(&vcc->stats->rx_err);
38295+ atomic_inc_unchecked(&vcc->stats->rx_err);
38296 atm_return(vcc, skb->truesize);
38297 dev_kfree_skb_any(skb);
38298 goto INCR_DLE;
38299@@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
38300 if ((length > iadev->rx_buf_sz) || (length >
38301 (skb->len - sizeof(struct cpcs_trailer))))
38302 {
38303- atomic_inc(&vcc->stats->rx_err);
38304+ atomic_inc_unchecked(&vcc->stats->rx_err);
38305 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
38306 length, skb->len);)
38307 atm_return(vcc, skb->truesize);
38308@@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
38309
38310 IF_RX(printk("rx_dle_intr: skb push");)
38311 vcc->push(vcc,skb);
38312- atomic_inc(&vcc->stats->rx);
38313+ atomic_inc_unchecked(&vcc->stats->rx);
38314 iadev->rx_pkt_cnt++;
38315 }
38316 INCR_DLE:
38317@@ -2828,15 +2828,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
38318 {
38319 struct k_sonet_stats *stats;
38320 stats = &PRIV(_ia_dev[board])->sonet_stats;
38321- printk("section_bip: %d\n", atomic_read(&stats->section_bip));
38322- printk("line_bip : %d\n", atomic_read(&stats->line_bip));
38323- printk("path_bip : %d\n", atomic_read(&stats->path_bip));
38324- printk("line_febe : %d\n", atomic_read(&stats->line_febe));
38325- printk("path_febe : %d\n", atomic_read(&stats->path_febe));
38326- printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
38327- printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
38328- printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
38329- printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
38330+ printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
38331+ printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
38332+ printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
38333+ printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
38334+ printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
38335+ printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
38336+ printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
38337+ printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
38338+ printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
38339 }
38340 ia_cmds.status = 0;
38341 break;
38342@@ -2941,7 +2941,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
38343 if ((desc == 0) || (desc > iadev->num_tx_desc))
38344 {
38345 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
38346- atomic_inc(&vcc->stats->tx);
38347+ atomic_inc_unchecked(&vcc->stats->tx);
38348 if (vcc->pop)
38349 vcc->pop(vcc, skb);
38350 else
38351@@ -3046,14 +3046,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
38352 ATM_DESC(skb) = vcc->vci;
38353 skb_queue_tail(&iadev->tx_dma_q, skb);
38354
38355- atomic_inc(&vcc->stats->tx);
38356+ atomic_inc_unchecked(&vcc->stats->tx);
38357 iadev->tx_pkt_cnt++;
38358 /* Increment transaction counter */
38359 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
38360
38361 #if 0
38362 /* add flow control logic */
38363- if (atomic_read(&vcc->stats->tx) % 20 == 0) {
38364+ if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
38365 if (iavcc->vc_desc_cnt > 10) {
38366 vcc->tx_quota = vcc->tx_quota * 3 / 4;
38367 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
38368diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
38369index ce43ae3..969de38 100644
38370--- a/drivers/atm/lanai.c
38371+++ b/drivers/atm/lanai.c
38372@@ -1295,7 +1295,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
38373 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
38374 lanai_endtx(lanai, lvcc);
38375 lanai_free_skb(lvcc->tx.atmvcc, skb);
38376- atomic_inc(&lvcc->tx.atmvcc->stats->tx);
38377+ atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
38378 }
38379
38380 /* Try to fill the buffer - don't call unless there is backlog */
38381@@ -1418,7 +1418,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
38382 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
38383 __net_timestamp(skb);
38384 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
38385- atomic_inc(&lvcc->rx.atmvcc->stats->rx);
38386+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
38387 out:
38388 lvcc->rx.buf.ptr = end;
38389 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
38390@@ -1659,7 +1659,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
38391 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
38392 "vcc %d\n", lanai->number, (unsigned int) s, vci);
38393 lanai->stats.service_rxnotaal5++;
38394- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
38395+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
38396 return 0;
38397 }
38398 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
38399@@ -1671,7 +1671,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
38400 int bytes;
38401 read_unlock(&vcc_sklist_lock);
38402 DPRINTK("got trashed rx pdu on vci %d\n", vci);
38403- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
38404+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
38405 lvcc->stats.x.aal5.service_trash++;
38406 bytes = (SERVICE_GET_END(s) * 16) -
38407 (((unsigned long) lvcc->rx.buf.ptr) -
38408@@ -1683,7 +1683,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
38409 }
38410 if (s & SERVICE_STREAM) {
38411 read_unlock(&vcc_sklist_lock);
38412- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
38413+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
38414 lvcc->stats.x.aal5.service_stream++;
38415 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
38416 "PDU on VCI %d!\n", lanai->number, vci);
38417@@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
38418 return 0;
38419 }
38420 DPRINTK("got rx crc error on vci %d\n", vci);
38421- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
38422+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
38423 lvcc->stats.x.aal5.service_rxcrc++;
38424 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
38425 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
38426diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
38427index ddc4ceb..36e29aa 100644
38428--- a/drivers/atm/nicstar.c
38429+++ b/drivers/atm/nicstar.c
38430@@ -1632,7 +1632,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
38431 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
38432 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
38433 card->index);
38434- atomic_inc(&vcc->stats->tx_err);
38435+ atomic_inc_unchecked(&vcc->stats->tx_err);
38436 dev_kfree_skb_any(skb);
38437 return -EINVAL;
38438 }
38439@@ -1640,7 +1640,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
38440 if (!vc->tx) {
38441 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
38442 card->index);
38443- atomic_inc(&vcc->stats->tx_err);
38444+ atomic_inc_unchecked(&vcc->stats->tx_err);
38445 dev_kfree_skb_any(skb);
38446 return -EINVAL;
38447 }
38448@@ -1648,14 +1648,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
38449 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
38450 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
38451 card->index);
38452- atomic_inc(&vcc->stats->tx_err);
38453+ atomic_inc_unchecked(&vcc->stats->tx_err);
38454 dev_kfree_skb_any(skb);
38455 return -EINVAL;
38456 }
38457
38458 if (skb_shinfo(skb)->nr_frags != 0) {
38459 printk("nicstar%d: No scatter-gather yet.\n", card->index);
38460- atomic_inc(&vcc->stats->tx_err);
38461+ atomic_inc_unchecked(&vcc->stats->tx_err);
38462 dev_kfree_skb_any(skb);
38463 return -EINVAL;
38464 }
38465@@ -1703,11 +1703,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
38466 }
38467
38468 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
38469- atomic_inc(&vcc->stats->tx_err);
38470+ atomic_inc_unchecked(&vcc->stats->tx_err);
38471 dev_kfree_skb_any(skb);
38472 return -EIO;
38473 }
38474- atomic_inc(&vcc->stats->tx);
38475+ atomic_inc_unchecked(&vcc->stats->tx);
38476
38477 return 0;
38478 }
38479@@ -2024,14 +2024,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38480 printk
38481 ("nicstar%d: Can't allocate buffers for aal0.\n",
38482 card->index);
38483- atomic_add(i, &vcc->stats->rx_drop);
38484+ atomic_add_unchecked(i, &vcc->stats->rx_drop);
38485 break;
38486 }
38487 if (!atm_charge(vcc, sb->truesize)) {
38488 RXPRINTK
38489 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
38490 card->index);
38491- atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
38492+ atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
38493 dev_kfree_skb_any(sb);
38494 break;
38495 }
38496@@ -2046,7 +2046,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38497 ATM_SKB(sb)->vcc = vcc;
38498 __net_timestamp(sb);
38499 vcc->push(vcc, sb);
38500- atomic_inc(&vcc->stats->rx);
38501+ atomic_inc_unchecked(&vcc->stats->rx);
38502 cell += ATM_CELL_PAYLOAD;
38503 }
38504
38505@@ -2063,7 +2063,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38506 if (iovb == NULL) {
38507 printk("nicstar%d: Out of iovec buffers.\n",
38508 card->index);
38509- atomic_inc(&vcc->stats->rx_drop);
38510+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38511 recycle_rx_buf(card, skb);
38512 return;
38513 }
38514@@ -2087,7 +2087,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38515 small or large buffer itself. */
38516 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
38517 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
38518- atomic_inc(&vcc->stats->rx_err);
38519+ atomic_inc_unchecked(&vcc->stats->rx_err);
38520 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
38521 NS_MAX_IOVECS);
38522 NS_PRV_IOVCNT(iovb) = 0;
38523@@ -2107,7 +2107,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38524 ("nicstar%d: Expected a small buffer, and this is not one.\n",
38525 card->index);
38526 which_list(card, skb);
38527- atomic_inc(&vcc->stats->rx_err);
38528+ atomic_inc_unchecked(&vcc->stats->rx_err);
38529 recycle_rx_buf(card, skb);
38530 vc->rx_iov = NULL;
38531 recycle_iov_buf(card, iovb);
38532@@ -2120,7 +2120,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38533 ("nicstar%d: Expected a large buffer, and this is not one.\n",
38534 card->index);
38535 which_list(card, skb);
38536- atomic_inc(&vcc->stats->rx_err);
38537+ atomic_inc_unchecked(&vcc->stats->rx_err);
38538 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
38539 NS_PRV_IOVCNT(iovb));
38540 vc->rx_iov = NULL;
38541@@ -2143,7 +2143,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38542 printk(" - PDU size mismatch.\n");
38543 else
38544 printk(".\n");
38545- atomic_inc(&vcc->stats->rx_err);
38546+ atomic_inc_unchecked(&vcc->stats->rx_err);
38547 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
38548 NS_PRV_IOVCNT(iovb));
38549 vc->rx_iov = NULL;
38550@@ -2157,14 +2157,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38551 /* skb points to a small buffer */
38552 if (!atm_charge(vcc, skb->truesize)) {
38553 push_rxbufs(card, skb);
38554- atomic_inc(&vcc->stats->rx_drop);
38555+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38556 } else {
38557 skb_put(skb, len);
38558 dequeue_sm_buf(card, skb);
38559 ATM_SKB(skb)->vcc = vcc;
38560 __net_timestamp(skb);
38561 vcc->push(vcc, skb);
38562- atomic_inc(&vcc->stats->rx);
38563+ atomic_inc_unchecked(&vcc->stats->rx);
38564 }
38565 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
38566 struct sk_buff *sb;
38567@@ -2175,14 +2175,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38568 if (len <= NS_SMBUFSIZE) {
38569 if (!atm_charge(vcc, sb->truesize)) {
38570 push_rxbufs(card, sb);
38571- atomic_inc(&vcc->stats->rx_drop);
38572+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38573 } else {
38574 skb_put(sb, len);
38575 dequeue_sm_buf(card, sb);
38576 ATM_SKB(sb)->vcc = vcc;
38577 __net_timestamp(sb);
38578 vcc->push(vcc, sb);
38579- atomic_inc(&vcc->stats->rx);
38580+ atomic_inc_unchecked(&vcc->stats->rx);
38581 }
38582
38583 push_rxbufs(card, skb);
38584@@ -2191,7 +2191,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38585
38586 if (!atm_charge(vcc, skb->truesize)) {
38587 push_rxbufs(card, skb);
38588- atomic_inc(&vcc->stats->rx_drop);
38589+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38590 } else {
38591 dequeue_lg_buf(card, skb);
38592 skb_push(skb, NS_SMBUFSIZE);
38593@@ -2201,7 +2201,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38594 ATM_SKB(skb)->vcc = vcc;
38595 __net_timestamp(skb);
38596 vcc->push(vcc, skb);
38597- atomic_inc(&vcc->stats->rx);
38598+ atomic_inc_unchecked(&vcc->stats->rx);
38599 }
38600
38601 push_rxbufs(card, sb);
38602@@ -2222,7 +2222,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38603 printk
38604 ("nicstar%d: Out of huge buffers.\n",
38605 card->index);
38606- atomic_inc(&vcc->stats->rx_drop);
38607+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38608 recycle_iovec_rx_bufs(card,
38609 (struct iovec *)
38610 iovb->data,
38611@@ -2273,7 +2273,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38612 card->hbpool.count++;
38613 } else
38614 dev_kfree_skb_any(hb);
38615- atomic_inc(&vcc->stats->rx_drop);
38616+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38617 } else {
38618 /* Copy the small buffer to the huge buffer */
38619 sb = (struct sk_buff *)iov->iov_base;
38620@@ -2307,7 +2307,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38621 ATM_SKB(hb)->vcc = vcc;
38622 __net_timestamp(hb);
38623 vcc->push(vcc, hb);
38624- atomic_inc(&vcc->stats->rx);
38625+ atomic_inc_unchecked(&vcc->stats->rx);
38626 }
38627 }
38628
38629diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
38630index 74e18b0..f16afa0 100644
38631--- a/drivers/atm/solos-pci.c
38632+++ b/drivers/atm/solos-pci.c
38633@@ -838,7 +838,7 @@ static void solos_bh(unsigned long card_arg)
38634 }
38635 atm_charge(vcc, skb->truesize);
38636 vcc->push(vcc, skb);
38637- atomic_inc(&vcc->stats->rx);
38638+ atomic_inc_unchecked(&vcc->stats->rx);
38639 break;
38640
38641 case PKT_STATUS:
38642@@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
38643 vcc = SKB_CB(oldskb)->vcc;
38644
38645 if (vcc) {
38646- atomic_inc(&vcc->stats->tx);
38647+ atomic_inc_unchecked(&vcc->stats->tx);
38648 solos_pop(vcc, oldskb);
38649 } else {
38650 dev_kfree_skb_irq(oldskb);
38651diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
38652index 0215934..ce9f5b1 100644
38653--- a/drivers/atm/suni.c
38654+++ b/drivers/atm/suni.c
38655@@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
38656
38657
38658 #define ADD_LIMITED(s,v) \
38659- atomic_add((v),&stats->s); \
38660- if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
38661+ atomic_add_unchecked((v),&stats->s); \
38662+ if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
38663
38664
38665 static void suni_hz(unsigned long from_timer)
38666diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
38667index 5120a96..e2572bd 100644
38668--- a/drivers/atm/uPD98402.c
38669+++ b/drivers/atm/uPD98402.c
38670@@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
38671 struct sonet_stats tmp;
38672 int error = 0;
38673
38674- atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
38675+ atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
38676 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
38677 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
38678 if (zero && !error) {
38679@@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
38680
38681
38682 #define ADD_LIMITED(s,v) \
38683- { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
38684- if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
38685- atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
38686+ { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
38687+ if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
38688+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
38689
38690
38691 static void stat_event(struct atm_dev *dev)
38692@@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
38693 if (reason & uPD98402_INT_PFM) stat_event(dev);
38694 if (reason & uPD98402_INT_PCO) {
38695 (void) GET(PCOCR); /* clear interrupt cause */
38696- atomic_add(GET(HECCT),
38697+ atomic_add_unchecked(GET(HECCT),
38698 &PRIV(dev)->sonet_stats.uncorr_hcs);
38699 }
38700 if ((reason & uPD98402_INT_RFO) &&
38701@@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
38702 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
38703 uPD98402_INT_LOS),PIMR); /* enable them */
38704 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
38705- atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
38706- atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
38707- atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
38708+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
38709+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
38710+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
38711 return 0;
38712 }
38713
38714diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
38715index cecfb94..87009ec 100644
38716--- a/drivers/atm/zatm.c
38717+++ b/drivers/atm/zatm.c
38718@@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
38719 }
38720 if (!size) {
38721 dev_kfree_skb_irq(skb);
38722- if (vcc) atomic_inc(&vcc->stats->rx_err);
38723+ if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
38724 continue;
38725 }
38726 if (!atm_charge(vcc,skb->truesize)) {
38727@@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
38728 skb->len = size;
38729 ATM_SKB(skb)->vcc = vcc;
38730 vcc->push(vcc,skb);
38731- atomic_inc(&vcc->stats->rx);
38732+ atomic_inc_unchecked(&vcc->stats->rx);
38733 }
38734 zout(pos & 0xffff,MTA(mbx));
38735 #if 0 /* probably a stupid idea */
38736@@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
38737 skb_queue_head(&zatm_vcc->backlog,skb);
38738 break;
38739 }
38740- atomic_inc(&vcc->stats->tx);
38741+ atomic_inc_unchecked(&vcc->stats->tx);
38742 wake_up(&zatm_vcc->tx_wait);
38743 }
38744
38745diff --git a/drivers/base/bus.c b/drivers/base/bus.c
38746index 5005924..9fc06c4 100644
38747--- a/drivers/base/bus.c
38748+++ b/drivers/base/bus.c
38749@@ -1141,7 +1141,7 @@ int subsys_interface_register(struct subsys_interface *sif)
38750 return -EINVAL;
38751
38752 mutex_lock(&subsys->p->mutex);
38753- list_add_tail(&sif->node, &subsys->p->interfaces);
38754+ pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
38755 if (sif->add_dev) {
38756 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
38757 while ((dev = subsys_dev_iter_next(&iter)))
38758@@ -1166,7 +1166,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
38759 subsys = sif->subsys;
38760
38761 mutex_lock(&subsys->p->mutex);
38762- list_del_init(&sif->node);
38763+ pax_list_del_init((struct list_head *)&sif->node);
38764 if (sif->remove_dev) {
38765 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
38766 while ((dev = subsys_dev_iter_next(&iter)))
38767diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
38768index 68f0314..ca2a609 100644
38769--- a/drivers/base/devtmpfs.c
38770+++ b/drivers/base/devtmpfs.c
38771@@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
38772 if (!thread)
38773 return 0;
38774
38775- err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
38776+ err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
38777 if (err)
38778 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
38779 else
38780@@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
38781 *err = sys_unshare(CLONE_NEWNS);
38782 if (*err)
38783 goto out;
38784- *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
38785+ *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
38786 if (*err)
38787 goto out;
38788- sys_chdir("/.."); /* will traverse into overmounted root */
38789- sys_chroot(".");
38790+ sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
38791+ sys_chroot((char __force_user *)".");
38792 complete(&setup_done);
38793 while (1) {
38794 spin_lock(&req_lock);
38795diff --git a/drivers/base/node.c b/drivers/base/node.c
38796index 560751b..3a4847a 100644
38797--- a/drivers/base/node.c
38798+++ b/drivers/base/node.c
38799@@ -627,7 +627,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
38800 struct node_attr {
38801 struct device_attribute attr;
38802 enum node_states state;
38803-};
38804+} __do_const;
38805
38806 static ssize_t show_node_state(struct device *dev,
38807 struct device_attribute *attr, char *buf)
38808diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
38809index 0ee43c1..369dd62 100644
38810--- a/drivers/base/power/domain.c
38811+++ b/drivers/base/power/domain.c
38812@@ -1738,7 +1738,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
38813 {
38814 struct cpuidle_driver *cpuidle_drv;
38815 struct gpd_cpuidle_data *cpuidle_data;
38816- struct cpuidle_state *idle_state;
38817+ cpuidle_state_no_const *idle_state;
38818 int ret = 0;
38819
38820 if (IS_ERR_OR_NULL(genpd) || state < 0)
38821@@ -1806,7 +1806,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
38822 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
38823 {
38824 struct gpd_cpuidle_data *cpuidle_data;
38825- struct cpuidle_state *idle_state;
38826+ cpuidle_state_no_const *idle_state;
38827 int ret = 0;
38828
38829 if (IS_ERR_OR_NULL(genpd))
38830@@ -2241,8 +2241,11 @@ int genpd_dev_pm_attach(struct device *dev)
38831 return ret;
38832 }
38833
38834- dev->pm_domain->detach = genpd_dev_pm_detach;
38835- dev->pm_domain->sync = genpd_dev_pm_sync;
38836+ pax_open_kernel();
38837+ *(void **)&dev->pm_domain->detach = genpd_dev_pm_detach;
38838+ *(void **)&dev->pm_domain->sync = genpd_dev_pm_sync;
38839+ pax_close_kernel();
38840+
38841 pm_genpd_poweron(pd);
38842
38843 return 0;
38844diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
38845index d2be3f9..0a3167a 100644
38846--- a/drivers/base/power/sysfs.c
38847+++ b/drivers/base/power/sysfs.c
38848@@ -181,7 +181,7 @@ static ssize_t rtpm_status_show(struct device *dev,
38849 return -EIO;
38850 }
38851 }
38852- return sprintf(buf, p);
38853+ return sprintf(buf, "%s", p);
38854 }
38855
38856 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
38857diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
38858index 51f15bc..892a668 100644
38859--- a/drivers/base/power/wakeup.c
38860+++ b/drivers/base/power/wakeup.c
38861@@ -33,14 +33,14 @@ static bool pm_abort_suspend __read_mostly;
38862 * They need to be modified together atomically, so it's better to use one
38863 * atomic variable to hold them both.
38864 */
38865-static atomic_t combined_event_count = ATOMIC_INIT(0);
38866+static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
38867
38868 #define IN_PROGRESS_BITS (sizeof(int) * 4)
38869 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
38870
38871 static void split_counters(unsigned int *cnt, unsigned int *inpr)
38872 {
38873- unsigned int comb = atomic_read(&combined_event_count);
38874+ unsigned int comb = atomic_read_unchecked(&combined_event_count);
38875
38876 *cnt = (comb >> IN_PROGRESS_BITS);
38877 *inpr = comb & MAX_IN_PROGRESS;
38878@@ -537,7 +537,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
38879 ws->start_prevent_time = ws->last_time;
38880
38881 /* Increment the counter of events in progress. */
38882- cec = atomic_inc_return(&combined_event_count);
38883+ cec = atomic_inc_return_unchecked(&combined_event_count);
38884
38885 trace_wakeup_source_activate(ws->name, cec);
38886 }
38887@@ -663,7 +663,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
38888 * Increment the counter of registered wakeup events and decrement the
38889 * couter of wakeup events in progress simultaneously.
38890 */
38891- cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
38892+ cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
38893 trace_wakeup_source_deactivate(ws->name, cec);
38894
38895 split_counters(&cnt, &inpr);
38896diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
38897index c8941f3..f7c7a7e 100644
38898--- a/drivers/base/regmap/regmap-debugfs.c
38899+++ b/drivers/base/regmap/regmap-debugfs.c
38900@@ -30,7 +30,7 @@ static LIST_HEAD(regmap_debugfs_early_list);
38901 static DEFINE_MUTEX(regmap_debugfs_early_lock);
38902
38903 /* Calculate the length of a fixed format */
38904-static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size)
38905+static size_t regmap_calc_reg_len(int max_val)
38906 {
38907 return snprintf(NULL, 0, "%x", max_val);
38908 }
38909@@ -173,8 +173,7 @@ static inline void regmap_calc_tot_len(struct regmap *map,
38910 {
38911 /* Calculate the length of a fixed format */
38912 if (!map->debugfs_tot_len) {
38913- map->debugfs_reg_len = regmap_calc_reg_len(map->max_register,
38914- buf, count);
38915+ map->debugfs_reg_len = regmap_calc_reg_len(map->max_register);
38916 map->debugfs_val_len = 2 * map->format.val_bytes;
38917 map->debugfs_tot_len = map->debugfs_reg_len +
38918 map->debugfs_val_len + 3; /* : \n */
38919@@ -404,7 +403,7 @@ static ssize_t regmap_access_read_file(struct file *file,
38920 char __user *user_buf, size_t count,
38921 loff_t *ppos)
38922 {
38923- int reg_len, tot_len;
38924+ size_t reg_len, tot_len;
38925 size_t buf_pos = 0;
38926 loff_t p = 0;
38927 ssize_t ret;
38928@@ -420,7 +419,7 @@ static ssize_t regmap_access_read_file(struct file *file,
38929 return -ENOMEM;
38930
38931 /* Calculate the length of a fixed format */
38932- reg_len = regmap_calc_reg_len(map->max_register, buf, count);
38933+ reg_len = regmap_calc_reg_len(map->max_register);
38934 tot_len = reg_len + 10; /* ': R W V P\n' */
38935
38936 for (i = 0; i <= map->max_register; i += map->reg_stride) {
38937diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
38938index 8d98a32..61d3165 100644
38939--- a/drivers/base/syscore.c
38940+++ b/drivers/base/syscore.c
38941@@ -22,7 +22,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
38942 void register_syscore_ops(struct syscore_ops *ops)
38943 {
38944 mutex_lock(&syscore_ops_lock);
38945- list_add_tail(&ops->node, &syscore_ops_list);
38946+ pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
38947 mutex_unlock(&syscore_ops_lock);
38948 }
38949 EXPORT_SYMBOL_GPL(register_syscore_ops);
38950@@ -34,7 +34,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
38951 void unregister_syscore_ops(struct syscore_ops *ops)
38952 {
38953 mutex_lock(&syscore_ops_lock);
38954- list_del(&ops->node);
38955+ pax_list_del((struct list_head *)&ops->node);
38956 mutex_unlock(&syscore_ops_lock);
38957 }
38958 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
38959diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
38960index 0422c47..b222c7a 100644
38961--- a/drivers/block/cciss.c
38962+++ b/drivers/block/cciss.c
38963@@ -3024,7 +3024,7 @@ static void start_io(ctlr_info_t *h)
38964 while (!list_empty(&h->reqQ)) {
38965 c = list_entry(h->reqQ.next, CommandList_struct, list);
38966 /* can't do anything if fifo is full */
38967- if ((h->access.fifo_full(h))) {
38968+ if ((h->access->fifo_full(h))) {
38969 dev_warn(&h->pdev->dev, "fifo full\n");
38970 break;
38971 }
38972@@ -3034,7 +3034,7 @@ static void start_io(ctlr_info_t *h)
38973 h->Qdepth--;
38974
38975 /* Tell the controller execute command */
38976- h->access.submit_command(h, c);
38977+ h->access->submit_command(h, c);
38978
38979 /* Put job onto the completed Q */
38980 addQ(&h->cmpQ, c);
38981@@ -3460,17 +3460,17 @@ startio:
38982
38983 static inline unsigned long get_next_completion(ctlr_info_t *h)
38984 {
38985- return h->access.command_completed(h);
38986+ return h->access->command_completed(h);
38987 }
38988
38989 static inline int interrupt_pending(ctlr_info_t *h)
38990 {
38991- return h->access.intr_pending(h);
38992+ return h->access->intr_pending(h);
38993 }
38994
38995 static inline long interrupt_not_for_us(ctlr_info_t *h)
38996 {
38997- return ((h->access.intr_pending(h) == 0) ||
38998+ return ((h->access->intr_pending(h) == 0) ||
38999 (h->interrupts_enabled == 0));
39000 }
39001
39002@@ -3503,7 +3503,7 @@ static inline u32 next_command(ctlr_info_t *h)
39003 u32 a;
39004
39005 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
39006- return h->access.command_completed(h);
39007+ return h->access->command_completed(h);
39008
39009 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
39010 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
39011@@ -4060,7 +4060,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
39012 trans_support & CFGTBL_Trans_use_short_tags);
39013
39014 /* Change the access methods to the performant access methods */
39015- h->access = SA5_performant_access;
39016+ h->access = &SA5_performant_access;
39017 h->transMethod = CFGTBL_Trans_Performant;
39018
39019 return;
39020@@ -4334,7 +4334,7 @@ static int cciss_pci_init(ctlr_info_t *h)
39021 if (prod_index < 0)
39022 return -ENODEV;
39023 h->product_name = products[prod_index].product_name;
39024- h->access = *(products[prod_index].access);
39025+ h->access = products[prod_index].access;
39026
39027 if (cciss_board_disabled(h)) {
39028 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
39029@@ -5065,7 +5065,7 @@ reinit_after_soft_reset:
39030 }
39031
39032 /* make sure the board interrupts are off */
39033- h->access.set_intr_mask(h, CCISS_INTR_OFF);
39034+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
39035 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
39036 if (rc)
39037 goto clean2;
39038@@ -5115,7 +5115,7 @@ reinit_after_soft_reset:
39039 * fake ones to scoop up any residual completions.
39040 */
39041 spin_lock_irqsave(&h->lock, flags);
39042- h->access.set_intr_mask(h, CCISS_INTR_OFF);
39043+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
39044 spin_unlock_irqrestore(&h->lock, flags);
39045 free_irq(h->intr[h->intr_mode], h);
39046 rc = cciss_request_irq(h, cciss_msix_discard_completions,
39047@@ -5135,9 +5135,9 @@ reinit_after_soft_reset:
39048 dev_info(&h->pdev->dev, "Board READY.\n");
39049 dev_info(&h->pdev->dev,
39050 "Waiting for stale completions to drain.\n");
39051- h->access.set_intr_mask(h, CCISS_INTR_ON);
39052+ h->access->set_intr_mask(h, CCISS_INTR_ON);
39053 msleep(10000);
39054- h->access.set_intr_mask(h, CCISS_INTR_OFF);
39055+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
39056
39057 rc = controller_reset_failed(h->cfgtable);
39058 if (rc)
39059@@ -5160,7 +5160,7 @@ reinit_after_soft_reset:
39060 cciss_scsi_setup(h);
39061
39062 /* Turn the interrupts on so we can service requests */
39063- h->access.set_intr_mask(h, CCISS_INTR_ON);
39064+ h->access->set_intr_mask(h, CCISS_INTR_ON);
39065
39066 /* Get the firmware version */
39067 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
39068@@ -5232,7 +5232,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
39069 kfree(flush_buf);
39070 if (return_code != IO_OK)
39071 dev_warn(&h->pdev->dev, "Error flushing cache\n");
39072- h->access.set_intr_mask(h, CCISS_INTR_OFF);
39073+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
39074 free_irq(h->intr[h->intr_mode], h);
39075 }
39076
39077diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
39078index 7fda30e..2f27946 100644
39079--- a/drivers/block/cciss.h
39080+++ b/drivers/block/cciss.h
39081@@ -101,7 +101,7 @@ struct ctlr_info
39082 /* information about each logical volume */
39083 drive_info_struct *drv[CISS_MAX_LUN];
39084
39085- struct access_method access;
39086+ struct access_method *access;
39087
39088 /* queue and queue Info */
39089 struct list_head reqQ;
39090@@ -402,27 +402,27 @@ static bool SA5_performant_intr_pending(ctlr_info_t *h)
39091 }
39092
39093 static struct access_method SA5_access = {
39094- SA5_submit_command,
39095- SA5_intr_mask,
39096- SA5_fifo_full,
39097- SA5_intr_pending,
39098- SA5_completed,
39099+ .submit_command = SA5_submit_command,
39100+ .set_intr_mask = SA5_intr_mask,
39101+ .fifo_full = SA5_fifo_full,
39102+ .intr_pending = SA5_intr_pending,
39103+ .command_completed = SA5_completed,
39104 };
39105
39106 static struct access_method SA5B_access = {
39107- SA5_submit_command,
39108- SA5B_intr_mask,
39109- SA5_fifo_full,
39110- SA5B_intr_pending,
39111- SA5_completed,
39112+ .submit_command = SA5_submit_command,
39113+ .set_intr_mask = SA5B_intr_mask,
39114+ .fifo_full = SA5_fifo_full,
39115+ .intr_pending = SA5B_intr_pending,
39116+ .command_completed = SA5_completed,
39117 };
39118
39119 static struct access_method SA5_performant_access = {
39120- SA5_submit_command,
39121- SA5_performant_intr_mask,
39122- SA5_fifo_full,
39123- SA5_performant_intr_pending,
39124- SA5_performant_completed,
39125+ .submit_command = SA5_submit_command,
39126+ .set_intr_mask = SA5_performant_intr_mask,
39127+ .fifo_full = SA5_fifo_full,
39128+ .intr_pending = SA5_performant_intr_pending,
39129+ .command_completed = SA5_performant_completed,
39130 };
39131
39132 struct board_type {
39133diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
39134index f749df9..5f8b9c4 100644
39135--- a/drivers/block/cpqarray.c
39136+++ b/drivers/block/cpqarray.c
39137@@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
39138 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
39139 goto Enomem4;
39140 }
39141- hba[i]->access.set_intr_mask(hba[i], 0);
39142+ hba[i]->access->set_intr_mask(hba[i], 0);
39143 if (request_irq(hba[i]->intr, do_ida_intr, IRQF_SHARED,
39144 hba[i]->devname, hba[i]))
39145 {
39146@@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
39147 add_timer(&hba[i]->timer);
39148
39149 /* Enable IRQ now that spinlock and rate limit timer are set up */
39150- hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
39151+ hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
39152
39153 for(j=0; j<NWD; j++) {
39154 struct gendisk *disk = ida_gendisk[i][j];
39155@@ -694,7 +694,7 @@ DBGINFO(
39156 for(i=0; i<NR_PRODUCTS; i++) {
39157 if (board_id == products[i].board_id) {
39158 c->product_name = products[i].product_name;
39159- c->access = *(products[i].access);
39160+ c->access = products[i].access;
39161 break;
39162 }
39163 }
39164@@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
39165 hba[ctlr]->intr = intr;
39166 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
39167 hba[ctlr]->product_name = products[j].product_name;
39168- hba[ctlr]->access = *(products[j].access);
39169+ hba[ctlr]->access = products[j].access;
39170 hba[ctlr]->ctlr = ctlr;
39171 hba[ctlr]->board_id = board_id;
39172 hba[ctlr]->pci_dev = NULL; /* not PCI */
39173@@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
39174
39175 while((c = h->reqQ) != NULL) {
39176 /* Can't do anything if we're busy */
39177- if (h->access.fifo_full(h) == 0)
39178+ if (h->access->fifo_full(h) == 0)
39179 return;
39180
39181 /* Get the first entry from the request Q */
39182@@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
39183 h->Qdepth--;
39184
39185 /* Tell the controller to do our bidding */
39186- h->access.submit_command(h, c);
39187+ h->access->submit_command(h, c);
39188
39189 /* Get onto the completion Q */
39190 addQ(&h->cmpQ, c);
39191@@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
39192 unsigned long flags;
39193 __u32 a,a1;
39194
39195- istat = h->access.intr_pending(h);
39196+ istat = h->access->intr_pending(h);
39197 /* Is this interrupt for us? */
39198 if (istat == 0)
39199 return IRQ_NONE;
39200@@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
39201 */
39202 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
39203 if (istat & FIFO_NOT_EMPTY) {
39204- while((a = h->access.command_completed(h))) {
39205+ while((a = h->access->command_completed(h))) {
39206 a1 = a; a &= ~3;
39207 if ((c = h->cmpQ) == NULL)
39208 {
39209@@ -1448,11 +1448,11 @@ static int sendcmd(
39210 /*
39211 * Disable interrupt
39212 */
39213- info_p->access.set_intr_mask(info_p, 0);
39214+ info_p->access->set_intr_mask(info_p, 0);
39215 /* Make sure there is room in the command FIFO */
39216 /* Actually it should be completely empty at this time. */
39217 for (i = 200000; i > 0; i--) {
39218- temp = info_p->access.fifo_full(info_p);
39219+ temp = info_p->access->fifo_full(info_p);
39220 if (temp != 0) {
39221 break;
39222 }
39223@@ -1465,7 +1465,7 @@ DBG(
39224 /*
39225 * Send the cmd
39226 */
39227- info_p->access.submit_command(info_p, c);
39228+ info_p->access->submit_command(info_p, c);
39229 complete = pollcomplete(ctlr);
39230
39231 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
39232@@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
39233 * we check the new geometry. Then turn interrupts back on when
39234 * we're done.
39235 */
39236- host->access.set_intr_mask(host, 0);
39237+ host->access->set_intr_mask(host, 0);
39238 getgeometry(ctlr);
39239- host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
39240+ host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
39241
39242 for(i=0; i<NWD; i++) {
39243 struct gendisk *disk = ida_gendisk[ctlr][i];
39244@@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
39245 /* Wait (up to 2 seconds) for a command to complete */
39246
39247 for (i = 200000; i > 0; i--) {
39248- done = hba[ctlr]->access.command_completed(hba[ctlr]);
39249+ done = hba[ctlr]->access->command_completed(hba[ctlr]);
39250 if (done == 0) {
39251 udelay(10); /* a short fixed delay */
39252 } else
39253diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
39254index be73e9d..7fbf140 100644
39255--- a/drivers/block/cpqarray.h
39256+++ b/drivers/block/cpqarray.h
39257@@ -99,7 +99,7 @@ struct ctlr_info {
39258 drv_info_t drv[NWD];
39259 struct proc_dir_entry *proc;
39260
39261- struct access_method access;
39262+ struct access_method *access;
39263
39264 cmdlist_t *reqQ;
39265 cmdlist_t *cmpQ;
39266diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
39267index 434c77d..6d3219a 100644
39268--- a/drivers/block/drbd/drbd_bitmap.c
39269+++ b/drivers/block/drbd/drbd_bitmap.c
39270@@ -1036,7 +1036,7 @@ static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, int page_nr) __must_ho
39271 submit_bio(rw, bio);
39272 /* this should not count as user activity and cause the
39273 * resync to throttle -- see drbd_rs_should_slow_down(). */
39274- atomic_add(len >> 9, &device->rs_sect_ev);
39275+ atomic_add_unchecked(len >> 9, &device->rs_sect_ev);
39276 }
39277 }
39278
39279diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
39280index efd19c2..6ccfa94 100644
39281--- a/drivers/block/drbd/drbd_int.h
39282+++ b/drivers/block/drbd/drbd_int.h
39283@@ -386,7 +386,7 @@ struct drbd_epoch {
39284 struct drbd_connection *connection;
39285 struct list_head list;
39286 unsigned int barrier_nr;
39287- atomic_t epoch_size; /* increased on every request added. */
39288+ atomic_unchecked_t epoch_size; /* increased on every request added. */
39289 atomic_t active; /* increased on every req. added, and dec on every finished. */
39290 unsigned long flags;
39291 };
39292@@ -947,7 +947,7 @@ struct drbd_device {
39293 unsigned int al_tr_number;
39294 int al_tr_cycle;
39295 wait_queue_head_t seq_wait;
39296- atomic_t packet_seq;
39297+ atomic_unchecked_t packet_seq;
39298 unsigned int peer_seq;
39299 spinlock_t peer_seq_lock;
39300 unsigned long comm_bm_set; /* communicated number of set bits. */
39301@@ -956,8 +956,8 @@ struct drbd_device {
39302 struct mutex own_state_mutex;
39303 struct mutex *state_mutex; /* either own_state_mutex or first_peer_device(device)->connection->cstate_mutex */
39304 char congestion_reason; /* Why we where congested... */
39305- atomic_t rs_sect_in; /* for incoming resync data rate, SyncTarget */
39306- atomic_t rs_sect_ev; /* for submitted resync data rate, both */
39307+ atomic_unchecked_t rs_sect_in; /* for incoming resync data rate, SyncTarget */
39308+ atomic_unchecked_t rs_sect_ev; /* for submitted resync data rate, both */
39309 int rs_last_sect_ev; /* counter to compare with */
39310 int rs_last_events; /* counter of read or write "events" (unit sectors)
39311 * on the lower level device when we last looked. */
39312diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
39313index a151853..b9b5baa 100644
39314--- a/drivers/block/drbd/drbd_main.c
39315+++ b/drivers/block/drbd/drbd_main.c
39316@@ -1328,7 +1328,7 @@ static int _drbd_send_ack(struct drbd_peer_device *peer_device, enum drbd_packet
39317 p->sector = sector;
39318 p->block_id = block_id;
39319 p->blksize = blksize;
39320- p->seq_num = cpu_to_be32(atomic_inc_return(&peer_device->device->packet_seq));
39321+ p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&peer_device->device->packet_seq));
39322 return drbd_send_command(peer_device, sock, cmd, sizeof(*p), NULL, 0);
39323 }
39324
39325@@ -1634,7 +1634,7 @@ int drbd_send_dblock(struct drbd_peer_device *peer_device, struct drbd_request *
39326 return -EIO;
39327 p->sector = cpu_to_be64(req->i.sector);
39328 p->block_id = (unsigned long)req;
39329- p->seq_num = cpu_to_be32(atomic_inc_return(&device->packet_seq));
39330+ p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&device->packet_seq));
39331 dp_flags = bio_flags_to_wire(peer_device->connection, req->master_bio->bi_rw);
39332 if (device->state.conn >= C_SYNC_SOURCE &&
39333 device->state.conn <= C_PAUSED_SYNC_T)
39334@@ -1915,8 +1915,8 @@ void drbd_init_set_defaults(struct drbd_device *device)
39335 atomic_set(&device->unacked_cnt, 0);
39336 atomic_set(&device->local_cnt, 0);
39337 atomic_set(&device->pp_in_use_by_net, 0);
39338- atomic_set(&device->rs_sect_in, 0);
39339- atomic_set(&device->rs_sect_ev, 0);
39340+ atomic_set_unchecked(&device->rs_sect_in, 0);
39341+ atomic_set_unchecked(&device->rs_sect_ev, 0);
39342 atomic_set(&device->ap_in_flight, 0);
39343 atomic_set(&device->md_io.in_use, 0);
39344
39345@@ -2683,8 +2683,8 @@ void drbd_destroy_connection(struct kref *kref)
39346 struct drbd_connection *connection = container_of(kref, struct drbd_connection, kref);
39347 struct drbd_resource *resource = connection->resource;
39348
39349- if (atomic_read(&connection->current_epoch->epoch_size) != 0)
39350- drbd_err(connection, "epoch_size:%d\n", atomic_read(&connection->current_epoch->epoch_size));
39351+ if (atomic_read_unchecked(&connection->current_epoch->epoch_size) != 0)
39352+ drbd_err(connection, "epoch_size:%d\n", atomic_read_unchecked(&connection->current_epoch->epoch_size));
39353 kfree(connection->current_epoch);
39354
39355 idr_destroy(&connection->peer_devices);
39356diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
39357index 74df8cf..e41fc24 100644
39358--- a/drivers/block/drbd/drbd_nl.c
39359+++ b/drivers/block/drbd/drbd_nl.c
39360@@ -3637,13 +3637,13 @@ finish:
39361
39362 void drbd_bcast_event(struct drbd_device *device, const struct sib_info *sib)
39363 {
39364- static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
39365+ static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
39366 struct sk_buff *msg;
39367 struct drbd_genlmsghdr *d_out;
39368 unsigned seq;
39369 int err = -ENOMEM;
39370
39371- seq = atomic_inc_return(&drbd_genl_seq);
39372+ seq = atomic_inc_return_unchecked(&drbd_genl_seq);
39373 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
39374 if (!msg)
39375 goto failed;
39376diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
39377index c097909..13688e1 100644
39378--- a/drivers/block/drbd/drbd_receiver.c
39379+++ b/drivers/block/drbd/drbd_receiver.c
39380@@ -870,7 +870,7 @@ int drbd_connected(struct drbd_peer_device *peer_device)
39381 struct drbd_device *device = peer_device->device;
39382 int err;
39383
39384- atomic_set(&device->packet_seq, 0);
39385+ atomic_set_unchecked(&device->packet_seq, 0);
39386 device->peer_seq = 0;
39387
39388 device->state_mutex = peer_device->connection->agreed_pro_version < 100 ?
39389@@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_connection *connectio
39390 do {
39391 next_epoch = NULL;
39392
39393- epoch_size = atomic_read(&epoch->epoch_size);
39394+ epoch_size = atomic_read_unchecked(&epoch->epoch_size);
39395
39396 switch (ev & ~EV_CLEANUP) {
39397 case EV_PUT:
39398@@ -1273,7 +1273,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_connection *connectio
39399 rv = FE_DESTROYED;
39400 } else {
39401 epoch->flags = 0;
39402- atomic_set(&epoch->epoch_size, 0);
39403+ atomic_set_unchecked(&epoch->epoch_size, 0);
39404 /* atomic_set(&epoch->active, 0); is already zero */
39405 if (rv == FE_STILL_LIVE)
39406 rv = FE_RECYCLED;
39407@@ -1550,7 +1550,7 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
39408 conn_wait_active_ee_empty(connection);
39409 drbd_flush(connection);
39410
39411- if (atomic_read(&connection->current_epoch->epoch_size)) {
39412+ if (atomic_read_unchecked(&connection->current_epoch->epoch_size)) {
39413 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
39414 if (epoch)
39415 break;
39416@@ -1564,11 +1564,11 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
39417 }
39418
39419 epoch->flags = 0;
39420- atomic_set(&epoch->epoch_size, 0);
39421+ atomic_set_unchecked(&epoch->epoch_size, 0);
39422 atomic_set(&epoch->active, 0);
39423
39424 spin_lock(&connection->epoch_lock);
39425- if (atomic_read(&connection->current_epoch->epoch_size)) {
39426+ if (atomic_read_unchecked(&connection->current_epoch->epoch_size)) {
39427 list_add(&epoch->list, &connection->current_epoch->list);
39428 connection->current_epoch = epoch;
39429 connection->epochs++;
39430@@ -1802,7 +1802,7 @@ static int recv_resync_read(struct drbd_peer_device *peer_device, sector_t secto
39431 list_add_tail(&peer_req->w.list, &device->sync_ee);
39432 spin_unlock_irq(&device->resource->req_lock);
39433
39434- atomic_add(pi->size >> 9, &device->rs_sect_ev);
39435+ atomic_add_unchecked(pi->size >> 9, &device->rs_sect_ev);
39436 if (drbd_submit_peer_request(device, peer_req, WRITE, DRBD_FAULT_RS_WR) == 0)
39437 return 0;
39438
39439@@ -1900,7 +1900,7 @@ static int receive_RSDataReply(struct drbd_connection *connection, struct packet
39440 drbd_send_ack_dp(peer_device, P_NEG_ACK, p, pi->size);
39441 }
39442
39443- atomic_add(pi->size >> 9, &device->rs_sect_in);
39444+ atomic_add_unchecked(pi->size >> 9, &device->rs_sect_in);
39445
39446 return err;
39447 }
39448@@ -2290,7 +2290,7 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info *
39449
39450 err = wait_for_and_update_peer_seq(peer_device, peer_seq);
39451 drbd_send_ack_dp(peer_device, P_NEG_ACK, p, pi->size);
39452- atomic_inc(&connection->current_epoch->epoch_size);
39453+ atomic_inc_unchecked(&connection->current_epoch->epoch_size);
39454 err2 = drbd_drain_block(peer_device, pi->size);
39455 if (!err)
39456 err = err2;
39457@@ -2334,7 +2334,7 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info *
39458
39459 spin_lock(&connection->epoch_lock);
39460 peer_req->epoch = connection->current_epoch;
39461- atomic_inc(&peer_req->epoch->epoch_size);
39462+ atomic_inc_unchecked(&peer_req->epoch->epoch_size);
39463 atomic_inc(&peer_req->epoch->active);
39464 spin_unlock(&connection->epoch_lock);
39465
39466@@ -2479,7 +2479,7 @@ bool drbd_rs_c_min_rate_throttle(struct drbd_device *device)
39467
39468 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
39469 (int)part_stat_read(&disk->part0, sectors[1]) -
39470- atomic_read(&device->rs_sect_ev);
39471+ atomic_read_unchecked(&device->rs_sect_ev);
39472
39473 if (atomic_read(&device->ap_actlog_cnt)
39474 || curr_events - device->rs_last_events > 64) {
39475@@ -2618,7 +2618,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet
39476 device->use_csums = true;
39477 } else if (pi->cmd == P_OV_REPLY) {
39478 /* track progress, we may need to throttle */
39479- atomic_add(size >> 9, &device->rs_sect_in);
39480+ atomic_add_unchecked(size >> 9, &device->rs_sect_in);
39481 peer_req->w.cb = w_e_end_ov_reply;
39482 dec_rs_pending(device);
39483 /* drbd_rs_begin_io done when we sent this request,
39484@@ -2691,7 +2691,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet
39485 goto out_free_e;
39486
39487 submit_for_resync:
39488- atomic_add(size >> 9, &device->rs_sect_ev);
39489+ atomic_add_unchecked(size >> 9, &device->rs_sect_ev);
39490
39491 submit:
39492 update_receiver_timing_details(connection, drbd_submit_peer_request);
39493@@ -4564,7 +4564,7 @@ struct data_cmd {
39494 int expect_payload;
39495 size_t pkt_size;
39496 int (*fn)(struct drbd_connection *, struct packet_info *);
39497-};
39498+} __do_const;
39499
39500 static struct data_cmd drbd_cmd_handler[] = {
39501 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
39502@@ -4678,7 +4678,7 @@ static void conn_disconnect(struct drbd_connection *connection)
39503 if (!list_empty(&connection->current_epoch->list))
39504 drbd_err(connection, "ASSERTION FAILED: connection->current_epoch->list not empty\n");
39505 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
39506- atomic_set(&connection->current_epoch->epoch_size, 0);
39507+ atomic_set_unchecked(&connection->current_epoch->epoch_size, 0);
39508 connection->send.seen_any_write_yet = false;
39509
39510 drbd_info(connection, "Connection closed\n");
39511@@ -5182,7 +5182,7 @@ static int got_IsInSync(struct drbd_connection *connection, struct packet_info *
39512 put_ldev(device);
39513 }
39514 dec_rs_pending(device);
39515- atomic_add(blksize >> 9, &device->rs_sect_in);
39516+ atomic_add_unchecked(blksize >> 9, &device->rs_sect_in);
39517
39518 return 0;
39519 }
39520@@ -5470,7 +5470,7 @@ static int connection_finish_peer_reqs(struct drbd_connection *connection)
39521 struct asender_cmd {
39522 size_t pkt_size;
39523 int (*fn)(struct drbd_connection *connection, struct packet_info *);
39524-};
39525+} __do_const;
39526
39527 static struct asender_cmd asender_tbl[] = {
39528 [P_PING] = { 0, got_Ping },
39529diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c
39530index d0fae55..4469096 100644
39531--- a/drivers/block/drbd/drbd_worker.c
39532+++ b/drivers/block/drbd/drbd_worker.c
39533@@ -408,7 +408,7 @@ static int read_for_csum(struct drbd_peer_device *peer_device, sector_t sector,
39534 list_add_tail(&peer_req->w.list, &device->read_ee);
39535 spin_unlock_irq(&device->resource->req_lock);
39536
39537- atomic_add(size >> 9, &device->rs_sect_ev);
39538+ atomic_add_unchecked(size >> 9, &device->rs_sect_ev);
39539 if (drbd_submit_peer_request(device, peer_req, READ, DRBD_FAULT_RS_RD) == 0)
39540 return 0;
39541
39542@@ -553,7 +553,7 @@ static int drbd_rs_number_requests(struct drbd_device *device)
39543 unsigned int sect_in; /* Number of sectors that came in since the last turn */
39544 int number, mxb;
39545
39546- sect_in = atomic_xchg(&device->rs_sect_in, 0);
39547+ sect_in = atomic_xchg_unchecked(&device->rs_sect_in, 0);
39548 device->rs_in_flight -= sect_in;
39549
39550 rcu_read_lock();
39551@@ -1595,8 +1595,8 @@ void drbd_rs_controller_reset(struct drbd_device *device)
39552 struct gendisk *disk = device->ldev->backing_bdev->bd_contains->bd_disk;
39553 struct fifo_buffer *plan;
39554
39555- atomic_set(&device->rs_sect_in, 0);
39556- atomic_set(&device->rs_sect_ev, 0);
39557+ atomic_set_unchecked(&device->rs_sect_in, 0);
39558+ atomic_set_unchecked(&device->rs_sect_ev, 0);
39559 device->rs_in_flight = 0;
39560 device->rs_last_events =
39561 (int)part_stat_read(&disk->part0, sectors[0]) +
39562diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
39563index 4c20c22..caef1eb 100644
39564--- a/drivers/block/pktcdvd.c
39565+++ b/drivers/block/pktcdvd.c
39566@@ -109,7 +109,7 @@ static int pkt_seq_show(struct seq_file *m, void *p);
39567
39568 static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
39569 {
39570- return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1);
39571+ return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1UL);
39572 }
39573
39574 /*
39575@@ -1891,7 +1891,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
39576 return -EROFS;
39577 }
39578 pd->settings.fp = ti.fp;
39579- pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
39580+ pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1UL);
39581
39582 if (ti.nwa_v) {
39583 pd->nwa = be32_to_cpu(ti.next_writable);
39584diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
39585index bc67a93..d552e86 100644
39586--- a/drivers/block/rbd.c
39587+++ b/drivers/block/rbd.c
39588@@ -64,7 +64,7 @@
39589 * If the counter is already at its maximum value returns
39590 * -EINVAL without updating it.
39591 */
39592-static int atomic_inc_return_safe(atomic_t *v)
39593+static int __intentional_overflow(-1) atomic_inc_return_safe(atomic_t *v)
39594 {
39595 unsigned int counter;
39596
39597diff --git a/drivers/block/smart1,2.h b/drivers/block/smart1,2.h
39598index e5565fb..71be10b4 100644
39599--- a/drivers/block/smart1,2.h
39600+++ b/drivers/block/smart1,2.h
39601@@ -108,11 +108,11 @@ static unsigned long smart4_intr_pending(ctlr_info_t *h)
39602 }
39603
39604 static struct access_method smart4_access = {
39605- smart4_submit_command,
39606- smart4_intr_mask,
39607- smart4_fifo_full,
39608- smart4_intr_pending,
39609- smart4_completed,
39610+ .submit_command = smart4_submit_command,
39611+ .set_intr_mask = smart4_intr_mask,
39612+ .fifo_full = smart4_fifo_full,
39613+ .intr_pending = smart4_intr_pending,
39614+ .command_completed = smart4_completed,
39615 };
39616
39617 /*
39618@@ -144,11 +144,11 @@ static unsigned long smart2_intr_pending(ctlr_info_t *h)
39619 }
39620
39621 static struct access_method smart2_access = {
39622- smart2_submit_command,
39623- smart2_intr_mask,
39624- smart2_fifo_full,
39625- smart2_intr_pending,
39626- smart2_completed,
39627+ .submit_command = smart2_submit_command,
39628+ .set_intr_mask = smart2_intr_mask,
39629+ .fifo_full = smart2_fifo_full,
39630+ .intr_pending = smart2_intr_pending,
39631+ .command_completed = smart2_completed,
39632 };
39633
39634 /*
39635@@ -180,11 +180,11 @@ static unsigned long smart2e_intr_pending(ctlr_info_t *h)
39636 }
39637
39638 static struct access_method smart2e_access = {
39639- smart2e_submit_command,
39640- smart2e_intr_mask,
39641- smart2e_fifo_full,
39642- smart2e_intr_pending,
39643- smart2e_completed,
39644+ .submit_command = smart2e_submit_command,
39645+ .set_intr_mask = smart2e_intr_mask,
39646+ .fifo_full = smart2e_fifo_full,
39647+ .intr_pending = smart2e_intr_pending,
39648+ .command_completed = smart2e_completed,
39649 };
39650
39651 /*
39652@@ -270,9 +270,9 @@ static unsigned long smart1_intr_pending(ctlr_info_t *h)
39653 }
39654
39655 static struct access_method smart1_access = {
39656- smart1_submit_command,
39657- smart1_intr_mask,
39658- smart1_fifo_full,
39659- smart1_intr_pending,
39660- smart1_completed,
39661+ .submit_command = smart1_submit_command,
39662+ .set_intr_mask = smart1_intr_mask,
39663+ .fifo_full = smart1_fifo_full,
39664+ .intr_pending = smart1_intr_pending,
39665+ .command_completed = smart1_completed,
39666 };
39667diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
39668index 7a722df..54b76ab 100644
39669--- a/drivers/bluetooth/btwilink.c
39670+++ b/drivers/bluetooth/btwilink.c
39671@@ -288,7 +288,7 @@ static int ti_st_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
39672
39673 static int bt_ti_probe(struct platform_device *pdev)
39674 {
39675- static struct ti_st *hst;
39676+ struct ti_st *hst;
39677 struct hci_dev *hdev;
39678 int err;
39679
39680diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
39681index 5d28a45..a538f90 100644
39682--- a/drivers/cdrom/cdrom.c
39683+++ b/drivers/cdrom/cdrom.c
39684@@ -610,7 +610,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
39685 ENSURE(reset, CDC_RESET);
39686 ENSURE(generic_packet, CDC_GENERIC_PACKET);
39687 cdi->mc_flags = 0;
39688- cdo->n_minors = 0;
39689 cdi->options = CDO_USE_FFLAGS;
39690
39691 if (autoclose == 1 && CDROM_CAN(CDC_CLOSE_TRAY))
39692@@ -630,8 +629,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
39693 else
39694 cdi->cdda_method = CDDA_OLD;
39695
39696- if (!cdo->generic_packet)
39697- cdo->generic_packet = cdrom_dummy_generic_packet;
39698+ if (!cdo->generic_packet) {
39699+ pax_open_kernel();
39700+ *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
39701+ pax_close_kernel();
39702+ }
39703
39704 cd_dbg(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
39705 mutex_lock(&cdrom_mutex);
39706@@ -652,7 +654,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
39707 if (cdi->exit)
39708 cdi->exit(cdi);
39709
39710- cdi->ops->n_minors--;
39711 cd_dbg(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
39712 }
39713
39714@@ -2126,7 +2127,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
39715 */
39716 nr = nframes;
39717 do {
39718- cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
39719+ cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
39720 if (cgc.buffer)
39721 break;
39722
39723@@ -3434,7 +3435,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
39724 struct cdrom_device_info *cdi;
39725 int ret;
39726
39727- ret = scnprintf(info + *pos, max_size - *pos, header);
39728+ ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
39729 if (!ret)
39730 return 1;
39731
39732diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
39733index 584bc31..e64a12c 100644
39734--- a/drivers/cdrom/gdrom.c
39735+++ b/drivers/cdrom/gdrom.c
39736@@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
39737 .audio_ioctl = gdrom_audio_ioctl,
39738 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
39739 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
39740- .n_minors = 1,
39741 };
39742
39743 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
39744diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
39745index a043107..1263e4a 100644
39746--- a/drivers/char/Kconfig
39747+++ b/drivers/char/Kconfig
39748@@ -17,7 +17,8 @@ config DEVMEM
39749
39750 config DEVKMEM
39751 bool "/dev/kmem virtual device support"
39752- default y
39753+ default n
39754+ depends on !GRKERNSEC_KMEM
39755 help
39756 Say Y here if you want to support the /dev/kmem device. The
39757 /dev/kmem device is rarely used, but can be used for certain
39758@@ -586,6 +587,7 @@ config DEVPORT
39759 bool
39760 depends on !M68K
39761 depends on ISA || PCI
39762+ depends on !GRKERNSEC_KMEM
39763 default y
39764
39765 source "drivers/s390/char/Kconfig"
39766diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
39767index a48e05b..6bac831 100644
39768--- a/drivers/char/agp/compat_ioctl.c
39769+++ b/drivers/char/agp/compat_ioctl.c
39770@@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
39771 return -ENOMEM;
39772 }
39773
39774- if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
39775+ if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
39776 sizeof(*usegment) * ureserve.seg_count)) {
39777 kfree(usegment);
39778 kfree(ksegment);
39779diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
39780index 09f17eb..8531d2f 100644
39781--- a/drivers/char/agp/frontend.c
39782+++ b/drivers/char/agp/frontend.c
39783@@ -806,7 +806,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
39784 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
39785 return -EFAULT;
39786
39787- if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
39788+ if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
39789 return -EFAULT;
39790
39791 client = agp_find_client_by_pid(reserve.pid);
39792@@ -836,7 +836,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
39793 if (segment == NULL)
39794 return -ENOMEM;
39795
39796- if (copy_from_user(segment, (void __user *) reserve.seg_list,
39797+ if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
39798 sizeof(struct agp_segment) * reserve.seg_count)) {
39799 kfree(segment);
39800 return -EFAULT;
39801diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
39802index c6dea3f..72ae4b0 100644
39803--- a/drivers/char/agp/intel-gtt.c
39804+++ b/drivers/char/agp/intel-gtt.c
39805@@ -1408,8 +1408,8 @@ int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
39806 }
39807 EXPORT_SYMBOL(intel_gmch_probe);
39808
39809-void intel_gtt_get(size_t *gtt_total, size_t *stolen_size,
39810- phys_addr_t *mappable_base, unsigned long *mappable_end)
39811+void intel_gtt_get(uint64_t *gtt_total, uint64_t *stolen_size,
39812+ uint64_t *mappable_base, uint64_t *mappable_end)
39813 {
39814 *gtt_total = intel_private.gtt_total_entries << PAGE_SHIFT;
39815 *stolen_size = intel_private.stolen_size;
39816diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
39817index 4f94375..413694e 100644
39818--- a/drivers/char/genrtc.c
39819+++ b/drivers/char/genrtc.c
39820@@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
39821 switch (cmd) {
39822
39823 case RTC_PLL_GET:
39824+ memset(&pll, 0, sizeof(pll));
39825 if (get_rtc_pll(&pll))
39826 return -EINVAL;
39827 else
39828diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
39829index 5c0baa9..44011b1 100644
39830--- a/drivers/char/hpet.c
39831+++ b/drivers/char/hpet.c
39832@@ -575,7 +575,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
39833 }
39834
39835 static int
39836-hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
39837+hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
39838 struct hpet_info *info)
39839 {
39840 struct hpet_timer __iomem *timer;
39841diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
39842index bf75f63..359fa10 100644
39843--- a/drivers/char/ipmi/ipmi_msghandler.c
39844+++ b/drivers/char/ipmi/ipmi_msghandler.c
39845@@ -436,7 +436,7 @@ struct ipmi_smi {
39846 struct proc_dir_entry *proc_dir;
39847 char proc_dir_name[10];
39848
39849- atomic_t stats[IPMI_NUM_STATS];
39850+ atomic_unchecked_t stats[IPMI_NUM_STATS];
39851
39852 /*
39853 * run_to_completion duplicate of smb_info, smi_info
39854@@ -468,9 +468,9 @@ static LIST_HEAD(smi_watchers);
39855 static DEFINE_MUTEX(smi_watchers_mutex);
39856
39857 #define ipmi_inc_stat(intf, stat) \
39858- atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
39859+ atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
39860 #define ipmi_get_stat(intf, stat) \
39861- ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
39862+ ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
39863
39864 static char *addr_src_to_str[] = { "invalid", "hotmod", "hardcoded", "SPMI",
39865 "ACPI", "SMBIOS", "PCI",
39866@@ -2828,7 +2828,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
39867 INIT_LIST_HEAD(&intf->cmd_rcvrs);
39868 init_waitqueue_head(&intf->waitq);
39869 for (i = 0; i < IPMI_NUM_STATS; i++)
39870- atomic_set(&intf->stats[i], 0);
39871+ atomic_set_unchecked(&intf->stats[i], 0);
39872
39873 intf->proc_dir = NULL;
39874
39875diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
39876index 8a45e92..e41b1c7 100644
39877--- a/drivers/char/ipmi/ipmi_si_intf.c
39878+++ b/drivers/char/ipmi/ipmi_si_intf.c
39879@@ -289,7 +289,7 @@ struct smi_info {
39880 unsigned char slave_addr;
39881
39882 /* Counters and things for the proc filesystem. */
39883- atomic_t stats[SI_NUM_STATS];
39884+ atomic_unchecked_t stats[SI_NUM_STATS];
39885
39886 struct task_struct *thread;
39887
39888@@ -298,9 +298,9 @@ struct smi_info {
39889 };
39890
39891 #define smi_inc_stat(smi, stat) \
39892- atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
39893+ atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
39894 #define smi_get_stat(smi, stat) \
39895- ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
39896+ ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
39897
39898 #define SI_MAX_PARMS 4
39899
39900@@ -3500,7 +3500,7 @@ static int try_smi_init(struct smi_info *new_smi)
39901 atomic_set(&new_smi->req_events, 0);
39902 new_smi->run_to_completion = false;
39903 for (i = 0; i < SI_NUM_STATS; i++)
39904- atomic_set(&new_smi->stats[i], 0);
39905+ atomic_set_unchecked(&new_smi->stats[i], 0);
39906
39907 new_smi->interrupt_disabled = true;
39908 atomic_set(&new_smi->need_watch, 0);
39909diff --git a/drivers/char/mem.c b/drivers/char/mem.c
39910index 6b1721f..fda9398 100644
39911--- a/drivers/char/mem.c
39912+++ b/drivers/char/mem.c
39913@@ -18,6 +18,7 @@
39914 #include <linux/raw.h>
39915 #include <linux/tty.h>
39916 #include <linux/capability.h>
39917+#include <linux/security.h>
39918 #include <linux/ptrace.h>
39919 #include <linux/device.h>
39920 #include <linux/highmem.h>
39921@@ -36,6 +37,10 @@
39922
39923 #define DEVPORT_MINOR 4
39924
39925+#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
39926+extern const struct file_operations grsec_fops;
39927+#endif
39928+
39929 static inline unsigned long size_inside_page(unsigned long start,
39930 unsigned long size)
39931 {
39932@@ -67,9 +72,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
39933
39934 while (cursor < to) {
39935 if (!devmem_is_allowed(pfn)) {
39936+#ifdef CONFIG_GRKERNSEC_KMEM
39937+ gr_handle_mem_readwrite(from, to);
39938+#else
39939 printk(KERN_INFO
39940 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
39941 current->comm, from, to);
39942+#endif
39943 return 0;
39944 }
39945 cursor += PAGE_SIZE;
39946@@ -77,6 +86,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
39947 }
39948 return 1;
39949 }
39950+#elif defined(CONFIG_GRKERNSEC_KMEM)
39951+static inline int range_is_allowed(unsigned long pfn, unsigned long size)
39952+{
39953+ return 0;
39954+}
39955 #else
39956 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
39957 {
39958@@ -124,7 +138,8 @@ static ssize_t read_mem(struct file *file, char __user *buf,
39959 #endif
39960
39961 while (count > 0) {
39962- unsigned long remaining;
39963+ unsigned long remaining = 0;
39964+ char *temp;
39965
39966 sz = size_inside_page(p, count);
39967
39968@@ -140,7 +155,24 @@ static ssize_t read_mem(struct file *file, char __user *buf,
39969 if (!ptr)
39970 return -EFAULT;
39971
39972- remaining = copy_to_user(buf, ptr, sz);
39973+#ifdef CONFIG_PAX_USERCOPY
39974+ temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
39975+ if (!temp) {
39976+ unxlate_dev_mem_ptr(p, ptr);
39977+ return -ENOMEM;
39978+ }
39979+ remaining = probe_kernel_read(temp, ptr, sz);
39980+#else
39981+ temp = ptr;
39982+#endif
39983+
39984+ if (!remaining)
39985+ remaining = copy_to_user(buf, temp, sz);
39986+
39987+#ifdef CONFIG_PAX_USERCOPY
39988+ kfree(temp);
39989+#endif
39990+
39991 unxlate_dev_mem_ptr(p, ptr);
39992 if (remaining)
39993 return -EFAULT;
39994@@ -380,9 +412,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
39995 size_t count, loff_t *ppos)
39996 {
39997 unsigned long p = *ppos;
39998- ssize_t low_count, read, sz;
39999+ ssize_t low_count, read, sz, err = 0;
40000 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
40001- int err = 0;
40002
40003 read = 0;
40004 if (p < (unsigned long) high_memory) {
40005@@ -404,6 +435,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
40006 }
40007 #endif
40008 while (low_count > 0) {
40009+ char *temp;
40010+
40011 sz = size_inside_page(p, low_count);
40012
40013 /*
40014@@ -413,7 +446,23 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
40015 */
40016 kbuf = xlate_dev_kmem_ptr((void *)p);
40017
40018- if (copy_to_user(buf, kbuf, sz))
40019+#ifdef CONFIG_PAX_USERCOPY
40020+ temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
40021+ if (!temp)
40022+ return -ENOMEM;
40023+ err = probe_kernel_read(temp, kbuf, sz);
40024+#else
40025+ temp = kbuf;
40026+#endif
40027+
40028+ if (!err)
40029+ err = copy_to_user(buf, temp, sz);
40030+
40031+#ifdef CONFIG_PAX_USERCOPY
40032+ kfree(temp);
40033+#endif
40034+
40035+ if (err)
40036 return -EFAULT;
40037 buf += sz;
40038 p += sz;
40039@@ -802,6 +851,9 @@ static const struct memdev {
40040 #ifdef CONFIG_PRINTK
40041 [11] = { "kmsg", 0644, &kmsg_fops, 0 },
40042 #endif
40043+#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
40044+ [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, 0 },
40045+#endif
40046 };
40047
40048 static int memory_open(struct inode *inode, struct file *filp)
40049@@ -863,7 +915,7 @@ static int __init chr_dev_init(void)
40050 continue;
40051
40052 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
40053- NULL, devlist[minor].name);
40054+ NULL, "%s", devlist[minor].name);
40055 }
40056
40057 return tty_init();
40058diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
40059index 9df78e2..01ba9ae 100644
40060--- a/drivers/char/nvram.c
40061+++ b/drivers/char/nvram.c
40062@@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
40063
40064 spin_unlock_irq(&rtc_lock);
40065
40066- if (copy_to_user(buf, contents, tmp - contents))
40067+ if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
40068 return -EFAULT;
40069
40070 *ppos = i;
40071diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
40072index 7680d52..073f799e 100644
40073--- a/drivers/char/pcmcia/synclink_cs.c
40074+++ b/drivers/char/pcmcia/synclink_cs.c
40075@@ -2345,7 +2345,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
40076
40077 if (debug_level >= DEBUG_LEVEL_INFO)
40078 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
40079- __FILE__, __LINE__, info->device_name, port->count);
40080+ __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
40081
40082 if (tty_port_close_start(port, tty, filp) == 0)
40083 goto cleanup;
40084@@ -2363,7 +2363,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
40085 cleanup:
40086 if (debug_level >= DEBUG_LEVEL_INFO)
40087 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
40088- tty->driver->name, port->count);
40089+ tty->driver->name, atomic_read(&port->count));
40090 }
40091
40092 /* Wait until the transmitter is empty.
40093@@ -2505,7 +2505,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
40094
40095 if (debug_level >= DEBUG_LEVEL_INFO)
40096 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
40097- __FILE__, __LINE__, tty->driver->name, port->count);
40098+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
40099
40100 /* If port is closing, signal caller to try again */
40101 if (port->flags & ASYNC_CLOSING){
40102@@ -2525,11 +2525,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
40103 goto cleanup;
40104 }
40105 spin_lock(&port->lock);
40106- port->count++;
40107+ atomic_inc(&port->count);
40108 spin_unlock(&port->lock);
40109 spin_unlock_irqrestore(&info->netlock, flags);
40110
40111- if (port->count == 1) {
40112+ if (atomic_read(&port->count) == 1) {
40113 /* 1st open on this device, init hardware */
40114 retval = startup(info, tty);
40115 if (retval < 0)
40116@@ -3918,7 +3918,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
40117 unsigned short new_crctype;
40118
40119 /* return error if TTY interface open */
40120- if (info->port.count)
40121+ if (atomic_read(&info->port.count))
40122 return -EBUSY;
40123
40124 switch (encoding)
40125@@ -4022,7 +4022,7 @@ static int hdlcdev_open(struct net_device *dev)
40126
40127 /* arbitrate between network and tty opens */
40128 spin_lock_irqsave(&info->netlock, flags);
40129- if (info->port.count != 0 || info->netcount != 0) {
40130+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
40131 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
40132 spin_unlock_irqrestore(&info->netlock, flags);
40133 return -EBUSY;
40134@@ -4112,7 +4112,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40135 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
40136
40137 /* return error if TTY interface open */
40138- if (info->port.count)
40139+ if (atomic_read(&info->port.count))
40140 return -EBUSY;
40141
40142 if (cmd != SIOCWANDEV)
40143diff --git a/drivers/char/random.c b/drivers/char/random.c
40144index d0da5d8..739fd3a 100644
40145--- a/drivers/char/random.c
40146+++ b/drivers/char/random.c
40147@@ -289,9 +289,6 @@
40148 /*
40149 * To allow fractional bits to be tracked, the entropy_count field is
40150 * denominated in units of 1/8th bits.
40151- *
40152- * 2*(ENTROPY_SHIFT + log2(poolbits)) must <= 31, or the multiply in
40153- * credit_entropy_bits() needs to be 64 bits wide.
40154 */
40155 #define ENTROPY_SHIFT 3
40156 #define ENTROPY_BITS(r) ((r)->entropy_count >> ENTROPY_SHIFT)
40157@@ -442,9 +439,9 @@ struct entropy_store {
40158 };
40159
40160 static void push_to_pool(struct work_struct *work);
40161-static __u32 input_pool_data[INPUT_POOL_WORDS];
40162-static __u32 blocking_pool_data[OUTPUT_POOL_WORDS];
40163-static __u32 nonblocking_pool_data[OUTPUT_POOL_WORDS];
40164+static __u32 input_pool_data[INPUT_POOL_WORDS] __latent_entropy;
40165+static __u32 blocking_pool_data[OUTPUT_POOL_WORDS] __latent_entropy;
40166+static __u32 nonblocking_pool_data[OUTPUT_POOL_WORDS] __latent_entropy;
40167
40168 static struct entropy_store input_pool = {
40169 .poolinfo = &poolinfo_table[0],
40170@@ -654,7 +651,7 @@ retry:
40171 /* The +2 corresponds to the /4 in the denominator */
40172
40173 do {
40174- unsigned int anfrac = min(pnfrac, pool_size/2);
40175+ u64 anfrac = min(pnfrac, pool_size/2);
40176 unsigned int add =
40177 ((pool_size - entropy_count)*anfrac*3) >> s;
40178
40179@@ -1227,7 +1224,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
40180
40181 extract_buf(r, tmp);
40182 i = min_t(int, nbytes, EXTRACT_SIZE);
40183- if (copy_to_user(buf, tmp, i)) {
40184+ if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
40185 ret = -EFAULT;
40186 break;
40187 }
40188@@ -1668,7 +1665,7 @@ static char sysctl_bootid[16];
40189 static int proc_do_uuid(struct ctl_table *table, int write,
40190 void __user *buffer, size_t *lenp, loff_t *ppos)
40191 {
40192- struct ctl_table fake_table;
40193+ ctl_table_no_const fake_table;
40194 unsigned char buf[64], tmp_uuid[16], *uuid;
40195
40196 uuid = table->data;
40197@@ -1698,7 +1695,7 @@ static int proc_do_uuid(struct ctl_table *table, int write,
40198 static int proc_do_entropy(struct ctl_table *table, int write,
40199 void __user *buffer, size_t *lenp, loff_t *ppos)
40200 {
40201- struct ctl_table fake_table;
40202+ ctl_table_no_const fake_table;
40203 int entropy_count;
40204
40205 entropy_count = *(int *)table->data >> ENTROPY_SHIFT;
40206diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
40207index e496dae..3db53b6 100644
40208--- a/drivers/char/sonypi.c
40209+++ b/drivers/char/sonypi.c
40210@@ -54,6 +54,7 @@
40211
40212 #include <asm/uaccess.h>
40213 #include <asm/io.h>
40214+#include <asm/local.h>
40215
40216 #include <linux/sonypi.h>
40217
40218@@ -490,7 +491,7 @@ static struct sonypi_device {
40219 spinlock_t fifo_lock;
40220 wait_queue_head_t fifo_proc_list;
40221 struct fasync_struct *fifo_async;
40222- int open_count;
40223+ local_t open_count;
40224 int model;
40225 struct input_dev *input_jog_dev;
40226 struct input_dev *input_key_dev;
40227@@ -892,7 +893,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
40228 static int sonypi_misc_release(struct inode *inode, struct file *file)
40229 {
40230 mutex_lock(&sonypi_device.lock);
40231- sonypi_device.open_count--;
40232+ local_dec(&sonypi_device.open_count);
40233 mutex_unlock(&sonypi_device.lock);
40234 return 0;
40235 }
40236@@ -901,9 +902,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
40237 {
40238 mutex_lock(&sonypi_device.lock);
40239 /* Flush input queue on first open */
40240- if (!sonypi_device.open_count)
40241+ if (!local_read(&sonypi_device.open_count))
40242 kfifo_reset(&sonypi_device.fifo);
40243- sonypi_device.open_count++;
40244+ local_inc(&sonypi_device.open_count);
40245 mutex_unlock(&sonypi_device.lock);
40246
40247 return 0;
40248@@ -1491,7 +1492,7 @@ static struct platform_driver sonypi_driver = {
40249
40250 static struct platform_device *sonypi_platform_device;
40251
40252-static struct dmi_system_id __initdata sonypi_dmi_table[] = {
40253+static const struct dmi_system_id __initconst sonypi_dmi_table[] = {
40254 {
40255 .ident = "Sony Vaio",
40256 .matches = {
40257diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
40258index 565a947..dcdc06e 100644
40259--- a/drivers/char/tpm/tpm_acpi.c
40260+++ b/drivers/char/tpm/tpm_acpi.c
40261@@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
40262 virt = acpi_os_map_iomem(start, len);
40263 if (!virt) {
40264 kfree(log->bios_event_log);
40265+ log->bios_event_log = NULL;
40266 printk("%s: ERROR - Unable to map memory\n", __func__);
40267 return -EIO;
40268 }
40269
40270- memcpy_fromio(log->bios_event_log, virt, len);
40271+ memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
40272
40273 acpi_os_unmap_iomem(virt, len);
40274 return 0;
40275diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
40276index 3a56a13..f8cbd25 100644
40277--- a/drivers/char/tpm/tpm_eventlog.c
40278+++ b/drivers/char/tpm/tpm_eventlog.c
40279@@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
40280 event = addr;
40281
40282 if ((event->event_type == 0 && event->event_size == 0) ||
40283- ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
40284+ (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
40285 return NULL;
40286
40287 return addr;
40288@@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
40289 return NULL;
40290
40291 if ((event->event_type == 0 && event->event_size == 0) ||
40292- ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
40293+ (event->event_size >= limit - v - sizeof(struct tcpa_event)))
40294 return NULL;
40295
40296 (*pos)++;
40297@@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
40298 int i;
40299
40300 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
40301- seq_putc(m, data[i]);
40302+ if (!seq_putc(m, data[i]))
40303+ return -EFAULT;
40304
40305 return 0;
40306 }
40307diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
40308index d2406fe..243951a 100644
40309--- a/drivers/char/virtio_console.c
40310+++ b/drivers/char/virtio_console.c
40311@@ -685,7 +685,7 @@ static ssize_t fill_readbuf(struct port *port, char __user *out_buf,
40312 if (to_user) {
40313 ssize_t ret;
40314
40315- ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
40316+ ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
40317 if (ret)
40318 return -EFAULT;
40319 } else {
40320@@ -789,7 +789,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
40321 if (!port_has_data(port) && !port->host_connected)
40322 return 0;
40323
40324- return fill_readbuf(port, ubuf, count, true);
40325+ return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
40326 }
40327
40328 static int wait_port_writable(struct port *port, bool nonblock)
40329diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
40330index 616f5ae..747bdd0 100644
40331--- a/drivers/clk/clk-composite.c
40332+++ b/drivers/clk/clk-composite.c
40333@@ -197,7 +197,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
40334 struct clk *clk;
40335 struct clk_init_data init;
40336 struct clk_composite *composite;
40337- struct clk_ops *clk_composite_ops;
40338+ clk_ops_no_const *clk_composite_ops;
40339
40340 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
40341 if (!composite)
40342diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h
40343index b775fc2..2d45b64 100644
40344--- a/drivers/clk/samsung/clk.h
40345+++ b/drivers/clk/samsung/clk.h
40346@@ -260,7 +260,7 @@ struct samsung_gate_clock {
40347 #define GATE_DA(_id, dname, cname, pname, o, b, f, gf, a) \
40348 __GATE(_id, dname, cname, pname, o, b, f, gf, a)
40349
40350-#define PNAME(x) static const char *x[] __initdata
40351+#define PNAME(x) static const char * const x[] __initconst
40352
40353 /**
40354 * struct samsung_clk_reg_dump: register dump of clock controller registers.
40355diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
40356index 82449cd..dcfec30 100644
40357--- a/drivers/clk/socfpga/clk-gate.c
40358+++ b/drivers/clk/socfpga/clk-gate.c
40359@@ -22,6 +22,7 @@
40360 #include <linux/mfd/syscon.h>
40361 #include <linux/of.h>
40362 #include <linux/regmap.h>
40363+#include <asm/pgtable.h>
40364
40365 #include "clk.h"
40366
40367@@ -170,7 +171,7 @@ static int socfpga_clk_prepare(struct clk_hw *hwclk)
40368 return 0;
40369 }
40370
40371-static struct clk_ops gateclk_ops = {
40372+static clk_ops_no_const gateclk_ops __read_only = {
40373 .prepare = socfpga_clk_prepare,
40374 .recalc_rate = socfpga_clk_recalc_rate,
40375 .get_parent = socfpga_clk_get_parent,
40376@@ -203,8 +204,10 @@ static void __init __socfpga_gate_init(struct device_node *node,
40377 socfpga_clk->hw.reg = clk_mgr_base_addr + clk_gate[0];
40378 socfpga_clk->hw.bit_idx = clk_gate[1];
40379
40380- gateclk_ops.enable = clk_gate_ops.enable;
40381- gateclk_ops.disable = clk_gate_ops.disable;
40382+ pax_open_kernel();
40383+ *(void **)&gateclk_ops.enable = clk_gate_ops.enable;
40384+ *(void **)&gateclk_ops.disable = clk_gate_ops.disable;
40385+ pax_close_kernel();
40386 }
40387
40388 rc = of_property_read_u32(node, "fixed-divider", &fixed_div);
40389diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
40390index 8f26b52..29f2a3a 100644
40391--- a/drivers/clk/socfpga/clk-pll.c
40392+++ b/drivers/clk/socfpga/clk-pll.c
40393@@ -21,6 +21,7 @@
40394 #include <linux/io.h>
40395 #include <linux/of.h>
40396 #include <linux/of_address.h>
40397+#include <asm/pgtable.h>
40398
40399 #include "clk.h"
40400
40401@@ -76,7 +77,7 @@ static u8 clk_pll_get_parent(struct clk_hw *hwclk)
40402 CLK_MGR_PLL_CLK_SRC_MASK;
40403 }
40404
40405-static struct clk_ops clk_pll_ops = {
40406+static clk_ops_no_const clk_pll_ops __read_only = {
40407 .recalc_rate = clk_pll_recalc_rate,
40408 .get_parent = clk_pll_get_parent,
40409 };
40410@@ -115,8 +116,10 @@ static __init struct clk *__socfpga_pll_init(struct device_node *node,
40411 pll_clk->hw.hw.init = &init;
40412
40413 pll_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
40414- clk_pll_ops.enable = clk_gate_ops.enable;
40415- clk_pll_ops.disable = clk_gate_ops.disable;
40416+ pax_open_kernel();
40417+ *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
40418+ *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
40419+ pax_close_kernel();
40420
40421 clk = clk_register(NULL, &pll_clk->hw.hw);
40422 if (WARN_ON(IS_ERR(clk))) {
40423diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
40424index 7c2a738..0b84bd6 100644
40425--- a/drivers/cpufreq/acpi-cpufreq.c
40426+++ b/drivers/cpufreq/acpi-cpufreq.c
40427@@ -678,8 +678,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
40428 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
40429 per_cpu(acfreq_data, cpu) = data;
40430
40431- if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
40432- acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
40433+ if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
40434+ pax_open_kernel();
40435+ *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
40436+ pax_close_kernel();
40437+ }
40438
40439 result = acpi_processor_register_performance(data->acpi_data, cpu);
40440 if (result)
40441@@ -813,7 +816,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
40442 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
40443 break;
40444 case ACPI_ADR_SPACE_FIXED_HARDWARE:
40445- acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
40446+ pax_open_kernel();
40447+ *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
40448+ pax_close_kernel();
40449 break;
40450 default:
40451 break;
40452@@ -907,8 +912,10 @@ static void __init acpi_cpufreq_boost_init(void)
40453 if (!msrs)
40454 return;
40455
40456- acpi_cpufreq_driver.boost_supported = true;
40457- acpi_cpufreq_driver.boost_enabled = boost_state(0);
40458+ pax_open_kernel();
40459+ *(bool *)&acpi_cpufreq_driver.boost_supported = true;
40460+ *(bool *)&acpi_cpufreq_driver.boost_enabled = boost_state(0);
40461+ pax_close_kernel();
40462
40463 cpu_notifier_register_begin();
40464
40465diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
40466index 99a4065..f97236c 100644
40467--- a/drivers/cpufreq/cpufreq-dt.c
40468+++ b/drivers/cpufreq/cpufreq-dt.c
40469@@ -393,7 +393,9 @@ static int dt_cpufreq_probe(struct platform_device *pdev)
40470 if (!IS_ERR(cpu_reg))
40471 regulator_put(cpu_reg);
40472
40473- dt_cpufreq_driver.driver_data = dev_get_platdata(&pdev->dev);
40474+ pax_open_kernel();
40475+ *(void **)&dt_cpufreq_driver.driver_data = dev_get_platdata(&pdev->dev);
40476+ pax_close_kernel();
40477
40478 ret = cpufreq_register_driver(&dt_cpufreq_driver);
40479 if (ret)
40480diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
40481index 7a3c30c..bac142e 100644
40482--- a/drivers/cpufreq/cpufreq.c
40483+++ b/drivers/cpufreq/cpufreq.c
40484@@ -2197,7 +2197,7 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor)
40485 read_unlock_irqrestore(&cpufreq_driver_lock, flags);
40486
40487 mutex_lock(&cpufreq_governor_mutex);
40488- list_del(&governor->governor_list);
40489+ pax_list_del(&governor->governor_list);
40490 mutex_unlock(&cpufreq_governor_mutex);
40491 return;
40492 }
40493@@ -2412,7 +2412,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
40494 return NOTIFY_OK;
40495 }
40496
40497-static struct notifier_block __refdata cpufreq_cpu_notifier = {
40498+static struct notifier_block cpufreq_cpu_notifier = {
40499 .notifier_call = cpufreq_cpu_callback,
40500 };
40501
40502@@ -2452,13 +2452,17 @@ int cpufreq_boost_trigger_state(int state)
40503 return 0;
40504
40505 write_lock_irqsave(&cpufreq_driver_lock, flags);
40506- cpufreq_driver->boost_enabled = state;
40507+ pax_open_kernel();
40508+ *(bool *)&cpufreq_driver->boost_enabled = state;
40509+ pax_close_kernel();
40510 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
40511
40512 ret = cpufreq_driver->set_boost(state);
40513 if (ret) {
40514 write_lock_irqsave(&cpufreq_driver_lock, flags);
40515- cpufreq_driver->boost_enabled = !state;
40516+ pax_open_kernel();
40517+ *(bool *)&cpufreq_driver->boost_enabled = !state;
40518+ pax_close_kernel();
40519 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
40520
40521 pr_err("%s: Cannot %s BOOST\n",
40522@@ -2523,16 +2527,22 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
40523 cpufreq_driver = driver_data;
40524 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
40525
40526- if (driver_data->setpolicy)
40527- driver_data->flags |= CPUFREQ_CONST_LOOPS;
40528+ if (driver_data->setpolicy) {
40529+ pax_open_kernel();
40530+ *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
40531+ pax_close_kernel();
40532+ }
40533
40534 if (cpufreq_boost_supported()) {
40535 /*
40536 * Check if driver provides function to enable boost -
40537 * if not, use cpufreq_boost_set_sw as default
40538 */
40539- if (!cpufreq_driver->set_boost)
40540- cpufreq_driver->set_boost = cpufreq_boost_set_sw;
40541+ if (!cpufreq_driver->set_boost) {
40542+ pax_open_kernel();
40543+ *(void **)&cpufreq_driver->set_boost = cpufreq_boost_set_sw;
40544+ pax_close_kernel();
40545+ }
40546
40547 ret = cpufreq_sysfs_create_file(&boost.attr);
40548 if (ret) {
40549diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
40550index 57a39f8..feb9c73 100644
40551--- a/drivers/cpufreq/cpufreq_governor.c
40552+++ b/drivers/cpufreq/cpufreq_governor.c
40553@@ -378,7 +378,7 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy,
40554 cs_dbs_info->enable = 1;
40555 cs_dbs_info->requested_freq = policy->cur;
40556 } else {
40557- struct od_ops *od_ops = cdata->gov_ops;
40558+ const struct od_ops *od_ops = cdata->gov_ops;
40559 struct od_cpu_dbs_info_s *od_dbs_info = cdata->get_cpu_dbs_info_s(cpu);
40560
40561 od_dbs_info->rate_mult = 1;
40562diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
40563index 34736f5..da8cf4a 100644
40564--- a/drivers/cpufreq/cpufreq_governor.h
40565+++ b/drivers/cpufreq/cpufreq_governor.h
40566@@ -212,7 +212,7 @@ struct common_dbs_data {
40567 void (*exit)(struct dbs_data *dbs_data, bool notify);
40568
40569 /* Governor specific ops, see below */
40570- void *gov_ops;
40571+ const void *gov_ops;
40572
40573 /*
40574 * Protects governor's data (struct dbs_data and struct common_dbs_data)
40575@@ -234,7 +234,7 @@ struct od_ops {
40576 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
40577 unsigned int freq_next, unsigned int relation);
40578 void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq);
40579-};
40580+} __no_const;
40581
40582 static inline int delay_for_sampling_rate(unsigned int sampling_rate)
40583 {
40584diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
40585index 3c1e10f..02f17af 100644
40586--- a/drivers/cpufreq/cpufreq_ondemand.c
40587+++ b/drivers/cpufreq/cpufreq_ondemand.c
40588@@ -523,7 +523,7 @@ static void od_exit(struct dbs_data *dbs_data, bool notify)
40589
40590 define_get_cpu_dbs_routines(od_cpu_dbs_info);
40591
40592-static struct od_ops od_ops = {
40593+static struct od_ops od_ops __read_only = {
40594 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
40595 .powersave_bias_target = generic_powersave_bias_target,
40596 .freq_increase = dbs_freq_increase,
40597@@ -579,14 +579,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
40598 (struct cpufreq_policy *, unsigned int, unsigned int),
40599 unsigned int powersave_bias)
40600 {
40601- od_ops.powersave_bias_target = f;
40602+ pax_open_kernel();
40603+ *(void **)&od_ops.powersave_bias_target = f;
40604+ pax_close_kernel();
40605 od_set_powersave_bias(powersave_bias);
40606 }
40607 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
40608
40609 void od_unregister_powersave_bias_handler(void)
40610 {
40611- od_ops.powersave_bias_target = generic_powersave_bias_target;
40612+ pax_open_kernel();
40613+ *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
40614+ pax_close_kernel();
40615 od_set_powersave_bias(0);
40616 }
40617 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
40618diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
40619index fcb929e..e628818 100644
40620--- a/drivers/cpufreq/intel_pstate.c
40621+++ b/drivers/cpufreq/intel_pstate.c
40622@@ -137,10 +137,10 @@ struct pstate_funcs {
40623 struct cpu_defaults {
40624 struct pstate_adjust_policy pid_policy;
40625 struct pstate_funcs funcs;
40626-};
40627+} __do_const;
40628
40629 static struct pstate_adjust_policy pid_params;
40630-static struct pstate_funcs pstate_funcs;
40631+static struct pstate_funcs *pstate_funcs;
40632 static int hwp_active;
40633
40634 struct perf_limits {
40635@@ -726,18 +726,18 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate, bool force)
40636
40637 cpu->pstate.current_pstate = pstate;
40638
40639- pstate_funcs.set(cpu, pstate);
40640+ pstate_funcs->set(cpu, pstate);
40641 }
40642
40643 static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
40644 {
40645- cpu->pstate.min_pstate = pstate_funcs.get_min();
40646- cpu->pstate.max_pstate = pstate_funcs.get_max();
40647- cpu->pstate.turbo_pstate = pstate_funcs.get_turbo();
40648- cpu->pstate.scaling = pstate_funcs.get_scaling();
40649+ cpu->pstate.min_pstate = pstate_funcs->get_min();
40650+ cpu->pstate.max_pstate = pstate_funcs->get_max();
40651+ cpu->pstate.turbo_pstate = pstate_funcs->get_turbo();
40652+ cpu->pstate.scaling = pstate_funcs->get_scaling();
40653
40654- if (pstate_funcs.get_vid)
40655- pstate_funcs.get_vid(cpu);
40656+ if (pstate_funcs->get_vid)
40657+ pstate_funcs->get_vid(cpu);
40658 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate, false);
40659 }
40660
40661@@ -1070,15 +1070,15 @@ static unsigned int force_load;
40662
40663 static int intel_pstate_msrs_not_valid(void)
40664 {
40665- if (!pstate_funcs.get_max() ||
40666- !pstate_funcs.get_min() ||
40667- !pstate_funcs.get_turbo())
40668+ if (!pstate_funcs->get_max() ||
40669+ !pstate_funcs->get_min() ||
40670+ !pstate_funcs->get_turbo())
40671 return -ENODEV;
40672
40673 return 0;
40674 }
40675
40676-static void copy_pid_params(struct pstate_adjust_policy *policy)
40677+static void copy_pid_params(const struct pstate_adjust_policy *policy)
40678 {
40679 pid_params.sample_rate_ms = policy->sample_rate_ms;
40680 pid_params.p_gain_pct = policy->p_gain_pct;
40681@@ -1090,12 +1090,7 @@ static void copy_pid_params(struct pstate_adjust_policy *policy)
40682
40683 static void copy_cpu_funcs(struct pstate_funcs *funcs)
40684 {
40685- pstate_funcs.get_max = funcs->get_max;
40686- pstate_funcs.get_min = funcs->get_min;
40687- pstate_funcs.get_turbo = funcs->get_turbo;
40688- pstate_funcs.get_scaling = funcs->get_scaling;
40689- pstate_funcs.set = funcs->set;
40690- pstate_funcs.get_vid = funcs->get_vid;
40691+ pstate_funcs = funcs;
40692 }
40693
40694 #if IS_ENABLED(CONFIG_ACPI)
40695diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
40696index 5dd95da..abc3837 100644
40697--- a/drivers/cpufreq/p4-clockmod.c
40698+++ b/drivers/cpufreq/p4-clockmod.c
40699@@ -134,10 +134,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
40700 case 0x0F: /* Core Duo */
40701 case 0x16: /* Celeron Core */
40702 case 0x1C: /* Atom */
40703- p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40704+ pax_open_kernel();
40705+ *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40706+ pax_close_kernel();
40707 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
40708 case 0x0D: /* Pentium M (Dothan) */
40709- p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40710+ pax_open_kernel();
40711+ *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40712+ pax_close_kernel();
40713 /* fall through */
40714 case 0x09: /* Pentium M (Banias) */
40715 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
40716@@ -149,7 +153,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
40717
40718 /* on P-4s, the TSC runs with constant frequency independent whether
40719 * throttling is active or not. */
40720- p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40721+ pax_open_kernel();
40722+ *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40723+ pax_close_kernel();
40724
40725 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
40726 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
40727diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
40728index 9bb42ba..b01b4a2 100644
40729--- a/drivers/cpufreq/sparc-us3-cpufreq.c
40730+++ b/drivers/cpufreq/sparc-us3-cpufreq.c
40731@@ -18,14 +18,12 @@
40732 #include <asm/head.h>
40733 #include <asm/timer.h>
40734
40735-static struct cpufreq_driver *cpufreq_us3_driver;
40736-
40737 struct us3_freq_percpu_info {
40738 struct cpufreq_frequency_table table[4];
40739 };
40740
40741 /* Indexed by cpu number. */
40742-static struct us3_freq_percpu_info *us3_freq_table;
40743+static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
40744
40745 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
40746 * in the Safari config register.
40747@@ -156,16 +154,27 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
40748
40749 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
40750 {
40751- if (cpufreq_us3_driver)
40752- us3_freq_target(policy, 0);
40753+ us3_freq_target(policy, 0);
40754
40755 return 0;
40756 }
40757
40758+static int __init us3_freq_init(void);
40759+static void __exit us3_freq_exit(void);
40760+
40761+static struct cpufreq_driver cpufreq_us3_driver = {
40762+ .init = us3_freq_cpu_init,
40763+ .verify = cpufreq_generic_frequency_table_verify,
40764+ .target_index = us3_freq_target,
40765+ .get = us3_freq_get,
40766+ .exit = us3_freq_cpu_exit,
40767+ .name = "UltraSPARC-III",
40768+
40769+};
40770+
40771 static int __init us3_freq_init(void)
40772 {
40773 unsigned long manuf, impl, ver;
40774- int ret;
40775
40776 if (tlb_type != cheetah && tlb_type != cheetah_plus)
40777 return -ENODEV;
40778@@ -178,55 +187,15 @@ static int __init us3_freq_init(void)
40779 (impl == CHEETAH_IMPL ||
40780 impl == CHEETAH_PLUS_IMPL ||
40781 impl == JAGUAR_IMPL ||
40782- impl == PANTHER_IMPL)) {
40783- struct cpufreq_driver *driver;
40784-
40785- ret = -ENOMEM;
40786- driver = kzalloc(sizeof(*driver), GFP_KERNEL);
40787- if (!driver)
40788- goto err_out;
40789-
40790- us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)),
40791- GFP_KERNEL);
40792- if (!us3_freq_table)
40793- goto err_out;
40794-
40795- driver->init = us3_freq_cpu_init;
40796- driver->verify = cpufreq_generic_frequency_table_verify;
40797- driver->target_index = us3_freq_target;
40798- driver->get = us3_freq_get;
40799- driver->exit = us3_freq_cpu_exit;
40800- strcpy(driver->name, "UltraSPARC-III");
40801-
40802- cpufreq_us3_driver = driver;
40803- ret = cpufreq_register_driver(driver);
40804- if (ret)
40805- goto err_out;
40806-
40807- return 0;
40808-
40809-err_out:
40810- if (driver) {
40811- kfree(driver);
40812- cpufreq_us3_driver = NULL;
40813- }
40814- kfree(us3_freq_table);
40815- us3_freq_table = NULL;
40816- return ret;
40817- }
40818+ impl == PANTHER_IMPL))
40819+ return cpufreq_register_driver(&cpufreq_us3_driver);
40820
40821 return -ENODEV;
40822 }
40823
40824 static void __exit us3_freq_exit(void)
40825 {
40826- if (cpufreq_us3_driver) {
40827- cpufreq_unregister_driver(cpufreq_us3_driver);
40828- kfree(cpufreq_us3_driver);
40829- cpufreq_us3_driver = NULL;
40830- kfree(us3_freq_table);
40831- us3_freq_table = NULL;
40832- }
40833+ cpufreq_unregister_driver(&cpufreq_us3_driver);
40834 }
40835
40836 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
40837diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
40838index 7d4a315..21bb886 100644
40839--- a/drivers/cpufreq/speedstep-centrino.c
40840+++ b/drivers/cpufreq/speedstep-centrino.c
40841@@ -351,8 +351,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
40842 !cpu_has(cpu, X86_FEATURE_EST))
40843 return -ENODEV;
40844
40845- if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
40846- centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
40847+ if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
40848+ pax_open_kernel();
40849+ *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
40850+ pax_close_kernel();
40851+ }
40852
40853 if (policy->cpu != 0)
40854 return -ENODEV;
40855diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
40856index 5db1478..e90e25e 100644
40857--- a/drivers/cpuidle/driver.c
40858+++ b/drivers/cpuidle/driver.c
40859@@ -193,7 +193,7 @@ static int poll_idle(struct cpuidle_device *dev,
40860
40861 static void poll_idle_init(struct cpuidle_driver *drv)
40862 {
40863- struct cpuidle_state *state = &drv->states[0];
40864+ cpuidle_state_no_const *state = &drv->states[0];
40865
40866 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
40867 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
40868diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c
40869index a5c111b..1113002 100644
40870--- a/drivers/cpuidle/dt_idle_states.c
40871+++ b/drivers/cpuidle/dt_idle_states.c
40872@@ -21,7 +21,7 @@
40873
40874 #include "dt_idle_states.h"
40875
40876-static int init_state_node(struct cpuidle_state *idle_state,
40877+static int init_state_node(cpuidle_state_no_const *idle_state,
40878 const struct of_device_id *matches,
40879 struct device_node *state_node)
40880 {
40881diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
40882index fb9f511..213e6cc 100644
40883--- a/drivers/cpuidle/governor.c
40884+++ b/drivers/cpuidle/governor.c
40885@@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
40886 mutex_lock(&cpuidle_lock);
40887 if (__cpuidle_find_governor(gov->name) == NULL) {
40888 ret = 0;
40889- list_add_tail(&gov->governor_list, &cpuidle_governors);
40890+ pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
40891 if (!cpuidle_curr_governor ||
40892 cpuidle_curr_governor->rating < gov->rating)
40893 cpuidle_switch_governor(gov);
40894diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
40895index 832a2c3..1794080 100644
40896--- a/drivers/cpuidle/sysfs.c
40897+++ b/drivers/cpuidle/sysfs.c
40898@@ -135,7 +135,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
40899 NULL
40900 };
40901
40902-static struct attribute_group cpuidle_attr_group = {
40903+static attribute_group_no_const cpuidle_attr_group = {
40904 .attrs = cpuidle_default_attrs,
40905 .name = "cpuidle",
40906 };
40907diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
40908index 8d2a772..33826c9 100644
40909--- a/drivers/crypto/hifn_795x.c
40910+++ b/drivers/crypto/hifn_795x.c
40911@@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
40912 MODULE_PARM_DESC(hifn_pll_ref,
40913 "PLL reference clock (pci[freq] or ext[freq], default ext)");
40914
40915-static atomic_t hifn_dev_number;
40916+static atomic_unchecked_t hifn_dev_number;
40917
40918 #define ACRYPTO_OP_DECRYPT 0
40919 #define ACRYPTO_OP_ENCRYPT 1
40920@@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
40921 goto err_out_disable_pci_device;
40922
40923 snprintf(name, sizeof(name), "hifn%d",
40924- atomic_inc_return(&hifn_dev_number)-1);
40925+ atomic_inc_return_unchecked(&hifn_dev_number)-1);
40926
40927 err = pci_request_regions(pdev, name);
40928 if (err)
40929diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
40930index ca1b362..01cae6a 100644
40931--- a/drivers/devfreq/devfreq.c
40932+++ b/drivers/devfreq/devfreq.c
40933@@ -672,7 +672,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
40934 goto err_out;
40935 }
40936
40937- list_add(&governor->node, &devfreq_governor_list);
40938+ pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
40939
40940 list_for_each_entry(devfreq, &devfreq_list, node) {
40941 int ret = 0;
40942@@ -760,7 +760,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
40943 }
40944 }
40945
40946- list_del(&governor->node);
40947+ pax_list_del((struct list_head *)&governor->node);
40948 err_out:
40949 mutex_unlock(&devfreq_list_lock);
40950
40951diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
40952index 10fcaba..326f709 100644
40953--- a/drivers/dma/sh/shdma-base.c
40954+++ b/drivers/dma/sh/shdma-base.c
40955@@ -227,8 +227,8 @@ static int shdma_alloc_chan_resources(struct dma_chan *chan)
40956 schan->slave_id = -EINVAL;
40957 }
40958
40959- schan->desc = kcalloc(NR_DESCS_PER_CHANNEL,
40960- sdev->desc_size, GFP_KERNEL);
40961+ schan->desc = kcalloc(sdev->desc_size,
40962+ NR_DESCS_PER_CHANNEL, GFP_KERNEL);
40963 if (!schan->desc) {
40964 ret = -ENOMEM;
40965 goto edescalloc;
40966diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
40967index 11707df..2ea96f7 100644
40968--- a/drivers/dma/sh/shdmac.c
40969+++ b/drivers/dma/sh/shdmac.c
40970@@ -513,7 +513,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
40971 return ret;
40972 }
40973
40974-static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
40975+static struct notifier_block sh_dmae_nmi_notifier = {
40976 .notifier_call = sh_dmae_nmi_handler,
40977
40978 /* Run before NMI debug handler and KGDB */
40979diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
40980index 592af5f..bb1d583 100644
40981--- a/drivers/edac/edac_device.c
40982+++ b/drivers/edac/edac_device.c
40983@@ -477,9 +477,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
40984 */
40985 int edac_device_alloc_index(void)
40986 {
40987- static atomic_t device_indexes = ATOMIC_INIT(0);
40988+ static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
40989
40990- return atomic_inc_return(&device_indexes) - 1;
40991+ return atomic_inc_return_unchecked(&device_indexes) - 1;
40992 }
40993 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
40994
40995diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
40996index 33df7d9..0794989 100644
40997--- a/drivers/edac/edac_mc_sysfs.c
40998+++ b/drivers/edac/edac_mc_sysfs.c
40999@@ -154,7 +154,7 @@ static const char * const edac_caps[] = {
41000 struct dev_ch_attribute {
41001 struct device_attribute attr;
41002 int channel;
41003-};
41004+} __do_const;
41005
41006 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
41007 static struct dev_ch_attribute dev_attr_legacy_##_name = \
41008diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
41009index 2cf44b4d..6dd2dc7 100644
41010--- a/drivers/edac/edac_pci.c
41011+++ b/drivers/edac/edac_pci.c
41012@@ -29,7 +29,7 @@
41013
41014 static DEFINE_MUTEX(edac_pci_ctls_mutex);
41015 static LIST_HEAD(edac_pci_list);
41016-static atomic_t pci_indexes = ATOMIC_INIT(0);
41017+static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
41018
41019 /*
41020 * edac_pci_alloc_ctl_info
41021@@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
41022 */
41023 int edac_pci_alloc_index(void)
41024 {
41025- return atomic_inc_return(&pci_indexes) - 1;
41026+ return atomic_inc_return_unchecked(&pci_indexes) - 1;
41027 }
41028 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
41029
41030diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
41031index 24d877f..4e30133 100644
41032--- a/drivers/edac/edac_pci_sysfs.c
41033+++ b/drivers/edac/edac_pci_sysfs.c
41034@@ -23,8 +23,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
41035 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
41036 static int edac_pci_poll_msec = 1000; /* one second workq period */
41037
41038-static atomic_t pci_parity_count = ATOMIC_INIT(0);
41039-static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
41040+static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
41041+static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
41042
41043 static struct kobject *edac_pci_top_main_kobj;
41044 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
41045@@ -232,7 +232,7 @@ struct edac_pci_dev_attribute {
41046 void *value;
41047 ssize_t(*show) (void *, char *);
41048 ssize_t(*store) (void *, const char *, size_t);
41049-};
41050+} __do_const;
41051
41052 /* Set of show/store abstract level functions for PCI Parity object */
41053 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
41054@@ -576,7 +576,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41055 edac_printk(KERN_CRIT, EDAC_PCI,
41056 "Signaled System Error on %s\n",
41057 pci_name(dev));
41058- atomic_inc(&pci_nonparity_count);
41059+ atomic_inc_unchecked(&pci_nonparity_count);
41060 }
41061
41062 if (status & (PCI_STATUS_PARITY)) {
41063@@ -584,7 +584,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41064 "Master Data Parity Error on %s\n",
41065 pci_name(dev));
41066
41067- atomic_inc(&pci_parity_count);
41068+ atomic_inc_unchecked(&pci_parity_count);
41069 }
41070
41071 if (status & (PCI_STATUS_DETECTED_PARITY)) {
41072@@ -592,7 +592,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41073 "Detected Parity Error on %s\n",
41074 pci_name(dev));
41075
41076- atomic_inc(&pci_parity_count);
41077+ atomic_inc_unchecked(&pci_parity_count);
41078 }
41079 }
41080
41081@@ -615,7 +615,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41082 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
41083 "Signaled System Error on %s\n",
41084 pci_name(dev));
41085- atomic_inc(&pci_nonparity_count);
41086+ atomic_inc_unchecked(&pci_nonparity_count);
41087 }
41088
41089 if (status & (PCI_STATUS_PARITY)) {
41090@@ -623,7 +623,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41091 "Master Data Parity Error on "
41092 "%s\n", pci_name(dev));
41093
41094- atomic_inc(&pci_parity_count);
41095+ atomic_inc_unchecked(&pci_parity_count);
41096 }
41097
41098 if (status & (PCI_STATUS_DETECTED_PARITY)) {
41099@@ -631,7 +631,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41100 "Detected Parity Error on %s\n",
41101 pci_name(dev));
41102
41103- atomic_inc(&pci_parity_count);
41104+ atomic_inc_unchecked(&pci_parity_count);
41105 }
41106 }
41107 }
41108@@ -669,7 +669,7 @@ void edac_pci_do_parity_check(void)
41109 if (!check_pci_errors)
41110 return;
41111
41112- before_count = atomic_read(&pci_parity_count);
41113+ before_count = atomic_read_unchecked(&pci_parity_count);
41114
41115 /* scan all PCI devices looking for a Parity Error on devices and
41116 * bridges.
41117@@ -681,7 +681,7 @@ void edac_pci_do_parity_check(void)
41118 /* Only if operator has selected panic on PCI Error */
41119 if (edac_pci_get_panic_on_pe()) {
41120 /* If the count is different 'after' from 'before' */
41121- if (before_count != atomic_read(&pci_parity_count))
41122+ if (before_count != atomic_read_unchecked(&pci_parity_count))
41123 panic("EDAC: PCI Parity Error");
41124 }
41125 }
41126diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
41127index c2359a1..8bd119d 100644
41128--- a/drivers/edac/mce_amd.h
41129+++ b/drivers/edac/mce_amd.h
41130@@ -74,7 +74,7 @@ struct amd_decoder_ops {
41131 bool (*mc0_mce)(u16, u8);
41132 bool (*mc1_mce)(u16, u8);
41133 bool (*mc2_mce)(u16, u8);
41134-};
41135+} __no_const;
41136
41137 void amd_report_gart_errors(bool);
41138 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
41139diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
41140index 57ea7f4..af06b76 100644
41141--- a/drivers/firewire/core-card.c
41142+++ b/drivers/firewire/core-card.c
41143@@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
41144 const struct fw_card_driver *driver,
41145 struct device *device)
41146 {
41147- static atomic_t index = ATOMIC_INIT(-1);
41148+ static atomic_unchecked_t index = ATOMIC_INIT(-1);
41149
41150- card->index = atomic_inc_return(&index);
41151+ card->index = atomic_inc_return_unchecked(&index);
41152 card->driver = driver;
41153 card->device = device;
41154 card->current_tlabel = 0;
41155@@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
41156
41157 void fw_core_remove_card(struct fw_card *card)
41158 {
41159- struct fw_card_driver dummy_driver = dummy_driver_template;
41160+ fw_card_driver_no_const dummy_driver = dummy_driver_template;
41161
41162 card->driver->update_phy_reg(card, 4,
41163 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
41164diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
41165index f9e3aee..269dbdb 100644
41166--- a/drivers/firewire/core-device.c
41167+++ b/drivers/firewire/core-device.c
41168@@ -256,7 +256,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
41169 struct config_rom_attribute {
41170 struct device_attribute attr;
41171 u32 key;
41172-};
41173+} __do_const;
41174
41175 static ssize_t show_immediate(struct device *dev,
41176 struct device_attribute *dattr, char *buf)
41177diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
41178index d6a09b9..18e90dd 100644
41179--- a/drivers/firewire/core-transaction.c
41180+++ b/drivers/firewire/core-transaction.c
41181@@ -38,6 +38,7 @@
41182 #include <linux/timer.h>
41183 #include <linux/types.h>
41184 #include <linux/workqueue.h>
41185+#include <linux/sched.h>
41186
41187 #include <asm/byteorder.h>
41188
41189diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
41190index e1480ff6..1a429bd 100644
41191--- a/drivers/firewire/core.h
41192+++ b/drivers/firewire/core.h
41193@@ -111,6 +111,7 @@ struct fw_card_driver {
41194
41195 int (*stop_iso)(struct fw_iso_context *ctx);
41196 };
41197+typedef struct fw_card_driver __no_const fw_card_driver_no_const;
41198
41199 void fw_card_initialize(struct fw_card *card,
41200 const struct fw_card_driver *driver, struct device *device);
41201diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
41202index f51d376..b118e40 100644
41203--- a/drivers/firewire/ohci.c
41204+++ b/drivers/firewire/ohci.c
41205@@ -2049,10 +2049,12 @@ static void bus_reset_work(struct work_struct *work)
41206 be32_to_cpu(ohci->next_header));
41207 }
41208
41209+#ifndef CONFIG_GRKERNSEC
41210 if (param_remote_dma) {
41211 reg_write(ohci, OHCI1394_PhyReqFilterHiSet, ~0);
41212 reg_write(ohci, OHCI1394_PhyReqFilterLoSet, ~0);
41213 }
41214+#endif
41215
41216 spin_unlock_irq(&ohci->lock);
41217
41218@@ -2584,8 +2586,10 @@ static int ohci_enable_phys_dma(struct fw_card *card,
41219 unsigned long flags;
41220 int n, ret = 0;
41221
41222+#ifndef CONFIG_GRKERNSEC
41223 if (param_remote_dma)
41224 return 0;
41225+#endif
41226
41227 /*
41228 * FIXME: Make sure this bitmask is cleared when we clear the busReset
41229diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
41230index 94a58a0..f5eba42 100644
41231--- a/drivers/firmware/dmi-id.c
41232+++ b/drivers/firmware/dmi-id.c
41233@@ -16,7 +16,7 @@
41234 struct dmi_device_attribute{
41235 struct device_attribute dev_attr;
41236 int field;
41237-};
41238+} __do_const;
41239 #define to_dmi_dev_attr(_dev_attr) \
41240 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
41241
41242diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
41243index ac1ce4a..321745e 100644
41244--- a/drivers/firmware/dmi_scan.c
41245+++ b/drivers/firmware/dmi_scan.c
41246@@ -690,14 +690,18 @@ static int __init dmi_init(void)
41247 if (!dmi_table)
41248 goto err_tables;
41249
41250- bin_attr_smbios_entry_point.size = smbios_entry_point_size;
41251- bin_attr_smbios_entry_point.private = smbios_entry_point;
41252+ pax_open_kernel();
41253+ *(size_t *)&bin_attr_smbios_entry_point.size = smbios_entry_point_size;
41254+ *(void **)&bin_attr_smbios_entry_point.private = smbios_entry_point;
41255+ pax_close_kernel();
41256 ret = sysfs_create_bin_file(tables_kobj, &bin_attr_smbios_entry_point);
41257 if (ret)
41258 goto err_unmap;
41259
41260- bin_attr_DMI.size = dmi_len;
41261- bin_attr_DMI.private = dmi_table;
41262+ pax_open_kernel();
41263+ *(size_t *)&bin_attr_DMI.size = dmi_len;
41264+ *(void **)&bin_attr_DMI.private = dmi_table;
41265+ pax_close_kernel();
41266 ret = sysfs_create_bin_file(tables_kobj, &bin_attr_DMI);
41267 if (!ret)
41268 return 0;
41269diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
41270index d425374..1da1716 100644
41271--- a/drivers/firmware/efi/cper.c
41272+++ b/drivers/firmware/efi/cper.c
41273@@ -44,12 +44,12 @@ static char rcd_decode_str[CPER_REC_LEN];
41274 */
41275 u64 cper_next_record_id(void)
41276 {
41277- static atomic64_t seq;
41278+ static atomic64_unchecked_t seq;
41279
41280- if (!atomic64_read(&seq))
41281- atomic64_set(&seq, ((u64)get_seconds()) << 32);
41282+ if (!atomic64_read_unchecked(&seq))
41283+ atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
41284
41285- return atomic64_inc_return(&seq);
41286+ return atomic64_inc_return_unchecked(&seq);
41287 }
41288 EXPORT_SYMBOL_GPL(cper_next_record_id);
41289
41290diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
41291index d6144e3..23f9686 100644
41292--- a/drivers/firmware/efi/efi.c
41293+++ b/drivers/firmware/efi/efi.c
41294@@ -170,14 +170,16 @@ static struct attribute_group efi_subsys_attr_group = {
41295 };
41296
41297 static struct efivars generic_efivars;
41298-static struct efivar_operations generic_ops;
41299+static efivar_operations_no_const generic_ops __read_only;
41300
41301 static int generic_ops_register(void)
41302 {
41303- generic_ops.get_variable = efi.get_variable;
41304- generic_ops.set_variable = efi.set_variable;
41305- generic_ops.get_next_variable = efi.get_next_variable;
41306- generic_ops.query_variable_store = efi_query_variable_store;
41307+ pax_open_kernel();
41308+ *(void **)&generic_ops.get_variable = efi.get_variable;
41309+ *(void **)&generic_ops.set_variable = efi.set_variable;
41310+ *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
41311+ *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
41312+ pax_close_kernel();
41313
41314 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
41315 }
41316diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
41317index 756eca8..2336d08 100644
41318--- a/drivers/firmware/efi/efivars.c
41319+++ b/drivers/firmware/efi/efivars.c
41320@@ -590,7 +590,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
41321 static int
41322 create_efivars_bin_attributes(void)
41323 {
41324- struct bin_attribute *attr;
41325+ bin_attribute_no_const *attr;
41326 int error;
41327
41328 /* new_var */
41329diff --git a/drivers/firmware/efi/runtime-map.c b/drivers/firmware/efi/runtime-map.c
41330index 5c55227..97f4978 100644
41331--- a/drivers/firmware/efi/runtime-map.c
41332+++ b/drivers/firmware/efi/runtime-map.c
41333@@ -97,7 +97,7 @@ static void map_release(struct kobject *kobj)
41334 kfree(entry);
41335 }
41336
41337-static struct kobj_type __refdata map_ktype = {
41338+static const struct kobj_type __refconst map_ktype = {
41339 .sysfs_ops = &map_attr_ops,
41340 .default_attrs = def_attrs,
41341 .release = map_release,
41342diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
41343index f1ab05e..ab51228 100644
41344--- a/drivers/firmware/google/gsmi.c
41345+++ b/drivers/firmware/google/gsmi.c
41346@@ -709,7 +709,7 @@ static u32 __init hash_oem_table_id(char s[8])
41347 return local_hash_64(input, 32);
41348 }
41349
41350-static struct dmi_system_id gsmi_dmi_table[] __initdata = {
41351+static const struct dmi_system_id gsmi_dmi_table[] __initconst = {
41352 {
41353 .ident = "Google Board",
41354 .matches = {
41355diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
41356index 2f569aa..26e4f39 100644
41357--- a/drivers/firmware/google/memconsole.c
41358+++ b/drivers/firmware/google/memconsole.c
41359@@ -136,7 +136,7 @@ static bool __init found_memconsole(void)
41360 return false;
41361 }
41362
41363-static struct dmi_system_id memconsole_dmi_table[] __initdata = {
41364+static const struct dmi_system_id memconsole_dmi_table[] __initconst = {
41365 {
41366 .ident = "Google Board",
41367 .matches = {
41368@@ -155,7 +155,10 @@ static int __init memconsole_init(void)
41369 if (!found_memconsole())
41370 return -ENODEV;
41371
41372- memconsole_bin_attr.size = memconsole_length;
41373+ pax_open_kernel();
41374+ *(size_t *)&memconsole_bin_attr.size = memconsole_length;
41375+ pax_close_kernel();
41376+
41377 return sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
41378 }
41379
41380diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
41381index 5de3ed2..d839c56 100644
41382--- a/drivers/firmware/memmap.c
41383+++ b/drivers/firmware/memmap.c
41384@@ -124,7 +124,7 @@ static void __meminit release_firmware_map_entry(struct kobject *kobj)
41385 kfree(entry);
41386 }
41387
41388-static struct kobj_type __refdata memmap_ktype = {
41389+static const struct kobj_type __refconst memmap_ktype = {
41390 .release = release_firmware_map_entry,
41391 .sysfs_ops = &memmap_attr_ops,
41392 .default_attrs = def_attrs,
41393diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
41394index c246ac3..6867ca6 100644
41395--- a/drivers/gpio/gpio-davinci.c
41396+++ b/drivers/gpio/gpio-davinci.c
41397@@ -442,9 +442,9 @@ static struct irq_chip *davinci_gpio_get_irq_chip(unsigned int irq)
41398 return &gpio_unbanked.chip;
41399 };
41400
41401-static struct irq_chip *keystone_gpio_get_irq_chip(unsigned int irq)
41402+static irq_chip_no_const *keystone_gpio_get_irq_chip(unsigned int irq)
41403 {
41404- static struct irq_chip gpio_unbanked;
41405+ static irq_chip_no_const gpio_unbanked;
41406
41407 gpio_unbanked = *irq_get_chip(irq);
41408 return &gpio_unbanked;
41409@@ -474,7 +474,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
41410 struct davinci_gpio_regs __iomem *g;
41411 struct irq_domain *irq_domain = NULL;
41412 const struct of_device_id *match;
41413- struct irq_chip *irq_chip;
41414+ irq_chip_no_const *irq_chip;
41415 gpio_get_irq_chip_cb_t gpio_get_irq_chip;
41416
41417 /*
41418diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c
41419index fbf2873..0a37114 100644
41420--- a/drivers/gpio/gpio-em.c
41421+++ b/drivers/gpio/gpio-em.c
41422@@ -278,7 +278,7 @@ static int em_gio_probe(struct platform_device *pdev)
41423 struct em_gio_priv *p;
41424 struct resource *io[2], *irq[2];
41425 struct gpio_chip *gpio_chip;
41426- struct irq_chip *irq_chip;
41427+ irq_chip_no_const *irq_chip;
41428 const char *name = dev_name(&pdev->dev);
41429 int ret;
41430
41431diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
41432index 4ba7ed5..1536b5d 100644
41433--- a/drivers/gpio/gpio-ich.c
41434+++ b/drivers/gpio/gpio-ich.c
41435@@ -94,7 +94,7 @@ struct ichx_desc {
41436 * this option allows driver caching written output values
41437 */
41438 bool use_outlvl_cache;
41439-};
41440+} __do_const;
41441
41442 static struct {
41443 spinlock_t lock;
41444diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
41445index 61a731f..d5ca6cb 100644
41446--- a/drivers/gpio/gpio-omap.c
41447+++ b/drivers/gpio/gpio-omap.c
41448@@ -1067,7 +1067,7 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)
41449 dev_err(bank->dev, "Could not get gpio dbck\n");
41450 }
41451
41452-static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
41453+static int omap_gpio_chip_init(struct gpio_bank *bank, irq_chip_no_const *irqc)
41454 {
41455 static int gpio;
41456 int irq_base = 0;
41457@@ -1150,7 +1150,7 @@ static int omap_gpio_probe(struct platform_device *pdev)
41458 const struct omap_gpio_platform_data *pdata;
41459 struct resource *res;
41460 struct gpio_bank *bank;
41461- struct irq_chip *irqc;
41462+ irq_chip_no_const *irqc;
41463 int ret;
41464
41465 match = of_match_device(of_match_ptr(omap_gpio_match), dev);
41466diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
41467index 1e14a6c..0442450 100644
41468--- a/drivers/gpio/gpio-rcar.c
41469+++ b/drivers/gpio/gpio-rcar.c
41470@@ -379,7 +379,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
41471 struct gpio_rcar_priv *p;
41472 struct resource *io, *irq;
41473 struct gpio_chip *gpio_chip;
41474- struct irq_chip *irq_chip;
41475+ irq_chip_no_const *irq_chip;
41476 struct device *dev = &pdev->dev;
41477 const char *name = dev_name(dev);
41478 int ret;
41479diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
41480index c1caa45..f0f97d2 100644
41481--- a/drivers/gpio/gpio-vr41xx.c
41482+++ b/drivers/gpio/gpio-vr41xx.c
41483@@ -224,7 +224,7 @@ static int giu_get_irq(unsigned int irq)
41484 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
41485 maskl, pendl, maskh, pendh);
41486
41487- atomic_inc(&irq_err_count);
41488+ atomic_inc_unchecked(&irq_err_count);
41489
41490 return -EINVAL;
41491 }
41492diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
41493index bf4bd1d..51154a3 100644
41494--- a/drivers/gpio/gpiolib.c
41495+++ b/drivers/gpio/gpiolib.c
41496@@ -569,8 +569,10 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)
41497 }
41498
41499 if (gpiochip->irqchip) {
41500- gpiochip->irqchip->irq_request_resources = NULL;
41501- gpiochip->irqchip->irq_release_resources = NULL;
41502+ pax_open_kernel();
41503+ *(void **)&gpiochip->irqchip->irq_request_resources = NULL;
41504+ *(void **)&gpiochip->irqchip->irq_release_resources = NULL;
41505+ pax_close_kernel();
41506 gpiochip->irqchip = NULL;
41507 }
41508 }
41509@@ -636,8 +638,11 @@ int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
41510 gpiochip->irqchip = NULL;
41511 return -EINVAL;
41512 }
41513- irqchip->irq_request_resources = gpiochip_irq_reqres;
41514- irqchip->irq_release_resources = gpiochip_irq_relres;
41515+
41516+ pax_open_kernel();
41517+ *(void **)&irqchip->irq_request_resources = gpiochip_irq_reqres;
41518+ *(void **)&irqchip->irq_release_resources = gpiochip_irq_relres;
41519+ pax_close_kernel();
41520
41521 /*
41522 * Prepare the mapping since the irqchip shall be orthogonal to
41523diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
41524index 99f158e..20b6c4c 100644
41525--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
41526+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
41527@@ -1071,7 +1071,7 @@ static bool amdgpu_switcheroo_can_switch(struct pci_dev *pdev)
41528 * locking inversion with the driver load path. And the access here is
41529 * completely racy anyway. So don't bother with locking for now.
41530 */
41531- return dev->open_count == 0;
41532+ return local_read(&dev->open_count) == 0;
41533 }
41534
41535 static const struct vga_switcheroo_client_ops amdgpu_switcheroo_ops = {
41536diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
41537index c991973..8eb176b 100644
41538--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
41539+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
41540@@ -419,7 +419,7 @@ static int kfd_ioctl_set_memory_policy(struct file *filep,
41541 (args->alternate_policy == KFD_IOC_CACHE_POLICY_COHERENT)
41542 ? cache_policy_coherent : cache_policy_noncoherent;
41543
41544- if (!dev->dqm->ops.set_cache_memory_policy(dev->dqm,
41545+ if (!dev->dqm->ops->set_cache_memory_policy(dev->dqm,
41546 &pdd->qpd,
41547 default_policy,
41548 alternate_policy,
41549diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
41550index 75312c8..e3684e6 100644
41551--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
41552+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
41553@@ -293,7 +293,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
41554 goto device_queue_manager_error;
41555 }
41556
41557- if (kfd->dqm->ops.start(kfd->dqm) != 0) {
41558+ if (kfd->dqm->ops->start(kfd->dqm) != 0) {
41559 dev_err(kfd_device,
41560 "Error starting queuen manager for device (%x:%x)\n",
41561 kfd->pdev->vendor, kfd->pdev->device);
41562@@ -349,7 +349,7 @@ void kgd2kfd_suspend(struct kfd_dev *kfd)
41563 BUG_ON(kfd == NULL);
41564
41565 if (kfd->init_complete) {
41566- kfd->dqm->ops.stop(kfd->dqm);
41567+ kfd->dqm->ops->stop(kfd->dqm);
41568 amd_iommu_set_invalidate_ctx_cb(kfd->pdev, NULL);
41569 amd_iommu_set_invalid_ppr_cb(kfd->pdev, NULL);
41570 amd_iommu_free_device(kfd->pdev);
41571@@ -372,7 +372,7 @@ int kgd2kfd_resume(struct kfd_dev *kfd)
41572 amd_iommu_set_invalidate_ctx_cb(kfd->pdev,
41573 iommu_pasid_shutdown_callback);
41574 amd_iommu_set_invalid_ppr_cb(kfd->pdev, iommu_invalid_ppr_cb);
41575- kfd->dqm->ops.start(kfd->dqm);
41576+ kfd->dqm->ops->start(kfd->dqm);
41577 }
41578
41579 return 0;
41580diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
41581index 4bb7f42..320fcac 100644
41582--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
41583+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
41584@@ -242,7 +242,7 @@ static int create_compute_queue_nocpsch(struct device_queue_manager *dqm,
41585
41586 BUG_ON(!dqm || !q || !qpd);
41587
41588- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41589+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41590 if (mqd == NULL)
41591 return -ENOMEM;
41592
41593@@ -288,14 +288,14 @@ static int destroy_queue_nocpsch(struct device_queue_manager *dqm,
41594 mutex_lock(&dqm->lock);
41595
41596 if (q->properties.type == KFD_QUEUE_TYPE_COMPUTE) {
41597- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41598+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41599 if (mqd == NULL) {
41600 retval = -ENOMEM;
41601 goto out;
41602 }
41603 deallocate_hqd(dqm, q);
41604 } else if (q->properties.type == KFD_QUEUE_TYPE_SDMA) {
41605- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_SDMA);
41606+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_SDMA);
41607 if (mqd == NULL) {
41608 retval = -ENOMEM;
41609 goto out;
41610@@ -347,7 +347,7 @@ static int update_queue(struct device_queue_manager *dqm, struct queue *q)
41611 BUG_ON(!dqm || !q || !q->mqd);
41612
41613 mutex_lock(&dqm->lock);
41614- mqd = dqm->ops.get_mqd_manager(dqm,
41615+ mqd = dqm->ops->get_mqd_manager(dqm,
41616 get_mqd_type_from_queue_type(q->properties.type));
41617 if (mqd == NULL) {
41618 mutex_unlock(&dqm->lock);
41619@@ -414,7 +414,7 @@ static int register_process_nocpsch(struct device_queue_manager *dqm,
41620 mutex_lock(&dqm->lock);
41621 list_add(&n->list, &dqm->queues);
41622
41623- retval = dqm->ops_asic_specific.register_process(dqm, qpd);
41624+ retval = dqm->ops_asic_specific->register_process(dqm, qpd);
41625
41626 dqm->processes_count++;
41627
41628@@ -502,7 +502,7 @@ int init_pipelines(struct device_queue_manager *dqm,
41629
41630 memset(hpdptr, 0, CIK_HPD_EOP_BYTES * pipes_num);
41631
41632- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41633+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41634 if (mqd == NULL) {
41635 kfd_gtt_sa_free(dqm->dev, dqm->pipeline_mem);
41636 return -ENOMEM;
41637@@ -635,7 +635,7 @@ static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,
41638 struct mqd_manager *mqd;
41639 int retval;
41640
41641- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_SDMA);
41642+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_SDMA);
41643 if (!mqd)
41644 return -ENOMEM;
41645
41646@@ -650,7 +650,7 @@ static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,
41647 pr_debug(" sdma queue id: %d\n", q->properties.sdma_queue_id);
41648 pr_debug(" sdma engine id: %d\n", q->properties.sdma_engine_id);
41649
41650- dqm->ops_asic_specific.init_sdma_vm(dqm, q, qpd);
41651+ dqm->ops_asic_specific->init_sdma_vm(dqm, q, qpd);
41652 retval = mqd->init_mqd(mqd, &q->mqd, &q->mqd_mem_obj,
41653 &q->gart_mqd_addr, &q->properties);
41654 if (retval != 0) {
41655@@ -712,7 +712,7 @@ static int initialize_cpsch(struct device_queue_manager *dqm)
41656 dqm->queue_count = dqm->processes_count = 0;
41657 dqm->sdma_queue_count = 0;
41658 dqm->active_runlist = false;
41659- retval = dqm->ops_asic_specific.initialize(dqm);
41660+ retval = dqm->ops_asic_specific->initialize(dqm);
41661 if (retval != 0)
41662 goto fail_init_pipelines;
41663
41664@@ -879,7 +879,7 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
41665 if (q->properties.type == KFD_QUEUE_TYPE_SDMA)
41666 select_sdma_engine_id(q);
41667
41668- mqd = dqm->ops.get_mqd_manager(dqm,
41669+ mqd = dqm->ops->get_mqd_manager(dqm,
41670 get_mqd_type_from_queue_type(q->properties.type));
41671
41672 if (mqd == NULL) {
41673@@ -887,7 +887,7 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
41674 return -ENOMEM;
41675 }
41676
41677- dqm->ops_asic_specific.init_sdma_vm(dqm, q, qpd);
41678+ dqm->ops_asic_specific->init_sdma_vm(dqm, q, qpd);
41679 retval = mqd->init_mqd(mqd, &q->mqd, &q->mqd_mem_obj,
41680 &q->gart_mqd_addr, &q->properties);
41681 if (retval != 0)
41682@@ -1060,7 +1060,7 @@ static int destroy_queue_cpsch(struct device_queue_manager *dqm,
41683
41684 }
41685
41686- mqd = dqm->ops.get_mqd_manager(dqm,
41687+ mqd = dqm->ops->get_mqd_manager(dqm,
41688 get_mqd_type_from_queue_type(q->properties.type));
41689 if (!mqd) {
41690 retval = -ENOMEM;
41691@@ -1149,7 +1149,7 @@ static bool set_cache_memory_policy(struct device_queue_manager *dqm,
41692 qpd->sh_mem_ape1_limit = limit >> 16;
41693 }
41694
41695- retval = dqm->ops_asic_specific.set_cache_memory_policy(
41696+ retval = dqm->ops_asic_specific->set_cache_memory_policy(
41697 dqm,
41698 qpd,
41699 default_policy,
41700@@ -1172,6 +1172,36 @@ out:
41701 return false;
41702 }
41703
41704+static const struct device_queue_manager_ops cp_dqm_ops = {
41705+ .create_queue = create_queue_cpsch,
41706+ .initialize = initialize_cpsch,
41707+ .start = start_cpsch,
41708+ .stop = stop_cpsch,
41709+ .destroy_queue = destroy_queue_cpsch,
41710+ .update_queue = update_queue,
41711+ .get_mqd_manager = get_mqd_manager_nocpsch,
41712+ .register_process = register_process_nocpsch,
41713+ .unregister_process = unregister_process_nocpsch,
41714+ .uninitialize = uninitialize_nocpsch,
41715+ .create_kernel_queue = create_kernel_queue_cpsch,
41716+ .destroy_kernel_queue = destroy_kernel_queue_cpsch,
41717+ .set_cache_memory_policy = set_cache_memory_policy,
41718+};
41719+
41720+static const struct device_queue_manager_ops no_cp_dqm_ops = {
41721+ .start = start_nocpsch,
41722+ .stop = stop_nocpsch,
41723+ .create_queue = create_queue_nocpsch,
41724+ .destroy_queue = destroy_queue_nocpsch,
41725+ .update_queue = update_queue,
41726+ .get_mqd_manager = get_mqd_manager_nocpsch,
41727+ .register_process = register_process_nocpsch,
41728+ .unregister_process = unregister_process_nocpsch,
41729+ .initialize = initialize_nocpsch,
41730+ .uninitialize = uninitialize_nocpsch,
41731+ .set_cache_memory_policy = set_cache_memory_policy,
41732+};
41733+
41734 struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
41735 {
41736 struct device_queue_manager *dqm;
41737@@ -1189,33 +1219,11 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
41738 case KFD_SCHED_POLICY_HWS:
41739 case KFD_SCHED_POLICY_HWS_NO_OVERSUBSCRIPTION:
41740 /* initialize dqm for cp scheduling */
41741- dqm->ops.create_queue = create_queue_cpsch;
41742- dqm->ops.initialize = initialize_cpsch;
41743- dqm->ops.start = start_cpsch;
41744- dqm->ops.stop = stop_cpsch;
41745- dqm->ops.destroy_queue = destroy_queue_cpsch;
41746- dqm->ops.update_queue = update_queue;
41747- dqm->ops.get_mqd_manager = get_mqd_manager_nocpsch;
41748- dqm->ops.register_process = register_process_nocpsch;
41749- dqm->ops.unregister_process = unregister_process_nocpsch;
41750- dqm->ops.uninitialize = uninitialize_nocpsch;
41751- dqm->ops.create_kernel_queue = create_kernel_queue_cpsch;
41752- dqm->ops.destroy_kernel_queue = destroy_kernel_queue_cpsch;
41753- dqm->ops.set_cache_memory_policy = set_cache_memory_policy;
41754+ dqm->ops = &cp_dqm_ops;
41755 break;
41756 case KFD_SCHED_POLICY_NO_HWS:
41757 /* initialize dqm for no cp scheduling */
41758- dqm->ops.start = start_nocpsch;
41759- dqm->ops.stop = stop_nocpsch;
41760- dqm->ops.create_queue = create_queue_nocpsch;
41761- dqm->ops.destroy_queue = destroy_queue_nocpsch;
41762- dqm->ops.update_queue = update_queue;
41763- dqm->ops.get_mqd_manager = get_mqd_manager_nocpsch;
41764- dqm->ops.register_process = register_process_nocpsch;
41765- dqm->ops.unregister_process = unregister_process_nocpsch;
41766- dqm->ops.initialize = initialize_nocpsch;
41767- dqm->ops.uninitialize = uninitialize_nocpsch;
41768- dqm->ops.set_cache_memory_policy = set_cache_memory_policy;
41769+ dqm->ops = &no_cp_dqm_ops;
41770 break;
41771 default:
41772 BUG();
41773@@ -1224,15 +1232,15 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
41774
41775 switch (dev->device_info->asic_family) {
41776 case CHIP_CARRIZO:
41777- device_queue_manager_init_vi(&dqm->ops_asic_specific);
41778+ device_queue_manager_init_vi(dqm);
41779 break;
41780
41781 case CHIP_KAVERI:
41782- device_queue_manager_init_cik(&dqm->ops_asic_specific);
41783+ device_queue_manager_init_cik(dqm);
41784 break;
41785 }
41786
41787- if (dqm->ops.initialize(dqm) != 0) {
41788+ if (dqm->ops->initialize(dqm) != 0) {
41789 kfree(dqm);
41790 return NULL;
41791 }
41792@@ -1244,6 +1252,6 @@ void device_queue_manager_uninit(struct device_queue_manager *dqm)
41793 {
41794 BUG_ON(!dqm);
41795
41796- dqm->ops.uninitialize(dqm);
41797+ dqm->ops->uninitialize(dqm);
41798 kfree(dqm);
41799 }
41800diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
41801index ec4036a..3ef0646 100644
41802--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
41803+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
41804@@ -154,8 +154,8 @@ struct device_queue_manager_asic_ops {
41805 */
41806
41807 struct device_queue_manager {
41808- struct device_queue_manager_ops ops;
41809- struct device_queue_manager_asic_ops ops_asic_specific;
41810+ struct device_queue_manager_ops *ops;
41811+ struct device_queue_manager_asic_ops *ops_asic_specific;
41812
41813 struct mqd_manager *mqds[KFD_MQD_TYPE_MAX];
41814 struct packet_manager packets;
41815@@ -178,8 +178,8 @@ struct device_queue_manager {
41816 bool active_runlist;
41817 };
41818
41819-void device_queue_manager_init_cik(struct device_queue_manager_asic_ops *ops);
41820-void device_queue_manager_init_vi(struct device_queue_manager_asic_ops *ops);
41821+void device_queue_manager_init_cik(struct device_queue_manager *dqm);
41822+void device_queue_manager_init_vi(struct device_queue_manager *dqm);
41823 void program_sh_mem_settings(struct device_queue_manager *dqm,
41824 struct qcm_process_device *qpd);
41825 int init_pipelines(struct device_queue_manager *dqm,
41826diff --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
41827index 9ce8a20..1ca4e22 100644
41828--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c
41829+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c
41830@@ -36,12 +36,16 @@ static int initialize_cpsch_cik(struct device_queue_manager *dqm);
41831 static void init_sdma_vm(struct device_queue_manager *dqm, struct queue *q,
41832 struct qcm_process_device *qpd);
41833
41834-void device_queue_manager_init_cik(struct device_queue_manager_asic_ops *ops)
41835+static const struct device_queue_manager_asic_ops cik_dqm_asic_ops = {
41836+ .set_cache_memory_policy = set_cache_memory_policy_cik,
41837+ .register_process = register_process_cik,
41838+ .initialize = initialize_cpsch_cik,
41839+ .init_sdma_vm = init_sdma_vm,
41840+};
41841+
41842+void device_queue_manager_init_cik(struct device_queue_manager *dqm)
41843 {
41844- ops->set_cache_memory_policy = set_cache_memory_policy_cik;
41845- ops->register_process = register_process_cik;
41846- ops->initialize = initialize_cpsch_cik;
41847- ops->init_sdma_vm = init_sdma_vm;
41848+ dqm->ops_asic_specific = &cik_dqm_asic_ops;
41849 }
41850
41851 static uint32_t compute_sh_mem_bases_64bit(unsigned int top_address_nybble)
41852diff --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
41853index 4c15212..61bfab8 100644
41854--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c
41855+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c
41856@@ -35,14 +35,18 @@ static int initialize_cpsch_vi(struct device_queue_manager *dqm);
41857 static void init_sdma_vm(struct device_queue_manager *dqm, struct queue *q,
41858 struct qcm_process_device *qpd);
41859
41860-void device_queue_manager_init_vi(struct device_queue_manager_asic_ops *ops)
41861+static const struct device_queue_manager_asic_ops vi_dqm_asic_ops = {
41862+ .set_cache_memory_policy = set_cache_memory_policy_vi,
41863+ .register_process = register_process_vi,
41864+ .initialize = initialize_cpsch_vi,
41865+ .init_sdma_vm = init_sdma_vm,
41866+};
41867+
41868+void device_queue_manager_init_vi(struct device_queue_manager *dqm)
41869 {
41870 pr_warn("amdkfd: VI DQM is not currently supported\n");
41871
41872- ops->set_cache_memory_policy = set_cache_memory_policy_vi;
41873- ops->register_process = register_process_vi;
41874- ops->initialize = initialize_cpsch_vi;
41875- ops->init_sdma_vm = init_sdma_vm;
41876+ dqm->ops_asic_specific = &vi_dqm_asic_ops;
41877 }
41878
41879 static bool set_cache_memory_policy_vi(struct device_queue_manager *dqm,
41880diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
41881index 7f134aa..cd34d4a 100644
41882--- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
41883+++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
41884@@ -50,8 +50,8 @@ static void interrupt_wq(struct work_struct *);
41885
41886 int kfd_interrupt_init(struct kfd_dev *kfd)
41887 {
41888- void *interrupt_ring = kmalloc_array(KFD_INTERRUPT_RING_SIZE,
41889- kfd->device_info->ih_ring_entry_size,
41890+ void *interrupt_ring = kmalloc_array(kfd->device_info->ih_ring_entry_size,
41891+ KFD_INTERRUPT_RING_SIZE,
41892 GFP_KERNEL);
41893 if (!interrupt_ring)
41894 return -ENOMEM;
41895diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
41896index 8fa8941..5ae07df 100644
41897--- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
41898+++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
41899@@ -56,7 +56,7 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
41900 switch (type) {
41901 case KFD_QUEUE_TYPE_DIQ:
41902 case KFD_QUEUE_TYPE_HIQ:
41903- kq->mqd = dev->dqm->ops.get_mqd_manager(dev->dqm,
41904+ kq->mqd = dev->dqm->ops->get_mqd_manager(dev->dqm,
41905 KFD_MQD_TYPE_HIQ);
41906 break;
41907 default:
41908diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h
41909index 5940531..a75b0e5 100644
41910--- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h
41911+++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h
41912@@ -62,7 +62,7 @@ struct kernel_queue_ops {
41913
41914 void (*submit_packet)(struct kernel_queue *kq);
41915 void (*rollback_packet)(struct kernel_queue *kq);
41916-};
41917+} __no_const;
41918
41919 struct kernel_queue {
41920 struct kernel_queue_ops ops;
41921diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
41922index 7b69070..d7bd78b 100644
41923--- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
41924+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
41925@@ -194,7 +194,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
41926
41927 if (list_empty(&pqm->queues)) {
41928 pdd->qpd.pqm = pqm;
41929- dev->dqm->ops.register_process(dev->dqm, &pdd->qpd);
41930+ dev->dqm->ops->register_process(dev->dqm, &pdd->qpd);
41931 }
41932
41933 pqn = kzalloc(sizeof(struct process_queue_node), GFP_KERNEL);
41934@@ -220,7 +220,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
41935 goto err_create_queue;
41936 pqn->q = q;
41937 pqn->kq = NULL;
41938- retval = dev->dqm->ops.create_queue(dev->dqm, q, &pdd->qpd,
41939+ retval = dev->dqm->ops->create_queue(dev->dqm, q, &pdd->qpd,
41940 &q->properties.vmid);
41941 pr_debug("DQM returned %d for create_queue\n", retval);
41942 print_queue(q);
41943@@ -234,7 +234,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
41944 kq->queue->properties.queue_id = *qid;
41945 pqn->kq = kq;
41946 pqn->q = NULL;
41947- retval = dev->dqm->ops.create_kernel_queue(dev->dqm,
41948+ retval = dev->dqm->ops->create_kernel_queue(dev->dqm,
41949 kq, &pdd->qpd);
41950 break;
41951 default:
41952@@ -265,7 +265,7 @@ err_allocate_pqn:
41953 /* check if queues list is empty unregister process from device */
41954 clear_bit(*qid, pqm->queue_slot_bitmap);
41955 if (list_empty(&pqm->queues))
41956- dev->dqm->ops.unregister_process(dev->dqm, &pdd->qpd);
41957+ dev->dqm->ops->unregister_process(dev->dqm, &pdd->qpd);
41958 return retval;
41959 }
41960
41961@@ -306,13 +306,13 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
41962 if (pqn->kq) {
41963 /* destroy kernel queue (DIQ) */
41964 dqm = pqn->kq->dev->dqm;
41965- dqm->ops.destroy_kernel_queue(dqm, pqn->kq, &pdd->qpd);
41966+ dqm->ops->destroy_kernel_queue(dqm, pqn->kq, &pdd->qpd);
41967 kernel_queue_uninit(pqn->kq);
41968 }
41969
41970 if (pqn->q) {
41971 dqm = pqn->q->device->dqm;
41972- retval = dqm->ops.destroy_queue(dqm, &pdd->qpd, pqn->q);
41973+ retval = dqm->ops->destroy_queue(dqm, &pdd->qpd, pqn->q);
41974 if (retval != 0)
41975 return retval;
41976
41977@@ -324,7 +324,7 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
41978 clear_bit(qid, pqm->queue_slot_bitmap);
41979
41980 if (list_empty(&pqm->queues))
41981- dqm->ops.unregister_process(dqm, &pdd->qpd);
41982+ dqm->ops->unregister_process(dqm, &pdd->qpd);
41983
41984 return retval;
41985 }
41986@@ -349,7 +349,7 @@ int pqm_update_queue(struct process_queue_manager *pqm, unsigned int qid,
41987 pqn->q->properties.queue_percent = p->queue_percent;
41988 pqn->q->properties.priority = p->priority;
41989
41990- retval = pqn->q->device->dqm->ops.update_queue(pqn->q->device->dqm,
41991+ retval = pqn->q->device->dqm->ops->update_queue(pqn->q->device->dqm,
41992 pqn->q);
41993 if (retval != 0)
41994 return retval;
41995diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
41996index 9b23525..65f4110 100644
41997--- a/drivers/gpu/drm/drm_context.c
41998+++ b/drivers/gpu/drm/drm_context.c
41999@@ -53,6 +53,9 @@ struct drm_ctx_list {
42000 */
42001 void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
42002 {
42003+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42004+ return;
42005+
42006 mutex_lock(&dev->struct_mutex);
42007 idr_remove(&dev->ctx_idr, ctx_handle);
42008 mutex_unlock(&dev->struct_mutex);
42009@@ -87,6 +90,9 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
42010 */
42011 int drm_legacy_ctxbitmap_init(struct drm_device * dev)
42012 {
42013+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42014+ return -EINVAL;
42015+
42016 idr_init(&dev->ctx_idr);
42017 return 0;
42018 }
42019@@ -101,6 +107,9 @@ int drm_legacy_ctxbitmap_init(struct drm_device * dev)
42020 */
42021 void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
42022 {
42023+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42024+ return;
42025+
42026 mutex_lock(&dev->struct_mutex);
42027 idr_destroy(&dev->ctx_idr);
42028 mutex_unlock(&dev->struct_mutex);
42029@@ -119,11 +128,14 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
42030 {
42031 struct drm_ctx_list *pos, *tmp;
42032
42033+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42034+ return;
42035+
42036 mutex_lock(&dev->ctxlist_mutex);
42037
42038 list_for_each_entry_safe(pos, tmp, &dev->ctxlist, head) {
42039 if (pos->tag == file &&
42040- pos->handle != DRM_KERNEL_CONTEXT) {
42041+ _DRM_LOCKING_CONTEXT(pos->handle) != DRM_KERNEL_CONTEXT) {
42042 if (dev->driver->context_dtor)
42043 dev->driver->context_dtor(dev, pos->handle);
42044
42045@@ -161,6 +173,9 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
42046 struct drm_local_map *map;
42047 struct drm_map_list *_entry;
42048
42049+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42050+ return -EINVAL;
42051+
42052 mutex_lock(&dev->struct_mutex);
42053
42054 map = idr_find(&dev->ctx_idr, request->ctx_id);
42055@@ -205,6 +220,9 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
42056 struct drm_local_map *map = NULL;
42057 struct drm_map_list *r_list = NULL;
42058
42059+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42060+ return -EINVAL;
42061+
42062 mutex_lock(&dev->struct_mutex);
42063 list_for_each_entry(r_list, &dev->maplist, head) {
42064 if (r_list->map
42065@@ -277,7 +295,13 @@ static int drm_context_switch_complete(struct drm_device *dev,
42066 {
42067 dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
42068
42069- if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock)) {
42070+ if (file_priv->master->lock.hw_lock == NULL) {
42071+ DRM_ERROR(
42072+ "Device has been unregistered. Hard exit. Process %d\n",
42073+ task_pid_nr(current));
42074+ send_sig(SIGTERM, current, 0);
42075+ return -EPERM;
42076+ } else if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock)) {
42077 DRM_ERROR("Lock isn't held after context switch\n");
42078 }
42079
42080@@ -305,6 +329,9 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
42081 struct drm_ctx ctx;
42082 int i;
42083
42084+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42085+ return -EINVAL;
42086+
42087 if (res->count >= DRM_RESERVED_CONTEXTS) {
42088 memset(&ctx, 0, sizeof(ctx));
42089 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
42090@@ -335,8 +362,11 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
42091 struct drm_ctx_list *ctx_entry;
42092 struct drm_ctx *ctx = data;
42093
42094+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42095+ return -EINVAL;
42096+
42097 ctx->handle = drm_legacy_ctxbitmap_next(dev);
42098- if (ctx->handle == DRM_KERNEL_CONTEXT) {
42099+ if (_DRM_LOCKING_CONTEXT(ctx->handle) == DRM_KERNEL_CONTEXT) {
42100 /* Skip kernel's context and get a new one. */
42101 ctx->handle = drm_legacy_ctxbitmap_next(dev);
42102 }
42103@@ -378,6 +408,9 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
42104 {
42105 struct drm_ctx *ctx = data;
42106
42107+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42108+ return -EINVAL;
42109+
42110 /* This is 0, because we don't handle any context flags */
42111 ctx->flags = 0;
42112
42113@@ -400,6 +433,9 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
42114 {
42115 struct drm_ctx *ctx = data;
42116
42117+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42118+ return -EINVAL;
42119+
42120 DRM_DEBUG("%d\n", ctx->handle);
42121 return drm_context_switch(dev, dev->last_context, ctx->handle);
42122 }
42123@@ -420,6 +456,9 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
42124 {
42125 struct drm_ctx *ctx = data;
42126
42127+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42128+ return -EINVAL;
42129+
42130 DRM_DEBUG("%d\n", ctx->handle);
42131 drm_context_switch_complete(dev, file_priv, ctx->handle);
42132
42133@@ -442,8 +481,11 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
42134 {
42135 struct drm_ctx *ctx = data;
42136
42137+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42138+ return -EINVAL;
42139+
42140 DRM_DEBUG("%d\n", ctx->handle);
42141- if (ctx->handle != DRM_KERNEL_CONTEXT) {
42142+ if (_DRM_LOCKING_CONTEXT(ctx->handle) != DRM_KERNEL_CONTEXT) {
42143 if (dev->driver->context_dtor)
42144 dev->driver->context_dtor(dev, ctx->handle);
42145 drm_legacy_ctxbitmap_free(dev, ctx->handle);
42146diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
42147index fed7483..5bc0335 100644
42148--- a/drivers/gpu/drm/drm_crtc.c
42149+++ b/drivers/gpu/drm/drm_crtc.c
42150@@ -4174,7 +4174,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
42151 goto done;
42152 }
42153
42154- if (copy_to_user(&enum_ptr[copied].name,
42155+ if (copy_to_user(enum_ptr[copied].name,
42156 &prop_enum->name, DRM_PROP_NAME_LEN)) {
42157 ret = -EFAULT;
42158 goto done;
42159diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
42160index b7bf4ce..585cf3b 100644
42161--- a/drivers/gpu/drm/drm_drv.c
42162+++ b/drivers/gpu/drm/drm_drv.c
42163@@ -434,7 +434,7 @@ void drm_unplug_dev(struct drm_device *dev)
42164
42165 drm_device_set_unplugged(dev);
42166
42167- if (dev->open_count == 0) {
42168+ if (local_read(&dev->open_count) == 0) {
42169 drm_put_dev(dev);
42170 }
42171 mutex_unlock(&drm_global_mutex);
42172@@ -582,10 +582,13 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
42173 if (drm_ht_create(&dev->map_hash, 12))
42174 goto err_minors;
42175
42176- ret = drm_legacy_ctxbitmap_init(dev);
42177- if (ret) {
42178- DRM_ERROR("Cannot allocate memory for context bitmap.\n");
42179- goto err_ht;
42180+ if (drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT)) {
42181+ ret = drm_legacy_ctxbitmap_init(dev);
42182+ if (ret) {
42183+ DRM_ERROR(
42184+ "Cannot allocate memory for context bitmap.\n");
42185+ goto err_ht;
42186+ }
42187 }
42188
42189 if (drm_core_check_feature(dev, DRIVER_GEM)) {
42190diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
42191index c59ce4d..056d413 100644
42192--- a/drivers/gpu/drm/drm_fops.c
42193+++ b/drivers/gpu/drm/drm_fops.c
42194@@ -89,7 +89,7 @@ int drm_open(struct inode *inode, struct file *filp)
42195 return PTR_ERR(minor);
42196
42197 dev = minor->dev;
42198- if (!dev->open_count++)
42199+ if (local_inc_return(&dev->open_count) == 1)
42200 need_setup = 1;
42201
42202 /* share address_space across all char-devs of a single device */
42203@@ -106,7 +106,7 @@ int drm_open(struct inode *inode, struct file *filp)
42204 return 0;
42205
42206 err_undo:
42207- dev->open_count--;
42208+ local_dec(&dev->open_count);
42209 drm_minor_release(minor);
42210 return retcode;
42211 }
42212@@ -377,7 +377,7 @@ int drm_release(struct inode *inode, struct file *filp)
42213
42214 mutex_lock(&drm_global_mutex);
42215
42216- DRM_DEBUG("open_count = %d\n", dev->open_count);
42217+ DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
42218
42219 mutex_lock(&dev->struct_mutex);
42220 list_del(&file_priv->lhead);
42221@@ -392,10 +392,10 @@ int drm_release(struct inode *inode, struct file *filp)
42222 * Begin inline drm_release
42223 */
42224
42225- DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
42226+ DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
42227 task_pid_nr(current),
42228 (long)old_encode_dev(file_priv->minor->kdev->devt),
42229- dev->open_count);
42230+ local_read(&dev->open_count));
42231
42232 /* if the master has gone away we can't do anything with the lock */
42233 if (file_priv->minor->master)
42234@@ -465,7 +465,7 @@ int drm_release(struct inode *inode, struct file *filp)
42235 * End inline drm_release
42236 */
42237
42238- if (!--dev->open_count) {
42239+ if (local_dec_and_test(&dev->open_count)) {
42240 retcode = drm_lastclose(dev);
42241 if (drm_device_is_unplugged(dev))
42242 drm_put_dev(dev);
42243diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
42244index 3d2e91c..d31c4c9 100644
42245--- a/drivers/gpu/drm/drm_global.c
42246+++ b/drivers/gpu/drm/drm_global.c
42247@@ -36,7 +36,7 @@
42248 struct drm_global_item {
42249 struct mutex mutex;
42250 void *object;
42251- int refcount;
42252+ atomic_t refcount;
42253 };
42254
42255 static struct drm_global_item glob[DRM_GLOBAL_NUM];
42256@@ -49,7 +49,7 @@ void drm_global_init(void)
42257 struct drm_global_item *item = &glob[i];
42258 mutex_init(&item->mutex);
42259 item->object = NULL;
42260- item->refcount = 0;
42261+ atomic_set(&item->refcount, 0);
42262 }
42263 }
42264
42265@@ -59,7 +59,7 @@ void drm_global_release(void)
42266 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
42267 struct drm_global_item *item = &glob[i];
42268 BUG_ON(item->object != NULL);
42269- BUG_ON(item->refcount != 0);
42270+ BUG_ON(atomic_read(&item->refcount) != 0);
42271 }
42272 }
42273
42274@@ -69,7 +69,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
42275 struct drm_global_item *item = &glob[ref->global_type];
42276
42277 mutex_lock(&item->mutex);
42278- if (item->refcount == 0) {
42279+ if (atomic_read(&item->refcount) == 0) {
42280 item->object = kzalloc(ref->size, GFP_KERNEL);
42281 if (unlikely(item->object == NULL)) {
42282 ret = -ENOMEM;
42283@@ -82,7 +82,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
42284 goto out_err;
42285
42286 }
42287- ++item->refcount;
42288+ atomic_inc(&item->refcount);
42289 ref->object = item->object;
42290 mutex_unlock(&item->mutex);
42291 return 0;
42292@@ -98,9 +98,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
42293 struct drm_global_item *item = &glob[ref->global_type];
42294
42295 mutex_lock(&item->mutex);
42296- BUG_ON(item->refcount == 0);
42297+ BUG_ON(atomic_read(&item->refcount) == 0);
42298 BUG_ON(ref->object != item->object);
42299- if (--item->refcount == 0) {
42300+ if (atomic_dec_and_test(&item->refcount)) {
42301 ref->release(ref);
42302 item->object = NULL;
42303 }
42304diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
42305index cbb4fc0..5c756cb9 100644
42306--- a/drivers/gpu/drm/drm_info.c
42307+++ b/drivers/gpu/drm/drm_info.c
42308@@ -77,10 +77,13 @@ int drm_vm_info(struct seq_file *m, void *data)
42309 struct drm_local_map *map;
42310 struct drm_map_list *r_list;
42311
42312- /* Hardcoded from _DRM_FRAME_BUFFER,
42313- _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
42314- _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
42315- const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
42316+ static const char * const types[] = {
42317+ [_DRM_FRAME_BUFFER] = "FB",
42318+ [_DRM_REGISTERS] = "REG",
42319+ [_DRM_SHM] = "SHM",
42320+ [_DRM_AGP] = "AGP",
42321+ [_DRM_SCATTER_GATHER] = "SG",
42322+ [_DRM_CONSISTENT] = "PCI"};
42323 const char *type;
42324 int i;
42325
42326@@ -91,7 +94,7 @@ int drm_vm_info(struct seq_file *m, void *data)
42327 map = r_list->map;
42328 if (!map)
42329 continue;
42330- if (map->type < 0 || map->type > 5)
42331+ if (map->type >= ARRAY_SIZE(types))
42332 type = "??";
42333 else
42334 type = types[map->type];
42335diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
42336index 9cfcd0a..7142a7f 100644
42337--- a/drivers/gpu/drm/drm_ioc32.c
42338+++ b/drivers/gpu/drm/drm_ioc32.c
42339@@ -459,7 +459,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
42340 request = compat_alloc_user_space(nbytes);
42341 if (!access_ok(VERIFY_WRITE, request, nbytes))
42342 return -EFAULT;
42343- list = (struct drm_buf_desc *) (request + 1);
42344+ list = (struct drm_buf_desc __user *) (request + 1);
42345
42346 if (__put_user(count, &request->count)
42347 || __put_user(list, &request->list))
42348@@ -520,7 +520,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
42349 request = compat_alloc_user_space(nbytes);
42350 if (!access_ok(VERIFY_WRITE, request, nbytes))
42351 return -EFAULT;
42352- list = (struct drm_buf_pub *) (request + 1);
42353+ list = (struct drm_buf_pub __user *) (request + 1);
42354
42355 if (__put_user(count, &request->count)
42356 || __put_user(list, &request->list))
42357@@ -1075,7 +1075,7 @@ static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
42358 return 0;
42359 }
42360
42361-static drm_ioctl_compat_t *drm_compat_ioctls[] = {
42362+static drm_ioctl_compat_t drm_compat_ioctls[] = {
42363 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
42364 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
42365 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
42366@@ -1122,7 +1122,6 @@ static drm_ioctl_compat_t *drm_compat_ioctls[] = {
42367 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42368 {
42369 unsigned int nr = DRM_IOCTL_NR(cmd);
42370- drm_ioctl_compat_t *fn;
42371 int ret;
42372
42373 /* Assume that ioctls without an explicit compat routine will just
42374@@ -1132,10 +1131,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42375 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
42376 return drm_ioctl(filp, cmd, arg);
42377
42378- fn = drm_compat_ioctls[nr];
42379-
42380- if (fn != NULL)
42381- ret = (*fn) (filp, cmd, arg);
42382+ if (drm_compat_ioctls[nr] != NULL)
42383+ ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
42384 else
42385 ret = drm_ioctl(filp, cmd, arg);
42386
42387diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
42388index b1d303f..c59012c 100644
42389--- a/drivers/gpu/drm/drm_ioctl.c
42390+++ b/drivers/gpu/drm/drm_ioctl.c
42391@@ -650,7 +650,7 @@ long drm_ioctl(struct file *filp,
42392 struct drm_file *file_priv = filp->private_data;
42393 struct drm_device *dev;
42394 const struct drm_ioctl_desc *ioctl = NULL;
42395- drm_ioctl_t *func;
42396+ drm_ioctl_no_const_t func;
42397 unsigned int nr = DRM_IOCTL_NR(cmd);
42398 int retcode = -EINVAL;
42399 char stack_kdata[128];
42400diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
42401index 4924d381..fd3b5ee 100644
42402--- a/drivers/gpu/drm/drm_lock.c
42403+++ b/drivers/gpu/drm/drm_lock.c
42404@@ -61,12 +61,15 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
42405 struct drm_master *master = file_priv->master;
42406 int ret = 0;
42407
42408+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42409+ return -EINVAL;
42410+
42411 if (drm_core_check_feature(dev, DRIVER_MODESET))
42412 return -EINVAL;
42413
42414 ++file_priv->lock_count;
42415
42416- if (lock->context == DRM_KERNEL_CONTEXT) {
42417+ if (_DRM_LOCKING_CONTEXT(lock->context) == DRM_KERNEL_CONTEXT) {
42418 DRM_ERROR("Process %d using kernel context %d\n",
42419 task_pid_nr(current), lock->context);
42420 return -EINVAL;
42421@@ -156,6 +159,9 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
42422 struct drm_lock *lock = data;
42423 struct drm_master *master = file_priv->master;
42424
42425+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42426+ return -EINVAL;
42427+
42428 if (drm_core_check_feature(dev, DRIVER_MODESET))
42429 return -EINVAL;
42430
42431@@ -165,6 +171,14 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
42432 return -EINVAL;
42433 }
42434
42435+ if (!master->lock.hw_lock) {
42436+ DRM_ERROR(
42437+ "Device has been unregistered. Hard exit. Process %d\n",
42438+ task_pid_nr(current));
42439+ send_sig(SIGTERM, current, 0);
42440+ return -EPERM;
42441+ }
42442+
42443 if (drm_legacy_lock_free(&master->lock, lock->context)) {
42444 /* FIXME: Should really bail out here. */
42445 }
42446diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
42447index d4813e0..6c1ab4d 100644
42448--- a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
42449+++ b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
42450@@ -825,10 +825,16 @@ void mdfld_dsi_dpi_mode_set(struct drm_encoder *encoder,
42451 u32 pipeconf_reg = PIPEACONF;
42452 u32 dspcntr_reg = DSPACNTR;
42453
42454- u32 pipeconf = dev_priv->pipeconf[pipe];
42455- u32 dspcntr = dev_priv->dspcntr[pipe];
42456+ u32 pipeconf;
42457+ u32 dspcntr;
42458 u32 mipi = MIPI_PORT_EN | PASS_FROM_SPHY_TO_AFE | SEL_FLOPPED_HSTX;
42459
42460+ if (pipe == -1)
42461+ return;
42462+
42463+ pipeconf = dev_priv->pipeconf[pipe];
42464+ dspcntr = dev_priv->dspcntr[pipe];
42465+
42466 if (pipe) {
42467 pipeconf_reg = PIPECCONF;
42468 dspcntr_reg = DSPCCNTR;
42469diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
42470index 93ec5dc..82acbaf 100644
42471--- a/drivers/gpu/drm/i810/i810_drv.h
42472+++ b/drivers/gpu/drm/i810/i810_drv.h
42473@@ -110,8 +110,8 @@ typedef struct drm_i810_private {
42474 int page_flipping;
42475
42476 wait_queue_head_t irq_queue;
42477- atomic_t irq_received;
42478- atomic_t irq_emitted;
42479+ atomic_unchecked_t irq_received;
42480+ atomic_unchecked_t irq_emitted;
42481
42482 int front_offset;
42483 } drm_i810_private_t;
42484diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
42485index 82bbe3f..ce004bf 100644
42486--- a/drivers/gpu/drm/i915/i915_debugfs.c
42487+++ b/drivers/gpu/drm/i915/i915_debugfs.c
42488@@ -480,7 +480,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
42489 seq_printf(m, "%u fault mappable objects, %zu bytes\n",
42490 count, size);
42491
42492- seq_printf(m, "%zu [%lu] gtt total\n",
42493+ seq_printf(m, "%llu [%llu] gtt total\n",
42494 dev_priv->gtt.base.total,
42495 dev_priv->gtt.mappable_end - dev_priv->gtt.base.start);
42496
42497diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
42498index d2df321..f746478 100644
42499--- a/drivers/gpu/drm/i915/i915_dma.c
42500+++ b/drivers/gpu/drm/i915/i915_dma.c
42501@@ -162,6 +162,8 @@ static int i915_getparam(struct drm_device *dev, void *data,
42502 value = INTEL_INFO(dev)->eu_total;
42503 if (!value)
42504 return -ENODEV;
42505+ case I915_PARAM_HAS_LEGACY_CONTEXT:
42506+ value = drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT);
42507 break;
42508 default:
42509 DRM_DEBUG("Unknown parameter %d\n", param->param);
42510@@ -376,7 +378,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
42511 * locking inversion with the driver load path. And the access here is
42512 * completely racy anyway. So don't bother with locking for now.
42513 */
42514- return dev->open_count == 0;
42515+ return local_read(&dev->open_count) == 0;
42516 }
42517
42518 static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {
42519diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
42520index 5e6b4a2..6ba2c85 100644
42521--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
42522+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
42523@@ -935,12 +935,12 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
42524 static int
42525 validate_exec_list(struct drm_device *dev,
42526 struct drm_i915_gem_exec_object2 *exec,
42527- int count)
42528+ unsigned int count)
42529 {
42530 unsigned relocs_total = 0;
42531 unsigned relocs_max = UINT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
42532 unsigned invalid_flags;
42533- int i;
42534+ unsigned int i;
42535
42536 invalid_flags = __EXEC_OBJECT_UNKNOWN_FLAGS;
42537 if (USES_FULL_PPGTT(dev))
42538diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
42539index 31e8269..7055934 100644
42540--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
42541+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
42542@@ -2360,10 +2360,10 @@ static void chv_setup_private_ppat(struct drm_i915_private *dev_priv)
42543 }
42544
42545 static int gen8_gmch_probe(struct drm_device *dev,
42546- size_t *gtt_total,
42547- size_t *stolen,
42548- phys_addr_t *mappable_base,
42549- unsigned long *mappable_end)
42550+ uint64_t *gtt_total,
42551+ uint64_t *stolen,
42552+ uint64_t *mappable_base,
42553+ uint64_t *mappable_end)
42554 {
42555 struct drm_i915_private *dev_priv = dev->dev_private;
42556 unsigned int gtt_size;
42557@@ -2408,10 +2408,10 @@ static int gen8_gmch_probe(struct drm_device *dev,
42558 }
42559
42560 static int gen6_gmch_probe(struct drm_device *dev,
42561- size_t *gtt_total,
42562- size_t *stolen,
42563- phys_addr_t *mappable_base,
42564- unsigned long *mappable_end)
42565+ uint64_t *gtt_total,
42566+ uint64_t *stolen,
42567+ uint64_t *mappable_base,
42568+ uint64_t *mappable_end)
42569 {
42570 struct drm_i915_private *dev_priv = dev->dev_private;
42571 unsigned int gtt_size;
42572@@ -2425,7 +2425,7 @@ static int gen6_gmch_probe(struct drm_device *dev,
42573 * a coarse sanity check.
42574 */
42575 if ((*mappable_end < (64<<20) || (*mappable_end > (512<<20)))) {
42576- DRM_ERROR("Unknown GMADR size (%lx)\n",
42577+ DRM_ERROR("Unknown GMADR size (%llx)\n",
42578 dev_priv->gtt.mappable_end);
42579 return -ENXIO;
42580 }
42581@@ -2459,10 +2459,10 @@ static void gen6_gmch_remove(struct i915_address_space *vm)
42582 }
42583
42584 static int i915_gmch_probe(struct drm_device *dev,
42585- size_t *gtt_total,
42586- size_t *stolen,
42587- phys_addr_t *mappable_base,
42588- unsigned long *mappable_end)
42589+ uint64_t *gtt_total,
42590+ uint64_t *stolen,
42591+ uint64_t *mappable_base,
42592+ uint64_t *mappable_end)
42593 {
42594 struct drm_i915_private *dev_priv = dev->dev_private;
42595 int ret;
42596@@ -2527,10 +2527,10 @@ int i915_gem_gtt_init(struct drm_device *dev)
42597 gtt->base.dev = dev;
42598
42599 /* GMADR is the PCI mmio aperture into the global GTT. */
42600- DRM_INFO("Memory usable by graphics device = %zdM\n",
42601+ DRM_INFO("Memory usable by graphics device = %lldM\n",
42602 gtt->base.total >> 20);
42603- DRM_DEBUG_DRIVER("GMADR size = %ldM\n", gtt->mappable_end >> 20);
42604- DRM_DEBUG_DRIVER("GTT stolen size = %zdM\n", gtt->stolen_size >> 20);
42605+ DRM_DEBUG_DRIVER("GMADR size = %lldM\n", gtt->mappable_end >> 20);
42606+ DRM_DEBUG_DRIVER("GTT stolen size = %lldM\n", gtt->stolen_size >> 20);
42607 #ifdef CONFIG_INTEL_IOMMU
42608 if (intel_iommu_gfx_mapped)
42609 DRM_INFO("VT-d active for gfx access\n");
42610diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
42611index 0d46dd2..1171c00 100644
42612--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
42613+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
42614@@ -233,8 +233,8 @@ struct i915_address_space {
42615 struct drm_mm mm;
42616 struct drm_device *dev;
42617 struct list_head global_link;
42618- unsigned long start; /* Start offset always 0 for dri2 */
42619- size_t total; /* size addr space maps (ex. 2GB for ggtt) */
42620+ uint64_t start; /* Start offset always 0 for dri2 */
42621+ uint64_t total; /* size addr space maps (ex. 2GB for ggtt) */
42622
42623 struct {
42624 dma_addr_t addr;
42625@@ -300,11 +300,11 @@ struct i915_address_space {
42626 */
42627 struct i915_gtt {
42628 struct i915_address_space base;
42629- size_t stolen_size; /* Total size of stolen memory */
42630+ uint64_t stolen_size; /* Total size of stolen memory */
42631
42632- unsigned long mappable_end; /* End offset that we can CPU map */
42633+ uint64_t mappable_end; /* End offset that we can CPU map */
42634 struct io_mapping *mappable; /* Mapping to our CPU mappable region */
42635- phys_addr_t mappable_base; /* PA of our GMADR */
42636+ uint64_t mappable_base; /* PA of our GMADR */
42637
42638 /** "Graphics Stolen Memory" holds the global PTEs */
42639 void __iomem *gsm;
42640@@ -314,9 +314,9 @@ struct i915_gtt {
42641 int mtrr;
42642
42643 /* global gtt ops */
42644- int (*gtt_probe)(struct drm_device *dev, size_t *gtt_total,
42645- size_t *stolen, phys_addr_t *mappable_base,
42646- unsigned long *mappable_end);
42647+ int (*gtt_probe)(struct drm_device *dev, uint64_t *gtt_total,
42648+ uint64_t *stolen, uint64_t *mappable_base,
42649+ uint64_t *mappable_end);
42650 };
42651
42652 struct i915_hw_ppgtt {
42653diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
42654index 8b5b784..78711f6 100644
42655--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
42656+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
42657@@ -310,7 +310,7 @@ int i915_gem_init_stolen(struct drm_device *dev)
42658 if (dev_priv->mm.stolen_base == 0)
42659 return 0;
42660
42661- DRM_DEBUG_KMS("found %zd bytes of stolen memory at %08lx\n",
42662+ DRM_DEBUG_KMS("found %lld bytes of stolen memory at %08lx\n",
42663 dev_priv->gtt.stolen_size, dev_priv->mm.stolen_base);
42664
42665 if (INTEL_INFO(dev)->gen >= 8) {
42666diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
42667index 23aa04c..1d25960 100644
42668--- a/drivers/gpu/drm/i915/i915_ioc32.c
42669+++ b/drivers/gpu/drm/i915/i915_ioc32.c
42670@@ -62,7 +62,7 @@ static int compat_i915_batchbuffer(struct file *file, unsigned int cmd,
42671 || __put_user(batchbuffer32.DR4, &batchbuffer->DR4)
42672 || __put_user(batchbuffer32.num_cliprects,
42673 &batchbuffer->num_cliprects)
42674- || __put_user((int __user *)(unsigned long)batchbuffer32.cliprects,
42675+ || __put_user((struct drm_clip_rect __user *)(unsigned long)batchbuffer32.cliprects,
42676 &batchbuffer->cliprects))
42677 return -EFAULT;
42678
42679@@ -91,13 +91,13 @@ static int compat_i915_cmdbuffer(struct file *file, unsigned int cmd,
42680
42681 cmdbuffer = compat_alloc_user_space(sizeof(*cmdbuffer));
42682 if (!access_ok(VERIFY_WRITE, cmdbuffer, sizeof(*cmdbuffer))
42683- || __put_user((int __user *)(unsigned long)cmdbuffer32.buf,
42684+ || __put_user((char __user *)(unsigned long)cmdbuffer32.buf,
42685 &cmdbuffer->buf)
42686 || __put_user(cmdbuffer32.sz, &cmdbuffer->sz)
42687 || __put_user(cmdbuffer32.DR1, &cmdbuffer->DR1)
42688 || __put_user(cmdbuffer32.DR4, &cmdbuffer->DR4)
42689 || __put_user(cmdbuffer32.num_cliprects, &cmdbuffer->num_cliprects)
42690- || __put_user((int __user *)(unsigned long)cmdbuffer32.cliprects,
42691+ || __put_user((struct drm_clip_rect __user *)(unsigned long)cmdbuffer32.cliprects,
42692 &cmdbuffer->cliprects))
42693 return -EFAULT;
42694
42695@@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
42696 (unsigned long)request);
42697 }
42698
42699-static drm_ioctl_compat_t *i915_compat_ioctls[] = {
42700+static drm_ioctl_compat_t i915_compat_ioctls[] = {
42701 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
42702 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
42703 [DRM_I915_GETPARAM] = compat_i915_getparam,
42704@@ -201,17 +201,13 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
42705 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42706 {
42707 unsigned int nr = DRM_IOCTL_NR(cmd);
42708- drm_ioctl_compat_t *fn = NULL;
42709 int ret;
42710
42711 if (nr < DRM_COMMAND_BASE || nr >= DRM_COMMAND_END)
42712 return drm_compat_ioctl(filp, cmd, arg);
42713
42714- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(i915_compat_ioctls))
42715- fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
42716-
42717- if (fn != NULL)
42718- ret = (*fn) (filp, cmd, arg);
42719+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(i915_compat_ioctls) && i915_compat_ioctls[nr - DRM_COMMAND_BASE])
42720+ ret = (*i915_compat_ioctls[nr - DRM_COMMAND_BASE])(filp, cmd, arg);
42721 else
42722 ret = drm_ioctl(filp, cmd, arg);
42723
42724diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
42725index 107c6c0..e1926b0 100644
42726--- a/drivers/gpu/drm/i915/intel_display.c
42727+++ b/drivers/gpu/drm/i915/intel_display.c
42728@@ -14501,13 +14501,13 @@ struct intel_quirk {
42729 int subsystem_vendor;
42730 int subsystem_device;
42731 void (*hook)(struct drm_device *dev);
42732-};
42733+} __do_const;
42734
42735 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
42736 struct intel_dmi_quirk {
42737 void (*hook)(struct drm_device *dev);
42738 const struct dmi_system_id (*dmi_id_list)[];
42739-};
42740+} __do_const;
42741
42742 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
42743 {
42744@@ -14515,18 +14515,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
42745 return 1;
42746 }
42747
42748-static const struct intel_dmi_quirk intel_dmi_quirks[] = {
42749+static const struct dmi_system_id intel_dmi_quirks_table[] = {
42750 {
42751- .dmi_id_list = &(const struct dmi_system_id[]) {
42752- {
42753- .callback = intel_dmi_reverse_brightness,
42754- .ident = "NCR Corporation",
42755- .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
42756- DMI_MATCH(DMI_PRODUCT_NAME, ""),
42757- },
42758- },
42759- { } /* terminating entry */
42760+ .callback = intel_dmi_reverse_brightness,
42761+ .ident = "NCR Corporation",
42762+ .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
42763+ DMI_MATCH(DMI_PRODUCT_NAME, ""),
42764 },
42765+ },
42766+ { } /* terminating entry */
42767+};
42768+
42769+static const struct intel_dmi_quirk intel_dmi_quirks[] = {
42770+ {
42771+ .dmi_id_list = &intel_dmi_quirks_table,
42772 .hook = quirk_invert_brightness,
42773 },
42774 };
42775diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
42776index 74f505b..21f6914 100644
42777--- a/drivers/gpu/drm/imx/imx-drm-core.c
42778+++ b/drivers/gpu/drm/imx/imx-drm-core.c
42779@@ -355,7 +355,7 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
42780 if (imxdrm->pipes >= MAX_CRTC)
42781 return -EINVAL;
42782
42783- if (imxdrm->drm->open_count)
42784+ if (local_read(&imxdrm->drm->open_count))
42785 return -EBUSY;
42786
42787 imx_drm_crtc = kzalloc(sizeof(*imx_drm_crtc), GFP_KERNEL);
42788diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
42789index b4a20149..219ab78 100644
42790--- a/drivers/gpu/drm/mga/mga_drv.h
42791+++ b/drivers/gpu/drm/mga/mga_drv.h
42792@@ -122,9 +122,9 @@ typedef struct drm_mga_private {
42793 u32 clear_cmd;
42794 u32 maccess;
42795
42796- atomic_t vbl_received; /**< Number of vblanks received. */
42797+ atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
42798 wait_queue_head_t fence_queue;
42799- atomic_t last_fence_retired;
42800+ atomic_unchecked_t last_fence_retired;
42801 u32 next_fence_to_post;
42802
42803 unsigned int fb_cpp;
42804diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
42805index 729bfd5..14bae78 100644
42806--- a/drivers/gpu/drm/mga/mga_ioc32.c
42807+++ b/drivers/gpu/drm/mga/mga_ioc32.c
42808@@ -190,7 +190,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
42809 return 0;
42810 }
42811
42812-drm_ioctl_compat_t *mga_compat_ioctls[] = {
42813+drm_ioctl_compat_t mga_compat_ioctls[] = {
42814 [DRM_MGA_INIT] = compat_mga_init,
42815 [DRM_MGA_GETPARAM] = compat_mga_getparam,
42816 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
42817@@ -208,17 +208,13 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
42818 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42819 {
42820 unsigned int nr = DRM_IOCTL_NR(cmd);
42821- drm_ioctl_compat_t *fn = NULL;
42822 int ret;
42823
42824 if (nr < DRM_COMMAND_BASE)
42825 return drm_compat_ioctl(filp, cmd, arg);
42826
42827- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(mga_compat_ioctls))
42828- fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
42829-
42830- if (fn != NULL)
42831- ret = (*fn) (filp, cmd, arg);
42832+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(mga_compat_ioctls) && mga_compat_ioctls[nr - DRM_COMMAND_BASE])
42833+ ret = (*mga_compat_ioctls[nr - DRM_COMMAND_BASE]) (filp, cmd, arg);
42834 else
42835 ret = drm_ioctl(filp, cmd, arg);
42836
42837diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
42838index 1b071b8..de8601a 100644
42839--- a/drivers/gpu/drm/mga/mga_irq.c
42840+++ b/drivers/gpu/drm/mga/mga_irq.c
42841@@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
42842 if (crtc != 0)
42843 return 0;
42844
42845- return atomic_read(&dev_priv->vbl_received);
42846+ return atomic_read_unchecked(&dev_priv->vbl_received);
42847 }
42848
42849
42850@@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(int irq, void *arg)
42851 /* VBLANK interrupt */
42852 if (status & MGA_VLINEPEN) {
42853 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
42854- atomic_inc(&dev_priv->vbl_received);
42855+ atomic_inc_unchecked(&dev_priv->vbl_received);
42856 drm_handle_vblank(dev, 0);
42857 handled = 1;
42858 }
42859@@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(int irq, void *arg)
42860 if ((prim_start & ~0x03) != (prim_end & ~0x03))
42861 MGA_WRITE(MGA_PRIMEND, prim_end);
42862
42863- atomic_inc(&dev_priv->last_fence_retired);
42864+ atomic_inc_unchecked(&dev_priv->last_fence_retired);
42865 wake_up(&dev_priv->fence_queue);
42866 handled = 1;
42867 }
42868@@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
42869 * using fences.
42870 */
42871 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * HZ,
42872- (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
42873+ (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
42874 - *sequence) <= (1 << 23)));
42875
42876 *sequence = cur_fence;
42877diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
42878index 0190b69..60c3eaf 100644
42879--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
42880+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
42881@@ -963,7 +963,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
42882 struct bit_table {
42883 const char id;
42884 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
42885-};
42886+} __no_const;
42887
42888 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
42889
42890diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
42891index 477cbb1..109b826 100644
42892--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
42893+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
42894@@ -946,7 +946,8 @@ static struct drm_driver
42895 driver_stub = {
42896 .driver_features =
42897 DRIVER_USE_AGP |
42898- DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER,
42899+ DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER |
42900+ DRIVER_KMS_LEGACY_CONTEXT,
42901
42902 .load = nouveau_drm_load,
42903 .unload = nouveau_drm_unload,
42904diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
42905index dd72652..1fd2368 100644
42906--- a/drivers/gpu/drm/nouveau/nouveau_drm.h
42907+++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
42908@@ -123,7 +123,6 @@ struct nouveau_drm {
42909 struct drm_global_reference mem_global_ref;
42910 struct ttm_bo_global_ref bo_global_ref;
42911 struct ttm_bo_device bdev;
42912- atomic_t validate_sequence;
42913 int (*move)(struct nouveau_channel *,
42914 struct ttm_buffer_object *,
42915 struct ttm_mem_reg *, struct ttm_mem_reg *);
42916diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
42917index 462679a..88e32a7 100644
42918--- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
42919+++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
42920@@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
42921 unsigned long arg)
42922 {
42923 unsigned int nr = DRM_IOCTL_NR(cmd);
42924- drm_ioctl_compat_t *fn = NULL;
42925+ drm_ioctl_compat_t fn = NULL;
42926 int ret;
42927
42928 if (nr < DRM_COMMAND_BASE)
42929diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
42930index 7464aef3..c63ae4f 100644
42931--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
42932+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
42933@@ -130,11 +130,11 @@ nouveau_vram_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
42934 }
42935
42936 const struct ttm_mem_type_manager_func nouveau_vram_manager = {
42937- nouveau_vram_manager_init,
42938- nouveau_vram_manager_fini,
42939- nouveau_vram_manager_new,
42940- nouveau_vram_manager_del,
42941- nouveau_vram_manager_debug
42942+ .init = nouveau_vram_manager_init,
42943+ .takedown = nouveau_vram_manager_fini,
42944+ .get_node = nouveau_vram_manager_new,
42945+ .put_node = nouveau_vram_manager_del,
42946+ .debug = nouveau_vram_manager_debug
42947 };
42948
42949 static int
42950@@ -207,11 +207,11 @@ nouveau_gart_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
42951 }
42952
42953 const struct ttm_mem_type_manager_func nouveau_gart_manager = {
42954- nouveau_gart_manager_init,
42955- nouveau_gart_manager_fini,
42956- nouveau_gart_manager_new,
42957- nouveau_gart_manager_del,
42958- nouveau_gart_manager_debug
42959+ .init = nouveau_gart_manager_init,
42960+ .takedown = nouveau_gart_manager_fini,
42961+ .get_node = nouveau_gart_manager_new,
42962+ .put_node = nouveau_gart_manager_del,
42963+ .debug = nouveau_gart_manager_debug
42964 };
42965
42966 /*XXX*/
42967@@ -280,11 +280,11 @@ nv04_gart_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
42968 }
42969
42970 const struct ttm_mem_type_manager_func nv04_gart_manager = {
42971- nv04_gart_manager_init,
42972- nv04_gart_manager_fini,
42973- nv04_gart_manager_new,
42974- nv04_gart_manager_del,
42975- nv04_gart_manager_debug
42976+ .init = nv04_gart_manager_init,
42977+ .takedown = nv04_gart_manager_fini,
42978+ .get_node = nv04_gart_manager_new,
42979+ .put_node = nv04_gart_manager_del,
42980+ .debug = nv04_gart_manager_debug
42981 };
42982
42983 int
42984diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
42985index c7592ec..dd45ebc 100644
42986--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
42987+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
42988@@ -72,7 +72,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
42989 * locking inversion with the driver load path. And the access here is
42990 * completely racy anyway. So don't bother with locking for now.
42991 */
42992- return dev->open_count == 0;
42993+ return local_read(&dev->open_count) == 0;
42994 }
42995
42996 static const struct vga_switcheroo_client_ops
42997diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
42998index 778372b..4b81cb4 100644
42999--- a/drivers/gpu/drm/omapdrm/Makefile
43000+++ b/drivers/gpu/drm/omapdrm/Makefile
43001@@ -3,7 +3,7 @@
43002 # Direct Rendering Infrastructure (DRI)
43003 #
43004
43005-ccflags-y := -Iinclude/drm -Werror
43006+ccflags-y := -Iinclude/drm
43007 omapdrm-y := omap_drv.o \
43008 omap_irq.o \
43009 omap_debugfs.o \
43010diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
43011index fdc1833..f307630 100644
43012--- a/drivers/gpu/drm/qxl/qxl_cmd.c
43013+++ b/drivers/gpu/drm/qxl/qxl_cmd.c
43014@@ -285,27 +285,27 @@ static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port,
43015 int ret;
43016
43017 mutex_lock(&qdev->async_io_mutex);
43018- irq_num = atomic_read(&qdev->irq_received_io_cmd);
43019+ irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
43020 if (qdev->last_sent_io_cmd > irq_num) {
43021 if (intr)
43022 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
43023- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43024+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43025 else
43026 ret = wait_event_timeout(qdev->io_cmd_event,
43027- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43028+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43029 /* 0 is timeout, just bail the "hw" has gone away */
43030 if (ret <= 0)
43031 goto out;
43032- irq_num = atomic_read(&qdev->irq_received_io_cmd);
43033+ irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
43034 }
43035 outb(val, addr);
43036 qdev->last_sent_io_cmd = irq_num + 1;
43037 if (intr)
43038 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
43039- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43040+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43041 else
43042 ret = wait_event_timeout(qdev->io_cmd_event,
43043- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43044+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43045 out:
43046 if (ret > 0)
43047 ret = 0;
43048diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
43049index 6911b8c..89d6867 100644
43050--- a/drivers/gpu/drm/qxl/qxl_debugfs.c
43051+++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
43052@@ -42,10 +42,10 @@ qxl_debugfs_irq_received(struct seq_file *m, void *data)
43053 struct drm_info_node *node = (struct drm_info_node *) m->private;
43054 struct qxl_device *qdev = node->minor->dev->dev_private;
43055
43056- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
43057- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
43058- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
43059- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
43060+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received));
43061+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_display));
43062+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_cursor));
43063+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_io_cmd));
43064 seq_printf(m, "%d\n", qdev->irq_received_error);
43065 return 0;
43066 }
43067diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
43068index 01a8694..584fb48 100644
43069--- a/drivers/gpu/drm/qxl/qxl_drv.h
43070+++ b/drivers/gpu/drm/qxl/qxl_drv.h
43071@@ -290,10 +290,10 @@ struct qxl_device {
43072 unsigned int last_sent_io_cmd;
43073
43074 /* interrupt handling */
43075- atomic_t irq_received;
43076- atomic_t irq_received_display;
43077- atomic_t irq_received_cursor;
43078- atomic_t irq_received_io_cmd;
43079+ atomic_unchecked_t irq_received;
43080+ atomic_unchecked_t irq_received_display;
43081+ atomic_unchecked_t irq_received_cursor;
43082+ atomic_unchecked_t irq_received_io_cmd;
43083 unsigned irq_received_error;
43084 wait_queue_head_t display_event;
43085 wait_queue_head_t cursor_event;
43086diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
43087index bda5c5f..140ac46 100644
43088--- a/drivers/gpu/drm/qxl/qxl_ioctl.c
43089+++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
43090@@ -183,7 +183,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
43091
43092 /* TODO copy slow path code from i915 */
43093 fb_cmd = qxl_bo_kmap_atomic_page(qdev, cmd_bo, (release->release_offset & PAGE_SIZE));
43094- 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);
43095+ 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);
43096
43097 {
43098 struct qxl_drawable *draw = fb_cmd;
43099@@ -203,7 +203,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
43100 struct drm_qxl_reloc reloc;
43101
43102 if (copy_from_user(&reloc,
43103- &((struct drm_qxl_reloc *)(uintptr_t)cmd->relocs)[i],
43104+ &((struct drm_qxl_reloc __force_user *)(uintptr_t)cmd->relocs)[i],
43105 sizeof(reloc))) {
43106 ret = -EFAULT;
43107 goto out_free_bos;
43108@@ -282,10 +282,10 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
43109
43110 for (cmd_num = 0; cmd_num < execbuffer->commands_num; ++cmd_num) {
43111
43112- struct drm_qxl_command *commands =
43113- (struct drm_qxl_command *)(uintptr_t)execbuffer->commands;
43114+ struct drm_qxl_command __user *commands =
43115+ (struct drm_qxl_command __user *)(uintptr_t)execbuffer->commands;
43116
43117- if (copy_from_user(&user_cmd, &commands[cmd_num],
43118+ if (copy_from_user(&user_cmd, (struct drm_qxl_command __force_user *)&commands[cmd_num],
43119 sizeof(user_cmd)))
43120 return -EFAULT;
43121
43122diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
43123index 0bf1e20..42a7310 100644
43124--- a/drivers/gpu/drm/qxl/qxl_irq.c
43125+++ b/drivers/gpu/drm/qxl/qxl_irq.c
43126@@ -36,19 +36,19 @@ irqreturn_t qxl_irq_handler(int irq, void *arg)
43127 if (!pending)
43128 return IRQ_NONE;
43129
43130- atomic_inc(&qdev->irq_received);
43131+ atomic_inc_unchecked(&qdev->irq_received);
43132
43133 if (pending & QXL_INTERRUPT_DISPLAY) {
43134- atomic_inc(&qdev->irq_received_display);
43135+ atomic_inc_unchecked(&qdev->irq_received_display);
43136 wake_up_all(&qdev->display_event);
43137 qxl_queue_garbage_collect(qdev, false);
43138 }
43139 if (pending & QXL_INTERRUPT_CURSOR) {
43140- atomic_inc(&qdev->irq_received_cursor);
43141+ atomic_inc_unchecked(&qdev->irq_received_cursor);
43142 wake_up_all(&qdev->cursor_event);
43143 }
43144 if (pending & QXL_INTERRUPT_IO_CMD) {
43145- atomic_inc(&qdev->irq_received_io_cmd);
43146+ atomic_inc_unchecked(&qdev->irq_received_io_cmd);
43147 wake_up_all(&qdev->io_cmd_event);
43148 }
43149 if (pending & QXL_INTERRUPT_ERROR) {
43150@@ -85,10 +85,10 @@ int qxl_irq_init(struct qxl_device *qdev)
43151 init_waitqueue_head(&qdev->io_cmd_event);
43152 INIT_WORK(&qdev->client_monitors_config_work,
43153 qxl_client_monitors_config_work_func);
43154- atomic_set(&qdev->irq_received, 0);
43155- atomic_set(&qdev->irq_received_display, 0);
43156- atomic_set(&qdev->irq_received_cursor, 0);
43157- atomic_set(&qdev->irq_received_io_cmd, 0);
43158+ atomic_set_unchecked(&qdev->irq_received, 0);
43159+ atomic_set_unchecked(&qdev->irq_received_display, 0);
43160+ atomic_set_unchecked(&qdev->irq_received_cursor, 0);
43161+ atomic_set_unchecked(&qdev->irq_received_io_cmd, 0);
43162 qdev->irq_received_error = 0;
43163 ret = drm_irq_install(qdev->ddev, qdev->ddev->pdev->irq);
43164 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
43165diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
43166index 0cbc4c9..0e46686 100644
43167--- a/drivers/gpu/drm/qxl/qxl_ttm.c
43168+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
43169@@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
43170 }
43171 }
43172
43173-static struct vm_operations_struct qxl_ttm_vm_ops;
43174+static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
43175 static const struct vm_operations_struct *ttm_vm_ops;
43176
43177 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
43178@@ -145,8 +145,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
43179 return r;
43180 if (unlikely(ttm_vm_ops == NULL)) {
43181 ttm_vm_ops = vma->vm_ops;
43182+ pax_open_kernel();
43183 qxl_ttm_vm_ops = *ttm_vm_ops;
43184 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
43185+ pax_close_kernel();
43186 }
43187 vma->vm_ops = &qxl_ttm_vm_ops;
43188 return 0;
43189@@ -464,25 +466,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
43190 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
43191 {
43192 #if defined(CONFIG_DEBUG_FS)
43193- static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
43194- static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
43195- unsigned i;
43196+ static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
43197+ {
43198+ .name = "qxl_mem_mm",
43199+ .show = &qxl_mm_dump_table,
43200+ },
43201+ {
43202+ .name = "qxl_surf_mm",
43203+ .show = &qxl_mm_dump_table,
43204+ }
43205+ };
43206
43207- for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
43208- if (i == 0)
43209- sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
43210- else
43211- sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
43212- qxl_mem_types_list[i].name = qxl_mem_types_names[i];
43213- qxl_mem_types_list[i].show = &qxl_mm_dump_table;
43214- qxl_mem_types_list[i].driver_features = 0;
43215- if (i == 0)
43216- qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
43217- else
43218- qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
43219+ pax_open_kernel();
43220+ *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
43221+ *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
43222+ pax_close_kernel();
43223
43224- }
43225- return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
43226+ return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
43227 #else
43228 return 0;
43229 #endif
43230diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
43231index 2c45ac9..5d740f8 100644
43232--- a/drivers/gpu/drm/r128/r128_cce.c
43233+++ b/drivers/gpu/drm/r128/r128_cce.c
43234@@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
43235
43236 /* GH: Simple idle check.
43237 */
43238- atomic_set(&dev_priv->idle_count, 0);
43239+ atomic_set_unchecked(&dev_priv->idle_count, 0);
43240
43241 /* We don't support anything other than bus-mastering ring mode,
43242 * but the ring can be in either AGP or PCI space for the ring
43243diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
43244index 723e5d6..102dbaf 100644
43245--- a/drivers/gpu/drm/r128/r128_drv.h
43246+++ b/drivers/gpu/drm/r128/r128_drv.h
43247@@ -93,14 +93,14 @@ typedef struct drm_r128_private {
43248 int is_pci;
43249 unsigned long cce_buffers_offset;
43250
43251- atomic_t idle_count;
43252+ atomic_unchecked_t idle_count;
43253
43254 int page_flipping;
43255 int current_page;
43256 u32 crtc_offset;
43257 u32 crtc_offset_cntl;
43258
43259- atomic_t vbl_received;
43260+ atomic_unchecked_t vbl_received;
43261
43262 u32 color_fmt;
43263 unsigned int front_offset;
43264diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
43265index 663f38c..ec159a1 100644
43266--- a/drivers/gpu/drm/r128/r128_ioc32.c
43267+++ b/drivers/gpu/drm/r128/r128_ioc32.c
43268@@ -178,7 +178,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
43269 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
43270 }
43271
43272-drm_ioctl_compat_t *r128_compat_ioctls[] = {
43273+drm_ioctl_compat_t r128_compat_ioctls[] = {
43274 [DRM_R128_INIT] = compat_r128_init,
43275 [DRM_R128_DEPTH] = compat_r128_depth,
43276 [DRM_R128_STIPPLE] = compat_r128_stipple,
43277@@ -197,17 +197,13 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
43278 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
43279 {
43280 unsigned int nr = DRM_IOCTL_NR(cmd);
43281- drm_ioctl_compat_t *fn = NULL;
43282 int ret;
43283
43284 if (nr < DRM_COMMAND_BASE)
43285 return drm_compat_ioctl(filp, cmd, arg);
43286
43287- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(r128_compat_ioctls))
43288- fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
43289-
43290- if (fn != NULL)
43291- ret = (*fn) (filp, cmd, arg);
43292+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(r128_compat_ioctls) && r128_compat_ioctls[nr - DRM_COMMAND_BASE])
43293+ ret = (*r128_compat_ioctls[nr - DRM_COMMAND_BASE]) (filp, cmd, arg);
43294 else
43295 ret = drm_ioctl(filp, cmd, arg);
43296
43297diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
43298index c2ae496..30b5993 100644
43299--- a/drivers/gpu/drm/r128/r128_irq.c
43300+++ b/drivers/gpu/drm/r128/r128_irq.c
43301@@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
43302 if (crtc != 0)
43303 return 0;
43304
43305- return atomic_read(&dev_priv->vbl_received);
43306+ return atomic_read_unchecked(&dev_priv->vbl_received);
43307 }
43308
43309 irqreturn_t r128_driver_irq_handler(int irq, void *arg)
43310@@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(int irq, void *arg)
43311 /* VBLANK interrupt */
43312 if (status & R128_CRTC_VBLANK_INT) {
43313 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
43314- atomic_inc(&dev_priv->vbl_received);
43315+ atomic_inc_unchecked(&dev_priv->vbl_received);
43316 drm_handle_vblank(dev, 0);
43317 return IRQ_HANDLED;
43318 }
43319diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
43320index 8fd2d9f..18c9660 100644
43321--- a/drivers/gpu/drm/r128/r128_state.c
43322+++ b/drivers/gpu/drm/r128/r128_state.c
43323@@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
43324
43325 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
43326 {
43327- if (atomic_read(&dev_priv->idle_count) == 0)
43328+ if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
43329 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
43330 else
43331- atomic_set(&dev_priv->idle_count, 0);
43332+ atomic_set_unchecked(&dev_priv->idle_count, 0);
43333 }
43334
43335 #endif
43336diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
43337index b928c17..e5d9400 100644
43338--- a/drivers/gpu/drm/radeon/mkregtable.c
43339+++ b/drivers/gpu/drm/radeon/mkregtable.c
43340@@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
43341 regex_t mask_rex;
43342 regmatch_t match[4];
43343 char buf[1024];
43344- size_t end;
43345+ long end;
43346 int len;
43347 int done = 0;
43348 int r;
43349 unsigned o;
43350 struct offset *offset;
43351 char last_reg_s[10];
43352- int last_reg;
43353+ unsigned long last_reg;
43354
43355 if (regcomp
43356 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
43357diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
43358index d8319da..d6e066f 100644
43359--- a/drivers/gpu/drm/radeon/radeon_device.c
43360+++ b/drivers/gpu/drm/radeon/radeon_device.c
43361@@ -1253,7 +1253,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
43362 * locking inversion with the driver load path. And the access here is
43363 * completely racy anyway. So don't bother with locking for now.
43364 */
43365- return dev->open_count == 0;
43366+ return local_read(&dev->open_count) == 0;
43367 }
43368
43369 static const struct vga_switcheroo_client_ops radeon_switcheroo_ops = {
43370diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
43371index 46bd393..6ae4719 100644
43372--- a/drivers/gpu/drm/radeon/radeon_drv.h
43373+++ b/drivers/gpu/drm/radeon/radeon_drv.h
43374@@ -264,7 +264,7 @@ typedef struct drm_radeon_private {
43375
43376 /* SW interrupt */
43377 wait_queue_head_t swi_queue;
43378- atomic_t swi_emitted;
43379+ atomic_unchecked_t swi_emitted;
43380 int vblank_crtc;
43381 uint32_t irq_enable_reg;
43382 uint32_t r500_disp_irq_reg;
43383diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
43384index 0b98ea1..a3c770f 100644
43385--- a/drivers/gpu/drm/radeon/radeon_ioc32.c
43386+++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
43387@@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
43388 request = compat_alloc_user_space(sizeof(*request));
43389 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
43390 || __put_user(req32.param, &request->param)
43391- || __put_user((void __user *)(unsigned long)req32.value,
43392+ || __put_user((unsigned long)req32.value,
43393 &request->value))
43394 return -EFAULT;
43395
43396@@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
43397 #define compat_radeon_cp_setparam NULL
43398 #endif /* X86_64 || IA64 */
43399
43400-static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
43401+static drm_ioctl_compat_t radeon_compat_ioctls[] = {
43402 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
43403 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
43404 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
43405@@ -393,17 +393,13 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
43406 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
43407 {
43408 unsigned int nr = DRM_IOCTL_NR(cmd);
43409- drm_ioctl_compat_t *fn = NULL;
43410 int ret;
43411
43412 if (nr < DRM_COMMAND_BASE)
43413 return drm_compat_ioctl(filp, cmd, arg);
43414
43415- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(radeon_compat_ioctls))
43416- fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
43417-
43418- if (fn != NULL)
43419- ret = (*fn) (filp, cmd, arg);
43420+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(radeon_compat_ioctls) && radeon_compat_ioctls[nr - DRM_COMMAND_BASE])
43421+ ret = (*radeon_compat_ioctls[nr - DRM_COMMAND_BASE]) (filp, cmd, arg);
43422 else
43423 ret = drm_ioctl(filp, cmd, arg);
43424
43425diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
43426index 244b19b..c19226d 100644
43427--- a/drivers/gpu/drm/radeon/radeon_irq.c
43428+++ b/drivers/gpu/drm/radeon/radeon_irq.c
43429@@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
43430 unsigned int ret;
43431 RING_LOCALS;
43432
43433- atomic_inc(&dev_priv->swi_emitted);
43434- ret = atomic_read(&dev_priv->swi_emitted);
43435+ atomic_inc_unchecked(&dev_priv->swi_emitted);
43436+ ret = atomic_read_unchecked(&dev_priv->swi_emitted);
43437
43438 BEGIN_RING(4);
43439 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
43440@@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
43441 drm_radeon_private_t *dev_priv =
43442 (drm_radeon_private_t *) dev->dev_private;
43443
43444- atomic_set(&dev_priv->swi_emitted, 0);
43445+ atomic_set_unchecked(&dev_priv->swi_emitted, 0);
43446 init_waitqueue_head(&dev_priv->swi_queue);
43447
43448 dev->max_vblank_count = 0x001fffff;
43449diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
43450index 15aee72..cda326e 100644
43451--- a/drivers/gpu/drm/radeon/radeon_state.c
43452+++ b/drivers/gpu/drm/radeon/radeon_state.c
43453@@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
43454 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
43455 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
43456
43457- if (copy_from_user(&depth_boxes, clear->depth_boxes,
43458+ if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || copy_from_user(&depth_boxes, clear->depth_boxes,
43459 sarea_priv->nbox * sizeof(depth_boxes[0])))
43460 return -EFAULT;
43461
43462@@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
43463 {
43464 drm_radeon_private_t *dev_priv = dev->dev_private;
43465 drm_radeon_getparam_t *param = data;
43466- int value;
43467+ int value = 0;
43468
43469 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
43470
43471diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
43472index 06ac59fe..57e0681 100644
43473--- a/drivers/gpu/drm/radeon/radeon_ttm.c
43474+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
43475@@ -961,7 +961,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
43476 man->size = size >> PAGE_SHIFT;
43477 }
43478
43479-static struct vm_operations_struct radeon_ttm_vm_ops;
43480+static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
43481 static const struct vm_operations_struct *ttm_vm_ops = NULL;
43482
43483 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
43484@@ -1002,8 +1002,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
43485 }
43486 if (unlikely(ttm_vm_ops == NULL)) {
43487 ttm_vm_ops = vma->vm_ops;
43488+ pax_open_kernel();
43489 radeon_ttm_vm_ops = *ttm_vm_ops;
43490 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
43491+ pax_close_kernel();
43492 }
43493 vma->vm_ops = &radeon_ttm_vm_ops;
43494 return 0;
43495diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
43496index a287e4f..df1d5dd 100644
43497--- a/drivers/gpu/drm/tegra/dc.c
43498+++ b/drivers/gpu/drm/tegra/dc.c
43499@@ -1594,7 +1594,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
43500 }
43501
43502 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
43503- dc->debugfs_files[i].data = dc;
43504+ *(void **)&dc->debugfs_files[i].data = dc;
43505
43506 err = drm_debugfs_create_files(dc->debugfs_files,
43507 ARRAY_SIZE(debugfs_files),
43508diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
43509index ed970f6..4eeea42 100644
43510--- a/drivers/gpu/drm/tegra/dsi.c
43511+++ b/drivers/gpu/drm/tegra/dsi.c
43512@@ -62,7 +62,7 @@ struct tegra_dsi {
43513 struct clk *clk_lp;
43514 struct clk *clk;
43515
43516- struct drm_info_list *debugfs_files;
43517+ drm_info_list_no_const *debugfs_files;
43518 struct drm_minor *minor;
43519 struct dentry *debugfs;
43520
43521diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
43522index 06ab178..b5324e4 100644
43523--- a/drivers/gpu/drm/tegra/hdmi.c
43524+++ b/drivers/gpu/drm/tegra/hdmi.c
43525@@ -64,7 +64,7 @@ struct tegra_hdmi {
43526 bool stereo;
43527 bool dvi;
43528
43529- struct drm_info_list *debugfs_files;
43530+ drm_info_list_no_const *debugfs_files;
43531 struct drm_minor *minor;
43532 struct dentry *debugfs;
43533 };
43534diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
43535index 7591d89..463e2b6 100644
43536--- a/drivers/gpu/drm/tegra/sor.c
43537+++ b/drivers/gpu/drm/tegra/sor.c
43538@@ -826,8 +826,11 @@ static int tegra_sor_debugfs_init(struct tegra_sor *sor,
43539 goto remove;
43540 }
43541
43542- for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
43543- sor->debugfs_files[i].data = sor;
43544+ for (i = 0; i < ARRAY_SIZE(debugfs_files); i++) {
43545+ pax_open_kernel();
43546+ *(void **)&sor->debugfs_files[i].data = sor;
43547+ pax_close_kernel();
43548+ }
43549
43550 err = drm_debugfs_create_files(sor->debugfs_files,
43551 ARRAY_SIZE(debugfs_files),
43552diff --git a/drivers/gpu/drm/tilcdc/Makefile b/drivers/gpu/drm/tilcdc/Makefile
43553index deeca48..54e1b6c 100644
43554--- a/drivers/gpu/drm/tilcdc/Makefile
43555+++ b/drivers/gpu/drm/tilcdc/Makefile
43556@@ -1,7 +1,7 @@
43557 ccflags-y := -Iinclude/drm
43558-ifeq (, $(findstring -W,$(EXTRA_CFLAGS)))
43559- ccflags-y += -Werror
43560-endif
43561+#ifeq (, $(findstring -W,$(EXTRA_CFLAGS)))
43562+# ccflags-y += -Werror
43563+#endif
43564
43565 obj-$(CONFIG_DRM_TILCDC_SLAVE_COMPAT) += tilcdc_slave_compat.o \
43566 tilcdc_slave_compat.dtb.o
43567diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
43568index aa0bd054..aea6a01 100644
43569--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
43570+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
43571@@ -148,10 +148,10 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
43572 }
43573
43574 const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
43575- ttm_bo_man_init,
43576- ttm_bo_man_takedown,
43577- ttm_bo_man_get_node,
43578- ttm_bo_man_put_node,
43579- ttm_bo_man_debug
43580+ .init = ttm_bo_man_init,
43581+ .takedown = ttm_bo_man_takedown,
43582+ .get_node = ttm_bo_man_get_node,
43583+ .put_node = ttm_bo_man_put_node,
43584+ .debug = ttm_bo_man_debug
43585 };
43586 EXPORT_SYMBOL(ttm_bo_manager_func);
43587diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
43588index a1803fb..c53f6b0 100644
43589--- a/drivers/gpu/drm/ttm/ttm_memory.c
43590+++ b/drivers/gpu/drm/ttm/ttm_memory.c
43591@@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
43592 zone->glob = glob;
43593 glob->zone_kernel = zone;
43594 ret = kobject_init_and_add(
43595- &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
43596+ &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
43597 if (unlikely(ret != 0)) {
43598 kobject_put(&zone->kobj);
43599 return ret;
43600@@ -348,7 +348,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
43601 zone->glob = glob;
43602 glob->zone_dma32 = zone;
43603 ret = kobject_init_and_add(
43604- &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
43605+ &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
43606 if (unlikely(ret != 0)) {
43607 kobject_put(&zone->kobj);
43608 return ret;
43609diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
43610index 025c429..314062f 100644
43611--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
43612+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
43613@@ -54,7 +54,7 @@
43614
43615 #define NUM_PAGES_TO_ALLOC (PAGE_SIZE/sizeof(struct page *))
43616 #define SMALL_ALLOCATION 16
43617-#define FREE_ALL_PAGES (~0U)
43618+#define FREE_ALL_PAGES (~0UL)
43619 /* times are in msecs */
43620 #define PAGE_FREE_INTERVAL 1000
43621
43622@@ -299,15 +299,14 @@ static void ttm_pool_update_free_locked(struct ttm_page_pool *pool,
43623 * @free_all: If set to true will free all pages in pool
43624 * @use_static: Safe to use static buffer
43625 **/
43626-static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free,
43627+static unsigned long ttm_page_pool_free(struct ttm_page_pool *pool, unsigned long nr_free,
43628 bool use_static)
43629 {
43630 static struct page *static_buf[NUM_PAGES_TO_ALLOC];
43631 unsigned long irq_flags;
43632 struct page *p;
43633 struct page **pages_to_free;
43634- unsigned freed_pages = 0,
43635- npages_to_free = nr_free;
43636+ unsigned long freed_pages = 0, npages_to_free = nr_free;
43637
43638 if (NUM_PAGES_TO_ALLOC < nr_free)
43639 npages_to_free = NUM_PAGES_TO_ALLOC;
43640@@ -371,7 +370,8 @@ restart:
43641 __list_del(&p->lru, &pool->list);
43642
43643 ttm_pool_update_free_locked(pool, freed_pages);
43644- nr_free -= freed_pages;
43645+ if (likely(nr_free != FREE_ALL_PAGES))
43646+ nr_free -= freed_pages;
43647 }
43648
43649 spin_unlock_irqrestore(&pool->lock, irq_flags);
43650@@ -399,7 +399,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43651 unsigned i;
43652 unsigned pool_offset;
43653 struct ttm_page_pool *pool;
43654- int shrink_pages = sc->nr_to_scan;
43655+ unsigned long shrink_pages = sc->nr_to_scan;
43656 unsigned long freed = 0;
43657
43658 if (!mutex_trylock(&lock))
43659@@ -407,7 +407,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43660 pool_offset = ++start_pool % NUM_POOLS;
43661 /* select start pool in round robin fashion */
43662 for (i = 0; i < NUM_POOLS; ++i) {
43663- unsigned nr_free = shrink_pages;
43664+ unsigned long nr_free = shrink_pages;
43665 if (shrink_pages == 0)
43666 break;
43667 pool = &_manager->pools[(i + pool_offset)%NUM_POOLS];
43668@@ -673,7 +673,7 @@ out:
43669 }
43670
43671 /* Put all pages in pages list to correct pool to wait for reuse */
43672-static void ttm_put_pages(struct page **pages, unsigned npages, int flags,
43673+static void ttm_put_pages(struct page **pages, unsigned long npages, int flags,
43674 enum ttm_caching_state cstate)
43675 {
43676 unsigned long irq_flags;
43677@@ -728,7 +728,7 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,
43678 struct list_head plist;
43679 struct page *p = NULL;
43680 gfp_t gfp_flags = GFP_USER;
43681- unsigned count;
43682+ unsigned long count;
43683 int r;
43684
43685 /* set zero flag for page allocation if required */
43686diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
43687index 624d941..106fa1f 100644
43688--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
43689+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
43690@@ -56,7 +56,7 @@
43691
43692 #define NUM_PAGES_TO_ALLOC (PAGE_SIZE/sizeof(struct page *))
43693 #define SMALL_ALLOCATION 4
43694-#define FREE_ALL_PAGES (~0U)
43695+#define FREE_ALL_PAGES (~0UL)
43696 /* times are in msecs */
43697 #define IS_UNDEFINED (0)
43698 #define IS_WC (1<<1)
43699@@ -416,7 +416,7 @@ static void ttm_dma_page_put(struct dma_pool *pool, struct dma_page *d_page)
43700 * @nr_free: If set to true will free all pages in pool
43701 * @use_static: Safe to use static buffer
43702 **/
43703-static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free,
43704+static unsigned long ttm_dma_page_pool_free(struct dma_pool *pool, unsigned long nr_free,
43705 bool use_static)
43706 {
43707 static struct page *static_buf[NUM_PAGES_TO_ALLOC];
43708@@ -424,8 +424,7 @@ static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free,
43709 struct dma_page *dma_p, *tmp;
43710 struct page **pages_to_free;
43711 struct list_head d_pages;
43712- unsigned freed_pages = 0,
43713- npages_to_free = nr_free;
43714+ unsigned long freed_pages = 0, npages_to_free = nr_free;
43715
43716 if (NUM_PAGES_TO_ALLOC < nr_free)
43717 npages_to_free = NUM_PAGES_TO_ALLOC;
43718@@ -502,7 +501,8 @@ restart:
43719 /* remove range of pages from the pool */
43720 if (freed_pages) {
43721 ttm_pool_update_free_locked(pool, freed_pages);
43722- nr_free -= freed_pages;
43723+ if (likely(nr_free != FREE_ALL_PAGES))
43724+ nr_free -= freed_pages;
43725 }
43726
43727 spin_unlock_irqrestore(&pool->lock, irq_flags);
43728@@ -939,7 +939,7 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)
43729 struct dma_page *d_page, *next;
43730 enum pool_type type;
43731 bool is_cached = false;
43732- unsigned count = 0, i, npages = 0;
43733+ unsigned long count = 0, i, npages = 0;
43734 unsigned long irq_flags;
43735
43736 type = ttm_to_type(ttm->page_flags, ttm->caching_state);
43737@@ -1014,7 +1014,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43738 static unsigned start_pool;
43739 unsigned idx = 0;
43740 unsigned pool_offset;
43741- unsigned shrink_pages = sc->nr_to_scan;
43742+ unsigned long shrink_pages = sc->nr_to_scan;
43743 struct device_pools *p;
43744 unsigned long freed = 0;
43745
43746@@ -1027,7 +1027,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43747 goto out;
43748 pool_offset = ++start_pool % _manager->npools;
43749 list_for_each_entry(p, &_manager->pools, pools) {
43750- unsigned nr_free;
43751+ unsigned long nr_free;
43752
43753 if (!p->dev)
43754 continue;
43755@@ -1041,7 +1041,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43756 shrink_pages = ttm_dma_page_pool_free(p->pool, nr_free, true);
43757 freed += nr_free - shrink_pages;
43758
43759- pr_debug("%s: (%s:%d) Asked to shrink %d, have %d more to go\n",
43760+ pr_debug("%s: (%s:%d) Asked to shrink %lu, have %lu more to go\n",
43761 p->pool->dev_name, p->pool->name, current->pid,
43762 nr_free, shrink_pages);
43763 }
43764diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
43765index 5fc16ce..1bd84ec 100644
43766--- a/drivers/gpu/drm/udl/udl_fb.c
43767+++ b/drivers/gpu/drm/udl/udl_fb.c
43768@@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
43769 fb_deferred_io_cleanup(info);
43770 kfree(info->fbdefio);
43771 info->fbdefio = NULL;
43772- info->fbops->fb_mmap = udl_fb_mmap;
43773 }
43774
43775 pr_warn("released /dev/fb%d user=%d count=%d\n",
43776diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
43777index ef8c500..01030c8 100644
43778--- a/drivers/gpu/drm/via/via_drv.h
43779+++ b/drivers/gpu/drm/via/via_drv.h
43780@@ -53,7 +53,7 @@ typedef struct drm_via_ring_buffer {
43781 typedef uint32_t maskarray_t[5];
43782
43783 typedef struct drm_via_irq {
43784- atomic_t irq_received;
43785+ atomic_unchecked_t irq_received;
43786 uint32_t pending_mask;
43787 uint32_t enable_mask;
43788 wait_queue_head_t irq_queue;
43789@@ -77,7 +77,7 @@ typedef struct drm_via_private {
43790 struct timeval last_vblank;
43791 int last_vblank_valid;
43792 unsigned usec_per_vblank;
43793- atomic_t vbl_received;
43794+ atomic_unchecked_t vbl_received;
43795 drm_via_state_t hc_state;
43796 char pci_buf[VIA_PCI_BUF_SIZE];
43797 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
43798diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
43799index 1319433..a993b0c 100644
43800--- a/drivers/gpu/drm/via/via_irq.c
43801+++ b/drivers/gpu/drm/via/via_irq.c
43802@@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
43803 if (crtc != 0)
43804 return 0;
43805
43806- return atomic_read(&dev_priv->vbl_received);
43807+ return atomic_read_unchecked(&dev_priv->vbl_received);
43808 }
43809
43810 irqreturn_t via_driver_irq_handler(int irq, void *arg)
43811@@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
43812
43813 status = VIA_READ(VIA_REG_INTERRUPT);
43814 if (status & VIA_IRQ_VBLANK_PENDING) {
43815- atomic_inc(&dev_priv->vbl_received);
43816- if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
43817+ atomic_inc_unchecked(&dev_priv->vbl_received);
43818+ if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
43819 do_gettimeofday(&cur_vblank);
43820 if (dev_priv->last_vblank_valid) {
43821 dev_priv->usec_per_vblank =
43822@@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
43823 dev_priv->last_vblank = cur_vblank;
43824 dev_priv->last_vblank_valid = 1;
43825 }
43826- if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
43827+ if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
43828 DRM_DEBUG("US per vblank is: %u\n",
43829 dev_priv->usec_per_vblank);
43830 }
43831@@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
43832
43833 for (i = 0; i < dev_priv->num_irqs; ++i) {
43834 if (status & cur_irq->pending_mask) {
43835- atomic_inc(&cur_irq->irq_received);
43836+ atomic_inc_unchecked(&cur_irq->irq_received);
43837 wake_up(&cur_irq->irq_queue);
43838 handled = 1;
43839 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
43840@@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
43841 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
43842 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
43843 masks[irq][4]));
43844- cur_irq_sequence = atomic_read(&cur_irq->irq_received);
43845+ cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
43846 } else {
43847 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
43848 (((cur_irq_sequence =
43849- atomic_read(&cur_irq->irq_received)) -
43850+ atomic_read_unchecked(&cur_irq->irq_received)) -
43851 *sequence) <= (1 << 23)));
43852 }
43853 *sequence = cur_irq_sequence;
43854@@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
43855 }
43856
43857 for (i = 0; i < dev_priv->num_irqs; ++i) {
43858- atomic_set(&cur_irq->irq_received, 0);
43859+ atomic_set_unchecked(&cur_irq->irq_received, 0);
43860 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
43861 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
43862 init_waitqueue_head(&cur_irq->irq_queue);
43863@@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
43864 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
43865 case VIA_IRQ_RELATIVE:
43866 irqwait->request.sequence +=
43867- atomic_read(&cur_irq->irq_received);
43868+ atomic_read_unchecked(&cur_irq->irq_received);
43869 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
43870 case VIA_IRQ_ABSOLUTE:
43871 break;
43872diff --git a/drivers/gpu/drm/virtio/virtgpu_debugfs.c b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
43873index db8b491..d87b27c 100644
43874--- a/drivers/gpu/drm/virtio/virtgpu_debugfs.c
43875+++ b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
43876@@ -34,7 +34,7 @@ virtio_gpu_debugfs_irq_info(struct seq_file *m, void *data)
43877 struct drm_info_node *node = (struct drm_info_node *) m->private;
43878 struct virtio_gpu_device *vgdev = node->minor->dev->dev_private;
43879
43880- seq_printf(m, "fence %ld %lld\n",
43881+ seq_printf(m, "fence %lld %lld\n",
43882 atomic64_read(&vgdev->fence_drv.last_seq),
43883 vgdev->fence_drv.sync_seq);
43884 return 0;
43885diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c
43886index 1da6326..98dd385 100644
43887--- a/drivers/gpu/drm/virtio/virtgpu_fence.c
43888+++ b/drivers/gpu/drm/virtio/virtgpu_fence.c
43889@@ -61,7 +61,7 @@ static void virtio_timeline_value_str(struct fence *f, char *str, int size)
43890 {
43891 struct virtio_gpu_fence *fence = to_virtio_fence(f);
43892
43893- snprintf(str, size, "%lu", atomic64_read(&fence->drv->last_seq));
43894+ snprintf(str, size, "%llu", atomic64_read(&fence->drv->last_seq));
43895 }
43896
43897 static const struct fence_ops virtio_fence_ops = {
43898diff --git a/drivers/gpu/drm/virtio/virtgpu_ttm.c b/drivers/gpu/drm/virtio/virtgpu_ttm.c
43899index b092d7b..3bbecd9 100644
43900--- a/drivers/gpu/drm/virtio/virtgpu_ttm.c
43901+++ b/drivers/gpu/drm/virtio/virtgpu_ttm.c
43902@@ -197,11 +197,11 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
43903 }
43904
43905 static const struct ttm_mem_type_manager_func virtio_gpu_bo_manager_func = {
43906- ttm_bo_man_init,
43907- ttm_bo_man_takedown,
43908- ttm_bo_man_get_node,
43909- ttm_bo_man_put_node,
43910- ttm_bo_man_debug
43911+ .init = &ttm_bo_man_init,
43912+ .takedown = &ttm_bo_man_takedown,
43913+ .get_node = &ttm_bo_man_get_node,
43914+ .put_node = &ttm_bo_man_put_node,
43915+ .debug = &ttm_bo_man_debug
43916 };
43917
43918 static int virtio_gpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
43919diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
43920index d26a6da..5fa41ed 100644
43921--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
43922+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
43923@@ -447,7 +447,7 @@ struct vmw_private {
43924 * Fencing and IRQs.
43925 */
43926
43927- atomic_t marker_seq;
43928+ atomic_unchecked_t marker_seq;
43929 wait_queue_head_t fence_queue;
43930 wait_queue_head_t fifo_queue;
43931 spinlock_t waiter_lock;
43932diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
43933index 39f2b03..d1b0a64 100644
43934--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
43935+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
43936@@ -152,7 +152,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
43937 (unsigned int) min,
43938 (unsigned int) fifo->capabilities);
43939
43940- atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
43941+ atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
43942 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
43943 vmw_marker_queue_init(&fifo->marker_queue);
43944 return vmw_fifo_send_fence(dev_priv, &dummy);
43945@@ -372,7 +372,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
43946 if (reserveable)
43947 iowrite32(bytes, fifo_mem +
43948 SVGA_FIFO_RESERVED);
43949- return fifo_mem + (next_cmd >> 2);
43950+ return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
43951 } else {
43952 need_bounce = true;
43953 }
43954@@ -492,7 +492,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
43955
43956 fm = vmw_fifo_reserve(dev_priv, bytes);
43957 if (unlikely(fm == NULL)) {
43958- *seqno = atomic_read(&dev_priv->marker_seq);
43959+ *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
43960 ret = -ENOMEM;
43961 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
43962 false, 3*HZ);
43963@@ -500,7 +500,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
43964 }
43965
43966 do {
43967- *seqno = atomic_add_return(1, &dev_priv->marker_seq);
43968+ *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
43969 } while (*seqno == 0);
43970
43971 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
43972diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
43973index 170b61b..fec7348 100644
43974--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
43975+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
43976@@ -164,9 +164,9 @@ static void vmw_gmrid_man_debug(struct ttm_mem_type_manager *man,
43977 }
43978
43979 const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
43980- vmw_gmrid_man_init,
43981- vmw_gmrid_man_takedown,
43982- vmw_gmrid_man_get_node,
43983- vmw_gmrid_man_put_node,
43984- vmw_gmrid_man_debug
43985+ .init = vmw_gmrid_man_init,
43986+ .takedown = vmw_gmrid_man_takedown,
43987+ .get_node = vmw_gmrid_man_get_node,
43988+ .put_node = vmw_gmrid_man_put_node,
43989+ .debug = vmw_gmrid_man_debug
43990 };
43991diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
43992index 69c8ce2..cacb0ab 100644
43993--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
43994+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
43995@@ -235,7 +235,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
43996 int ret;
43997
43998 num_clips = arg->num_clips;
43999- clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
44000+ clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
44001
44002 if (unlikely(num_clips == 0))
44003 return 0;
44004@@ -318,7 +318,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
44005 int ret;
44006
44007 num_clips = arg->num_clips;
44008- clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
44009+ clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
44010
44011 if (unlikely(num_clips == 0))
44012 return 0;
44013diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
44014index 9fe9827..0aa2fc0 100644
44015--- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
44016+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
44017@@ -102,7 +102,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
44018 * emitted. Then the fence is stale and signaled.
44019 */
44020
44021- ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
44022+ ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
44023 > VMW_FENCE_WRAP);
44024
44025 return ret;
44026@@ -133,7 +133,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
44027
44028 if (fifo_idle)
44029 down_read(&fifo_state->rwsem);
44030- signal_seq = atomic_read(&dev_priv->marker_seq);
44031+ signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
44032 ret = 0;
44033
44034 for (;;) {
44035diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
44036index efd1ffd..0ae13ca 100644
44037--- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
44038+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
44039@@ -135,7 +135,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
44040 while (!vmw_lag_lt(queue, us)) {
44041 spin_lock(&queue->lock);
44042 if (list_empty(&queue->head))
44043- seqno = atomic_read(&dev_priv->marker_seq);
44044+ seqno = atomic_read_unchecked(&dev_priv->marker_seq);
44045 else {
44046 marker = list_first_entry(&queue->head,
44047 struct vmw_marker, head);
44048diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
44049index 37ac7b5..d52a5c9 100644
44050--- a/drivers/gpu/vga/vga_switcheroo.c
44051+++ b/drivers/gpu/vga/vga_switcheroo.c
44052@@ -644,7 +644,7 @@ static int vga_switcheroo_runtime_resume(struct device *dev)
44053
44054 /* this version is for the case where the power switch is separate
44055 to the device being powered down. */
44056-int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain)
44057+int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain)
44058 {
44059 /* copy over all the bus versions */
44060 if (dev->bus && dev->bus->pm) {
44061@@ -695,7 +695,7 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
44062 return ret;
44063 }
44064
44065-int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain)
44066+int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain)
44067 {
44068 /* copy over all the bus versions */
44069 if (dev->bus && dev->bus->pm) {
44070diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
44071index e6fce23..85949a0 100644
44072--- a/drivers/hid/hid-core.c
44073+++ b/drivers/hid/hid-core.c
44074@@ -2550,7 +2550,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
44075
44076 int hid_add_device(struct hid_device *hdev)
44077 {
44078- static atomic_t id = ATOMIC_INIT(0);
44079+ static atomic_unchecked_t id = ATOMIC_INIT(0);
44080 int ret;
44081
44082 if (WARN_ON(hdev->status & HID_STAT_ADDED))
44083@@ -2593,7 +2593,7 @@ int hid_add_device(struct hid_device *hdev)
44084 /* XXX hack, any other cleaner solution after the driver core
44085 * is converted to allow more than 20 bytes as the device name? */
44086 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
44087- hdev->vendor, hdev->product, atomic_inc_return(&id));
44088+ hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
44089
44090 hid_debug_register(hdev, dev_name(&hdev->dev));
44091 ret = device_add(&hdev->dev);
44092diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
44093index 5614fee..8a6f5f6 100644
44094--- a/drivers/hid/hid-sensor-custom.c
44095+++ b/drivers/hid/hid-sensor-custom.c
44096@@ -590,7 +590,7 @@ static int hid_sensor_custom_add_attributes(struct hid_sensor_custom
44097 j = 0;
44098 while (j < HID_CUSTOM_TOTAL_ATTRS &&
44099 hid_custom_attrs[j].name) {
44100- struct device_attribute *device_attr;
44101+ device_attribute_no_const *device_attr;
44102
44103 device_attr = &sensor_inst->fields[i].sd_attrs[j];
44104
44105diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
44106index c13fb5b..55a3802 100644
44107--- a/drivers/hid/hid-wiimote-debug.c
44108+++ b/drivers/hid/hid-wiimote-debug.c
44109@@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
44110 else if (size == 0)
44111 return -EIO;
44112
44113- if (copy_to_user(u, buf, size))
44114+ if (size > sizeof(buf) || copy_to_user(u, buf, size))
44115 return -EFAULT;
44116
44117 *off += size;
44118diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
44119index 603ce97..7f27468 100644
44120--- a/drivers/hv/channel.c
44121+++ b/drivers/hv/channel.c
44122@@ -382,7 +382,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
44123 int ret = 0;
44124
44125 next_gpadl_handle =
44126- (atomic_inc_return(&vmbus_connection.next_gpadl_handle) - 1);
44127+ (atomic_inc_return_unchecked(&vmbus_connection.next_gpadl_handle) - 1);
44128
44129 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
44130 if (ret)
44131diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
44132index d3943bc..597fd1e 100644
44133--- a/drivers/hv/hv.c
44134+++ b/drivers/hv/hv.c
44135@@ -118,7 +118,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
44136 u64 output_address = (output) ? virt_to_phys(output) : 0;
44137 u32 output_address_hi = output_address >> 32;
44138 u32 output_address_lo = output_address & 0xFFFFFFFF;
44139- void *hypercall_page = hv_context.hypercall_page;
44140+ void *hypercall_page = (void *)ktva_ktla((unsigned long)hv_context.hypercall_page);
44141
44142 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
44143 "=a"(hv_status_lo) : "d" (control_hi),
44144@@ -164,7 +164,7 @@ int hv_init(void)
44145 /* See if the hypercall page is already set */
44146 rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
44147
44148- virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
44149+ virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_RX);
44150
44151 if (!virtaddr)
44152 goto cleanup;
44153diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
44154index 8a725cd..91abaf0 100644
44155--- a/drivers/hv/hv_balloon.c
44156+++ b/drivers/hv/hv_balloon.c
44157@@ -469,7 +469,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
44158
44159 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
44160 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
44161-static atomic_t trans_id = ATOMIC_INIT(0);
44162+static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
44163
44164 static int dm_ring_size = (5 * PAGE_SIZE);
44165
44166@@ -943,7 +943,7 @@ static void hot_add_req(struct work_struct *dummy)
44167 pr_info("Memory hot add failed\n");
44168
44169 dm->state = DM_INITIALIZED;
44170- resp.hdr.trans_id = atomic_inc_return(&trans_id);
44171+ resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44172 vmbus_sendpacket(dm->dev->channel, &resp,
44173 sizeof(struct dm_hot_add_response),
44174 (unsigned long)NULL,
44175@@ -1024,7 +1024,7 @@ static void post_status(struct hv_dynmem_device *dm)
44176 memset(&status, 0, sizeof(struct dm_status));
44177 status.hdr.type = DM_STATUS_REPORT;
44178 status.hdr.size = sizeof(struct dm_status);
44179- status.hdr.trans_id = atomic_inc_return(&trans_id);
44180+ status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44181
44182 /*
44183 * The host expects the guest to report free and committed memory.
44184@@ -1048,7 +1048,7 @@ static void post_status(struct hv_dynmem_device *dm)
44185 * send the status. This can happen if we were interrupted
44186 * after we picked our transaction ID.
44187 */
44188- if (status.hdr.trans_id != atomic_read(&trans_id))
44189+ if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
44190 return;
44191
44192 /*
44193@@ -1193,7 +1193,7 @@ static void balloon_up(struct work_struct *dummy)
44194 */
44195
44196 do {
44197- bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
44198+ bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44199 ret = vmbus_sendpacket(dm_device.dev->channel,
44200 bl_resp,
44201 bl_resp->hdr.size,
44202@@ -1239,7 +1239,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
44203
44204 memset(&resp, 0, sizeof(struct dm_unballoon_response));
44205 resp.hdr.type = DM_UNBALLOON_RESPONSE;
44206- resp.hdr.trans_id = atomic_inc_return(&trans_id);
44207+ resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44208 resp.hdr.size = sizeof(struct dm_unballoon_response);
44209
44210 vmbus_sendpacket(dm_device.dev->channel, &resp,
44211@@ -1300,7 +1300,7 @@ static void version_resp(struct hv_dynmem_device *dm,
44212 memset(&version_req, 0, sizeof(struct dm_version_request));
44213 version_req.hdr.type = DM_VERSION_REQUEST;
44214 version_req.hdr.size = sizeof(struct dm_version_request);
44215- version_req.hdr.trans_id = atomic_inc_return(&trans_id);
44216+ version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44217 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
44218 version_req.is_last_attempt = 1;
44219
44220@@ -1473,7 +1473,7 @@ static int balloon_probe(struct hv_device *dev,
44221 memset(&version_req, 0, sizeof(struct dm_version_request));
44222 version_req.hdr.type = DM_VERSION_REQUEST;
44223 version_req.hdr.size = sizeof(struct dm_version_request);
44224- version_req.hdr.trans_id = atomic_inc_return(&trans_id);
44225+ version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44226 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
44227 version_req.is_last_attempt = 0;
44228
44229@@ -1504,7 +1504,7 @@ static int balloon_probe(struct hv_device *dev,
44230 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
44231 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
44232 cap_msg.hdr.size = sizeof(struct dm_capabilities);
44233- cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
44234+ cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44235
44236 cap_msg.caps.cap_bits.balloon = 1;
44237 cap_msg.caps.cap_bits.hot_add = 1;
44238diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
44239index cddc0c9..2eb587d 100644
44240--- a/drivers/hv/hyperv_vmbus.h
44241+++ b/drivers/hv/hyperv_vmbus.h
44242@@ -645,7 +645,7 @@ enum vmbus_connect_state {
44243 struct vmbus_connection {
44244 enum vmbus_connect_state conn_state;
44245
44246- atomic_t next_gpadl_handle;
44247+ atomic_unchecked_t next_gpadl_handle;
44248
44249 struct completion unload_event;
44250 /*
44251diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
44252index 579bdf9..0dac21d5 100644
44253--- a/drivers/hwmon/acpi_power_meter.c
44254+++ b/drivers/hwmon/acpi_power_meter.c
44255@@ -116,7 +116,7 @@ struct sensor_template {
44256 struct device_attribute *devattr,
44257 const char *buf, size_t count);
44258 int index;
44259-};
44260+} __do_const;
44261
44262 /* Averaging interval */
44263 static int update_avg_interval(struct acpi_power_meter_resource *resource)
44264@@ -631,7 +631,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
44265 struct sensor_template *attrs)
44266 {
44267 struct device *dev = &resource->acpi_dev->dev;
44268- struct sensor_device_attribute *sensors =
44269+ sensor_device_attribute_no_const *sensors =
44270 &resource->sensors[resource->num_sensors];
44271 int res = 0;
44272
44273@@ -973,7 +973,7 @@ static int __init enable_cap_knobs(const struct dmi_system_id *d)
44274 return 0;
44275 }
44276
44277-static struct dmi_system_id __initdata pm_dmi_table[] = {
44278+static const struct dmi_system_id __initconst pm_dmi_table[] = {
44279 {
44280 enable_cap_knobs, "IBM Active Energy Manager",
44281 {
44282diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
44283index 0af63da..05a183a 100644
44284--- a/drivers/hwmon/applesmc.c
44285+++ b/drivers/hwmon/applesmc.c
44286@@ -1105,7 +1105,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
44287 {
44288 struct applesmc_node_group *grp;
44289 struct applesmc_dev_attr *node;
44290- struct attribute *attr;
44291+ attribute_no_const *attr;
44292 int ret, i;
44293
44294 for (grp = groups; grp->format; grp++) {
44295diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
44296index cccef87..06ce8ec 100644
44297--- a/drivers/hwmon/asus_atk0110.c
44298+++ b/drivers/hwmon/asus_atk0110.c
44299@@ -147,10 +147,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
44300 struct atk_sensor_data {
44301 struct list_head list;
44302 struct atk_data *data;
44303- struct device_attribute label_attr;
44304- struct device_attribute input_attr;
44305- struct device_attribute limit1_attr;
44306- struct device_attribute limit2_attr;
44307+ device_attribute_no_const label_attr;
44308+ device_attribute_no_const input_attr;
44309+ device_attribute_no_const limit1_attr;
44310+ device_attribute_no_const limit2_attr;
44311 char label_attr_name[ATTR_NAME_SIZE];
44312 char input_attr_name[ATTR_NAME_SIZE];
44313 char limit1_attr_name[ATTR_NAME_SIZE];
44314@@ -270,7 +270,7 @@ static ssize_t atk_name_show(struct device *dev,
44315 static struct device_attribute atk_name_attr =
44316 __ATTR(name, 0444, atk_name_show, NULL);
44317
44318-static void atk_init_attribute(struct device_attribute *attr, char *name,
44319+static void atk_init_attribute(device_attribute_no_const *attr, char *name,
44320 sysfs_show_func show)
44321 {
44322 sysfs_attr_init(&attr->attr);
44323diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
44324index 3e03379..ec521d3 100644
44325--- a/drivers/hwmon/coretemp.c
44326+++ b/drivers/hwmon/coretemp.c
44327@@ -783,7 +783,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
44328 return NOTIFY_OK;
44329 }
44330
44331-static struct notifier_block coretemp_cpu_notifier __refdata = {
44332+static struct notifier_block coretemp_cpu_notifier = {
44333 .notifier_call = coretemp_cpu_callback,
44334 };
44335
44336diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
44337index c848789..e9e9217 100644
44338--- a/drivers/hwmon/dell-smm-hwmon.c
44339+++ b/drivers/hwmon/dell-smm-hwmon.c
44340@@ -819,7 +819,7 @@ static const struct i8k_config_data i8k_config_data[] = {
44341 },
44342 };
44343
44344-static struct dmi_system_id i8k_dmi_table[] __initdata = {
44345+static const struct dmi_system_id i8k_dmi_table[] __initconst = {
44346 {
44347 .ident = "Dell Inspiron",
44348 .matches = {
44349diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
44350index 7a8a6fb..015c1fd 100644
44351--- a/drivers/hwmon/ibmaem.c
44352+++ b/drivers/hwmon/ibmaem.c
44353@@ -924,7 +924,7 @@ static int aem_register_sensors(struct aem_data *data,
44354 struct aem_rw_sensor_template *rw)
44355 {
44356 struct device *dev = &data->pdev->dev;
44357- struct sensor_device_attribute *sensors = data->sensors;
44358+ sensor_device_attribute_no_const *sensors = data->sensors;
44359 int err;
44360
44361 /* Set up read-only sensors */
44362diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
44363index 17ae2eb..21b71dd 100644
44364--- a/drivers/hwmon/iio_hwmon.c
44365+++ b/drivers/hwmon/iio_hwmon.c
44366@@ -61,7 +61,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
44367 {
44368 struct device *dev = &pdev->dev;
44369 struct iio_hwmon_state *st;
44370- struct sensor_device_attribute *a;
44371+ sensor_device_attribute_no_const *a;
44372 int ret, i;
44373 int in_i = 1, temp_i = 1, curr_i = 1, humidity_i = 1;
44374 enum iio_chan_type type;
44375diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
44376index 37f0170..414ec2c 100644
44377--- a/drivers/hwmon/nct6683.c
44378+++ b/drivers/hwmon/nct6683.c
44379@@ -397,11 +397,11 @@ static struct attribute_group *
44380 nct6683_create_attr_group(struct device *dev, struct sensor_template_group *tg,
44381 int repeat)
44382 {
44383- struct sensor_device_attribute_2 *a2;
44384- struct sensor_device_attribute *a;
44385+ sensor_device_attribute_2_no_const *a2;
44386+ sensor_device_attribute_no_const *a;
44387 struct sensor_device_template **t;
44388 struct sensor_device_attr_u *su;
44389- struct attribute_group *group;
44390+ attribute_group_no_const *group;
44391 struct attribute **attrs;
44392 int i, j, count;
44393
44394diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
44395index 2aaedbe..e944f14 100644
44396--- a/drivers/hwmon/nct6775.c
44397+++ b/drivers/hwmon/nct6775.c
44398@@ -957,10 +957,10 @@ static struct attribute_group *
44399 nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
44400 int repeat)
44401 {
44402- struct attribute_group *group;
44403+ attribute_group_no_const *group;
44404 struct sensor_device_attr_u *su;
44405- struct sensor_device_attribute *a;
44406- struct sensor_device_attribute_2 *a2;
44407+ sensor_device_attribute_no_const *a;
44408+ sensor_device_attribute_2_no_const *a2;
44409 struct attribute **attrs;
44410 struct sensor_device_template **t;
44411 int i, count;
44412diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
44413index f2e47c7..45d7941 100644
44414--- a/drivers/hwmon/pmbus/pmbus_core.c
44415+++ b/drivers/hwmon/pmbus/pmbus_core.c
44416@@ -816,7 +816,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
44417 return 0;
44418 }
44419
44420-static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
44421+static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
44422 const char *name,
44423 umode_t mode,
44424 ssize_t (*show)(struct device *dev,
44425@@ -833,7 +833,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
44426 dev_attr->store = store;
44427 }
44428
44429-static void pmbus_attr_init(struct sensor_device_attribute *a,
44430+static void pmbus_attr_init(sensor_device_attribute_no_const *a,
44431 const char *name,
44432 umode_t mode,
44433 ssize_t (*show)(struct device *dev,
44434@@ -855,7 +855,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
44435 u16 reg, u8 mask)
44436 {
44437 struct pmbus_boolean *boolean;
44438- struct sensor_device_attribute *a;
44439+ sensor_device_attribute_no_const *a;
44440
44441 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
44442 if (!boolean)
44443@@ -880,7 +880,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
44444 bool update, bool readonly)
44445 {
44446 struct pmbus_sensor *sensor;
44447- struct device_attribute *a;
44448+ device_attribute_no_const *a;
44449
44450 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
44451 if (!sensor)
44452@@ -911,7 +911,7 @@ static int pmbus_add_label(struct pmbus_data *data,
44453 const char *lstring, int index)
44454 {
44455 struct pmbus_label *label;
44456- struct device_attribute *a;
44457+ device_attribute_no_const *a;
44458
44459 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
44460 if (!label)
44461diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
44462index 497a7f8..3fffedf 100644
44463--- a/drivers/hwmon/sht15.c
44464+++ b/drivers/hwmon/sht15.c
44465@@ -169,7 +169,7 @@ struct sht15_data {
44466 int supply_uv;
44467 bool supply_uv_valid;
44468 struct work_struct update_supply_work;
44469- atomic_t interrupt_handled;
44470+ atomic_unchecked_t interrupt_handled;
44471 };
44472
44473 /**
44474@@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
44475 ret = gpio_direction_input(data->pdata->gpio_data);
44476 if (ret)
44477 return ret;
44478- atomic_set(&data->interrupt_handled, 0);
44479+ atomic_set_unchecked(&data->interrupt_handled, 0);
44480
44481 enable_irq(gpio_to_irq(data->pdata->gpio_data));
44482 if (gpio_get_value(data->pdata->gpio_data) == 0) {
44483 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
44484 /* Only relevant if the interrupt hasn't occurred. */
44485- if (!atomic_read(&data->interrupt_handled))
44486+ if (!atomic_read_unchecked(&data->interrupt_handled))
44487 schedule_work(&data->read_work);
44488 }
44489 ret = wait_event_timeout(data->wait_queue,
44490@@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
44491
44492 /* First disable the interrupt */
44493 disable_irq_nosync(irq);
44494- atomic_inc(&data->interrupt_handled);
44495+ atomic_inc_unchecked(&data->interrupt_handled);
44496 /* Then schedule a reading work struct */
44497 if (data->state != SHT15_READING_NOTHING)
44498 schedule_work(&data->read_work);
44499@@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
44500 * If not, then start the interrupt again - care here as could
44501 * have gone low in meantime so verify it hasn't!
44502 */
44503- atomic_set(&data->interrupt_handled, 0);
44504+ atomic_set_unchecked(&data->interrupt_handled, 0);
44505 enable_irq(gpio_to_irq(data->pdata->gpio_data));
44506 /* If still not occurred or another handler was scheduled */
44507 if (gpio_get_value(data->pdata->gpio_data)
44508- || atomic_read(&data->interrupt_handled))
44509+ || atomic_read_unchecked(&data->interrupt_handled))
44510 return;
44511 }
44512
44513diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
44514index ac91c07..8e69663 100644
44515--- a/drivers/hwmon/via-cputemp.c
44516+++ b/drivers/hwmon/via-cputemp.c
44517@@ -295,7 +295,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
44518 return NOTIFY_OK;
44519 }
44520
44521-static struct notifier_block via_cputemp_cpu_notifier __refdata = {
44522+static struct notifier_block via_cputemp_cpu_notifier = {
44523 .notifier_call = via_cputemp_cpu_callback,
44524 };
44525
44526diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
44527index 65e3240..e6c511d 100644
44528--- a/drivers/i2c/busses/i2c-amd756-s4882.c
44529+++ b/drivers/i2c/busses/i2c-amd756-s4882.c
44530@@ -39,7 +39,7 @@
44531 extern struct i2c_adapter amd756_smbus;
44532
44533 static struct i2c_adapter *s4882_adapter;
44534-static struct i2c_algorithm *s4882_algo;
44535+static i2c_algorithm_no_const *s4882_algo;
44536
44537 /* Wrapper access functions for multiplexed SMBus */
44538 static DEFINE_MUTEX(amd756_lock);
44539diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
44540index 88eda09..cf40434 100644
44541--- a/drivers/i2c/busses/i2c-nforce2-s4985.c
44542+++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
44543@@ -37,7 +37,7 @@
44544 extern struct i2c_adapter *nforce2_smbus;
44545
44546 static struct i2c_adapter *s4985_adapter;
44547-static struct i2c_algorithm *s4985_algo;
44548+static i2c_algorithm_no_const *s4985_algo;
44549
44550 /* Wrapper access functions for multiplexed SMBus */
44551 static DEFINE_MUTEX(nforce2_lock);
44552diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
44553index 71c7a39..71dd3e0 100644
44554--- a/drivers/i2c/i2c-dev.c
44555+++ b/drivers/i2c/i2c-dev.c
44556@@ -272,7 +272,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
44557 break;
44558 }
44559
44560- data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
44561+ data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
44562 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
44563 if (IS_ERR(rdwr_pa[i].buf)) {
44564 res = PTR_ERR(rdwr_pa[i].buf);
44565diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
44566index 64a6b82..a524354 100644
44567--- a/drivers/ide/ide-cd.c
44568+++ b/drivers/ide/ide-cd.c
44569@@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
44570 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
44571 if ((unsigned long)buf & alignment
44572 || blk_rq_bytes(rq) & q->dma_pad_mask
44573- || object_is_on_stack(buf))
44574+ || object_starts_on_stack(buf))
44575 drive->dma = 0;
44576 }
44577 }
44578diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
44579index 56b9708..980b63b 100644
44580--- a/drivers/ide/ide-disk.c
44581+++ b/drivers/ide/ide-disk.c
44582@@ -178,7 +178,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
44583 * 1073741822 == 549756 MB or 48bit addressing fake drive
44584 */
44585
44586-static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
44587+static ide_startstop_t __intentional_overflow(-1) ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
44588 sector_t block)
44589 {
44590 ide_hwif_t *hwif = drive->hwif;
44591diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
44592index 3524b0d..8c14520 100644
44593--- a/drivers/iio/industrialio-core.c
44594+++ b/drivers/iio/industrialio-core.c
44595@@ -576,7 +576,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
44596 }
44597
44598 static
44599-int __iio_device_attr_init(struct device_attribute *dev_attr,
44600+int __iio_device_attr_init(device_attribute_no_const *dev_attr,
44601 const char *postfix,
44602 struct iio_chan_spec const *chan,
44603 ssize_t (*readfunc)(struct device *dev,
44604diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
44605index b13936d..65322b2 100644
44606--- a/drivers/iio/magnetometer/ak8975.c
44607+++ b/drivers/iio/magnetometer/ak8975.c
44608@@ -776,7 +776,7 @@ static int ak8975_probe(struct i2c_client *client,
44609 name = id->name;
44610 } else if (ACPI_HANDLE(&client->dev))
44611 name = ak8975_match_acpi_device(&client->dev, &chipset);
44612- else
44613+ if (!name)
44614 return -ENOSYS;
44615
44616 if (chipset >= AK_MAX_TYPE) {
44617diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
44618index 3a972eb..4126183 100644
44619--- a/drivers/infiniband/core/cm.c
44620+++ b/drivers/infiniband/core/cm.c
44621@@ -115,7 +115,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
44622
44623 struct cm_counter_group {
44624 struct kobject obj;
44625- atomic_long_t counter[CM_ATTR_COUNT];
44626+ atomic_long_unchecked_t counter[CM_ATTR_COUNT];
44627 };
44628
44629 struct cm_counter_attribute {
44630@@ -1411,7 +1411,7 @@ static void cm_dup_req_handler(struct cm_work *work,
44631 struct ib_mad_send_buf *msg = NULL;
44632 int ret;
44633
44634- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44635+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44636 counter[CM_REQ_COUNTER]);
44637
44638 /* Quick state check to discard duplicate REQs. */
44639@@ -1798,7 +1798,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
44640 if (!cm_id_priv)
44641 return;
44642
44643- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44644+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44645 counter[CM_REP_COUNTER]);
44646 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
44647 if (ret)
44648@@ -1965,7 +1965,7 @@ static int cm_rtu_handler(struct cm_work *work)
44649 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
44650 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
44651 spin_unlock_irq(&cm_id_priv->lock);
44652- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44653+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44654 counter[CM_RTU_COUNTER]);
44655 goto out;
44656 }
44657@@ -2148,7 +2148,7 @@ static int cm_dreq_handler(struct cm_work *work)
44658 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
44659 dreq_msg->local_comm_id);
44660 if (!cm_id_priv) {
44661- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44662+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44663 counter[CM_DREQ_COUNTER]);
44664 cm_issue_drep(work->port, work->mad_recv_wc);
44665 return -EINVAL;
44666@@ -2173,7 +2173,7 @@ static int cm_dreq_handler(struct cm_work *work)
44667 case IB_CM_MRA_REP_RCVD:
44668 break;
44669 case IB_CM_TIMEWAIT:
44670- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44671+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44672 counter[CM_DREQ_COUNTER]);
44673 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
44674 goto unlock;
44675@@ -2187,7 +2187,7 @@ static int cm_dreq_handler(struct cm_work *work)
44676 cm_free_msg(msg);
44677 goto deref;
44678 case IB_CM_DREQ_RCVD:
44679- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44680+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44681 counter[CM_DREQ_COUNTER]);
44682 goto unlock;
44683 default:
44684@@ -2554,7 +2554,7 @@ static int cm_mra_handler(struct cm_work *work)
44685 ib_modify_mad(cm_id_priv->av.port->mad_agent,
44686 cm_id_priv->msg, timeout)) {
44687 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
44688- atomic_long_inc(&work->port->
44689+ atomic_long_inc_unchecked(&work->port->
44690 counter_group[CM_RECV_DUPLICATES].
44691 counter[CM_MRA_COUNTER]);
44692 goto out;
44693@@ -2563,7 +2563,7 @@ static int cm_mra_handler(struct cm_work *work)
44694 break;
44695 case IB_CM_MRA_REQ_RCVD:
44696 case IB_CM_MRA_REP_RCVD:
44697- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44698+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44699 counter[CM_MRA_COUNTER]);
44700 /* fall through */
44701 default:
44702@@ -2725,7 +2725,7 @@ static int cm_lap_handler(struct cm_work *work)
44703 case IB_CM_LAP_IDLE:
44704 break;
44705 case IB_CM_MRA_LAP_SENT:
44706- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44707+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44708 counter[CM_LAP_COUNTER]);
44709 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
44710 goto unlock;
44711@@ -2741,7 +2741,7 @@ static int cm_lap_handler(struct cm_work *work)
44712 cm_free_msg(msg);
44713 goto deref;
44714 case IB_CM_LAP_RCVD:
44715- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44716+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44717 counter[CM_LAP_COUNTER]);
44718 goto unlock;
44719 default:
44720@@ -3025,7 +3025,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
44721 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
44722 if (cur_cm_id_priv) {
44723 spin_unlock_irq(&cm.lock);
44724- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44725+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44726 counter[CM_SIDR_REQ_COUNTER]);
44727 goto out; /* Duplicate message. */
44728 }
44729@@ -3237,10 +3237,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
44730 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
44731 msg->retries = 1;
44732
44733- atomic_long_add(1 + msg->retries,
44734+ atomic_long_add_unchecked(1 + msg->retries,
44735 &port->counter_group[CM_XMIT].counter[attr_index]);
44736 if (msg->retries)
44737- atomic_long_add(msg->retries,
44738+ atomic_long_add_unchecked(msg->retries,
44739 &port->counter_group[CM_XMIT_RETRIES].
44740 counter[attr_index]);
44741
44742@@ -3466,7 +3466,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
44743 }
44744
44745 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
44746- atomic_long_inc(&port->counter_group[CM_RECV].
44747+ atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
44748 counter[attr_id - CM_ATTR_ID_OFFSET]);
44749
44750 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
44751@@ -3709,7 +3709,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
44752 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
44753
44754 return sprintf(buf, "%ld\n",
44755- atomic_long_read(&group->counter[cm_attr->index]));
44756+ atomic_long_read_unchecked(&group->counter[cm_attr->index]));
44757 }
44758
44759 static const struct sysfs_ops cm_counter_ops = {
44760diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
44761index 9f5ad7c..588cd84 100644
44762--- a/drivers/infiniband/core/fmr_pool.c
44763+++ b/drivers/infiniband/core/fmr_pool.c
44764@@ -98,8 +98,8 @@ struct ib_fmr_pool {
44765
44766 struct task_struct *thread;
44767
44768- atomic_t req_ser;
44769- atomic_t flush_ser;
44770+ atomic_unchecked_t req_ser;
44771+ atomic_unchecked_t flush_ser;
44772
44773 wait_queue_head_t force_wait;
44774 };
44775@@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
44776 struct ib_fmr_pool *pool = pool_ptr;
44777
44778 do {
44779- if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
44780+ if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
44781 ib_fmr_batch_release(pool);
44782
44783- atomic_inc(&pool->flush_ser);
44784+ atomic_inc_unchecked(&pool->flush_ser);
44785 wake_up_interruptible(&pool->force_wait);
44786
44787 if (pool->flush_function)
44788@@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
44789 }
44790
44791 set_current_state(TASK_INTERRUPTIBLE);
44792- if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
44793+ if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
44794 !kthread_should_stop())
44795 schedule();
44796 __set_current_state(TASK_RUNNING);
44797@@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
44798 pool->dirty_watermark = params->dirty_watermark;
44799 pool->dirty_len = 0;
44800 spin_lock_init(&pool->pool_lock);
44801- atomic_set(&pool->req_ser, 0);
44802- atomic_set(&pool->flush_ser, 0);
44803+ atomic_set_unchecked(&pool->req_ser, 0);
44804+ atomic_set_unchecked(&pool->flush_ser, 0);
44805 init_waitqueue_head(&pool->force_wait);
44806
44807 pool->thread = kthread_run(ib_fmr_cleanup_thread,
44808@@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
44809 }
44810 spin_unlock_irq(&pool->pool_lock);
44811
44812- serial = atomic_inc_return(&pool->req_ser);
44813+ serial = atomic_inc_return_unchecked(&pool->req_ser);
44814 wake_up_process(pool->thread);
44815
44816 if (wait_event_interruptible(pool->force_wait,
44817- atomic_read(&pool->flush_ser) - serial >= 0))
44818+ atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
44819 return -EINTR;
44820
44821 return 0;
44822@@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
44823 } else {
44824 list_add_tail(&fmr->list, &pool->dirty_list);
44825 if (++pool->dirty_len >= pool->dirty_watermark) {
44826- atomic_inc(&pool->req_ser);
44827+ atomic_inc_unchecked(&pool->req_ser);
44828 wake_up_process(pool->thread);
44829 }
44830 }
44831diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
44832index a6ca83b..bd3a726 100644
44833--- a/drivers/infiniband/core/uverbs_cmd.c
44834+++ b/drivers/infiniband/core/uverbs_cmd.c
44835@@ -951,6 +951,9 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
44836 if (copy_from_user(&cmd, buf, sizeof cmd))
44837 return -EFAULT;
44838
44839+ if (!access_ok_noprefault(VERIFY_READ, cmd.start, cmd.length))
44840+ return -EFAULT;
44841+
44842 INIT_UDATA(&udata, buf + sizeof cmd,
44843 (unsigned long) cmd.response + sizeof resp,
44844 in_len - sizeof cmd, out_len - sizeof resp);
44845diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
44846index cff815b..75576dd 100644
44847--- a/drivers/infiniband/hw/cxgb4/mem.c
44848+++ b/drivers/infiniband/hw/cxgb4/mem.c
44849@@ -256,7 +256,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
44850 int err;
44851 struct fw_ri_tpte tpt;
44852 u32 stag_idx;
44853- static atomic_t key;
44854+ static atomic_unchecked_t key;
44855
44856 if (c4iw_fatal_error(rdev))
44857 return -EIO;
44858@@ -277,7 +277,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
44859 if (rdev->stats.stag.cur > rdev->stats.stag.max)
44860 rdev->stats.stag.max = rdev->stats.stag.cur;
44861 mutex_unlock(&rdev->stats.lock);
44862- *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
44863+ *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
44864 }
44865 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
44866 __func__, stag_state, type, pdid, stag_idx);
44867diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
44868index 79b3dbc..96e5fcc 100644
44869--- a/drivers/infiniband/hw/ipath/ipath_rc.c
44870+++ b/drivers/infiniband/hw/ipath/ipath_rc.c
44871@@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
44872 struct ib_atomic_eth *ateth;
44873 struct ipath_ack_entry *e;
44874 u64 vaddr;
44875- atomic64_t *maddr;
44876+ atomic64_unchecked_t *maddr;
44877 u64 sdata;
44878 u32 rkey;
44879 u8 next;
44880@@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
44881 IB_ACCESS_REMOTE_ATOMIC)))
44882 goto nack_acc_unlck;
44883 /* Perform atomic OP and save result. */
44884- maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
44885+ maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
44886 sdata = be64_to_cpu(ateth->swap_data);
44887 e = &qp->s_ack_queue[qp->r_head_ack_queue];
44888 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
44889- (u64) atomic64_add_return(sdata, maddr) - sdata :
44890+ (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
44891 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
44892 be64_to_cpu(ateth->compare_data),
44893 sdata);
44894diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
44895index 1f95bba..9530f87 100644
44896--- a/drivers/infiniband/hw/ipath/ipath_ruc.c
44897+++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
44898@@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
44899 unsigned long flags;
44900 struct ib_wc wc;
44901 u64 sdata;
44902- atomic64_t *maddr;
44903+ atomic64_unchecked_t *maddr;
44904 enum ib_wc_status send_status;
44905
44906 /*
44907@@ -382,11 +382,11 @@ again:
44908 IB_ACCESS_REMOTE_ATOMIC)))
44909 goto acc_err;
44910 /* Perform atomic OP and save result. */
44911- maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
44912+ maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
44913 sdata = wqe->wr.wr.atomic.compare_add;
44914 *(u64 *) sqp->s_sge.sge.vaddr =
44915 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
44916- (u64) atomic64_add_return(sdata, maddr) - sdata :
44917+ (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
44918 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
44919 sdata, wqe->wr.wr.atomic.swap);
44920 goto send_comp;
44921diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
44922index 68b3dfa..3e0c511 100644
44923--- a/drivers/infiniband/hw/mlx4/mad.c
44924+++ b/drivers/infiniband/hw/mlx4/mad.c
44925@@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
44926
44927 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
44928 {
44929- return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
44930+ return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
44931 cpu_to_be64(0xff00000000000000LL);
44932 }
44933
44934diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
44935index a0559a8..86a2320 100644
44936--- a/drivers/infiniband/hw/mlx4/mcg.c
44937+++ b/drivers/infiniband/hw/mlx4/mcg.c
44938@@ -1042,7 +1042,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
44939 {
44940 char name[20];
44941
44942- atomic_set(&ctx->tid, 0);
44943+ atomic_set_unchecked(&ctx->tid, 0);
44944 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
44945 ctx->mcg_wq = create_singlethread_workqueue(name);
44946 if (!ctx->mcg_wq)
44947diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
44948index 334387f..e640d74 100644
44949--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
44950+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
44951@@ -436,7 +436,7 @@ struct mlx4_ib_demux_ctx {
44952 struct list_head mcg_mgid0_list;
44953 struct workqueue_struct *mcg_wq;
44954 struct mlx4_ib_demux_pv_ctx **tun;
44955- atomic_t tid;
44956+ atomic_unchecked_t tid;
44957 int flushing; /* flushing the work queue */
44958 };
44959
44960diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
44961index c7f49bb..6a021bb 100644
44962--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
44963+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
44964@@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
44965 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
44966 }
44967
44968-int mthca_QUERY_FW(struct mthca_dev *dev)
44969+int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
44970 {
44971 struct mthca_mailbox *mailbox;
44972 u32 *outbox;
44973@@ -1612,7 +1612,7 @@ int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
44974 CMD_TIME_CLASS_B);
44975 }
44976
44977-int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
44978+int __intentional_overflow(-1) mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
44979 int num_mtt)
44980 {
44981 return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
44982@@ -1634,7 +1634,7 @@ int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
44983 0, CMD_MAP_EQ, CMD_TIME_CLASS_B);
44984 }
44985
44986-int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
44987+int __intentional_overflow(-1) mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
44988 int eq_num)
44989 {
44990 return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
44991@@ -1857,7 +1857,7 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn)
44992 CMD_TIME_CLASS_B);
44993 }
44994
44995-int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
44996+int __intentional_overflow(-1) mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
44997 int port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
44998 const void *in_mad, void *response_mad)
44999 {
45000diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
45001index ded76c1..0cf0a08 100644
45002--- a/drivers/infiniband/hw/mthca/mthca_main.c
45003+++ b/drivers/infiniband/hw/mthca/mthca_main.c
45004@@ -692,7 +692,7 @@ err_close:
45005 return err;
45006 }
45007
45008-static int mthca_setup_hca(struct mthca_dev *dev)
45009+static int __intentional_overflow(-1) mthca_setup_hca(struct mthca_dev *dev)
45010 {
45011 int err;
45012
45013diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
45014index ed9a989..6aa5dc2 100644
45015--- a/drivers/infiniband/hw/mthca/mthca_mr.c
45016+++ b/drivers/infiniband/hw/mthca/mthca_mr.c
45017@@ -81,7 +81,7 @@ struct mthca_mpt_entry {
45018 * through the bitmaps)
45019 */
45020
45021-static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
45022+static u32 __intentional_overflow(-1) mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
45023 {
45024 int o;
45025 int m;
45026@@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
45027 return key;
45028 }
45029
45030-int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
45031+int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
45032 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
45033 {
45034 struct mthca_mailbox *mailbox;
45035@@ -516,7 +516,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
45036 return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
45037 }
45038
45039-int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
45040+int __intentional_overflow(-1) mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
45041 u64 *buffer_list, int buffer_size_shift,
45042 int list_len, u64 iova, u64 total_size,
45043 u32 access, struct mthca_mr *mr)
45044diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
45045index 93ae51d..84c4a44 100644
45046--- a/drivers/infiniband/hw/mthca/mthca_provider.c
45047+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
45048@@ -771,7 +771,7 @@ unlock:
45049 return 0;
45050 }
45051
45052-static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
45053+static int __intentional_overflow(-1) mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
45054 {
45055 struct mthca_dev *dev = to_mdev(ibcq->device);
45056 struct mthca_cq *cq = to_mcq(ibcq);
45057diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
45058index 9f9d5c5..3c19aac 100644
45059--- a/drivers/infiniband/hw/nes/nes.c
45060+++ b/drivers/infiniband/hw/nes/nes.c
45061@@ -97,7 +97,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
45062 LIST_HEAD(nes_adapter_list);
45063 static LIST_HEAD(nes_dev_list);
45064
45065-atomic_t qps_destroyed;
45066+atomic_unchecked_t qps_destroyed;
45067
45068 static unsigned int ee_flsh_adapter;
45069 static unsigned int sysfs_nonidx_addr;
45070@@ -279,7 +279,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
45071 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
45072 struct nes_adapter *nesadapter = nesdev->nesadapter;
45073
45074- atomic_inc(&qps_destroyed);
45075+ atomic_inc_unchecked(&qps_destroyed);
45076
45077 /* Free the control structures */
45078
45079diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
45080index bd9d132..70d84f4 100644
45081--- a/drivers/infiniband/hw/nes/nes.h
45082+++ b/drivers/infiniband/hw/nes/nes.h
45083@@ -180,17 +180,17 @@ extern unsigned int nes_debug_level;
45084 extern unsigned int wqm_quanta;
45085 extern struct list_head nes_adapter_list;
45086
45087-extern atomic_t cm_connects;
45088-extern atomic_t cm_accepts;
45089-extern atomic_t cm_disconnects;
45090-extern atomic_t cm_closes;
45091-extern atomic_t cm_connecteds;
45092-extern atomic_t cm_connect_reqs;
45093-extern atomic_t cm_rejects;
45094-extern atomic_t mod_qp_timouts;
45095-extern atomic_t qps_created;
45096-extern atomic_t qps_destroyed;
45097-extern atomic_t sw_qps_destroyed;
45098+extern atomic_unchecked_t cm_connects;
45099+extern atomic_unchecked_t cm_accepts;
45100+extern atomic_unchecked_t cm_disconnects;
45101+extern atomic_unchecked_t cm_closes;
45102+extern atomic_unchecked_t cm_connecteds;
45103+extern atomic_unchecked_t cm_connect_reqs;
45104+extern atomic_unchecked_t cm_rejects;
45105+extern atomic_unchecked_t mod_qp_timouts;
45106+extern atomic_unchecked_t qps_created;
45107+extern atomic_unchecked_t qps_destroyed;
45108+extern atomic_unchecked_t sw_qps_destroyed;
45109 extern u32 mh_detected;
45110 extern u32 mh_pauses_sent;
45111 extern u32 cm_packets_sent;
45112@@ -199,16 +199,16 @@ extern u32 cm_packets_created;
45113 extern u32 cm_packets_received;
45114 extern u32 cm_packets_dropped;
45115 extern u32 cm_packets_retrans;
45116-extern atomic_t cm_listens_created;
45117-extern atomic_t cm_listens_destroyed;
45118+extern atomic_unchecked_t cm_listens_created;
45119+extern atomic_unchecked_t cm_listens_destroyed;
45120 extern u32 cm_backlog_drops;
45121-extern atomic_t cm_loopbacks;
45122-extern atomic_t cm_nodes_created;
45123-extern atomic_t cm_nodes_destroyed;
45124-extern atomic_t cm_accel_dropped_pkts;
45125-extern atomic_t cm_resets_recvd;
45126-extern atomic_t pau_qps_created;
45127-extern atomic_t pau_qps_destroyed;
45128+extern atomic_unchecked_t cm_loopbacks;
45129+extern atomic_unchecked_t cm_nodes_created;
45130+extern atomic_unchecked_t cm_nodes_destroyed;
45131+extern atomic_unchecked_t cm_accel_dropped_pkts;
45132+extern atomic_unchecked_t cm_resets_recvd;
45133+extern atomic_unchecked_t pau_qps_created;
45134+extern atomic_unchecked_t pau_qps_destroyed;
45135
45136 extern u32 int_mod_timer_init;
45137 extern u32 int_mod_cq_depth_256;
45138diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
45139index 8a3ad17..e1ed4bc 100644
45140--- a/drivers/infiniband/hw/nes/nes_cm.c
45141+++ b/drivers/infiniband/hw/nes/nes_cm.c
45142@@ -69,14 +69,14 @@ u32 cm_packets_dropped;
45143 u32 cm_packets_retrans;
45144 u32 cm_packets_created;
45145 u32 cm_packets_received;
45146-atomic_t cm_listens_created;
45147-atomic_t cm_listens_destroyed;
45148+atomic_unchecked_t cm_listens_created;
45149+atomic_unchecked_t cm_listens_destroyed;
45150 u32 cm_backlog_drops;
45151-atomic_t cm_loopbacks;
45152-atomic_t cm_nodes_created;
45153-atomic_t cm_nodes_destroyed;
45154-atomic_t cm_accel_dropped_pkts;
45155-atomic_t cm_resets_recvd;
45156+atomic_unchecked_t cm_loopbacks;
45157+atomic_unchecked_t cm_nodes_created;
45158+atomic_unchecked_t cm_nodes_destroyed;
45159+atomic_unchecked_t cm_accel_dropped_pkts;
45160+atomic_unchecked_t cm_resets_recvd;
45161
45162 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
45163 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
45164@@ -135,28 +135,28 @@ static void record_ird_ord(struct nes_cm_node *, u16, u16);
45165 /* instance of function pointers for client API */
45166 /* set address of this instance to cm_core->cm_ops at cm_core alloc */
45167 static struct nes_cm_ops nes_cm_api = {
45168- mini_cm_accelerated,
45169- mini_cm_listen,
45170- mini_cm_del_listen,
45171- mini_cm_connect,
45172- mini_cm_close,
45173- mini_cm_accept,
45174- mini_cm_reject,
45175- mini_cm_recv_pkt,
45176- mini_cm_dealloc_core,
45177- mini_cm_get,
45178- mini_cm_set
45179+ .accelerated = mini_cm_accelerated,
45180+ .listen = mini_cm_listen,
45181+ .stop_listener = mini_cm_del_listen,
45182+ .connect = mini_cm_connect,
45183+ .close = mini_cm_close,
45184+ .accept = mini_cm_accept,
45185+ .reject = mini_cm_reject,
45186+ .recv_pkt = mini_cm_recv_pkt,
45187+ .destroy_cm_core = mini_cm_dealloc_core,
45188+ .get = mini_cm_get,
45189+ .set = mini_cm_set
45190 };
45191
45192 static struct nes_cm_core *g_cm_core;
45193
45194-atomic_t cm_connects;
45195-atomic_t cm_accepts;
45196-atomic_t cm_disconnects;
45197-atomic_t cm_closes;
45198-atomic_t cm_connecteds;
45199-atomic_t cm_connect_reqs;
45200-atomic_t cm_rejects;
45201+atomic_unchecked_t cm_connects;
45202+atomic_unchecked_t cm_accepts;
45203+atomic_unchecked_t cm_disconnects;
45204+atomic_unchecked_t cm_closes;
45205+atomic_unchecked_t cm_connecteds;
45206+atomic_unchecked_t cm_connect_reqs;
45207+atomic_unchecked_t cm_rejects;
45208
45209 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
45210 {
45211@@ -1461,7 +1461,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
45212 kfree(listener);
45213 listener = NULL;
45214 ret = 0;
45215- atomic_inc(&cm_listens_destroyed);
45216+ atomic_inc_unchecked(&cm_listens_destroyed);
45217 } else {
45218 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
45219 }
45220@@ -1670,7 +1670,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
45221 cm_node->rem_mac);
45222
45223 add_hte_node(cm_core, cm_node);
45224- atomic_inc(&cm_nodes_created);
45225+ atomic_inc_unchecked(&cm_nodes_created);
45226
45227 return cm_node;
45228 }
45229@@ -1731,7 +1731,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
45230 }
45231
45232 atomic_dec(&cm_core->node_cnt);
45233- atomic_inc(&cm_nodes_destroyed);
45234+ atomic_inc_unchecked(&cm_nodes_destroyed);
45235 nesqp = cm_node->nesqp;
45236 if (nesqp) {
45237 nesqp->cm_node = NULL;
45238@@ -1795,7 +1795,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
45239
45240 static void drop_packet(struct sk_buff *skb)
45241 {
45242- atomic_inc(&cm_accel_dropped_pkts);
45243+ atomic_inc_unchecked(&cm_accel_dropped_pkts);
45244 dev_kfree_skb_any(skb);
45245 }
45246
45247@@ -1858,7 +1858,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
45248 {
45249
45250 int reset = 0; /* whether to send reset in case of err.. */
45251- atomic_inc(&cm_resets_recvd);
45252+ atomic_inc_unchecked(&cm_resets_recvd);
45253 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
45254 " refcnt=%d\n", cm_node, cm_node->state,
45255 atomic_read(&cm_node->ref_count));
45256@@ -2526,7 +2526,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
45257 rem_ref_cm_node(cm_node->cm_core, cm_node);
45258 return NULL;
45259 }
45260- atomic_inc(&cm_loopbacks);
45261+ atomic_inc_unchecked(&cm_loopbacks);
45262 loopbackremotenode->loopbackpartner = cm_node;
45263 loopbackremotenode->tcp_cntxt.rcv_wscale =
45264 NES_CM_DEFAULT_RCV_WND_SCALE;
45265@@ -2807,7 +2807,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
45266 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
45267 else {
45268 rem_ref_cm_node(cm_core, cm_node);
45269- atomic_inc(&cm_accel_dropped_pkts);
45270+ atomic_inc_unchecked(&cm_accel_dropped_pkts);
45271 dev_kfree_skb_any(skb);
45272 }
45273 break;
45274@@ -3118,7 +3118,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
45275
45276 if ((cm_id) && (cm_id->event_handler)) {
45277 if (issue_disconn) {
45278- atomic_inc(&cm_disconnects);
45279+ atomic_inc_unchecked(&cm_disconnects);
45280 cm_event.event = IW_CM_EVENT_DISCONNECT;
45281 cm_event.status = disconn_status;
45282 cm_event.local_addr = cm_id->local_addr;
45283@@ -3140,7 +3140,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
45284 }
45285
45286 if (issue_close) {
45287- atomic_inc(&cm_closes);
45288+ atomic_inc_unchecked(&cm_closes);
45289 nes_disconnect(nesqp, 1);
45290
45291 cm_id->provider_data = nesqp;
45292@@ -3278,7 +3278,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
45293
45294 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
45295 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
45296- atomic_inc(&cm_accepts);
45297+ atomic_inc_unchecked(&cm_accepts);
45298
45299 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
45300 netdev_refcnt_read(nesvnic->netdev));
45301@@ -3476,7 +3476,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
45302 struct nes_cm_core *cm_core;
45303 u8 *start_buff;
45304
45305- atomic_inc(&cm_rejects);
45306+ atomic_inc_unchecked(&cm_rejects);
45307 cm_node = (struct nes_cm_node *)cm_id->provider_data;
45308 loopback = cm_node->loopbackpartner;
45309 cm_core = cm_node->cm_core;
45310@@ -3541,7 +3541,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
45311 ntohs(raddr->sin_port), ntohl(laddr->sin_addr.s_addr),
45312 ntohs(laddr->sin_port));
45313
45314- atomic_inc(&cm_connects);
45315+ atomic_inc_unchecked(&cm_connects);
45316 nesqp->active_conn = 1;
45317
45318 /* cache the cm_id in the qp */
45319@@ -3688,7 +3688,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
45320 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
45321 return err;
45322 }
45323- atomic_inc(&cm_listens_created);
45324+ atomic_inc_unchecked(&cm_listens_created);
45325 }
45326
45327 cm_id->add_ref(cm_id);
45328@@ -3795,7 +3795,7 @@ static void cm_event_connected(struct nes_cm_event *event)
45329
45330 if (nesqp->destroyed)
45331 return;
45332- atomic_inc(&cm_connecteds);
45333+ atomic_inc_unchecked(&cm_connecteds);
45334 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
45335 " local port 0x%04X. jiffies = %lu.\n",
45336 nesqp->hwqp.qp_id, ntohl(raddr->sin_addr.s_addr),
45337@@ -3980,7 +3980,7 @@ static void cm_event_reset(struct nes_cm_event *event)
45338
45339 cm_id->add_ref(cm_id);
45340 ret = cm_id->event_handler(cm_id, &cm_event);
45341- atomic_inc(&cm_closes);
45342+ atomic_inc_unchecked(&cm_closes);
45343 cm_event.event = IW_CM_EVENT_CLOSE;
45344 cm_event.status = 0;
45345 cm_event.provider_data = cm_id->provider_data;
45346@@ -4020,7 +4020,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
45347 return;
45348 cm_id = cm_node->cm_id;
45349
45350- atomic_inc(&cm_connect_reqs);
45351+ atomic_inc_unchecked(&cm_connect_reqs);
45352 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
45353 cm_node, cm_id, jiffies);
45354
45355@@ -4069,7 +4069,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
45356 return;
45357 cm_id = cm_node->cm_id;
45358
45359- atomic_inc(&cm_connect_reqs);
45360+ atomic_inc_unchecked(&cm_connect_reqs);
45361 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
45362 cm_node, cm_id, jiffies);
45363
45364diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
45365index 4166452..fc952c3 100644
45366--- a/drivers/infiniband/hw/nes/nes_mgt.c
45367+++ b/drivers/infiniband/hw/nes/nes_mgt.c
45368@@ -40,8 +40,8 @@
45369 #include "nes.h"
45370 #include "nes_mgt.h"
45371
45372-atomic_t pau_qps_created;
45373-atomic_t pau_qps_destroyed;
45374+atomic_unchecked_t pau_qps_created;
45375+atomic_unchecked_t pau_qps_destroyed;
45376
45377 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
45378 {
45379@@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
45380 {
45381 struct sk_buff *skb;
45382 unsigned long flags;
45383- atomic_inc(&pau_qps_destroyed);
45384+ atomic_inc_unchecked(&pau_qps_destroyed);
45385
45386 /* Free packets that have not yet been forwarded */
45387 /* Lock is acquired by skb_dequeue when removing the skb */
45388@@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
45389 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
45390 skb_queue_head_init(&nesqp->pau_list);
45391 spin_lock_init(&nesqp->pau_lock);
45392- atomic_inc(&pau_qps_created);
45393+ atomic_inc_unchecked(&pau_qps_created);
45394 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
45395 }
45396
45397diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
45398index 70acda9..a96de9d 100644
45399--- a/drivers/infiniband/hw/nes/nes_nic.c
45400+++ b/drivers/infiniband/hw/nes/nes_nic.c
45401@@ -1274,39 +1274,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
45402 target_stat_values[++index] = mh_detected;
45403 target_stat_values[++index] = mh_pauses_sent;
45404 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
45405- target_stat_values[++index] = atomic_read(&cm_connects);
45406- target_stat_values[++index] = atomic_read(&cm_accepts);
45407- target_stat_values[++index] = atomic_read(&cm_disconnects);
45408- target_stat_values[++index] = atomic_read(&cm_connecteds);
45409- target_stat_values[++index] = atomic_read(&cm_connect_reqs);
45410- target_stat_values[++index] = atomic_read(&cm_rejects);
45411- target_stat_values[++index] = atomic_read(&mod_qp_timouts);
45412- target_stat_values[++index] = atomic_read(&qps_created);
45413- target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
45414- target_stat_values[++index] = atomic_read(&qps_destroyed);
45415- target_stat_values[++index] = atomic_read(&cm_closes);
45416+ target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
45417+ target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
45418+ target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
45419+ target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
45420+ target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
45421+ target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
45422+ target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
45423+ target_stat_values[++index] = atomic_read_unchecked(&qps_created);
45424+ target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
45425+ target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
45426+ target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
45427 target_stat_values[++index] = cm_packets_sent;
45428 target_stat_values[++index] = cm_packets_bounced;
45429 target_stat_values[++index] = cm_packets_created;
45430 target_stat_values[++index] = cm_packets_received;
45431 target_stat_values[++index] = cm_packets_dropped;
45432 target_stat_values[++index] = cm_packets_retrans;
45433- target_stat_values[++index] = atomic_read(&cm_listens_created);
45434- target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
45435+ target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
45436+ target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
45437 target_stat_values[++index] = cm_backlog_drops;
45438- target_stat_values[++index] = atomic_read(&cm_loopbacks);
45439- target_stat_values[++index] = atomic_read(&cm_nodes_created);
45440- target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
45441- target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
45442- target_stat_values[++index] = atomic_read(&cm_resets_recvd);
45443+ target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
45444+ target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
45445+ target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
45446+ target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
45447+ target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
45448 target_stat_values[++index] = nesadapter->free_4kpbl;
45449 target_stat_values[++index] = nesadapter->free_256pbl;
45450 target_stat_values[++index] = int_mod_timer_init;
45451 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
45452 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
45453 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
45454- target_stat_values[++index] = atomic_read(&pau_qps_created);
45455- target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
45456+ target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
45457+ target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
45458 }
45459
45460 /**
45461diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
45462index fbc43e5..3672792 100644
45463--- a/drivers/infiniband/hw/nes/nes_verbs.c
45464+++ b/drivers/infiniband/hw/nes/nes_verbs.c
45465@@ -46,9 +46,9 @@
45466
45467 #include <rdma/ib_umem.h>
45468
45469-atomic_t mod_qp_timouts;
45470-atomic_t qps_created;
45471-atomic_t sw_qps_destroyed;
45472+atomic_unchecked_t mod_qp_timouts;
45473+atomic_unchecked_t qps_created;
45474+atomic_unchecked_t sw_qps_destroyed;
45475
45476 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
45477
45478@@ -1137,7 +1137,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
45479 if (init_attr->create_flags)
45480 return ERR_PTR(-EINVAL);
45481
45482- atomic_inc(&qps_created);
45483+ atomic_inc_unchecked(&qps_created);
45484 switch (init_attr->qp_type) {
45485 case IB_QPT_RC:
45486 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
45487@@ -1471,7 +1471,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
45488 struct iw_cm_event cm_event;
45489 int ret = 0;
45490
45491- atomic_inc(&sw_qps_destroyed);
45492+ atomic_inc_unchecked(&sw_qps_destroyed);
45493 nesqp->destroyed = 1;
45494
45495 /* Blow away the connection if it exists. */
45496diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
45497index 7df16f7..7e1b21e 100644
45498--- a/drivers/infiniband/hw/qib/qib.h
45499+++ b/drivers/infiniband/hw/qib/qib.h
45500@@ -52,6 +52,7 @@
45501 #include <linux/kref.h>
45502 #include <linux/sched.h>
45503 #include <linux/kthread.h>
45504+#include <linux/slab.h>
45505
45506 #include "qib_common.h"
45507 #include "qib_verbs.h"
45508diff --git a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
45509index cdc7df4..a2fdfdb 100644
45510--- a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
45511+++ b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
45512@@ -156,7 +156,7 @@ static size_t ipoib_get_size(const struct net_device *dev)
45513 nla_total_size(2); /* IFLA_IPOIB_UMCAST */
45514 }
45515
45516-static struct rtnl_link_ops ipoib_link_ops __read_mostly = {
45517+static struct rtnl_link_ops ipoib_link_ops = {
45518 .kind = "ipoib",
45519 .maxtype = IFLA_IPOIB_MAX,
45520 .policy = ipoib_policy,
45521diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
45522index e853a21..56fc5a8 100644
45523--- a/drivers/input/gameport/gameport.c
45524+++ b/drivers/input/gameport/gameport.c
45525@@ -527,14 +527,14 @@ EXPORT_SYMBOL(gameport_set_phys);
45526 */
45527 static void gameport_init_port(struct gameport *gameport)
45528 {
45529- static atomic_t gameport_no = ATOMIC_INIT(-1);
45530+ static atomic_unchecked_t gameport_no = ATOMIC_INIT(-1);
45531
45532 __module_get(THIS_MODULE);
45533
45534 mutex_init(&gameport->drv_mutex);
45535 device_initialize(&gameport->dev);
45536 dev_set_name(&gameport->dev, "gameport%lu",
45537- (unsigned long)atomic_inc_return(&gameport_no));
45538+ (unsigned long)atomic_inc_return_unchecked(&gameport_no));
45539 gameport->dev.bus = &gameport_bus;
45540 gameport->dev.release = gameport_release_port;
45541 if (gameport->parent)
45542diff --git a/drivers/input/input.c b/drivers/input/input.c
45543index 78d2499..1f0318e 100644
45544--- a/drivers/input/input.c
45545+++ b/drivers/input/input.c
45546@@ -1775,7 +1775,7 @@ EXPORT_SYMBOL_GPL(input_class);
45547 */
45548 struct input_dev *input_allocate_device(void)
45549 {
45550- static atomic_t input_no = ATOMIC_INIT(-1);
45551+ static atomic_unchecked_t input_no = ATOMIC_INIT(-1);
45552 struct input_dev *dev;
45553
45554 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
45555@@ -1790,7 +1790,7 @@ struct input_dev *input_allocate_device(void)
45556 INIT_LIST_HEAD(&dev->node);
45557
45558 dev_set_name(&dev->dev, "input%lu",
45559- (unsigned long)atomic_inc_return(&input_no));
45560+ (unsigned long)atomic_inc_return_unchecked(&input_no));
45561
45562 __module_get(THIS_MODULE);
45563 }
45564diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
45565index 4a95b22..874c182 100644
45566--- a/drivers/input/joystick/sidewinder.c
45567+++ b/drivers/input/joystick/sidewinder.c
45568@@ -30,6 +30,7 @@
45569 #include <linux/kernel.h>
45570 #include <linux/module.h>
45571 #include <linux/slab.h>
45572+#include <linux/sched.h>
45573 #include <linux/input.h>
45574 #include <linux/gameport.h>
45575 #include <linux/jiffies.h>
45576diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
45577index f8850f9..9708a2d 100644
45578--- a/drivers/input/joystick/xpad.c
45579+++ b/drivers/input/joystick/xpad.c
45580@@ -959,7 +959,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
45581
45582 static int xpad_led_probe(struct usb_xpad *xpad)
45583 {
45584- static atomic_t led_seq = ATOMIC_INIT(-1);
45585+ static atomic_unchecked_t led_seq = ATOMIC_INIT(-1);
45586 struct xpad_led *led;
45587 struct led_classdev *led_cdev;
45588 int error;
45589@@ -971,7 +971,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
45590 if (!led)
45591 return -ENOMEM;
45592
45593- xpad->led_no = atomic_inc_return(&led_seq);
45594+ xpad->led_no = atomic_inc_return_unchecked(&led_seq);
45595
45596 snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->led_no);
45597 led->xpad = xpad;
45598diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
45599index ac1fa5f..5f7502c 100644
45600--- a/drivers/input/misc/ims-pcu.c
45601+++ b/drivers/input/misc/ims-pcu.c
45602@@ -1851,7 +1851,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
45603
45604 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
45605 {
45606- static atomic_t device_no = ATOMIC_INIT(-1);
45607+ static atomic_unchecked_t device_no = ATOMIC_INIT(-1);
45608
45609 const struct ims_pcu_device_info *info;
45610 int error;
45611@@ -1882,7 +1882,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
45612 }
45613
45614 /* Device appears to be operable, complete initialization */
45615- pcu->device_no = atomic_inc_return(&device_no);
45616+ pcu->device_no = atomic_inc_return_unchecked(&device_no);
45617
45618 /*
45619 * PCU-B devices, both GEN_1 and GEN_2 do not have OFN sensor
45620diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
45621index ad5a5a1..5eac214 100644
45622--- a/drivers/input/mouse/psmouse.h
45623+++ b/drivers/input/mouse/psmouse.h
45624@@ -125,7 +125,7 @@ struct psmouse_attribute {
45625 ssize_t (*set)(struct psmouse *psmouse, void *data,
45626 const char *buf, size_t count);
45627 bool protect;
45628-};
45629+} __do_const;
45630 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
45631
45632 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
45633diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
45634index b604564..3f14ae4 100644
45635--- a/drivers/input/mousedev.c
45636+++ b/drivers/input/mousedev.c
45637@@ -744,7 +744,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
45638
45639 spin_unlock_irq(&client->packet_lock);
45640
45641- if (copy_to_user(buffer, data, count))
45642+ if (count > sizeof(data) || copy_to_user(buffer, data, count))
45643 return -EFAULT;
45644
45645 return count;
45646diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
45647index a05a517..323a2fd 100644
45648--- a/drivers/input/serio/serio.c
45649+++ b/drivers/input/serio/serio.c
45650@@ -514,7 +514,7 @@ static void serio_release_port(struct device *dev)
45651 */
45652 static void serio_init_port(struct serio *serio)
45653 {
45654- static atomic_t serio_no = ATOMIC_INIT(-1);
45655+ static atomic_unchecked_t serio_no = ATOMIC_INIT(-1);
45656
45657 __module_get(THIS_MODULE);
45658
45659@@ -525,7 +525,7 @@ static void serio_init_port(struct serio *serio)
45660 mutex_init(&serio->drv_mutex);
45661 device_initialize(&serio->dev);
45662 dev_set_name(&serio->dev, "serio%lu",
45663- (unsigned long)atomic_inc_return(&serio_no));
45664+ (unsigned long)atomic_inc_return_unchecked(&serio_no));
45665 serio->dev.bus = &serio_bus;
45666 serio->dev.release = serio_release_port;
45667 serio->dev.groups = serio_device_attr_groups;
45668diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
45669index 71ef5d6..93380a9 100644
45670--- a/drivers/input/serio/serio_raw.c
45671+++ b/drivers/input/serio/serio_raw.c
45672@@ -292,7 +292,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
45673
45674 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
45675 {
45676- static atomic_t serio_raw_no = ATOMIC_INIT(-1);
45677+ static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(-1);
45678 struct serio_raw *serio_raw;
45679 int err;
45680
45681@@ -303,7 +303,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
45682 }
45683
45684 snprintf(serio_raw->name, sizeof(serio_raw->name),
45685- "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no));
45686+ "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no));
45687 kref_init(&serio_raw->kref);
45688 INIT_LIST_HEAD(&serio_raw->client_list);
45689 init_waitqueue_head(&serio_raw->wait);
45690diff --git a/drivers/input/touchscreen/htcpen.c b/drivers/input/touchscreen/htcpen.c
45691index 92e2243..8fd9092 100644
45692--- a/drivers/input/touchscreen/htcpen.c
45693+++ b/drivers/input/touchscreen/htcpen.c
45694@@ -219,7 +219,7 @@ static struct isa_driver htcpen_isa_driver = {
45695 }
45696 };
45697
45698-static struct dmi_system_id htcshift_dmi_table[] __initdata = {
45699+static const struct dmi_system_id htcshift_dmi_table[] __initconst = {
45700 {
45701 .ident = "Shift",
45702 .matches = {
45703diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
45704index f1fb1d3..82257cc 100644
45705--- a/drivers/iommu/Kconfig
45706+++ b/drivers/iommu/Kconfig
45707@@ -102,6 +102,7 @@ config AMD_IOMMU_STATS
45708 bool "Export AMD IOMMU statistics to debugfs"
45709 depends on AMD_IOMMU
45710 select DEBUG_FS
45711+ depends on !GRKERNSEC_KMEM
45712 ---help---
45713 This option enables code in the AMD IOMMU driver to collect various
45714 statistics about whats happening in the driver and exports that
45715diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
45716index 658ee39..6fde5be 100644
45717--- a/drivers/iommu/amd_iommu.c
45718+++ b/drivers/iommu/amd_iommu.c
45719@@ -794,11 +794,21 @@ static void copy_cmd_to_buffer(struct amd_iommu *iommu,
45720
45721 static void build_completion_wait(struct iommu_cmd *cmd, u64 address)
45722 {
45723+ phys_addr_t physaddr;
45724 WARN_ON(address & 0x7ULL);
45725
45726 memset(cmd, 0, sizeof(*cmd));
45727- cmd->data[0] = lower_32_bits(__pa(address)) | CMD_COMPL_WAIT_STORE_MASK;
45728- cmd->data[1] = upper_32_bits(__pa(address));
45729+
45730+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
45731+ if (object_starts_on_stack((void *)address)) {
45732+ void *adjbuf = (void *)address - current->stack + current->lowmem_stack;
45733+ physaddr = __pa((u64)adjbuf);
45734+ } else
45735+#endif
45736+ physaddr = __pa(address);
45737+
45738+ cmd->data[0] = lower_32_bits(physaddr) | CMD_COMPL_WAIT_STORE_MASK;
45739+ cmd->data[1] = upper_32_bits(physaddr);
45740 cmd->data[2] = 1;
45741 CMD_SET_TYPE(cmd, CMD_COMPL_WAIT);
45742 }
45743diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
45744index 4cd0c29..afd3cbe 100644
45745--- a/drivers/iommu/arm-smmu.c
45746+++ b/drivers/iommu/arm-smmu.c
45747@@ -330,7 +330,7 @@ enum arm_smmu_domain_stage {
45748
45749 struct arm_smmu_domain {
45750 struct arm_smmu_device *smmu;
45751- struct io_pgtable_ops *pgtbl_ops;
45752+ struct io_pgtable *pgtbl;
45753 spinlock_t pgtbl_lock;
45754 struct arm_smmu_cfg cfg;
45755 enum arm_smmu_domain_stage stage;
45756@@ -816,7 +816,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
45757 {
45758 int irq, start, ret = 0;
45759 unsigned long ias, oas;
45760- struct io_pgtable_ops *pgtbl_ops;
45761+ struct io_pgtable *pgtbl;
45762 struct io_pgtable_cfg pgtbl_cfg;
45763 enum io_pgtable_fmt fmt;
45764 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
45765@@ -901,14 +901,16 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
45766 };
45767
45768 smmu_domain->smmu = smmu;
45769- pgtbl_ops = alloc_io_pgtable_ops(fmt, &pgtbl_cfg, smmu_domain);
45770- if (!pgtbl_ops) {
45771+ pgtbl = alloc_io_pgtable(fmt, &pgtbl_cfg, smmu_domain);
45772+ if (!pgtbl) {
45773 ret = -ENOMEM;
45774 goto out_clear_smmu;
45775 }
45776
45777 /* Update our support page sizes to reflect the page table format */
45778- arm_smmu_ops.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
45779+ pax_open_kernel();
45780+ *(unsigned long *)&arm_smmu_ops.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
45781+ pax_close_kernel();
45782
45783 /* Initialise the context bank with our page table cfg */
45784 arm_smmu_init_context_bank(smmu_domain, &pgtbl_cfg);
45785@@ -929,7 +931,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
45786 mutex_unlock(&smmu_domain->init_mutex);
45787
45788 /* Publish page table ops for map/unmap */
45789- smmu_domain->pgtbl_ops = pgtbl_ops;
45790+ smmu_domain->pgtbl = pgtbl;
45791 return 0;
45792
45793 out_clear_smmu:
45794@@ -962,8 +964,7 @@ static void arm_smmu_destroy_domain_context(struct iommu_domain *domain)
45795 free_irq(irq, domain);
45796 }
45797
45798- if (smmu_domain->pgtbl_ops)
45799- free_io_pgtable_ops(smmu_domain->pgtbl_ops);
45800+ free_io_pgtable(smmu_domain->pgtbl);
45801
45802 __arm_smmu_free_bitmap(smmu->context_map, cfg->cbndx);
45803 }
45804@@ -1189,13 +1190,13 @@ static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova,
45805 int ret;
45806 unsigned long flags;
45807 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
45808- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
45809+ struct io_pgtable *iop = smmu_domain->pgtbl;
45810
45811- if (!ops)
45812+ if (!iop)
45813 return -ENODEV;
45814
45815 spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags);
45816- ret = ops->map(ops, iova, paddr, size, prot);
45817+ ret = iop->ops->map(iop, iova, paddr, size, prot);
45818 spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags);
45819 return ret;
45820 }
45821@@ -1206,13 +1207,13 @@ static size_t arm_smmu_unmap(struct iommu_domain *domain, unsigned long iova,
45822 size_t ret;
45823 unsigned long flags;
45824 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
45825- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
45826+ struct io_pgtable *iop = smmu_domain->pgtbl;
45827
45828- if (!ops)
45829+ if (!iop)
45830 return 0;
45831
45832 spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags);
45833- ret = ops->unmap(ops, iova, size);
45834+ ret = iop->ops->unmap(iop, iova, size);
45835 spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags);
45836 return ret;
45837 }
45838@@ -1223,7 +1224,7 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain,
45839 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
45840 struct arm_smmu_device *smmu = smmu_domain->smmu;
45841 struct arm_smmu_cfg *cfg = &smmu_domain->cfg;
45842- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
45843+ struct io_pgtable *iop = smmu_domain->pgtbl;
45844 struct device *dev = smmu->dev;
45845 void __iomem *cb_base;
45846 u32 tmp;
45847@@ -1246,7 +1247,7 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain,
45848 dev_err(dev,
45849 "iova to phys timed out on 0x%pad. Falling back to software table walk.\n",
45850 &iova);
45851- return ops->iova_to_phys(ops, iova);
45852+ return iop->ops->iova_to_phys(iop, iova);
45853 }
45854
45855 phys = readl_relaxed(cb_base + ARM_SMMU_CB_PAR_LO);
45856@@ -1267,9 +1268,9 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
45857 phys_addr_t ret;
45858 unsigned long flags;
45859 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
45860- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
45861+ struct io_pgtable *iop = smmu_domain->pgtbl;
45862
45863- if (!ops)
45864+ if (!iop)
45865 return 0;
45866
45867 spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags);
45868@@ -1277,7 +1278,7 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
45869 smmu_domain->stage == ARM_SMMU_DOMAIN_S1) {
45870 ret = arm_smmu_iova_to_phys_hard(domain, iova);
45871 } else {
45872- ret = ops->iova_to_phys(ops, iova);
45873+ ret = iop->ops->iova_to_phys(iop, iova);
45874 }
45875
45876 spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags);
45877@@ -1667,7 +1668,9 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
45878 size |= SZ_64K | SZ_512M;
45879 }
45880
45881- arm_smmu_ops.pgsize_bitmap &= size;
45882+ pax_open_kernel();
45883+ *(unsigned long *)&arm_smmu_ops.pgsize_bitmap &= size;
45884+ pax_close_kernel();
45885 dev_notice(smmu->dev, "\tSupported page sizes: 0x%08lx\n", size);
45886
45887 if (smmu->features & ARM_SMMU_FEAT_TRANS_S1)
45888diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
45889index e29d5d7..e5eeb3e 100644
45890--- a/drivers/iommu/io-pgtable-arm.c
45891+++ b/drivers/iommu/io-pgtable-arm.c
45892@@ -36,12 +36,6 @@
45893 #define io_pgtable_to_data(x) \
45894 container_of((x), struct arm_lpae_io_pgtable, iop)
45895
45896-#define io_pgtable_ops_to_pgtable(x) \
45897- container_of((x), struct io_pgtable, ops)
45898-
45899-#define io_pgtable_ops_to_data(x) \
45900- io_pgtable_to_data(io_pgtable_ops_to_pgtable(x))
45901-
45902 /*
45903 * For consistency with the architecture, we always consider
45904 * ARM_LPAE_MAX_LEVELS levels, with the walk starting at level n >=0
45905@@ -319,10 +313,10 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data,
45906 return pte;
45907 }
45908
45909-static int arm_lpae_map(struct io_pgtable_ops *ops, unsigned long iova,
45910+static int arm_lpae_map(struct io_pgtable *iop, unsigned long iova,
45911 phys_addr_t paddr, size_t size, int iommu_prot)
45912 {
45913- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
45914+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
45915 arm_lpae_iopte *ptep = data->pgd;
45916 int lvl = ARM_LPAE_START_LVL(data);
45917 arm_lpae_iopte prot;
45918@@ -462,12 +456,11 @@ static int __arm_lpae_unmap(struct arm_lpae_io_pgtable *data,
45919 return __arm_lpae_unmap(data, iova, size, lvl + 1, ptep);
45920 }
45921
45922-static int arm_lpae_unmap(struct io_pgtable_ops *ops, unsigned long iova,
45923+static int arm_lpae_unmap(struct io_pgtable *iop, unsigned long iova,
45924 size_t size)
45925 {
45926 size_t unmapped;
45927- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
45928- struct io_pgtable *iop = &data->iop;
45929+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
45930 arm_lpae_iopte *ptep = data->pgd;
45931 int lvl = ARM_LPAE_START_LVL(data);
45932
45933@@ -478,10 +471,10 @@ static int arm_lpae_unmap(struct io_pgtable_ops *ops, unsigned long iova,
45934 return unmapped;
45935 }
45936
45937-static phys_addr_t arm_lpae_iova_to_phys(struct io_pgtable_ops *ops,
45938+static phys_addr_t arm_lpae_iova_to_phys(struct io_pgtable *iop,
45939 unsigned long iova)
45940 {
45941- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
45942+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
45943 arm_lpae_iopte pte, *ptep = data->pgd;
45944 int lvl = ARM_LPAE_START_LVL(data);
45945
45946@@ -548,6 +541,12 @@ static void arm_lpae_restrict_pgsizes(struct io_pgtable_cfg *cfg)
45947 }
45948 }
45949
45950+static struct io_pgtable_ops arm_lpae_io_pgtable_ops = {
45951+ .map = arm_lpae_map,
45952+ .unmap = arm_lpae_unmap,
45953+ .iova_to_phys = arm_lpae_iova_to_phys,
45954+};
45955+
45956 static struct arm_lpae_io_pgtable *
45957 arm_lpae_alloc_pgtable(struct io_pgtable_cfg *cfg)
45958 {
45959@@ -579,11 +578,7 @@ arm_lpae_alloc_pgtable(struct io_pgtable_cfg *cfg)
45960 pgd_bits = va_bits - (data->bits_per_level * (data->levels - 1));
45961 data->pgd_size = 1UL << (pgd_bits + ilog2(sizeof(arm_lpae_iopte)));
45962
45963- data->iop.ops = (struct io_pgtable_ops) {
45964- .map = arm_lpae_map,
45965- .unmap = arm_lpae_unmap,
45966- .iova_to_phys = arm_lpae_iova_to_phys,
45967- };
45968+ data->iop.ops = &arm_lpae_io_pgtable_ops;
45969
45970 return data;
45971 }
45972@@ -845,9 +840,9 @@ static struct iommu_gather_ops dummy_tlb_ops __initdata = {
45973 .flush_pgtable = dummy_flush_pgtable,
45974 };
45975
45976-static void __init arm_lpae_dump_ops(struct io_pgtable_ops *ops)
45977+static void __init arm_lpae_dump_ops(struct io_pgtable *iop)
45978 {
45979- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
45980+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
45981 struct io_pgtable_cfg *cfg = &data->iop.cfg;
45982
45983 pr_err("cfg: pgsize_bitmap 0x%lx, ias %u-bit\n",
45984@@ -857,9 +852,9 @@ static void __init arm_lpae_dump_ops(struct io_pgtable_ops *ops)
45985 data->bits_per_level, data->pgd);
45986 }
45987
45988-#define __FAIL(ops, i) ({ \
45989+#define __FAIL(iop, i) ({ \
45990 WARN(1, "selftest: test failed for fmt idx %d\n", (i)); \
45991- arm_lpae_dump_ops(ops); \
45992+ arm_lpae_dump_ops(iop); \
45993 selftest_running = false; \
45994 -EFAULT; \
45995 })
45996@@ -874,30 +869,32 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
45997 int i, j;
45998 unsigned long iova;
45999 size_t size;
46000- struct io_pgtable_ops *ops;
46001+ struct io_pgtable *iop;
46002+ const struct io_pgtable_ops *ops;
46003
46004 selftest_running = true;
46005
46006 for (i = 0; i < ARRAY_SIZE(fmts); ++i) {
46007 cfg_cookie = cfg;
46008- ops = alloc_io_pgtable_ops(fmts[i], cfg, cfg);
46009- if (!ops) {
46010+ iop = alloc_io_pgtable(fmts[i], cfg, cfg);
46011+ if (!iop) {
46012 pr_err("selftest: failed to allocate io pgtable ops\n");
46013 return -ENOMEM;
46014 }
46015+ ops = iop->ops;
46016
46017 /*
46018 * Initial sanity checks.
46019 * Empty page tables shouldn't provide any translations.
46020 */
46021- if (ops->iova_to_phys(ops, 42))
46022- return __FAIL(ops, i);
46023+ if (ops->iova_to_phys(iop, 42))
46024+ return __FAIL(iop, i);
46025
46026- if (ops->iova_to_phys(ops, SZ_1G + 42))
46027- return __FAIL(ops, i);
46028+ if (ops->iova_to_phys(iop, SZ_1G + 42))
46029+ return __FAIL(iop, i);
46030
46031- if (ops->iova_to_phys(ops, SZ_2G + 42))
46032- return __FAIL(ops, i);
46033+ if (ops->iova_to_phys(iop, SZ_2G + 42))
46034+ return __FAIL(iop, i);
46035
46036 /*
46037 * Distinct mappings of different granule sizes.
46038@@ -907,19 +904,19 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
46039 while (j != BITS_PER_LONG) {
46040 size = 1UL << j;
46041
46042- if (ops->map(ops, iova, iova, size, IOMMU_READ |
46043+ if (ops->map(iop, iova, iova, size, IOMMU_READ |
46044 IOMMU_WRITE |
46045 IOMMU_NOEXEC |
46046 IOMMU_CACHE))
46047- return __FAIL(ops, i);
46048+ return __FAIL(iop, i);
46049
46050 /* Overlapping mappings */
46051- if (!ops->map(ops, iova, iova + size, size,
46052+ if (!ops->map(iop, iova, iova + size, size,
46053 IOMMU_READ | IOMMU_NOEXEC))
46054- return __FAIL(ops, i);
46055+ return __FAIL(iop, i);
46056
46057- if (ops->iova_to_phys(ops, iova + 42) != (iova + 42))
46058- return __FAIL(ops, i);
46059+ if (ops->iova_to_phys(iop, iova + 42) != (iova + 42))
46060+ return __FAIL(iop, i);
46061
46062 iova += SZ_1G;
46063 j++;
46064@@ -928,15 +925,15 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
46065
46066 /* Partial unmap */
46067 size = 1UL << __ffs(cfg->pgsize_bitmap);
46068- if (ops->unmap(ops, SZ_1G + size, size) != size)
46069- return __FAIL(ops, i);
46070+ if (ops->unmap(iop, SZ_1G + size, size) != size)
46071+ return __FAIL(iop, i);
46072
46073 /* Remap of partial unmap */
46074- if (ops->map(ops, SZ_1G + size, size, size, IOMMU_READ))
46075- return __FAIL(ops, i);
46076+ if (ops->map(iop, SZ_1G + size, size, size, IOMMU_READ))
46077+ return __FAIL(iop, i);
46078
46079- if (ops->iova_to_phys(ops, SZ_1G + size + 42) != (size + 42))
46080- return __FAIL(ops, i);
46081+ if (ops->iova_to_phys(iop, SZ_1G + size + 42) != (size + 42))
46082+ return __FAIL(iop, i);
46083
46084 /* Full unmap */
46085 iova = 0;
46086@@ -944,25 +941,25 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
46087 while (j != BITS_PER_LONG) {
46088 size = 1UL << j;
46089
46090- if (ops->unmap(ops, iova, size) != size)
46091- return __FAIL(ops, i);
46092+ if (ops->unmap(iop, iova, size) != size)
46093+ return __FAIL(iop, i);
46094
46095- if (ops->iova_to_phys(ops, iova + 42))
46096- return __FAIL(ops, i);
46097+ if (ops->iova_to_phys(iop, iova + 42))
46098+ return __FAIL(iop, i);
46099
46100 /* Remap full block */
46101- if (ops->map(ops, iova, iova, size, IOMMU_WRITE))
46102- return __FAIL(ops, i);
46103+ if (ops->map(iop, iova, iova, size, IOMMU_WRITE))
46104+ return __FAIL(iop, i);
46105
46106- if (ops->iova_to_phys(ops, iova + 42) != (iova + 42))
46107- return __FAIL(ops, i);
46108+ if (ops->iova_to_phys(iop, iova + 42) != (iova + 42))
46109+ return __FAIL(iop, i);
46110
46111 iova += SZ_1G;
46112 j++;
46113 j = find_next_bit(&cfg->pgsize_bitmap, BITS_PER_LONG, j);
46114 }
46115
46116- free_io_pgtable_ops(ops);
46117+ free_io_pgtable(iop);
46118 }
46119
46120 selftest_running = false;
46121diff --git a/drivers/iommu/io-pgtable.c b/drivers/iommu/io-pgtable.c
46122index 6436fe2..088c965 100644
46123--- a/drivers/iommu/io-pgtable.c
46124+++ b/drivers/iommu/io-pgtable.c
46125@@ -40,7 +40,7 @@ io_pgtable_init_table[IO_PGTABLE_NUM_FMTS] =
46126 #endif
46127 };
46128
46129-struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
46130+struct io_pgtable *alloc_io_pgtable(enum io_pgtable_fmt fmt,
46131 struct io_pgtable_cfg *cfg,
46132 void *cookie)
46133 {
46134@@ -62,21 +62,18 @@ struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
46135 iop->cookie = cookie;
46136 iop->cfg = *cfg;
46137
46138- return &iop->ops;
46139+ return iop;
46140 }
46141
46142 /*
46143 * It is the IOMMU driver's responsibility to ensure that the page table
46144 * is no longer accessible to the walker by this point.
46145 */
46146-void free_io_pgtable_ops(struct io_pgtable_ops *ops)
46147+void free_io_pgtable(struct io_pgtable *iop)
46148 {
46149- struct io_pgtable *iop;
46150-
46151- if (!ops)
46152+ if (!iop)
46153 return;
46154
46155- iop = container_of(ops, struct io_pgtable, ops);
46156 iop->cfg.tlb->tlb_flush_all(iop->cookie);
46157 io_pgtable_init_table[iop->fmt]->free(iop);
46158 }
46159diff --git a/drivers/iommu/io-pgtable.h b/drivers/iommu/io-pgtable.h
46160index 10e32f6..0b276c8 100644
46161--- a/drivers/iommu/io-pgtable.h
46162+++ b/drivers/iommu/io-pgtable.h
46163@@ -75,17 +75,18 @@ struct io_pgtable_cfg {
46164 * These functions map directly onto the iommu_ops member functions with
46165 * the same names.
46166 */
46167+struct io_pgtable;
46168 struct io_pgtable_ops {
46169- int (*map)(struct io_pgtable_ops *ops, unsigned long iova,
46170+ int (*map)(struct io_pgtable *iop, unsigned long iova,
46171 phys_addr_t paddr, size_t size, int prot);
46172- int (*unmap)(struct io_pgtable_ops *ops, unsigned long iova,
46173+ int (*unmap)(struct io_pgtable *iop, unsigned long iova,
46174 size_t size);
46175- phys_addr_t (*iova_to_phys)(struct io_pgtable_ops *ops,
46176+ phys_addr_t (*iova_to_phys)(struct io_pgtable *iop,
46177 unsigned long iova);
46178 };
46179
46180 /**
46181- * alloc_io_pgtable_ops() - Allocate a page table allocator for use by an IOMMU.
46182+ * alloc_io_pgtable() - Allocate a page table allocator for use by an IOMMU.
46183 *
46184 * @fmt: The page table format.
46185 * @cfg: The page table configuration. This will be modified to represent
46186@@ -94,9 +95,9 @@ struct io_pgtable_ops {
46187 * @cookie: An opaque token provided by the IOMMU driver and passed back to
46188 * the callback routines in cfg->tlb.
46189 */
46190-struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
46191- struct io_pgtable_cfg *cfg,
46192- void *cookie);
46193+struct io_pgtable *alloc_io_pgtable(enum io_pgtable_fmt fmt,
46194+ struct io_pgtable_cfg *cfg,
46195+ void *cookie);
46196
46197 /**
46198 * free_io_pgtable_ops() - Free an io_pgtable_ops structure. The caller
46199@@ -105,7 +106,7 @@ struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
46200 *
46201 * @ops: The ops returned from alloc_io_pgtable_ops.
46202 */
46203-void free_io_pgtable_ops(struct io_pgtable_ops *ops);
46204+void free_io_pgtable(struct io_pgtable *iop);
46205
46206
46207 /*
46208@@ -125,7 +126,7 @@ struct io_pgtable {
46209 enum io_pgtable_fmt fmt;
46210 void *cookie;
46211 struct io_pgtable_cfg cfg;
46212- struct io_pgtable_ops ops;
46213+ const struct io_pgtable_ops *ops;
46214 };
46215
46216 /**
46217diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
46218index f286090..bac3e7e 100644
46219--- a/drivers/iommu/iommu.c
46220+++ b/drivers/iommu/iommu.c
46221@@ -934,7 +934,7 @@ static int iommu_bus_notifier(struct notifier_block *nb,
46222 static int iommu_bus_init(struct bus_type *bus, const struct iommu_ops *ops)
46223 {
46224 int err;
46225- struct notifier_block *nb;
46226+ notifier_block_no_const *nb;
46227 struct iommu_callback_data cb = {
46228 .ops = ops,
46229 };
46230diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
46231index 1a67c53..23181d8 100644
46232--- a/drivers/iommu/ipmmu-vmsa.c
46233+++ b/drivers/iommu/ipmmu-vmsa.c
46234@@ -41,7 +41,7 @@ struct ipmmu_vmsa_domain {
46235 struct iommu_domain io_domain;
46236
46237 struct io_pgtable_cfg cfg;
46238- struct io_pgtable_ops *iop;
46239+ struct io_pgtable *iop;
46240
46241 unsigned int context_id;
46242 spinlock_t lock; /* Protects mappings */
46243@@ -328,8 +328,7 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
46244 domain->cfg.oas = 40;
46245 domain->cfg.tlb = &ipmmu_gather_ops;
46246
46247- domain->iop = alloc_io_pgtable_ops(ARM_32_LPAE_S1, &domain->cfg,
46248- domain);
46249+ domain->iop = alloc_io_pgtable(ARM_32_LPAE_S1, &domain->cfg, domain);
46250 if (!domain->iop)
46251 return -EINVAL;
46252
46253@@ -487,7 +486,7 @@ static void ipmmu_domain_free(struct iommu_domain *io_domain)
46254 * been detached.
46255 */
46256 ipmmu_domain_destroy_context(domain);
46257- free_io_pgtable_ops(domain->iop);
46258+ free_io_pgtable(domain->iop);
46259 kfree(domain);
46260 }
46261
46262@@ -556,7 +555,7 @@ static int ipmmu_map(struct iommu_domain *io_domain, unsigned long iova,
46263 if (!domain)
46264 return -ENODEV;
46265
46266- return domain->iop->map(domain->iop, iova, paddr, size, prot);
46267+ return domain->iop->ops->map(domain->iop, iova, paddr, size, prot);
46268 }
46269
46270 static size_t ipmmu_unmap(struct iommu_domain *io_domain, unsigned long iova,
46271@@ -564,7 +563,7 @@ static size_t ipmmu_unmap(struct iommu_domain *io_domain, unsigned long iova,
46272 {
46273 struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);
46274
46275- return domain->iop->unmap(domain->iop, iova, size);
46276+ return domain->iop->ops->unmap(domain->iop, iova, size);
46277 }
46278
46279 static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain,
46280@@ -574,7 +573,7 @@ static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain,
46281
46282 /* TODO: Is locking needed ? */
46283
46284- return domain->iop->iova_to_phys(domain->iop, iova);
46285+ return domain->iop->ops->iova_to_phys(domain->iop, iova);
46286 }
46287
46288 static int ipmmu_find_utlbs(struct ipmmu_vmsa_device *mmu, struct device *dev,
46289diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
46290index 2d99930..b8b358c 100644
46291--- a/drivers/iommu/irq_remapping.c
46292+++ b/drivers/iommu/irq_remapping.c
46293@@ -149,7 +149,7 @@ int __init irq_remap_enable_fault_handling(void)
46294 void panic_if_irq_remap(const char *msg)
46295 {
46296 if (irq_remapping_enabled)
46297- panic(msg);
46298+ panic("%s", msg);
46299 }
46300
46301 void ir_ack_apic_edge(struct irq_data *data)
46302diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c
46303index f3d20a2..5dcb85e 100644
46304--- a/drivers/iommu/omap-iommu-debug.c
46305+++ b/drivers/iommu/omap-iommu-debug.c
46306@@ -55,34 +55,22 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf,
46307 return bytes;
46308 }
46309
46310-static ssize_t debug_read_tlb(struct file *file, char __user *userbuf,
46311- size_t count, loff_t *ppos)
46312+static int debug_read_tlb(struct seq_file *s, void *data)
46313 {
46314- struct omap_iommu *obj = file->private_data;
46315- char *p, *buf;
46316- ssize_t bytes, rest;
46317+ struct omap_iommu *obj = s->private;
46318
46319 if (is_omap_iommu_detached(obj))
46320 return -EPERM;
46321
46322- buf = kmalloc(count, GFP_KERNEL);
46323- if (!buf)
46324- return -ENOMEM;
46325- p = buf;
46326-
46327 mutex_lock(&iommu_debug_lock);
46328
46329- p += sprintf(p, "%8s %8s\n", "cam:", "ram:");
46330- p += sprintf(p, "-----------------------------------------\n");
46331- rest = count - (p - buf);
46332- p += omap_dump_tlb_entries(obj, p, rest);
46333-
46334- bytes = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
46335+ seq_printf(s, "%8s %8s\n", "cam:", "ram:");
46336+ seq_puts(s, "-----------------------------------------\n");
46337+ omap_dump_tlb_entries(obj, s);
46338
46339 mutex_unlock(&iommu_debug_lock);
46340- kfree(buf);
46341
46342- return bytes;
46343+ return 0;
46344 }
46345
46346 static void dump_ioptable(struct seq_file *s)
46347@@ -157,7 +145,7 @@ static int debug_read_pagetable(struct seq_file *s, void *data)
46348 };
46349
46350 DEBUG_FOPS_RO(regs);
46351-DEBUG_FOPS_RO(tlb);
46352+DEBUG_SEQ_FOPS_RO(tlb);
46353 DEBUG_SEQ_FOPS_RO(pagetable);
46354
46355 #define __DEBUG_ADD_FILE(attr, mode) \
46356diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
46357index a22c33d..2247075e2 100644
46358--- a/drivers/iommu/omap-iommu.c
46359+++ b/drivers/iommu/omap-iommu.c
46360@@ -546,36 +546,30 @@ __dump_tlb_entries(struct omap_iommu *obj, struct cr_regs *crs, int num)
46361 }
46362
46363 /**
46364- * iotlb_dump_cr - Dump an iommu tlb entry into buf
46365+ * iotlb_dump_cr - Dump an iommu tlb entry into seq_file
46366 * @obj: target iommu
46367 * @cr: contents of cam and ram register
46368- * @buf: output buffer
46369+ * @s: output seq_file
46370 **/
46371 static ssize_t iotlb_dump_cr(struct omap_iommu *obj, struct cr_regs *cr,
46372- char *buf)
46373+ struct seq_file *s)
46374 {
46375- char *p = buf;
46376-
46377 /* FIXME: Need more detail analysis of cam/ram */
46378- p += sprintf(p, "%08x %08x %01x\n", cr->cam, cr->ram,
46379- (cr->cam & MMU_CAM_P) ? 1 : 0);
46380-
46381- return p - buf;
46382+ return seq_printf(s, "%08x %08x %01x\n", cr->cam, cr->ram,
46383+ (cr->cam & MMU_CAM_P) ? 1 : 0);
46384 }
46385
46386 /**
46387- * omap_dump_tlb_entries - dump cr arrays to given buffer
46388+ * omap_dump_tlb_entries - dump cr arrays to given seq_file
46389 * @obj: target iommu
46390- * @buf: output buffer
46391+ * @s: output seq_file
46392 **/
46393-size_t omap_dump_tlb_entries(struct omap_iommu *obj, char *buf, ssize_t bytes)
46394+size_t omap_dump_tlb_entries(struct omap_iommu *obj, struct seq_file *s)
46395 {
46396 int i, num;
46397 struct cr_regs *cr;
46398- char *p = buf;
46399
46400- num = bytes / sizeof(*cr);
46401- num = min(obj->nr_tlb_entries, num);
46402+ num = obj->nr_tlb_entries;
46403
46404 cr = kcalloc(num, sizeof(*cr), GFP_KERNEL);
46405 if (!cr)
46406@@ -583,10 +577,10 @@ size_t omap_dump_tlb_entries(struct omap_iommu *obj, char *buf, ssize_t bytes)
46407
46408 num = __dump_tlb_entries(obj, cr, num);
46409 for (i = 0; i < num; i++)
46410- p += iotlb_dump_cr(obj, cr + i, p);
46411+ iotlb_dump_cr(obj, cr + i, s);
46412 kfree(cr);
46413
46414- return p - buf;
46415+ return 0;
46416 }
46417
46418 #endif /* CONFIG_OMAP_IOMMU_DEBUG */
46419diff --git a/drivers/iommu/omap-iommu.h b/drivers/iommu/omap-iommu.h
46420index d736630..5df9755 100644
46421--- a/drivers/iommu/omap-iommu.h
46422+++ b/drivers/iommu/omap-iommu.h
46423@@ -193,8 +193,7 @@ static inline struct omap_iommu *dev_to_omap_iommu(struct device *dev)
46424 #ifdef CONFIG_OMAP_IOMMU_DEBUG
46425 extern ssize_t
46426 omap_iommu_dump_ctx(struct omap_iommu *obj, char *buf, ssize_t len);
46427-extern size_t
46428-omap_dump_tlb_entries(struct omap_iommu *obj, char *buf, ssize_t len);
46429+extern size_t omap_dump_tlb_entries(struct omap_iommu *obj, struct seq_file *s);
46430
46431 void omap_iommu_debugfs_init(void);
46432 void omap_iommu_debugfs_exit(void);
46433diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
46434index 4dd8826..1f33400 100644
46435--- a/drivers/irqchip/irq-gic.c
46436+++ b/drivers/irqchip/irq-gic.c
46437@@ -313,7 +313,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
46438 chained_irq_exit(chip, desc);
46439 }
46440
46441-static struct irq_chip gic_chip = {
46442+static irq_chip_no_const gic_chip __read_only = {
46443 .name = "GIC",
46444 .irq_mask = gic_mask_irq,
46445 .irq_unmask = gic_unmask_irq,
46446diff --git a/drivers/irqchip/irq-renesas-intc-irqpin.c b/drivers/irqchip/irq-renesas-intc-irqpin.c
46447index 0670ab4..1094651 100644
46448--- a/drivers/irqchip/irq-renesas-intc-irqpin.c
46449+++ b/drivers/irqchip/irq-renesas-intc-irqpin.c
46450@@ -373,7 +373,7 @@ static int intc_irqpin_probe(struct platform_device *pdev)
46451 struct intc_irqpin_iomem *i;
46452 struct resource *io[INTC_IRQPIN_REG_NR];
46453 struct resource *irq;
46454- struct irq_chip *irq_chip;
46455+ irq_chip_no_const *irq_chip;
46456 void (*enable_fn)(struct irq_data *d);
46457 void (*disable_fn)(struct irq_data *d);
46458 const char *name = dev_name(dev);
46459diff --git a/drivers/irqchip/irq-renesas-irqc.c b/drivers/irqchip/irq-renesas-irqc.c
46460index 778bd07..0397152 100644
46461--- a/drivers/irqchip/irq-renesas-irqc.c
46462+++ b/drivers/irqchip/irq-renesas-irqc.c
46463@@ -176,7 +176,7 @@ static int irqc_probe(struct platform_device *pdev)
46464 struct irqc_priv *p;
46465 struct resource *io;
46466 struct resource *irq;
46467- struct irq_chip *irq_chip;
46468+ irq_chip_no_const *irq_chip;
46469 const char *name = dev_name(&pdev->dev);
46470 int ret;
46471 int k;
46472diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
46473index 6a2df32..dc962f1 100644
46474--- a/drivers/isdn/capi/capi.c
46475+++ b/drivers/isdn/capi/capi.c
46476@@ -81,8 +81,8 @@ struct capiminor {
46477
46478 struct capi20_appl *ap;
46479 u32 ncci;
46480- atomic_t datahandle;
46481- atomic_t msgid;
46482+ atomic_unchecked_t datahandle;
46483+ atomic_unchecked_t msgid;
46484
46485 struct tty_port port;
46486 int ttyinstop;
46487@@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
46488 capimsg_setu16(s, 2, mp->ap->applid);
46489 capimsg_setu8 (s, 4, CAPI_DATA_B3);
46490 capimsg_setu8 (s, 5, CAPI_RESP);
46491- capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
46492+ capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
46493 capimsg_setu32(s, 8, mp->ncci);
46494 capimsg_setu16(s, 12, datahandle);
46495 }
46496@@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
46497 mp->outbytes -= len;
46498 spin_unlock_bh(&mp->outlock);
46499
46500- datahandle = atomic_inc_return(&mp->datahandle);
46501+ datahandle = atomic_inc_return_unchecked(&mp->datahandle);
46502 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
46503 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
46504 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
46505 capimsg_setu16(skb->data, 2, mp->ap->applid);
46506 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
46507 capimsg_setu8 (skb->data, 5, CAPI_REQ);
46508- capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
46509+ capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
46510 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
46511 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
46512 capimsg_setu16(skb->data, 16, len); /* Data length */
46513diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
46514index aecec6d..11e13c5 100644
46515--- a/drivers/isdn/gigaset/bas-gigaset.c
46516+++ b/drivers/isdn/gigaset/bas-gigaset.c
46517@@ -2565,22 +2565,22 @@ static int gigaset_post_reset(struct usb_interface *intf)
46518
46519
46520 static const struct gigaset_ops gigops = {
46521- gigaset_write_cmd,
46522- gigaset_write_room,
46523- gigaset_chars_in_buffer,
46524- gigaset_brkchars,
46525- gigaset_init_bchannel,
46526- gigaset_close_bchannel,
46527- gigaset_initbcshw,
46528- gigaset_freebcshw,
46529- gigaset_reinitbcshw,
46530- gigaset_initcshw,
46531- gigaset_freecshw,
46532- gigaset_set_modem_ctrl,
46533- gigaset_baud_rate,
46534- gigaset_set_line_ctrl,
46535- gigaset_isoc_send_skb,
46536- gigaset_isoc_input,
46537+ .write_cmd = gigaset_write_cmd,
46538+ .write_room = gigaset_write_room,
46539+ .chars_in_buffer = gigaset_chars_in_buffer,
46540+ .brkchars = gigaset_brkchars,
46541+ .init_bchannel = gigaset_init_bchannel,
46542+ .close_bchannel = gigaset_close_bchannel,
46543+ .initbcshw = gigaset_initbcshw,
46544+ .freebcshw = gigaset_freebcshw,
46545+ .reinitbcshw = gigaset_reinitbcshw,
46546+ .initcshw = gigaset_initcshw,
46547+ .freecshw = gigaset_freecshw,
46548+ .set_modem_ctrl = gigaset_set_modem_ctrl,
46549+ .baud_rate = gigaset_baud_rate,
46550+ .set_line_ctrl = gigaset_set_line_ctrl,
46551+ .send_skb = gigaset_isoc_send_skb,
46552+ .handle_input = gigaset_isoc_input,
46553 };
46554
46555 /* bas_gigaset_init
46556diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
46557index 600c79b..3752bab 100644
46558--- a/drivers/isdn/gigaset/interface.c
46559+++ b/drivers/isdn/gigaset/interface.c
46560@@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
46561 }
46562 tty->driver_data = cs;
46563
46564- ++cs->port.count;
46565+ atomic_inc(&cs->port.count);
46566
46567- if (cs->port.count == 1) {
46568+ if (atomic_read(&cs->port.count) == 1) {
46569 tty_port_tty_set(&cs->port, tty);
46570 cs->port.low_latency = 1;
46571 }
46572@@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
46573
46574 if (!cs->connected)
46575 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
46576- else if (!cs->port.count)
46577+ else if (!atomic_read(&cs->port.count))
46578 dev_warn(cs->dev, "%s: device not opened\n", __func__);
46579- else if (!--cs->port.count)
46580+ else if (!atomic_dec_return(&cs->port.count))
46581 tty_port_tty_set(&cs->port, NULL);
46582
46583 mutex_unlock(&cs->mutex);
46584diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
46585index 375be50..675293c 100644
46586--- a/drivers/isdn/gigaset/ser-gigaset.c
46587+++ b/drivers/isdn/gigaset/ser-gigaset.c
46588@@ -453,22 +453,22 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
46589 }
46590
46591 static const struct gigaset_ops ops = {
46592- gigaset_write_cmd,
46593- gigaset_write_room,
46594- gigaset_chars_in_buffer,
46595- gigaset_brkchars,
46596- gigaset_init_bchannel,
46597- gigaset_close_bchannel,
46598- gigaset_initbcshw,
46599- gigaset_freebcshw,
46600- gigaset_reinitbcshw,
46601- gigaset_initcshw,
46602- gigaset_freecshw,
46603- gigaset_set_modem_ctrl,
46604- gigaset_baud_rate,
46605- gigaset_set_line_ctrl,
46606- gigaset_m10x_send_skb, /* asyncdata.c */
46607- gigaset_m10x_input, /* asyncdata.c */
46608+ .write_cmd = gigaset_write_cmd,
46609+ .write_room = gigaset_write_room,
46610+ .chars_in_buffer = gigaset_chars_in_buffer,
46611+ .brkchars = gigaset_brkchars,
46612+ .init_bchannel = gigaset_init_bchannel,
46613+ .close_bchannel = gigaset_close_bchannel,
46614+ .initbcshw = gigaset_initbcshw,
46615+ .freebcshw = gigaset_freebcshw,
46616+ .reinitbcshw = gigaset_reinitbcshw,
46617+ .initcshw = gigaset_initcshw,
46618+ .freecshw = gigaset_freecshw,
46619+ .set_modem_ctrl = gigaset_set_modem_ctrl,
46620+ .baud_rate = gigaset_baud_rate,
46621+ .set_line_ctrl = gigaset_set_line_ctrl,
46622+ .send_skb = gigaset_m10x_send_skb, /* asyncdata.c */
46623+ .handle_input = gigaset_m10x_input, /* asyncdata.c */
46624 };
46625
46626
46627diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
46628index 5f306e2..5342f88 100644
46629--- a/drivers/isdn/gigaset/usb-gigaset.c
46630+++ b/drivers/isdn/gigaset/usb-gigaset.c
46631@@ -543,7 +543,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
46632 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
46633 memcpy(cs->hw.usb->bchars, buf, 6);
46634 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
46635- 0, 0, &buf, 6, 2000);
46636+ 0, 0, buf, 6, 2000);
46637 }
46638
46639 static void gigaset_freebcshw(struct bc_state *bcs)
46640@@ -862,22 +862,22 @@ static int gigaset_pre_reset(struct usb_interface *intf)
46641 }
46642
46643 static const struct gigaset_ops ops = {
46644- gigaset_write_cmd,
46645- gigaset_write_room,
46646- gigaset_chars_in_buffer,
46647- gigaset_brkchars,
46648- gigaset_init_bchannel,
46649- gigaset_close_bchannel,
46650- gigaset_initbcshw,
46651- gigaset_freebcshw,
46652- gigaset_reinitbcshw,
46653- gigaset_initcshw,
46654- gigaset_freecshw,
46655- gigaset_set_modem_ctrl,
46656- gigaset_baud_rate,
46657- gigaset_set_line_ctrl,
46658- gigaset_m10x_send_skb,
46659- gigaset_m10x_input,
46660+ .write_cmd = gigaset_write_cmd,
46661+ .write_room = gigaset_write_room,
46662+ .chars_in_buffer = gigaset_chars_in_buffer,
46663+ .brkchars = gigaset_brkchars,
46664+ .init_bchannel = gigaset_init_bchannel,
46665+ .close_bchannel = gigaset_close_bchannel,
46666+ .initbcshw = gigaset_initbcshw,
46667+ .freebcshw = gigaset_freebcshw,
46668+ .reinitbcshw = gigaset_reinitbcshw,
46669+ .initcshw = gigaset_initcshw,
46670+ .freecshw = gigaset_freecshw,
46671+ .set_modem_ctrl = gigaset_set_modem_ctrl,
46672+ .baud_rate = gigaset_baud_rate,
46673+ .set_line_ctrl = gigaset_set_line_ctrl,
46674+ .send_skb = gigaset_m10x_send_skb,
46675+ .handle_input = gigaset_m10x_input,
46676 };
46677
46678 /*
46679diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
46680index 4d9b195..455075c 100644
46681--- a/drivers/isdn/hardware/avm/b1.c
46682+++ b/drivers/isdn/hardware/avm/b1.c
46683@@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
46684 }
46685 if (left) {
46686 if (t4file->user) {
46687- if (copy_from_user(buf, dp, left))
46688+ if (left > sizeof buf || copy_from_user(buf, dp, left))
46689 return -EFAULT;
46690 } else {
46691 memcpy(buf, dp, left);
46692@@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
46693 }
46694 if (left) {
46695 if (config->user) {
46696- if (copy_from_user(buf, dp, left))
46697+ if (left > sizeof buf || copy_from_user(buf, dp, left))
46698 return -EFAULT;
46699 } else {
46700 memcpy(buf, dp, left);
46701diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
46702index 9b856e1..fa03c92 100644
46703--- a/drivers/isdn/i4l/isdn_common.c
46704+++ b/drivers/isdn/i4l/isdn_common.c
46705@@ -1654,6 +1654,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
46706 } else
46707 return -EINVAL;
46708 case IIOCDBGVAR:
46709+ if (!capable(CAP_SYS_RAWIO))
46710+ return -EPERM;
46711 if (arg) {
46712 if (copy_to_user(argp, &dev, sizeof(ulong)))
46713 return -EFAULT;
46714diff --git a/drivers/isdn/i4l/isdn_concap.c b/drivers/isdn/i4l/isdn_concap.c
46715index 91d5730..336523e 100644
46716--- a/drivers/isdn/i4l/isdn_concap.c
46717+++ b/drivers/isdn/i4l/isdn_concap.c
46718@@ -80,9 +80,9 @@ static int isdn_concap_dl_disconn_req(struct concap_proto *concap)
46719 }
46720
46721 struct concap_device_ops isdn_concap_reliable_dl_dops = {
46722- &isdn_concap_dl_data_req,
46723- &isdn_concap_dl_connect_req,
46724- &isdn_concap_dl_disconn_req
46725+ .data_req = &isdn_concap_dl_data_req,
46726+ .connect_req = &isdn_concap_dl_connect_req,
46727+ .disconn_req = &isdn_concap_dl_disconn_req
46728 };
46729
46730 /* The following should better go into a dedicated source file such that
46731diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
46732index bc91261..2ef7e36 100644
46733--- a/drivers/isdn/i4l/isdn_tty.c
46734+++ b/drivers/isdn/i4l/isdn_tty.c
46735@@ -1503,9 +1503,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
46736
46737 #ifdef ISDN_DEBUG_MODEM_OPEN
46738 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
46739- port->count);
46740+ atomic_read(&port->count));
46741 #endif
46742- port->count++;
46743+ atomic_inc(&port->count);
46744 port->tty = tty;
46745 /*
46746 * Start up serial port
46747@@ -1549,7 +1549,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
46748 #endif
46749 return;
46750 }
46751- if ((tty->count == 1) && (port->count != 1)) {
46752+ if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
46753 /*
46754 * Uh, oh. tty->count is 1, which means that the tty
46755 * structure will be freed. Info->count should always
46756@@ -1558,15 +1558,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
46757 * serial port won't be shutdown.
46758 */
46759 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
46760- "info->count is %d\n", port->count);
46761- port->count = 1;
46762+ "info->count is %d\n", atomic_read(&port->count));
46763+ atomic_set(&port->count, 1);
46764 }
46765- if (--port->count < 0) {
46766+ if (atomic_dec_return(&port->count) < 0) {
46767 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
46768- info->line, port->count);
46769- port->count = 0;
46770+ info->line, atomic_read(&port->count));
46771+ atomic_set(&port->count, 0);
46772 }
46773- if (port->count) {
46774+ if (atomic_read(&port->count)) {
46775 #ifdef ISDN_DEBUG_MODEM_OPEN
46776 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
46777 #endif
46778@@ -1620,7 +1620,7 @@ isdn_tty_hangup(struct tty_struct *tty)
46779 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
46780 return;
46781 isdn_tty_shutdown(info);
46782- port->count = 0;
46783+ atomic_set(&port->count, 0);
46784 port->flags &= ~ASYNC_NORMAL_ACTIVE;
46785 port->tty = NULL;
46786 wake_up_interruptible(&port->open_wait);
46787@@ -1965,7 +1965,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
46788 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
46789 modem_info *info = &dev->mdm.info[i];
46790
46791- if (info->port.count == 0)
46792+ if (atomic_read(&info->port.count) == 0)
46793 continue;
46794 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
46795 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
46796diff --git a/drivers/isdn/i4l/isdn_x25iface.c b/drivers/isdn/i4l/isdn_x25iface.c
46797index e2d4e58..40cd045 100644
46798--- a/drivers/isdn/i4l/isdn_x25iface.c
46799+++ b/drivers/isdn/i4l/isdn_x25iface.c
46800@@ -53,14 +53,14 @@ static int isdn_x25iface_disconn_ind(struct concap_proto *);
46801
46802
46803 static struct concap_proto_ops ix25_pops = {
46804- &isdn_x25iface_proto_new,
46805- &isdn_x25iface_proto_del,
46806- &isdn_x25iface_proto_restart,
46807- &isdn_x25iface_proto_close,
46808- &isdn_x25iface_xmit,
46809- &isdn_x25iface_receive,
46810- &isdn_x25iface_connect_ind,
46811- &isdn_x25iface_disconn_ind
46812+ .proto_new = &isdn_x25iface_proto_new,
46813+ .proto_del = &isdn_x25iface_proto_del,
46814+ .restart = &isdn_x25iface_proto_restart,
46815+ .close = &isdn_x25iface_proto_close,
46816+ .encap_and_xmit = &isdn_x25iface_xmit,
46817+ .data_ind = &isdn_x25iface_receive,
46818+ .connect_ind = &isdn_x25iface_connect_ind,
46819+ .disconn_ind = &isdn_x25iface_disconn_ind
46820 };
46821
46822 /* error message helper function */
46823diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
46824index 358a574..b4987ea 100644
46825--- a/drivers/isdn/icn/icn.c
46826+++ b/drivers/isdn/icn/icn.c
46827@@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
46828 if (count > len)
46829 count = len;
46830 if (user) {
46831- if (copy_from_user(msg, buf, count))
46832+ if (count > sizeof msg || copy_from_user(msg, buf, count))
46833 return -EFAULT;
46834 } else
46835 memcpy(msg, buf, count);
46836diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
46837index 52c4382..09e0c7c 100644
46838--- a/drivers/isdn/mISDN/dsp_cmx.c
46839+++ b/drivers/isdn/mISDN/dsp_cmx.c
46840@@ -1625,7 +1625,7 @@ unsigned long dsp_spl_jiffies; /* calculate the next time to fire */
46841 static u16 dsp_count; /* last sample count */
46842 static int dsp_count_valid; /* if we have last sample count */
46843
46844-void
46845+void __intentional_overflow(-1)
46846 dsp_cmx_send(void *arg)
46847 {
46848 struct dsp_conf *conf;
46849diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
46850index 312ffd3..9263d05 100644
46851--- a/drivers/lguest/core.c
46852+++ b/drivers/lguest/core.c
46853@@ -96,9 +96,17 @@ static __init int map_switcher(void)
46854 * The end address needs +1 because __get_vm_area allocates an
46855 * extra guard page, so we need space for that.
46856 */
46857+
46858+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
46859+ switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
46860+ VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
46861+ + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
46862+#else
46863 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
46864 VM_ALLOC, switcher_addr, switcher_addr
46865 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
46866+#endif
46867+
46868 if (!switcher_vma) {
46869 err = -ENOMEM;
46870 printk("lguest: could not map switcher pages high\n");
46871@@ -121,7 +129,7 @@ static __init int map_switcher(void)
46872 * Now the Switcher is mapped at the right address, we can't fail!
46873 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
46874 */
46875- memcpy(switcher_vma->addr, start_switcher_text,
46876+ memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
46877 end_switcher_text - start_switcher_text);
46878
46879 printk(KERN_INFO "lguest: mapped switcher at %p\n",
46880diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
46881index e3abebc9..6a35328 100644
46882--- a/drivers/lguest/page_tables.c
46883+++ b/drivers/lguest/page_tables.c
46884@@ -585,7 +585,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
46885 /*:*/
46886
46887 #ifdef CONFIG_X86_PAE
46888-static void release_pmd(pmd_t *spmd)
46889+static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
46890 {
46891 /* If the entry's not present, there's nothing to release. */
46892 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
46893diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
46894index 6a4cd77..c9e2d9f 100644
46895--- a/drivers/lguest/x86/core.c
46896+++ b/drivers/lguest/x86/core.c
46897@@ -60,7 +60,7 @@ static struct {
46898 /* Offset from where switcher.S was compiled to where we've copied it */
46899 static unsigned long switcher_offset(void)
46900 {
46901- return switcher_addr - (unsigned long)start_switcher_text;
46902+ return switcher_addr - ktla_ktva((unsigned long)start_switcher_text);
46903 }
46904
46905 /* This cpu's struct lguest_pages (after the Switcher text page) */
46906@@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
46907 * These copies are pretty cheap, so we do them unconditionally: */
46908 /* Save the current Host top-level page directory.
46909 */
46910+
46911+#ifdef CONFIG_PAX_PER_CPU_PGD
46912+ pages->state.host_cr3 = read_cr3();
46913+#else
46914 pages->state.host_cr3 = __pa(current->mm->pgd);
46915+#endif
46916+
46917 /*
46918 * Set up the Guest's page tables to see this CPU's pages (and no
46919 * other CPU's pages).
46920@@ -494,7 +500,7 @@ void __init lguest_arch_host_init(void)
46921 * compiled-in switcher code and the high-mapped copy we just made.
46922 */
46923 for (i = 0; i < IDT_ENTRIES; i++)
46924- default_idt_entries[i] += switcher_offset();
46925+ default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
46926
46927 /*
46928 * Set up the Switcher's per-cpu areas.
46929@@ -577,7 +583,7 @@ void __init lguest_arch_host_init(void)
46930 * it will be undisturbed when we switch. To change %cs and jump we
46931 * need this structure to feed to Intel's "lcall" instruction.
46932 */
46933- lguest_entry.offset = (long)switch_to_guest + switcher_offset();
46934+ lguest_entry.offset = ktla_ktva((unsigned long)switch_to_guest) + switcher_offset();
46935 lguest_entry.segment = LGUEST_CS;
46936
46937 /*
46938diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
46939index 40634b0..4f5855e 100644
46940--- a/drivers/lguest/x86/switcher_32.S
46941+++ b/drivers/lguest/x86/switcher_32.S
46942@@ -87,6 +87,7 @@
46943 #include <asm/page.h>
46944 #include <asm/segment.h>
46945 #include <asm/lguest.h>
46946+#include <asm/processor-flags.h>
46947
46948 // We mark the start of the code to copy
46949 // It's placed in .text tho it's never run here
46950@@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
46951 // Changes type when we load it: damn Intel!
46952 // For after we switch over our page tables
46953 // That entry will be read-only: we'd crash.
46954+
46955+#ifdef CONFIG_PAX_KERNEXEC
46956+ mov %cr0, %edx
46957+ xor $X86_CR0_WP, %edx
46958+ mov %edx, %cr0
46959+#endif
46960+
46961 movl $(GDT_ENTRY_TSS*8), %edx
46962 ltr %dx
46963
46964@@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
46965 // Let's clear it again for our return.
46966 // The GDT descriptor of the Host
46967 // Points to the table after two "size" bytes
46968- movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
46969+ movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
46970 // Clear "used" from type field (byte 5, bit 2)
46971- andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
46972+ andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
46973+
46974+#ifdef CONFIG_PAX_KERNEXEC
46975+ mov %cr0, %eax
46976+ xor $X86_CR0_WP, %eax
46977+ mov %eax, %cr0
46978+#endif
46979
46980 // Once our page table's switched, the Guest is live!
46981 // The Host fades as we run this final step.
46982@@ -295,13 +309,12 @@ deliver_to_host:
46983 // I consulted gcc, and it gave
46984 // These instructions, which I gladly credit:
46985 leal (%edx,%ebx,8), %eax
46986- movzwl (%eax),%edx
46987- movl 4(%eax), %eax
46988- xorw %ax, %ax
46989- orl %eax, %edx
46990+ movl 4(%eax), %edx
46991+ movw (%eax), %dx
46992 // Now the address of the handler's in %edx
46993 // We call it now: its "iret" drops us home.
46994- jmp *%edx
46995+ ljmp $__KERNEL_CS, $1f
46996+1: jmp *%edx
46997
46998 // Every interrupt can come to us here
46999 // But we must truly tell each apart.
47000diff --git a/drivers/md/bcache/Kconfig b/drivers/md/bcache/Kconfig
47001index 4d20088..de60cb2 100644
47002--- a/drivers/md/bcache/Kconfig
47003+++ b/drivers/md/bcache/Kconfig
47004@@ -20,6 +20,7 @@ config BCACHE_CLOSURES_DEBUG
47005 bool "Debug closures"
47006 depends on BCACHE
47007 select DEBUG_FS
47008+ depends on !GRKERNSEC_KMEM
47009 ---help---
47010 Keeps all active closures in a linked list and provides a debugfs
47011 interface to list them, which makes it possible to see asynchronous
47012diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
47013index 79a6d63..47acff6 100644
47014--- a/drivers/md/bcache/closure.h
47015+++ b/drivers/md/bcache/closure.h
47016@@ -238,7 +238,7 @@ static inline void closure_set_stopped(struct closure *cl)
47017 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
47018 struct workqueue_struct *wq)
47019 {
47020- BUG_ON(object_is_on_stack(cl));
47021+ BUG_ON(object_starts_on_stack(cl));
47022 closure_set_ip(cl);
47023 cl->fn = fn;
47024 cl->wq = wq;
47025diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
47026index 48b5890..b0af0ca 100644
47027--- a/drivers/md/bitmap.c
47028+++ b/drivers/md/bitmap.c
47029@@ -1933,7 +1933,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
47030 chunk_kb ? "KB" : "B");
47031 if (bitmap->storage.file) {
47032 seq_printf(seq, ", file: ");
47033- seq_file_path(seq, bitmap->storage.file, " \t\n");
47034+ seq_file_path(seq, bitmap->storage.file, " \t\n\\");
47035 }
47036
47037 seq_printf(seq, "\n");
47038diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
47039index 720ceeb..030f1d4 100644
47040--- a/drivers/md/dm-ioctl.c
47041+++ b/drivers/md/dm-ioctl.c
47042@@ -1773,7 +1773,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
47043 cmd == DM_LIST_VERSIONS_CMD)
47044 return 0;
47045
47046- if ((cmd == DM_DEV_CREATE_CMD)) {
47047+ if (cmd == DM_DEV_CREATE_CMD) {
47048 if (!*param->name) {
47049 DMWARN("name not supplied when creating device");
47050 return -EINVAL;
47051diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
47052index d83696b..44f22f7 100644
47053--- a/drivers/md/dm-raid1.c
47054+++ b/drivers/md/dm-raid1.c
47055@@ -42,7 +42,7 @@ enum dm_raid1_error {
47056
47057 struct mirror {
47058 struct mirror_set *ms;
47059- atomic_t error_count;
47060+ atomic_unchecked_t error_count;
47061 unsigned long error_type;
47062 struct dm_dev *dev;
47063 sector_t offset;
47064@@ -188,7 +188,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
47065 struct mirror *m;
47066
47067 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
47068- if (!atomic_read(&m->error_count))
47069+ if (!atomic_read_unchecked(&m->error_count))
47070 return m;
47071
47072 return NULL;
47073@@ -220,7 +220,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
47074 * simple way to tell if a device has encountered
47075 * errors.
47076 */
47077- atomic_inc(&m->error_count);
47078+ atomic_inc_unchecked(&m->error_count);
47079
47080 if (test_and_set_bit(error_type, &m->error_type))
47081 return;
47082@@ -378,7 +378,7 @@ static void reset_ms_flags(struct mirror_set *ms)
47083
47084 ms->leg_failure = 0;
47085 for (m = 0; m < ms->nr_mirrors; m++) {
47086- atomic_set(&(ms->mirror[m].error_count), 0);
47087+ atomic_set_unchecked(&(ms->mirror[m].error_count), 0);
47088 ms->mirror[m].error_type = 0;
47089 }
47090 }
47091@@ -423,7 +423,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
47092 struct mirror *m = get_default_mirror(ms);
47093
47094 do {
47095- if (likely(!atomic_read(&m->error_count)))
47096+ if (likely(!atomic_read_unchecked(&m->error_count)))
47097 return m;
47098
47099 if (m-- == ms->mirror)
47100@@ -437,7 +437,7 @@ static int default_ok(struct mirror *m)
47101 {
47102 struct mirror *default_mirror = get_default_mirror(m->ms);
47103
47104- return !atomic_read(&default_mirror->error_count);
47105+ return !atomic_read_unchecked(&default_mirror->error_count);
47106 }
47107
47108 static int mirror_available(struct mirror_set *ms, struct bio *bio)
47109@@ -574,7 +574,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
47110 */
47111 if (likely(region_in_sync(ms, region, 1)))
47112 m = choose_mirror(ms, bio->bi_iter.bi_sector);
47113- else if (m && atomic_read(&m->error_count))
47114+ else if (m && atomic_read_unchecked(&m->error_count))
47115 m = NULL;
47116
47117 if (likely(m))
47118@@ -956,7 +956,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
47119 }
47120
47121 ms->mirror[mirror].ms = ms;
47122- atomic_set(&(ms->mirror[mirror].error_count), 0);
47123+ atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
47124 ms->mirror[mirror].error_type = 0;
47125 ms->mirror[mirror].offset = offset;
47126
47127@@ -1380,7 +1380,7 @@ static void mirror_resume(struct dm_target *ti)
47128 */
47129 static char device_status_char(struct mirror *m)
47130 {
47131- if (!atomic_read(&(m->error_count)))
47132+ if (!atomic_read_unchecked(&(m->error_count)))
47133 return 'A';
47134
47135 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
47136diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
47137index 8289804..12db118 100644
47138--- a/drivers/md/dm-stats.c
47139+++ b/drivers/md/dm-stats.c
47140@@ -435,7 +435,7 @@ do_sync_free:
47141 synchronize_rcu_expedited();
47142 dm_stat_free(&s->rcu_head);
47143 } else {
47144- ACCESS_ONCE(dm_stat_need_rcu_barrier) = 1;
47145+ ACCESS_ONCE_RW(dm_stat_need_rcu_barrier) = 1;
47146 call_rcu(&s->rcu_head, dm_stat_free);
47147 }
47148 return 0;
47149@@ -648,8 +648,8 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
47150 ((bi_rw & (REQ_WRITE | REQ_DISCARD)) ==
47151 (ACCESS_ONCE(last->last_rw) & (REQ_WRITE | REQ_DISCARD)))
47152 ));
47153- ACCESS_ONCE(last->last_sector) = end_sector;
47154- ACCESS_ONCE(last->last_rw) = bi_rw;
47155+ ACCESS_ONCE_RW(last->last_sector) = end_sector;
47156+ ACCESS_ONCE_RW(last->last_rw) = bi_rw;
47157 }
47158
47159 rcu_read_lock();
47160diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
47161index a672a15..dc85e99 100644
47162--- a/drivers/md/dm-stripe.c
47163+++ b/drivers/md/dm-stripe.c
47164@@ -21,7 +21,7 @@ struct stripe {
47165 struct dm_dev *dev;
47166 sector_t physical_start;
47167
47168- atomic_t error_count;
47169+ atomic_unchecked_t error_count;
47170 };
47171
47172 struct stripe_c {
47173@@ -188,7 +188,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
47174 kfree(sc);
47175 return r;
47176 }
47177- atomic_set(&(sc->stripe[i].error_count), 0);
47178+ atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
47179 }
47180
47181 ti->private = sc;
47182@@ -332,7 +332,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
47183 DMEMIT("%d ", sc->stripes);
47184 for (i = 0; i < sc->stripes; i++) {
47185 DMEMIT("%s ", sc->stripe[i].dev->name);
47186- buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
47187+ buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
47188 'D' : 'A';
47189 }
47190 buffer[i] = '\0';
47191@@ -377,8 +377,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
47192 */
47193 for (i = 0; i < sc->stripes; i++)
47194 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
47195- atomic_inc(&(sc->stripe[i].error_count));
47196- if (atomic_read(&(sc->stripe[i].error_count)) <
47197+ atomic_inc_unchecked(&(sc->stripe[i].error_count));
47198+ if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
47199 DM_IO_ERROR_THRESHOLD)
47200 schedule_work(&sc->trigger_event);
47201 }
47202diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
47203index 16ba55a..31af906 100644
47204--- a/drivers/md/dm-table.c
47205+++ b/drivers/md/dm-table.c
47206@@ -305,7 +305,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
47207 if (!dev_size)
47208 return 0;
47209
47210- if ((start >= dev_size) || (start + len > dev_size)) {
47211+ if ((start >= dev_size) || (len > dev_size - start)) {
47212 DMWARN("%s: %s too small for target: "
47213 "start=%llu, len=%llu, dev_size=%llu",
47214 dm_device_name(ti->table->md), bdevname(bdev, b),
47215diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
47216index 6ba47cf..a870ba2 100644
47217--- a/drivers/md/dm-thin-metadata.c
47218+++ b/drivers/md/dm-thin-metadata.c
47219@@ -403,7 +403,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
47220 {
47221 pmd->info.tm = pmd->tm;
47222 pmd->info.levels = 2;
47223- pmd->info.value_type.context = pmd->data_sm;
47224+ pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
47225 pmd->info.value_type.size = sizeof(__le64);
47226 pmd->info.value_type.inc = data_block_inc;
47227 pmd->info.value_type.dec = data_block_dec;
47228@@ -422,7 +422,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
47229
47230 pmd->bl_info.tm = pmd->tm;
47231 pmd->bl_info.levels = 1;
47232- pmd->bl_info.value_type.context = pmd->data_sm;
47233+ pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
47234 pmd->bl_info.value_type.size = sizeof(__le64);
47235 pmd->bl_info.value_type.inc = data_block_inc;
47236 pmd->bl_info.value_type.dec = data_block_dec;
47237diff --git a/drivers/md/dm.c b/drivers/md/dm.c
47238index 3e32f4e..01e0a7f 100644
47239--- a/drivers/md/dm.c
47240+++ b/drivers/md/dm.c
47241@@ -194,9 +194,9 @@ struct mapped_device {
47242 /*
47243 * Event handling.
47244 */
47245- atomic_t event_nr;
47246+ atomic_unchecked_t event_nr;
47247 wait_queue_head_t eventq;
47248- atomic_t uevent_seq;
47249+ atomic_unchecked_t uevent_seq;
47250 struct list_head uevent_list;
47251 spinlock_t uevent_lock; /* Protect access to uevent_list */
47252
47253@@ -2339,8 +2339,8 @@ static struct mapped_device *alloc_dev(int minor)
47254 spin_lock_init(&md->deferred_lock);
47255 atomic_set(&md->holders, 1);
47256 atomic_set(&md->open_count, 0);
47257- atomic_set(&md->event_nr, 0);
47258- atomic_set(&md->uevent_seq, 0);
47259+ atomic_set_unchecked(&md->event_nr, 0);
47260+ atomic_set_unchecked(&md->uevent_seq, 0);
47261 INIT_LIST_HEAD(&md->uevent_list);
47262 INIT_LIST_HEAD(&md->table_devices);
47263 spin_lock_init(&md->uevent_lock);
47264@@ -2481,7 +2481,7 @@ static void event_callback(void *context)
47265
47266 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
47267
47268- atomic_inc(&md->event_nr);
47269+ atomic_inc_unchecked(&md->event_nr);
47270 wake_up(&md->eventq);
47271 }
47272
47273@@ -3479,18 +3479,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
47274
47275 uint32_t dm_next_uevent_seq(struct mapped_device *md)
47276 {
47277- return atomic_add_return(1, &md->uevent_seq);
47278+ return atomic_add_return_unchecked(1, &md->uevent_seq);
47279 }
47280
47281 uint32_t dm_get_event_nr(struct mapped_device *md)
47282 {
47283- return atomic_read(&md->event_nr);
47284+ return atomic_read_unchecked(&md->event_nr);
47285 }
47286
47287 int dm_wait_event(struct mapped_device *md, int event_nr)
47288 {
47289 return wait_event_interruptible(md->eventq,
47290- (event_nr != atomic_read(&md->event_nr)));
47291+ (event_nr != atomic_read_unchecked(&md->event_nr)));
47292 }
47293
47294 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
47295diff --git a/drivers/md/md.c b/drivers/md/md.c
47296index e25f00f..12caa60 100644
47297--- a/drivers/md/md.c
47298+++ b/drivers/md/md.c
47299@@ -197,10 +197,10 @@ EXPORT_SYMBOL_GPL(bio_clone_mddev);
47300 * start build, activate spare
47301 */
47302 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
47303-static atomic_t md_event_count;
47304+static atomic_unchecked_t md_event_count;
47305 void md_new_event(struct mddev *mddev)
47306 {
47307- atomic_inc(&md_event_count);
47308+ atomic_inc_unchecked(&md_event_count);
47309 wake_up(&md_event_waiters);
47310 }
47311 EXPORT_SYMBOL_GPL(md_new_event);
47312@@ -210,7 +210,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
47313 */
47314 static void md_new_event_inintr(struct mddev *mddev)
47315 {
47316- atomic_inc(&md_event_count);
47317+ atomic_inc_unchecked(&md_event_count);
47318 wake_up(&md_event_waiters);
47319 }
47320
47321@@ -1449,7 +1449,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
47322 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
47323 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
47324 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
47325- atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
47326+ atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
47327
47328 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
47329 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
47330@@ -1700,7 +1700,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
47331 else
47332 sb->resync_offset = cpu_to_le64(0);
47333
47334- sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
47335+ sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
47336
47337 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
47338 sb->size = cpu_to_le64(mddev->dev_sectors);
47339@@ -2622,7 +2622,7 @@ __ATTR_PREALLOC(state, S_IRUGO|S_IWUSR, state_show, state_store);
47340 static ssize_t
47341 errors_show(struct md_rdev *rdev, char *page)
47342 {
47343- return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
47344+ return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
47345 }
47346
47347 static ssize_t
47348@@ -2634,7 +2634,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
47349 rv = kstrtouint(buf, 10, &n);
47350 if (rv < 0)
47351 return rv;
47352- atomic_set(&rdev->corrected_errors, n);
47353+ atomic_set_unchecked(&rdev->corrected_errors, n);
47354 return len;
47355 }
47356 static struct rdev_sysfs_entry rdev_errors =
47357@@ -3071,8 +3071,8 @@ int md_rdev_init(struct md_rdev *rdev)
47358 rdev->sb_loaded = 0;
47359 rdev->bb_page = NULL;
47360 atomic_set(&rdev->nr_pending, 0);
47361- atomic_set(&rdev->read_errors, 0);
47362- atomic_set(&rdev->corrected_errors, 0);
47363+ atomic_set_unchecked(&rdev->read_errors, 0);
47364+ atomic_set_unchecked(&rdev->corrected_errors, 0);
47365
47366 INIT_LIST_HEAD(&rdev->same_set);
47367 init_waitqueue_head(&rdev->blocked_wait);
47368@@ -7256,7 +7256,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
47369
47370 spin_unlock(&pers_lock);
47371 seq_printf(seq, "\n");
47372- seq->poll_event = atomic_read(&md_event_count);
47373+ seq->poll_event = atomic_read_unchecked(&md_event_count);
47374 return 0;
47375 }
47376 if (v == (void*)2) {
47377@@ -7359,7 +7359,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
47378 return error;
47379
47380 seq = file->private_data;
47381- seq->poll_event = atomic_read(&md_event_count);
47382+ seq->poll_event = atomic_read_unchecked(&md_event_count);
47383 return error;
47384 }
47385
47386@@ -7376,7 +7376,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
47387 /* always allow read */
47388 mask = POLLIN | POLLRDNORM;
47389
47390- if (seq->poll_event != atomic_read(&md_event_count))
47391+ if (seq->poll_event != atomic_read_unchecked(&md_event_count))
47392 mask |= POLLERR | POLLPRI;
47393 return mask;
47394 }
47395@@ -7472,7 +7472,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
47396 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
47397 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
47398 (int)part_stat_read(&disk->part0, sectors[1]) -
47399- atomic_read(&disk->sync_io);
47400+ atomic_read_unchecked(&disk->sync_io);
47401 /* sync IO will cause sync_io to increase before the disk_stats
47402 * as sync_io is counted when a request starts, and
47403 * disk_stats is counted when it completes.
47404diff --git a/drivers/md/md.h b/drivers/md/md.h
47405index 7da6e9c..f0c1f10 100644
47406--- a/drivers/md/md.h
47407+++ b/drivers/md/md.h
47408@@ -96,13 +96,13 @@ struct md_rdev {
47409 * only maintained for arrays that
47410 * support hot removal
47411 */
47412- atomic_t read_errors; /* number of consecutive read errors that
47413+ atomic_unchecked_t read_errors; /* number of consecutive read errors that
47414 * we have tried to ignore.
47415 */
47416 struct timespec last_read_error; /* monotonic time since our
47417 * last read error
47418 */
47419- atomic_t corrected_errors; /* number of corrected read errors,
47420+ atomic_unchecked_t corrected_errors; /* number of corrected read errors,
47421 * for reporting to userspace and storing
47422 * in superblock.
47423 */
47424@@ -487,7 +487,7 @@ extern void mddev_unlock(struct mddev *mddev);
47425
47426 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
47427 {
47428- atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
47429+ atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
47430 }
47431
47432 struct md_personality
47433diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
47434index 5309129..7fb096e 100644
47435--- a/drivers/md/persistent-data/dm-space-map-metadata.c
47436+++ b/drivers/md/persistent-data/dm-space-map-metadata.c
47437@@ -691,7 +691,7 @@ static int sm_metadata_extend(struct dm_space_map *sm, dm_block_t extra_blocks)
47438 * Flick into a mode where all blocks get allocated in the new area.
47439 */
47440 smm->begin = old_len;
47441- memcpy(sm, &bootstrap_ops, sizeof(*sm));
47442+ memcpy((void *)sm, &bootstrap_ops, sizeof(*sm));
47443
47444 /*
47445 * Extend.
47446@@ -728,7 +728,7 @@ out:
47447 /*
47448 * Switch back to normal behaviour.
47449 */
47450- memcpy(sm, &ops, sizeof(*sm));
47451+ memcpy((void *)sm, &ops, sizeof(*sm));
47452 return r;
47453 }
47454
47455diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
47456index 3e6d115..ffecdeb 100644
47457--- a/drivers/md/persistent-data/dm-space-map.h
47458+++ b/drivers/md/persistent-data/dm-space-map.h
47459@@ -71,6 +71,7 @@ struct dm_space_map {
47460 dm_sm_threshold_fn fn,
47461 void *context);
47462 };
47463+typedef struct dm_space_map __no_const dm_space_map_no_const;
47464
47465 /*----------------------------------------------------------------*/
47466
47467diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
47468index 967a4ed..002d339 100644
47469--- a/drivers/md/raid1.c
47470+++ b/drivers/md/raid1.c
47471@@ -1937,7 +1937,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
47472 if (r1_sync_page_io(rdev, sect, s,
47473 bio->bi_io_vec[idx].bv_page,
47474 READ) != 0)
47475- atomic_add(s, &rdev->corrected_errors);
47476+ atomic_add_unchecked(s, &rdev->corrected_errors);
47477 }
47478 sectors -= s;
47479 sect += s;
47480@@ -2170,7 +2170,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
47481 !test_bit(Faulty, &rdev->flags)) {
47482 if (r1_sync_page_io(rdev, sect, s,
47483 conf->tmppage, READ)) {
47484- atomic_add(s, &rdev->corrected_errors);
47485+ atomic_add_unchecked(s, &rdev->corrected_errors);
47486 printk(KERN_INFO
47487 "md/raid1:%s: read error corrected "
47488 "(%d sectors at %llu on %s)\n",
47489diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
47490index 38c58e1..89c3e0f 100644
47491--- a/drivers/md/raid10.c
47492+++ b/drivers/md/raid10.c
47493@@ -1934,7 +1934,7 @@ static void end_sync_read(struct bio *bio, int error)
47494 /* The write handler will notice the lack of
47495 * R10BIO_Uptodate and record any errors etc
47496 */
47497- atomic_add(r10_bio->sectors,
47498+ atomic_add_unchecked(r10_bio->sectors,
47499 &conf->mirrors[d].rdev->corrected_errors);
47500
47501 /* for reconstruct, we always reschedule after a read.
47502@@ -2281,7 +2281,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
47503 {
47504 struct timespec cur_time_mon;
47505 unsigned long hours_since_last;
47506- unsigned int read_errors = atomic_read(&rdev->read_errors);
47507+ unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
47508
47509 ktime_get_ts(&cur_time_mon);
47510
47511@@ -2303,9 +2303,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
47512 * overflowing the shift of read_errors by hours_since_last.
47513 */
47514 if (hours_since_last >= 8 * sizeof(read_errors))
47515- atomic_set(&rdev->read_errors, 0);
47516+ atomic_set_unchecked(&rdev->read_errors, 0);
47517 else
47518- atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
47519+ atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
47520 }
47521
47522 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
47523@@ -2359,8 +2359,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
47524 return;
47525
47526 check_decay_read_errors(mddev, rdev);
47527- atomic_inc(&rdev->read_errors);
47528- if (atomic_read(&rdev->read_errors) > max_read_errors) {
47529+ atomic_inc_unchecked(&rdev->read_errors);
47530+ if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
47531 char b[BDEVNAME_SIZE];
47532 bdevname(rdev->bdev, b);
47533
47534@@ -2368,7 +2368,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
47535 "md/raid10:%s: %s: Raid device exceeded "
47536 "read_error threshold [cur %d:max %d]\n",
47537 mdname(mddev), b,
47538- atomic_read(&rdev->read_errors), max_read_errors);
47539+ atomic_read_unchecked(&rdev->read_errors), max_read_errors);
47540 printk(KERN_NOTICE
47541 "md/raid10:%s: %s: Failing raid device\n",
47542 mdname(mddev), b);
47543@@ -2523,7 +2523,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
47544 sect +
47545 choose_data_offset(r10_bio, rdev)),
47546 bdevname(rdev->bdev, b));
47547- atomic_add(s, &rdev->corrected_errors);
47548+ atomic_add_unchecked(s, &rdev->corrected_errors);
47549 }
47550
47551 rdev_dec_pending(rdev, mddev);
47552diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
47553index f757023..f958632 100644
47554--- a/drivers/md/raid5.c
47555+++ b/drivers/md/raid5.c
47556@@ -1119,23 +1119,23 @@ async_copy_data(int frombio, struct bio *bio, struct page **page,
47557 struct bio_vec bvl;
47558 struct bvec_iter iter;
47559 struct page *bio_page;
47560- int page_offset;
47561+ s64 page_offset;
47562 struct async_submit_ctl submit;
47563 enum async_tx_flags flags = 0;
47564
47565 if (bio->bi_iter.bi_sector >= sector)
47566- page_offset = (signed)(bio->bi_iter.bi_sector - sector) * 512;
47567+ page_offset = (s64)(bio->bi_iter.bi_sector - sector) * 512;
47568 else
47569- page_offset = (signed)(sector - bio->bi_iter.bi_sector) * -512;
47570+ page_offset = (s64)(sector - bio->bi_iter.bi_sector) * -512;
47571
47572 if (frombio)
47573 flags |= ASYNC_TX_FENCE;
47574 init_async_submit(&submit, flags, tx, NULL, NULL, NULL);
47575
47576 bio_for_each_segment(bvl, bio, iter) {
47577- int len = bvl.bv_len;
47578- int clen;
47579- int b_offset = 0;
47580+ s64 len = bvl.bv_len;
47581+ s64 clen;
47582+ s64 b_offset = 0;
47583
47584 if (page_offset < 0) {
47585 b_offset = -page_offset;
47586@@ -2028,6 +2028,10 @@ static int grow_one_stripe(struct r5conf *conf, gfp_t gfp)
47587 return 1;
47588 }
47589
47590+#ifdef CONFIG_GRKERNSEC_HIDESYM
47591+static atomic_unchecked_t raid5_cache_id = ATOMIC_INIT(0);
47592+#endif
47593+
47594 static int grow_stripes(struct r5conf *conf, int num)
47595 {
47596 struct kmem_cache *sc;
47597@@ -2038,7 +2042,11 @@ static int grow_stripes(struct r5conf *conf, int num)
47598 "raid%d-%s", conf->level, mdname(conf->mddev));
47599 else
47600 sprintf(conf->cache_name[0],
47601+#ifdef CONFIG_GRKERNSEC_HIDESYM
47602+ "raid%d-%08lx", conf->level, atomic_inc_return_unchecked(&raid5_cache_id));
47603+#else
47604 "raid%d-%p", conf->level, conf->mddev);
47605+#endif
47606 sprintf(conf->cache_name[1], "%s-alt", conf->cache_name[0]);
47607
47608 conf->active_name = 0;
47609@@ -2331,21 +2339,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
47610 mdname(conf->mddev), STRIPE_SECTORS,
47611 (unsigned long long)s,
47612 bdevname(rdev->bdev, b));
47613- atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
47614+ atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
47615 clear_bit(R5_ReadError, &sh->dev[i].flags);
47616 clear_bit(R5_ReWrite, &sh->dev[i].flags);
47617 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
47618 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
47619
47620- if (atomic_read(&rdev->read_errors))
47621- atomic_set(&rdev->read_errors, 0);
47622+ if (atomic_read_unchecked(&rdev->read_errors))
47623+ atomic_set_unchecked(&rdev->read_errors, 0);
47624 } else {
47625 const char *bdn = bdevname(rdev->bdev, b);
47626 int retry = 0;
47627 int set_bad = 0;
47628
47629 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
47630- atomic_inc(&rdev->read_errors);
47631+ atomic_inc_unchecked(&rdev->read_errors);
47632 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
47633 printk_ratelimited(
47634 KERN_WARNING
47635@@ -2373,7 +2381,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
47636 mdname(conf->mddev),
47637 (unsigned long long)s,
47638 bdn);
47639- } else if (atomic_read(&rdev->read_errors)
47640+ } else if (atomic_read_unchecked(&rdev->read_errors)
47641 > conf->max_nr_stripes)
47642 printk(KERN_WARNING
47643 "md/raid:%s: Too many read errors, failing device %s.\n",
47644diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
47645index 13bb57f..0ca21b2 100644
47646--- a/drivers/media/dvb-core/dvbdev.c
47647+++ b/drivers/media/dvb-core/dvbdev.c
47648@@ -272,7 +272,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
47649 const struct dvb_device *template, void *priv, int type)
47650 {
47651 struct dvb_device *dvbdev;
47652- struct file_operations *dvbdevfops;
47653+ file_operations_no_const *dvbdevfops;
47654 struct device *clsdev;
47655 int minor;
47656 int id;
47657diff --git a/drivers/media/dvb-frontends/af9033.h b/drivers/media/dvb-frontends/af9033.h
47658index 6ad22b6..6e90e2a 100644
47659--- a/drivers/media/dvb-frontends/af9033.h
47660+++ b/drivers/media/dvb-frontends/af9033.h
47661@@ -96,6 +96,6 @@ struct af9033_ops {
47662 int (*pid_filter_ctrl)(struct dvb_frontend *fe, int onoff);
47663 int (*pid_filter)(struct dvb_frontend *fe, int index, u16 pid,
47664 int onoff);
47665-};
47666+} __no_const;
47667
47668 #endif /* AF9033_H */
47669diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
47670index 6ae9899..07d8543 100644
47671--- a/drivers/media/dvb-frontends/dib3000.h
47672+++ b/drivers/media/dvb-frontends/dib3000.h
47673@@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
47674 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
47675 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
47676 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
47677-};
47678+} __no_const;
47679
47680 #if IS_REACHABLE(CONFIG_DVB_DIB3000MB)
47681 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
47682diff --git a/drivers/media/dvb-frontends/dib7000p.h b/drivers/media/dvb-frontends/dib7000p.h
47683index baa2789..c8de7fe 100644
47684--- a/drivers/media/dvb-frontends/dib7000p.h
47685+++ b/drivers/media/dvb-frontends/dib7000p.h
47686@@ -64,7 +64,7 @@ struct dib7000p_ops {
47687 int (*get_adc_power)(struct dvb_frontend *fe);
47688 int (*slave_reset)(struct dvb_frontend *fe);
47689 struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib7000p_config *cfg);
47690-};
47691+} __no_const;
47692
47693 #if IS_REACHABLE(CONFIG_DVB_DIB7000P)
47694 void *dib7000p_attach(struct dib7000p_ops *ops);
47695diff --git a/drivers/media/dvb-frontends/dib8000.h b/drivers/media/dvb-frontends/dib8000.h
47696index 2b8b4b1..8cef451 100644
47697--- a/drivers/media/dvb-frontends/dib8000.h
47698+++ b/drivers/media/dvb-frontends/dib8000.h
47699@@ -61,7 +61,7 @@ struct dib8000_ops {
47700 int (*pid_filter_ctrl)(struct dvb_frontend *fe, u8 onoff);
47701 int (*pid_filter)(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff);
47702 struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib8000_config *cfg);
47703-};
47704+} __no_const;
47705
47706 #if IS_REACHABLE(CONFIG_DVB_DIB8000)
47707 void *dib8000_attach(struct dib8000_ops *ops);
47708diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
47709index 400e5ca..f69f748 100644
47710--- a/drivers/media/pci/cx88/cx88-video.c
47711+++ b/drivers/media/pci/cx88/cx88-video.c
47712@@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
47713
47714 /* ------------------------------------------------------------------ */
47715
47716-static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47717-static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47718-static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47719+static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47720+static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47721+static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47722
47723 module_param_array(video_nr, int, NULL, 0444);
47724 module_param_array(vbi_nr, int, NULL, 0444);
47725diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
47726index 8616fa8..e16eeaf 100644
47727--- a/drivers/media/pci/ivtv/ivtv-driver.c
47728+++ b/drivers/media/pci/ivtv/ivtv-driver.c
47729@@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
47730 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
47731
47732 /* ivtv instance counter */
47733-static atomic_t ivtv_instance = ATOMIC_INIT(0);
47734+static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
47735
47736 /* Parameter declarations */
47737 static int cardtype[IVTV_MAX_CARDS];
47738diff --git a/drivers/media/pci/solo6x10/solo6x10-core.c b/drivers/media/pci/solo6x10/solo6x10-core.c
47739index 570d119..ed25830 100644
47740--- a/drivers/media/pci/solo6x10/solo6x10-core.c
47741+++ b/drivers/media/pci/solo6x10/solo6x10-core.c
47742@@ -424,7 +424,7 @@ static void solo_device_release(struct device *dev)
47743
47744 static int solo_sysfs_init(struct solo_dev *solo_dev)
47745 {
47746- struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47747+ bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47748 struct device *dev = &solo_dev->dev;
47749 const char *driver;
47750 int i;
47751diff --git a/drivers/media/pci/solo6x10/solo6x10-g723.c b/drivers/media/pci/solo6x10/solo6x10-g723.c
47752index 7ddc767..1c24361 100644
47753--- a/drivers/media/pci/solo6x10/solo6x10-g723.c
47754+++ b/drivers/media/pci/solo6x10/solo6x10-g723.c
47755@@ -351,7 +351,7 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
47756
47757 int solo_g723_init(struct solo_dev *solo_dev)
47758 {
47759- static struct snd_device_ops ops = { NULL };
47760+ static struct snd_device_ops ops = { };
47761 struct snd_card *card;
47762 struct snd_kcontrol_new kctl;
47763 char name[32];
47764diff --git a/drivers/media/pci/solo6x10/solo6x10-p2m.c b/drivers/media/pci/solo6x10/solo6x10-p2m.c
47765index 8c84846..27b4f83 100644
47766--- a/drivers/media/pci/solo6x10/solo6x10-p2m.c
47767+++ b/drivers/media/pci/solo6x10/solo6x10-p2m.c
47768@@ -73,7 +73,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47769
47770 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47771 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47772- p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47773+ p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47774 if (p2m_id < 0)
47775 p2m_id = -p2m_id;
47776 }
47777diff --git a/drivers/media/pci/solo6x10/solo6x10.h b/drivers/media/pci/solo6x10/solo6x10.h
47778index 1ca54b0..7d7cb9a 100644
47779--- a/drivers/media/pci/solo6x10/solo6x10.h
47780+++ b/drivers/media/pci/solo6x10/solo6x10.h
47781@@ -218,7 +218,7 @@ struct solo_dev {
47782
47783 /* P2M DMA Engine */
47784 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47785- atomic_t p2m_count;
47786+ atomic_unchecked_t p2m_count;
47787 int p2m_jiffies;
47788 unsigned int p2m_timeouts;
47789
47790diff --git a/drivers/media/pci/tw68/tw68-core.c b/drivers/media/pci/tw68/tw68-core.c
47791index c135165..dc69499 100644
47792--- a/drivers/media/pci/tw68/tw68-core.c
47793+++ b/drivers/media/pci/tw68/tw68-core.c
47794@@ -60,7 +60,7 @@ static unsigned int card[] = {[0 ... (TW68_MAXBOARDS - 1)] = UNSET };
47795 module_param_array(card, int, NULL, 0444);
47796 MODULE_PARM_DESC(card, "card type");
47797
47798-static atomic_t tw68_instance = ATOMIC_INIT(0);
47799+static atomic_unchecked_t tw68_instance = ATOMIC_INIT(0);
47800
47801 /* ------------------------------------------------------------------ */
47802
47803diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
47804index f09c5f1..38f6d65 100644
47805--- a/drivers/media/platform/omap/omap_vout.c
47806+++ b/drivers/media/platform/omap/omap_vout.c
47807@@ -63,7 +63,6 @@ enum omap_vout_channels {
47808 OMAP_VIDEO2,
47809 };
47810
47811-static struct videobuf_queue_ops video_vbq_ops;
47812 /* Variables configurable through module params*/
47813 static u32 video1_numbuffers = 3;
47814 static u32 video2_numbuffers = 3;
47815@@ -1008,6 +1007,12 @@ static int omap_vout_open(struct file *file)
47816 {
47817 struct videobuf_queue *q;
47818 struct omap_vout_device *vout = NULL;
47819+ static struct videobuf_queue_ops video_vbq_ops = {
47820+ .buf_setup = omap_vout_buffer_setup,
47821+ .buf_prepare = omap_vout_buffer_prepare,
47822+ .buf_release = omap_vout_buffer_release,
47823+ .buf_queue = omap_vout_buffer_queue,
47824+ };
47825
47826 vout = video_drvdata(file);
47827 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
47828@@ -1025,10 +1030,6 @@ static int omap_vout_open(struct file *file)
47829 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
47830
47831 q = &vout->vbq;
47832- video_vbq_ops.buf_setup = omap_vout_buffer_setup;
47833- video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
47834- video_vbq_ops.buf_release = omap_vout_buffer_release;
47835- video_vbq_ops.buf_queue = omap_vout_buffer_queue;
47836 spin_lock_init(&vout->vbq_lock);
47837
47838 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
47839diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
47840index fb2acc5..a2fcbdc4 100644
47841--- a/drivers/media/platform/s5p-tv/mixer.h
47842+++ b/drivers/media/platform/s5p-tv/mixer.h
47843@@ -156,7 +156,7 @@ struct mxr_layer {
47844 /** layer index (unique identifier) */
47845 int idx;
47846 /** callbacks for layer methods */
47847- struct mxr_layer_ops ops;
47848+ struct mxr_layer_ops *ops;
47849 /** format array */
47850 const struct mxr_format **fmt_array;
47851 /** size of format array */
47852diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
47853index 74344c7..a39e70e 100644
47854--- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
47855+++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
47856@@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
47857 {
47858 struct mxr_layer *layer;
47859 int ret;
47860- struct mxr_layer_ops ops = {
47861+ static struct mxr_layer_ops ops = {
47862 .release = mxr_graph_layer_release,
47863 .buffer_set = mxr_graph_buffer_set,
47864 .stream_set = mxr_graph_stream_set,
47865diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
47866index b713403..53cb5ad 100644
47867--- a/drivers/media/platform/s5p-tv/mixer_reg.c
47868+++ b/drivers/media/platform/s5p-tv/mixer_reg.c
47869@@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
47870 layer->update_buf = next;
47871 }
47872
47873- layer->ops.buffer_set(layer, layer->update_buf);
47874+ layer->ops->buffer_set(layer, layer->update_buf);
47875
47876 if (done && done != layer->shadow_buf)
47877 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
47878diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
47879index 751f3b6..d829203 100644
47880--- a/drivers/media/platform/s5p-tv/mixer_video.c
47881+++ b/drivers/media/platform/s5p-tv/mixer_video.c
47882@@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
47883 layer->geo.src.height = layer->geo.src.full_height;
47884
47885 mxr_geometry_dump(mdev, &layer->geo);
47886- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
47887+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
47888 mxr_geometry_dump(mdev, &layer->geo);
47889 }
47890
47891@@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
47892 layer->geo.dst.full_width = mbus_fmt.width;
47893 layer->geo.dst.full_height = mbus_fmt.height;
47894 layer->geo.dst.field = mbus_fmt.field;
47895- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
47896+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
47897
47898 mxr_geometry_dump(mdev, &layer->geo);
47899 }
47900@@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
47901 /* set source size to highest accepted value */
47902 geo->src.full_width = max(geo->dst.full_width, pix->width);
47903 geo->src.full_height = max(geo->dst.full_height, pix->height);
47904- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
47905+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
47906 mxr_geometry_dump(mdev, &layer->geo);
47907 /* set cropping to total visible screen */
47908 geo->src.width = pix->width;
47909@@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
47910 geo->src.x_offset = 0;
47911 geo->src.y_offset = 0;
47912 /* assure consistency of geometry */
47913- layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
47914+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
47915 mxr_geometry_dump(mdev, &layer->geo);
47916 /* set full size to lowest possible value */
47917 geo->src.full_width = 0;
47918 geo->src.full_height = 0;
47919- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
47920+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
47921 mxr_geometry_dump(mdev, &layer->geo);
47922
47923 /* returning results */
47924@@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
47925 target->width = s->r.width;
47926 target->height = s->r.height;
47927
47928- layer->ops.fix_geometry(layer, stage, s->flags);
47929+ layer->ops->fix_geometry(layer, stage, s->flags);
47930
47931 /* retrieve update selection rectangle */
47932 res.left = target->x_offset;
47933@@ -938,13 +938,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
47934 mxr_output_get(mdev);
47935
47936 mxr_layer_update_output(layer);
47937- layer->ops.format_set(layer);
47938+ layer->ops->format_set(layer);
47939 /* enabling layer in hardware */
47940 spin_lock_irqsave(&layer->enq_slock, flags);
47941 layer->state = MXR_LAYER_STREAMING;
47942 spin_unlock_irqrestore(&layer->enq_slock, flags);
47943
47944- layer->ops.stream_set(layer, MXR_ENABLE);
47945+ layer->ops->stream_set(layer, MXR_ENABLE);
47946 mxr_streamer_get(mdev);
47947
47948 return 0;
47949@@ -1014,7 +1014,7 @@ static void stop_streaming(struct vb2_queue *vq)
47950 spin_unlock_irqrestore(&layer->enq_slock, flags);
47951
47952 /* disabling layer in hardware */
47953- layer->ops.stream_set(layer, MXR_DISABLE);
47954+ layer->ops->stream_set(layer, MXR_DISABLE);
47955 /* remove one streamer */
47956 mxr_streamer_put(mdev);
47957 /* allow changes in output configuration */
47958@@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
47959
47960 void mxr_layer_release(struct mxr_layer *layer)
47961 {
47962- if (layer->ops.release)
47963- layer->ops.release(layer);
47964+ if (layer->ops->release)
47965+ layer->ops->release(layer);
47966 }
47967
47968 void mxr_base_layer_release(struct mxr_layer *layer)
47969@@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
47970
47971 layer->mdev = mdev;
47972 layer->idx = idx;
47973- layer->ops = *ops;
47974+ layer->ops = ops;
47975
47976 spin_lock_init(&layer->enq_slock);
47977 INIT_LIST_HEAD(&layer->enq_list);
47978diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
47979index c9388c4..ce71ece 100644
47980--- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
47981+++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
47982@@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
47983 {
47984 struct mxr_layer *layer;
47985 int ret;
47986- struct mxr_layer_ops ops = {
47987+ static struct mxr_layer_ops ops = {
47988 .release = mxr_vp_layer_release,
47989 .buffer_set = mxr_vp_buffer_set,
47990 .stream_set = mxr_vp_stream_set,
47991diff --git a/drivers/media/platform/vivid/vivid-osd.c b/drivers/media/platform/vivid/vivid-osd.c
47992index 084d346..e15eef6 100644
47993--- a/drivers/media/platform/vivid/vivid-osd.c
47994+++ b/drivers/media/platform/vivid/vivid-osd.c
47995@@ -85,6 +85,7 @@ static int vivid_fb_ioctl(struct fb_info *info, unsigned cmd, unsigned long arg)
47996 case FBIOGET_VBLANK: {
47997 struct fb_vblank vblank;
47998
47999+ memset(&vblank, 0, sizeof(vblank));
48000 vblank.flags = FB_VBLANK_HAVE_COUNT | FB_VBLANK_HAVE_VCOUNT |
48001 FB_VBLANK_HAVE_VSYNC;
48002 vblank.count = 0;
48003diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
48004index 82affae..42833ec 100644
48005--- a/drivers/media/radio/radio-cadet.c
48006+++ b/drivers/media/radio/radio-cadet.c
48007@@ -333,6 +333,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
48008 unsigned char readbuf[RDS_BUFFER];
48009 int i = 0;
48010
48011+ if (count > RDS_BUFFER)
48012+ return -EFAULT;
48013 mutex_lock(&dev->lock);
48014 if (dev->rdsstat == 0)
48015 cadet_start_rds(dev);
48016@@ -349,8 +351,9 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
48017 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
48018 mutex_unlock(&dev->lock);
48019
48020- if (i && copy_to_user(data, readbuf, i))
48021- return -EFAULT;
48022+ if (i > sizeof(readbuf) || (i && copy_to_user(data, readbuf, i)))
48023+ i = -EFAULT;
48024+
48025 return i;
48026 }
48027
48028diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
48029index 5236035..c622c74 100644
48030--- a/drivers/media/radio/radio-maxiradio.c
48031+++ b/drivers/media/radio/radio-maxiradio.c
48032@@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
48033 /* TEA5757 pin mappings */
48034 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
48035
48036-static atomic_t maxiradio_instance = ATOMIC_INIT(0);
48037+static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
48038
48039 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
48040 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
48041diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
48042index 050b3bb..79f62b9 100644
48043--- a/drivers/media/radio/radio-shark.c
48044+++ b/drivers/media/radio/radio-shark.c
48045@@ -79,7 +79,7 @@ struct shark_device {
48046 u32 last_val;
48047 };
48048
48049-static atomic_t shark_instance = ATOMIC_INIT(0);
48050+static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
48051
48052 static void shark_write_val(struct snd_tea575x *tea, u32 val)
48053 {
48054diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
48055index 8654e0d..0608a64 100644
48056--- a/drivers/media/radio/radio-shark2.c
48057+++ b/drivers/media/radio/radio-shark2.c
48058@@ -74,7 +74,7 @@ struct shark_device {
48059 u8 *transfer_buffer;
48060 };
48061
48062-static atomic_t shark_instance = ATOMIC_INIT(0);
48063+static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
48064
48065 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
48066 {
48067diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
48068index 9cbb8cd..2bf2ff3 100644
48069--- a/drivers/media/radio/radio-si476x.c
48070+++ b/drivers/media/radio/radio-si476x.c
48071@@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
48072 struct si476x_radio *radio;
48073 struct v4l2_ctrl *ctrl;
48074
48075- static atomic_t instance = ATOMIC_INIT(0);
48076+ static atomic_unchecked_t instance = ATOMIC_INIT(0);
48077
48078 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
48079 if (!radio)
48080diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
48081index 704397f..4d05977 100644
48082--- a/drivers/media/radio/wl128x/fmdrv_common.c
48083+++ b/drivers/media/radio/wl128x/fmdrv_common.c
48084@@ -71,7 +71,7 @@ module_param(default_rds_buf, uint, 0444);
48085 MODULE_PARM_DESC(rds_buf, "RDS buffer entries");
48086
48087 /* Radio Nr */
48088-static u32 radio_nr = -1;
48089+static int radio_nr = -1;
48090 module_param(radio_nr, int, 0444);
48091 MODULE_PARM_DESC(radio_nr, "Radio Nr");
48092
48093diff --git a/drivers/media/usb/dvb-usb/cinergyT2-core.c b/drivers/media/usb/dvb-usb/cinergyT2-core.c
48094index 9fd1527..8927230 100644
48095--- a/drivers/media/usb/dvb-usb/cinergyT2-core.c
48096+++ b/drivers/media/usb/dvb-usb/cinergyT2-core.c
48097@@ -50,29 +50,73 @@ static struct dvb_usb_device_properties cinergyt2_properties;
48098
48099 static int cinergyt2_streaming_ctrl(struct dvb_usb_adapter *adap, int enable)
48100 {
48101- char buf[] = { CINERGYT2_EP1_CONTROL_STREAM_TRANSFER, enable ? 1 : 0 };
48102- char result[64];
48103- return dvb_usb_generic_rw(adap->dev, buf, sizeof(buf), result,
48104- sizeof(result), 0);
48105+ char *buf;
48106+ char *result;
48107+ int retval;
48108+
48109+ buf = kmalloc(2, GFP_KERNEL);
48110+ if (buf == NULL)
48111+ return -ENOMEM;
48112+ result = kmalloc(64, GFP_KERNEL);
48113+ if (result == NULL) {
48114+ kfree(buf);
48115+ return -ENOMEM;
48116+ }
48117+
48118+ buf[0] = CINERGYT2_EP1_CONTROL_STREAM_TRANSFER;
48119+ buf[1] = enable ? 1 : 0;
48120+
48121+ retval = dvb_usb_generic_rw(adap->dev, buf, 2, result, 64, 0);
48122+
48123+ kfree(buf);
48124+ kfree(result);
48125+ return retval;
48126 }
48127
48128 static int cinergyt2_power_ctrl(struct dvb_usb_device *d, int enable)
48129 {
48130- char buf[] = { CINERGYT2_EP1_SLEEP_MODE, enable ? 0 : 1 };
48131- char state[3];
48132- return dvb_usb_generic_rw(d, buf, sizeof(buf), state, sizeof(state), 0);
48133+ char *buf;
48134+ char *state;
48135+ int retval;
48136+
48137+ buf = kmalloc(2, GFP_KERNEL);
48138+ if (buf == NULL)
48139+ return -ENOMEM;
48140+ state = kmalloc(3, GFP_KERNEL);
48141+ if (state == NULL) {
48142+ kfree(buf);
48143+ return -ENOMEM;
48144+ }
48145+
48146+ buf[0] = CINERGYT2_EP1_SLEEP_MODE;
48147+ buf[1] = enable ? 1 : 0;
48148+
48149+ retval = dvb_usb_generic_rw(d, buf, 2, state, 3, 0);
48150+
48151+ kfree(buf);
48152+ kfree(state);
48153+ return retval;
48154 }
48155
48156 static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
48157 {
48158- char query[] = { CINERGYT2_EP1_GET_FIRMWARE_VERSION };
48159- char state[3];
48160+ char *query;
48161+ char *state;
48162 int ret;
48163+ query = kmalloc(1, GFP_KERNEL);
48164+ if (query == NULL)
48165+ return -ENOMEM;
48166+ state = kmalloc(3, GFP_KERNEL);
48167+ if (state == NULL) {
48168+ kfree(query);
48169+ return -ENOMEM;
48170+ }
48171+
48172+ query[0] = CINERGYT2_EP1_GET_FIRMWARE_VERSION;
48173
48174 adap->fe_adap[0].fe = cinergyt2_fe_attach(adap->dev);
48175
48176- ret = dvb_usb_generic_rw(adap->dev, query, sizeof(query), state,
48177- sizeof(state), 0);
48178+ ret = dvb_usb_generic_rw(adap->dev, query, 1, state, 3, 0);
48179 if (ret < 0) {
48180 deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep "
48181 "state info\n");
48182@@ -80,7 +124,8 @@ static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
48183
48184 /* Copy this pointer as we are gonna need it in the release phase */
48185 cinergyt2_usb_device = adap->dev;
48186-
48187+ kfree(query);
48188+ kfree(state);
48189 return 0;
48190 }
48191
48192@@ -141,12 +186,23 @@ static int repeatable_keys[] = {
48193 static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
48194 {
48195 struct cinergyt2_state *st = d->priv;
48196- u8 key[5] = {0, 0, 0, 0, 0}, cmd = CINERGYT2_EP1_GET_RC_EVENTS;
48197+ u8 *key, *cmd;
48198 int i;
48199
48200+ cmd = kmalloc(1, GFP_KERNEL);
48201+ if (cmd == NULL)
48202+ return -EINVAL;
48203+ key = kzalloc(5, GFP_KERNEL);
48204+ if (key == NULL) {
48205+ kfree(cmd);
48206+ return -EINVAL;
48207+ }
48208+
48209+ cmd[0] = CINERGYT2_EP1_GET_RC_EVENTS;
48210+
48211 *state = REMOTE_NO_KEY_PRESSED;
48212
48213- dvb_usb_generic_rw(d, &cmd, 1, key, sizeof(key), 0);
48214+ dvb_usb_generic_rw(d, cmd, 1, key, 5, 0);
48215 if (key[4] == 0xff) {
48216 /* key repeat */
48217 st->rc_counter++;
48218@@ -157,12 +213,12 @@ static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
48219 *event = d->last_event;
48220 deb_rc("repeat key, event %x\n",
48221 *event);
48222- return 0;
48223+ goto out;
48224 }
48225 }
48226 deb_rc("repeated key (non repeatable)\n");
48227 }
48228- return 0;
48229+ goto out;
48230 }
48231
48232 /* hack to pass checksum on the custom field */
48233@@ -174,6 +230,9 @@ static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
48234
48235 deb_rc("key: %*ph\n", 5, key);
48236 }
48237+out:
48238+ kfree(cmd);
48239+ kfree(key);
48240 return 0;
48241 }
48242
48243diff --git a/drivers/media/usb/dvb-usb/cinergyT2-fe.c b/drivers/media/usb/dvb-usb/cinergyT2-fe.c
48244index b3ec743..9c0e418 100644
48245--- a/drivers/media/usb/dvb-usb/cinergyT2-fe.c
48246+++ b/drivers/media/usb/dvb-usb/cinergyT2-fe.c
48247@@ -145,103 +145,176 @@ static int cinergyt2_fe_read_status(struct dvb_frontend *fe,
48248 enum fe_status *status)
48249 {
48250 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48251- struct dvbt_get_status_msg result;
48252- u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48253+ struct dvbt_get_status_msg *result;
48254+ u8 *cmd;
48255 int ret;
48256
48257- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&result,
48258- sizeof(result), 0);
48259+ cmd = kmalloc(1, GFP_KERNEL);
48260+ if (cmd == NULL)
48261+ return -ENOMEM;
48262+ result = kmalloc(sizeof(*result), GFP_KERNEL);
48263+ if (result == NULL) {
48264+ kfree(cmd);
48265+ return -ENOMEM;
48266+ }
48267+
48268+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48269+
48270+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (u8 *)result,
48271+ sizeof(*result), 0);
48272 if (ret < 0)
48273- return ret;
48274+ goto out;
48275
48276 *status = 0;
48277
48278- if (0xffff - le16_to_cpu(result.gain) > 30)
48279+ if (0xffff - le16_to_cpu(result->gain) > 30)
48280 *status |= FE_HAS_SIGNAL;
48281- if (result.lock_bits & (1 << 6))
48282+ if (result->lock_bits & (1 << 6))
48283 *status |= FE_HAS_LOCK;
48284- if (result.lock_bits & (1 << 5))
48285+ if (result->lock_bits & (1 << 5))
48286 *status |= FE_HAS_SYNC;
48287- if (result.lock_bits & (1 << 4))
48288+ if (result->lock_bits & (1 << 4))
48289 *status |= FE_HAS_CARRIER;
48290- if (result.lock_bits & (1 << 1))
48291+ if (result->lock_bits & (1 << 1))
48292 *status |= FE_HAS_VITERBI;
48293
48294 if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) !=
48295 (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))
48296 *status &= ~FE_HAS_LOCK;
48297
48298- return 0;
48299+out:
48300+ kfree(cmd);
48301+ kfree(result);
48302+ return ret;
48303 }
48304
48305 static int cinergyt2_fe_read_ber(struct dvb_frontend *fe, u32 *ber)
48306 {
48307 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48308- struct dvbt_get_status_msg status;
48309- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48310+ struct dvbt_get_status_msg *status;
48311+ char *cmd;
48312 int ret;
48313
48314- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
48315- sizeof(status), 0);
48316+ cmd = kmalloc(1, GFP_KERNEL);
48317+ if (cmd == NULL)
48318+ return -ENOMEM;
48319+ status = kmalloc(sizeof(*status), GFP_KERNEL);
48320+ if (status == NULL) {
48321+ kfree(cmd);
48322+ return -ENOMEM;
48323+ }
48324+
48325+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48326+
48327+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status,
48328+ sizeof(*status), 0);
48329 if (ret < 0)
48330- return ret;
48331+ goto out;
48332
48333- *ber = le32_to_cpu(status.viterbi_error_rate);
48334+ *ber = le32_to_cpu(status->viterbi_error_rate);
48335+out:
48336+ kfree(cmd);
48337+ kfree(status);
48338 return 0;
48339 }
48340
48341 static int cinergyt2_fe_read_unc_blocks(struct dvb_frontend *fe, u32 *unc)
48342 {
48343 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48344- struct dvbt_get_status_msg status;
48345- u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48346+ struct dvbt_get_status_msg *status;
48347+ u8 *cmd;
48348 int ret;
48349
48350- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&status,
48351- sizeof(status), 0);
48352+ cmd = kmalloc(1, GFP_KERNEL);
48353+ if (cmd == NULL)
48354+ return -ENOMEM;
48355+ status = kmalloc(sizeof(*status), GFP_KERNEL);
48356+ if (status == NULL) {
48357+ kfree(cmd);
48358+ return -ENOMEM;
48359+ }
48360+
48361+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48362+
48363+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (u8 *)status,
48364+ sizeof(*status), 0);
48365 if (ret < 0) {
48366 err("cinergyt2_fe_read_unc_blocks() Failed! (Error=%d)\n",
48367 ret);
48368- return ret;
48369+ goto out;
48370 }
48371- *unc = le32_to_cpu(status.uncorrected_block_count);
48372- return 0;
48373+ *unc = le32_to_cpu(status->uncorrected_block_count);
48374+
48375+out:
48376+ kfree(cmd);
48377+ kfree(status);
48378+ return ret;
48379 }
48380
48381 static int cinergyt2_fe_read_signal_strength(struct dvb_frontend *fe,
48382 u16 *strength)
48383 {
48384 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48385- struct dvbt_get_status_msg status;
48386- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48387+ struct dvbt_get_status_msg *status;
48388+ char *cmd;
48389 int ret;
48390
48391- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
48392- sizeof(status), 0);
48393+ cmd = kmalloc(1, GFP_KERNEL);
48394+ if (cmd == NULL)
48395+ return -ENOMEM;
48396+ status = kmalloc(sizeof(*status), GFP_KERNEL);
48397+ if (status == NULL) {
48398+ kfree(cmd);
48399+ return -ENOMEM;
48400+ }
48401+
48402+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48403+
48404+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status,
48405+ sizeof(*status), 0);
48406 if (ret < 0) {
48407 err("cinergyt2_fe_read_signal_strength() Failed!"
48408 " (Error=%d)\n", ret);
48409- return ret;
48410+ goto out;
48411 }
48412- *strength = (0xffff - le16_to_cpu(status.gain));
48413+ *strength = (0xffff - le16_to_cpu(status->gain));
48414+
48415+out:
48416+ kfree(cmd);
48417+ kfree(status);
48418 return 0;
48419 }
48420
48421 static int cinergyt2_fe_read_snr(struct dvb_frontend *fe, u16 *snr)
48422 {
48423 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48424- struct dvbt_get_status_msg status;
48425- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48426+ struct dvbt_get_status_msg *status;
48427+ char *cmd;
48428 int ret;
48429
48430- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
48431- sizeof(status), 0);
48432+ cmd = kmalloc(1, GFP_KERNEL);
48433+ if (cmd == NULL)
48434+ return -ENOMEM;
48435+ status = kmalloc(sizeof(*status), GFP_KERNEL);
48436+ if (status == NULL) {
48437+ kfree(cmd);
48438+ return -ENOMEM;
48439+ }
48440+
48441+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48442+
48443+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status,
48444+ sizeof(*status), 0);
48445 if (ret < 0) {
48446 err("cinergyt2_fe_read_snr() Failed! (Error=%d)\n", ret);
48447- return ret;
48448+ goto out;
48449 }
48450- *snr = (status.snr << 8) | status.snr;
48451- return 0;
48452+ *snr = (status->snr << 8) | status->snr;
48453+
48454+out:
48455+ kfree(cmd);
48456+ kfree(status);
48457+ return ret;
48458 }
48459
48460 static int cinergyt2_fe_init(struct dvb_frontend *fe)
48461@@ -266,35 +339,46 @@ static int cinergyt2_fe_set_frontend(struct dvb_frontend *fe)
48462 {
48463 struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
48464 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48465- struct dvbt_set_parameters_msg param;
48466- char result[2];
48467+ struct dvbt_set_parameters_msg *param;
48468+ char *result;
48469 int err;
48470
48471- param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
48472- param.tps = cpu_to_le16(compute_tps(fep));
48473- param.freq = cpu_to_le32(fep->frequency / 1000);
48474- param.flags = 0;
48475+ result = kmalloc(2, GFP_KERNEL);
48476+ if (result == NULL)
48477+ return -ENOMEM;
48478+ param = kmalloc(sizeof(*param), GFP_KERNEL);
48479+ if (param == NULL) {
48480+ kfree(result);
48481+ return -ENOMEM;
48482+ }
48483+
48484+ param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
48485+ param->tps = cpu_to_le16(compute_tps(fep));
48486+ param->freq = cpu_to_le32(fep->frequency / 1000);
48487+ param->flags = 0;
48488
48489 switch (fep->bandwidth_hz) {
48490 default:
48491 case 8000000:
48492- param.bandwidth = 8;
48493+ param->bandwidth = 8;
48494 break;
48495 case 7000000:
48496- param.bandwidth = 7;
48497+ param->bandwidth = 7;
48498 break;
48499 case 6000000:
48500- param.bandwidth = 6;
48501+ param->bandwidth = 6;
48502 break;
48503 }
48504
48505 err = dvb_usb_generic_rw(state->d,
48506- (char *)&param, sizeof(param),
48507- result, sizeof(result), 0);
48508+ (char *)param, sizeof(*param),
48509+ result, 2, 0);
48510 if (err < 0)
48511 err("cinergyt2_fe_set_frontend() Failed! err=%d\n", err);
48512
48513- return (err < 0) ? err : 0;
48514+ kfree(result);
48515+ kfree(param);
48516+ return err;
48517 }
48518
48519 static void cinergyt2_fe_release(struct dvb_frontend *fe)
48520diff --git a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
48521index 733a7ff..f8b52e3 100644
48522--- a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
48523+++ b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
48524@@ -35,42 +35,57 @@ static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 le
48525
48526 int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type)
48527 {
48528- struct hexline hx;
48529- u8 reset;
48530+ struct hexline *hx;
48531+ u8 *reset;
48532 int ret,pos=0;
48533
48534+ reset = kmalloc(1, GFP_KERNEL);
48535+ if (reset == NULL)
48536+ return -ENOMEM;
48537+
48538+ hx = kmalloc(sizeof(struct hexline), GFP_KERNEL);
48539+ if (hx == NULL) {
48540+ kfree(reset);
48541+ return -ENOMEM;
48542+ }
48543+
48544 /* stop the CPU */
48545- reset = 1;
48546- if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1)
48547+ reset[0] = 1;
48548+ if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,reset,1)) != 1)
48549 err("could not stop the USB controller CPU.");
48550
48551- while ((ret = dvb_usb_get_hexline(fw,&hx,&pos)) > 0) {
48552- deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx.addr,hx.len,hx.chk);
48553- ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len);
48554+ while ((ret = dvb_usb_get_hexline(fw,hx,&pos)) > 0) {
48555+ deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx->addr,hx->len,hx->chk);
48556+ ret = usb_cypress_writemem(udev,hx->addr,hx->data,hx->len);
48557
48558- if (ret != hx.len) {
48559+ if (ret != hx->len) {
48560 err("error while transferring firmware "
48561 "(transferred size: %d, block size: %d)",
48562- ret,hx.len);
48563+ ret,hx->len);
48564 ret = -EINVAL;
48565 break;
48566 }
48567 }
48568 if (ret < 0) {
48569 err("firmware download failed at %d with %d",pos,ret);
48570+ kfree(reset);
48571+ kfree(hx);
48572 return ret;
48573 }
48574
48575 if (ret == 0) {
48576 /* restart the CPU */
48577- reset = 0;
48578- if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) {
48579+ reset[0] = 0;
48580+ if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,reset,1) != 1) {
48581 err("could not restart the USB controller CPU.");
48582 ret = -EINVAL;
48583 }
48584 } else
48585 ret = -EIO;
48586
48587+ kfree(reset);
48588+ kfree(hx);
48589+
48590 return ret;
48591 }
48592 EXPORT_SYMBOL(usb_cypress_load_firmware);
48593diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c
48594index 03f334d..0986492 100644
48595--- a/drivers/media/usb/dvb-usb/technisat-usb2.c
48596+++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
48597@@ -87,8 +87,11 @@ struct technisat_usb2_state {
48598 static int technisat_usb2_i2c_access(struct usb_device *udev,
48599 u8 device_addr, u8 *tx, u8 txlen, u8 *rx, u8 rxlen)
48600 {
48601- u8 b[64];
48602- int ret, actual_length;
48603+ u8 *b = kmalloc(64, GFP_KERNEL);
48604+ int ret, actual_length, error = 0;
48605+
48606+ if (b == NULL)
48607+ return -ENOMEM;
48608
48609 deb_i2c("i2c-access: %02x, tx: ", device_addr);
48610 debug_dump(tx, txlen, deb_i2c);
48611@@ -121,7 +124,8 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
48612
48613 if (ret < 0) {
48614 err("i2c-error: out failed %02x = %d", device_addr, ret);
48615- return -ENODEV;
48616+ error = -ENODEV;
48617+ goto out;
48618 }
48619
48620 ret = usb_bulk_msg(udev,
48621@@ -129,7 +133,8 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
48622 b, 64, &actual_length, 1000);
48623 if (ret < 0) {
48624 err("i2c-error: in failed %02x = %d", device_addr, ret);
48625- return -ENODEV;
48626+ error = -ENODEV;
48627+ goto out;
48628 }
48629
48630 if (b[0] != I2C_STATUS_OK) {
48631@@ -137,8 +142,10 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
48632 /* handle tuner-i2c-nak */
48633 if (!(b[0] == I2C_STATUS_NAK &&
48634 device_addr == 0x60
48635- /* && device_is_technisat_usb2 */))
48636- return -ENODEV;
48637+ /* && device_is_technisat_usb2 */)) {
48638+ error = -ENODEV;
48639+ goto out;
48640+ }
48641 }
48642
48643 deb_i2c("status: %d, ", b[0]);
48644@@ -152,7 +159,9 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
48645
48646 deb_i2c("\n");
48647
48648- return 0;
48649+out:
48650+ kfree(b);
48651+ return error;
48652 }
48653
48654 static int technisat_usb2_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,
48655@@ -224,14 +233,16 @@ static int technisat_usb2_set_led(struct dvb_usb_device *d, int red, enum techni
48656 {
48657 int ret;
48658
48659- u8 led[8] = {
48660- red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST,
48661- 0
48662- };
48663+ u8 *led = kzalloc(8, GFP_KERNEL);
48664+
48665+ if (led == NULL)
48666+ return -ENOMEM;
48667
48668 if (disable_led_control && state != TECH_LED_OFF)
48669 return 0;
48670
48671+ led[0] = red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST;
48672+
48673 switch (state) {
48674 case TECH_LED_ON:
48675 led[1] = 0x82;
48676@@ -263,16 +274,22 @@ static int technisat_usb2_set_led(struct dvb_usb_device *d, int red, enum techni
48677 red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST,
48678 USB_TYPE_VENDOR | USB_DIR_OUT,
48679 0, 0,
48680- led, sizeof(led), 500);
48681+ led, 8, 500);
48682
48683 mutex_unlock(&d->i2c_mutex);
48684+
48685+ kfree(led);
48686+
48687 return ret;
48688 }
48689
48690 static int technisat_usb2_set_led_timer(struct dvb_usb_device *d, u8 red, u8 green)
48691 {
48692 int ret;
48693- u8 b = 0;
48694+ u8 *b = kzalloc(1, GFP_KERNEL);
48695+
48696+ if (b == NULL)
48697+ return -ENOMEM;
48698
48699 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
48700 return -EAGAIN;
48701@@ -281,10 +298,12 @@ static int technisat_usb2_set_led_timer(struct dvb_usb_device *d, u8 red, u8 gre
48702 SET_LED_TIMER_DIVIDER_VENDOR_REQUEST,
48703 USB_TYPE_VENDOR | USB_DIR_OUT,
48704 (red << 8) | green, 0,
48705- &b, 1, 500);
48706+ b, 1, 500);
48707
48708 mutex_unlock(&d->i2c_mutex);
48709
48710+ kfree(b);
48711+
48712 return ret;
48713 }
48714
48715@@ -328,7 +347,7 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
48716 struct dvb_usb_device_description **desc, int *cold)
48717 {
48718 int ret;
48719- u8 version[3];
48720+ u8 *version = kmalloc(3, GFP_KERNEL);
48721
48722 /* first select the interface */
48723 if (usb_set_interface(udev, 0, 1) != 0)
48724@@ -338,11 +357,14 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
48725
48726 *cold = 0; /* by default do not download a firmware - just in case something is wrong */
48727
48728+ if (version == NULL)
48729+ return 0;
48730+
48731 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
48732 GET_VERSION_INFO_VENDOR_REQUEST,
48733 USB_TYPE_VENDOR | USB_DIR_IN,
48734 0, 0,
48735- version, sizeof(version), 500);
48736+ version, 3, 500);
48737
48738 if (ret < 0)
48739 *cold = 1;
48740@@ -351,6 +373,8 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
48741 *cold = 0;
48742 }
48743
48744+ kfree(version);
48745+
48746 return 0;
48747 }
48748
48749@@ -594,10 +618,15 @@ static int technisat_usb2_frontend_attach(struct dvb_usb_adapter *a)
48750
48751 static int technisat_usb2_get_ir(struct dvb_usb_device *d)
48752 {
48753- u8 buf[62], *b;
48754+ u8 *buf, *b;
48755 int ret;
48756 struct ir_raw_event ev;
48757
48758+ buf = kmalloc(62, GFP_KERNEL);
48759+
48760+ if (buf == NULL)
48761+ return -ENOMEM;
48762+
48763 buf[0] = GET_IR_DATA_VENDOR_REQUEST;
48764 buf[1] = 0x08;
48765 buf[2] = 0x8f;
48766@@ -620,16 +649,20 @@ static int technisat_usb2_get_ir(struct dvb_usb_device *d)
48767 GET_IR_DATA_VENDOR_REQUEST,
48768 USB_TYPE_VENDOR | USB_DIR_IN,
48769 0x8080, 0,
48770- buf, sizeof(buf), 500);
48771+ buf, 62, 500);
48772
48773 unlock:
48774 mutex_unlock(&d->i2c_mutex);
48775
48776- if (ret < 0)
48777+ if (ret < 0) {
48778+ kfree(buf);
48779 return ret;
48780+ }
48781
48782- if (ret == 1)
48783+ if (ret == 1) {
48784+ kfree(buf);
48785 return 0; /* no key pressed */
48786+ }
48787
48788 /* decoding */
48789 b = buf+1;
48790@@ -656,6 +689,8 @@ unlock:
48791
48792 ir_raw_event_handle(d->rc_dev);
48793
48794+ kfree(buf);
48795+
48796 return 1;
48797 }
48798
48799diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
48800index af63543..0436f20 100644
48801--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
48802+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
48803@@ -429,7 +429,7 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
48804 * by passing a very big num_planes value */
48805 uplane = compat_alloc_user_space(num_planes *
48806 sizeof(struct v4l2_plane));
48807- kp->m.planes = (__force struct v4l2_plane *)uplane;
48808+ kp->m.planes = (__force_kernel struct v4l2_plane *)uplane;
48809
48810 while (--num_planes >= 0) {
48811 ret = get_v4l2_plane32(uplane, uplane32, kp->memory);
48812@@ -500,7 +500,7 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
48813 if (num_planes == 0)
48814 return 0;
48815
48816- uplane = (__force struct v4l2_plane __user *)kp->m.planes;
48817+ uplane = (struct v4l2_plane __force_user *)kp->m.planes;
48818 if (get_user(p, &up->m.planes))
48819 return -EFAULT;
48820 uplane32 = compat_ptr(p);
48821@@ -564,7 +564,7 @@ static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_frame
48822 get_user(kp->flags, &up->flags) ||
48823 copy_from_user(&kp->fmt, &up->fmt, sizeof(up->fmt)))
48824 return -EFAULT;
48825- kp->base = (__force void *)compat_ptr(tmp);
48826+ kp->base = (__force_kernel void *)compat_ptr(tmp);
48827 return 0;
48828 }
48829
48830@@ -669,7 +669,7 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
48831 n * sizeof(struct v4l2_ext_control32)))
48832 return -EFAULT;
48833 kcontrols = compat_alloc_user_space(n * sizeof(struct v4l2_ext_control));
48834- kp->controls = (__force struct v4l2_ext_control *)kcontrols;
48835+ kp->controls = (__force_kernel struct v4l2_ext_control *)kcontrols;
48836 while (--n >= 0) {
48837 u32 id;
48838
48839@@ -696,7 +696,7 @@ static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
48840 {
48841 struct v4l2_ext_control32 __user *ucontrols;
48842 struct v4l2_ext_control __user *kcontrols =
48843- (__force struct v4l2_ext_control __user *)kp->controls;
48844+ (struct v4l2_ext_control __force_user *)kp->controls;
48845 int n = kp->count;
48846 compat_caddr_t p;
48847
48848@@ -780,7 +780,7 @@ static int get_v4l2_edid32(struct v4l2_edid *kp, struct v4l2_edid32 __user *up)
48849 get_user(tmp, &up->edid) ||
48850 copy_from_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
48851 return -EFAULT;
48852- kp->edid = (__force u8 *)compat_ptr(tmp);
48853+ kp->edid = (__force_kernel u8 *)compat_ptr(tmp);
48854 return 0;
48855 }
48856
48857diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
48858index 5b0a30b..1974b38 100644
48859--- a/drivers/media/v4l2-core/v4l2-device.c
48860+++ b/drivers/media/v4l2-core/v4l2-device.c
48861@@ -74,9 +74,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
48862 EXPORT_SYMBOL_GPL(v4l2_device_put);
48863
48864 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
48865- atomic_t *instance)
48866+ atomic_unchecked_t *instance)
48867 {
48868- int num = atomic_inc_return(instance) - 1;
48869+ int num = atomic_inc_return_unchecked(instance) - 1;
48870 int len = strlen(basename);
48871
48872 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
48873diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
48874index 85de455..4987854 100644
48875--- a/drivers/media/v4l2-core/v4l2-ioctl.c
48876+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
48877@@ -2341,7 +2341,8 @@ struct v4l2_ioctl_info {
48878 struct file *file, void *fh, void *p);
48879 } u;
48880 void (*debug)(const void *arg, bool write_only);
48881-};
48882+} __do_const;
48883+typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
48884
48885 /* This control needs a priority check */
48886 #define INFO_FL_PRIO (1 << 0)
48887@@ -2525,7 +2526,7 @@ static long __video_do_ioctl(struct file *file,
48888 struct video_device *vfd = video_devdata(file);
48889 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
48890 bool write_only = false;
48891- struct v4l2_ioctl_info default_info;
48892+ v4l2_ioctl_info_no_const default_info;
48893 const struct v4l2_ioctl_info *info;
48894 void *fh = file->private_data;
48895 struct v4l2_fh *vfh = NULL;
48896@@ -2616,7 +2617,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
48897 ret = -EINVAL;
48898 break;
48899 }
48900- *user_ptr = (void __user *)buf->m.planes;
48901+ *user_ptr = (void __force_user *)buf->m.planes;
48902 *kernel_ptr = (void **)&buf->m.planes;
48903 *array_size = sizeof(struct v4l2_plane) * buf->length;
48904 ret = 1;
48905@@ -2633,7 +2634,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
48906 ret = -EINVAL;
48907 break;
48908 }
48909- *user_ptr = (void __user *)edid->edid;
48910+ *user_ptr = (void __force_user *)edid->edid;
48911 *kernel_ptr = (void **)&edid->edid;
48912 *array_size = edid->blocks * 128;
48913 ret = 1;
48914@@ -2651,7 +2652,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
48915 ret = -EINVAL;
48916 break;
48917 }
48918- *user_ptr = (void __user *)ctrls->controls;
48919+ *user_ptr = (void __force_user *)ctrls->controls;
48920 *kernel_ptr = (void **)&ctrls->controls;
48921 *array_size = sizeof(struct v4l2_ext_control)
48922 * ctrls->count;
48923@@ -2752,7 +2753,7 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
48924 }
48925
48926 if (has_array_args) {
48927- *kernel_ptr = (void __force *)user_ptr;
48928+ *kernel_ptr = (void __force_kernel *)user_ptr;
48929 if (copy_to_user(user_ptr, mbuf, array_size))
48930 err = -EFAULT;
48931 goto out_array_args;
48932diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
48933index 9426276..9abd11e 100644
48934--- a/drivers/memory/omap-gpmc.c
48935+++ b/drivers/memory/omap-gpmc.c
48936@@ -232,7 +232,6 @@ struct omap3_gpmc_regs {
48937 };
48938
48939 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
48940-static struct irq_chip gpmc_irq_chip;
48941 static int gpmc_irq_start;
48942
48943 static struct resource gpmc_mem_root;
48944@@ -1146,6 +1145,17 @@ static void gpmc_irq_noop(struct irq_data *data) { }
48945
48946 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
48947
48948+static struct irq_chip gpmc_irq_chip = {
48949+ .name = "gpmc",
48950+ .irq_startup = gpmc_irq_noop_ret,
48951+ .irq_enable = gpmc_irq_enable,
48952+ .irq_disable = gpmc_irq_disable,
48953+ .irq_shutdown = gpmc_irq_noop,
48954+ .irq_ack = gpmc_irq_noop,
48955+ .irq_mask = gpmc_irq_noop,
48956+ .irq_unmask = gpmc_irq_noop,
48957+};
48958+
48959 static int gpmc_setup_irq(void)
48960 {
48961 int i;
48962@@ -1160,15 +1170,6 @@ static int gpmc_setup_irq(void)
48963 return gpmc_irq_start;
48964 }
48965
48966- gpmc_irq_chip.name = "gpmc";
48967- gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
48968- gpmc_irq_chip.irq_enable = gpmc_irq_enable;
48969- gpmc_irq_chip.irq_disable = gpmc_irq_disable;
48970- gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
48971- gpmc_irq_chip.irq_ack = gpmc_irq_noop;
48972- gpmc_irq_chip.irq_mask = gpmc_irq_noop;
48973- gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
48974-
48975 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
48976 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
48977
48978diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
48979index 5dcc031..e08ecd2 100644
48980--- a/drivers/message/fusion/mptbase.c
48981+++ b/drivers/message/fusion/mptbase.c
48982@@ -6722,8 +6722,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
48983 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
48984 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
48985
48986+#ifdef CONFIG_GRKERNSEC_HIDESYM
48987+ seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
48988+#else
48989 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
48990 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
48991+#endif
48992+
48993 /*
48994 * Rounding UP to nearest 4-kB boundary here...
48995 */
48996@@ -6736,7 +6741,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
48997 ioc->facts.GlobalCredits);
48998
48999 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
49000+#ifdef CONFIG_GRKERNSEC_HIDESYM
49001+ NULL, NULL);
49002+#else
49003 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
49004+#endif
49005 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
49006 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
49007 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
49008diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
49009index 005a88b..5a90fbb 100644
49010--- a/drivers/message/fusion/mptsas.c
49011+++ b/drivers/message/fusion/mptsas.c
49012@@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
49013 return 0;
49014 }
49015
49016+static inline void
49017+mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
49018+{
49019+ if (phy_info->port_details) {
49020+ phy_info->port_details->rphy = rphy;
49021+ dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
49022+ ioc->name, rphy));
49023+ }
49024+
49025+ if (rphy) {
49026+ dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
49027+ &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
49028+ dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
49029+ ioc->name, rphy, rphy->dev.release));
49030+ }
49031+}
49032+
49033 /* no mutex */
49034 static void
49035 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
49036@@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
49037 return NULL;
49038 }
49039
49040-static inline void
49041-mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
49042-{
49043- if (phy_info->port_details) {
49044- phy_info->port_details->rphy = rphy;
49045- dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
49046- ioc->name, rphy));
49047- }
49048-
49049- if (rphy) {
49050- dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
49051- &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
49052- dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
49053- ioc->name, rphy, rphy->dev.release));
49054- }
49055-}
49056-
49057 static inline struct sas_port *
49058 mptsas_get_port(struct mptsas_phyinfo *phy_info)
49059 {
49060diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
49061index 0236cd7..53b10d7 100644
49062--- a/drivers/mfd/ab8500-debugfs.c
49063+++ b/drivers/mfd/ab8500-debugfs.c
49064@@ -100,7 +100,7 @@ static int irq_last;
49065 static u32 *irq_count;
49066 static int num_irqs;
49067
49068-static struct device_attribute **dev_attr;
49069+static device_attribute_no_const **dev_attr;
49070 static char **event_name;
49071
49072 static u8 avg_sample = SAMPLE_16;
49073diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
49074index 8057849..0550fdf 100644
49075--- a/drivers/mfd/kempld-core.c
49076+++ b/drivers/mfd/kempld-core.c
49077@@ -499,7 +499,7 @@ static struct platform_driver kempld_driver = {
49078 .remove = kempld_remove,
49079 };
49080
49081-static struct dmi_system_id kempld_dmi_table[] __initdata = {
49082+static const struct dmi_system_id kempld_dmi_table[] __initconst = {
49083 {
49084 .ident = "BHL6",
49085 .matches = {
49086diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
49087index c880c89..45a7c68 100644
49088--- a/drivers/mfd/max8925-i2c.c
49089+++ b/drivers/mfd/max8925-i2c.c
49090@@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
49091 const struct i2c_device_id *id)
49092 {
49093 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
49094- static struct max8925_chip *chip;
49095+ struct max8925_chip *chip;
49096 struct device_node *node = client->dev.of_node;
49097
49098 if (node && !pdata) {
49099diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
49100index 7612d89..70549c2 100644
49101--- a/drivers/mfd/tps65910.c
49102+++ b/drivers/mfd/tps65910.c
49103@@ -230,7 +230,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
49104 struct tps65910_platform_data *pdata)
49105 {
49106 int ret = 0;
49107- static struct regmap_irq_chip *tps6591x_irqs_chip;
49108+ struct regmap_irq_chip *tps6591x_irqs_chip;
49109
49110 if (!irq) {
49111 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
49112diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
49113index a3fa7f4..eac02ef 100644
49114--- a/drivers/mfd/twl4030-irq.c
49115+++ b/drivers/mfd/twl4030-irq.c
49116@@ -34,6 +34,7 @@
49117 #include <linux/of.h>
49118 #include <linux/irqdomain.h>
49119 #include <linux/i2c/twl.h>
49120+#include <asm/pgtable.h>
49121
49122 #include "twl-core.h"
49123
49124@@ -729,10 +730,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
49125 * Install an irq handler for each of the SIH modules;
49126 * clone dummy irq_chip since PIH can't *do* anything
49127 */
49128- twl4030_irq_chip = dummy_irq_chip;
49129- twl4030_irq_chip.name = "twl4030";
49130+ pax_open_kernel();
49131+ memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
49132+ *(const char **)&twl4030_irq_chip.name = "twl4030";
49133
49134- twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
49135+ *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
49136+ pax_close_kernel();
49137
49138 for (i = irq_base; i < irq_end; i++) {
49139 irq_set_chip_and_handler(i, &twl4030_irq_chip,
49140diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
49141index 464419b..64bae8d 100644
49142--- a/drivers/misc/c2port/core.c
49143+++ b/drivers/misc/c2port/core.c
49144@@ -922,7 +922,9 @@ struct c2port_device *c2port_device_register(char *name,
49145 goto error_idr_alloc;
49146 c2dev->id = ret;
49147
49148- bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
49149+ pax_open_kernel();
49150+ *(size_t *)&bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
49151+ pax_close_kernel();
49152
49153 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
49154 "c2port%d", c2dev->id);
49155diff --git a/drivers/misc/eeprom/sunxi_sid.c b/drivers/misc/eeprom/sunxi_sid.c
49156index 8385177..2f54635 100644
49157--- a/drivers/misc/eeprom/sunxi_sid.c
49158+++ b/drivers/misc/eeprom/sunxi_sid.c
49159@@ -126,7 +126,9 @@ static int sunxi_sid_probe(struct platform_device *pdev)
49160
49161 platform_set_drvdata(pdev, sid_data);
49162
49163- sid_bin_attr.size = sid_data->keysize;
49164+ pax_open_kernel();
49165+ *(size_t *)&sid_bin_attr.size = sid_data->keysize;
49166+ pax_close_kernel();
49167 if (device_create_bin_file(&pdev->dev, &sid_bin_attr))
49168 return -ENODEV;
49169
49170diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
49171index 9a60bd4..cee2069 100644
49172--- a/drivers/misc/kgdbts.c
49173+++ b/drivers/misc/kgdbts.c
49174@@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
49175 char before[BREAK_INSTR_SIZE];
49176 char after[BREAK_INSTR_SIZE];
49177
49178- probe_kernel_read(before, (char *)kgdbts_break_test,
49179+ probe_kernel_read(before, (void *)ktla_ktva((unsigned long)kgdbts_break_test),
49180 BREAK_INSTR_SIZE);
49181 init_simple_test();
49182 ts.tst = plant_and_detach_test;
49183@@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
49184 /* Activate test with initial breakpoint */
49185 if (!is_early)
49186 kgdb_breakpoint();
49187- probe_kernel_read(after, (char *)kgdbts_break_test,
49188+ probe_kernel_read(after, (void *)ktla_ktva((unsigned long)kgdbts_break_test),
49189 BREAK_INSTR_SIZE);
49190 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
49191 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
49192diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
49193index fb8705f..dc2f679 100644
49194--- a/drivers/misc/lis3lv02d/lis3lv02d.c
49195+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
49196@@ -497,7 +497,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
49197 * the lid is closed. This leads to interrupts as soon as a little move
49198 * is done.
49199 */
49200- atomic_inc(&lis3->count);
49201+ atomic_inc_unchecked(&lis3->count);
49202
49203 wake_up_interruptible(&lis3->misc_wait);
49204 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
49205@@ -583,7 +583,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
49206 if (lis3->pm_dev)
49207 pm_runtime_get_sync(lis3->pm_dev);
49208
49209- atomic_set(&lis3->count, 0);
49210+ atomic_set_unchecked(&lis3->count, 0);
49211 return 0;
49212 }
49213
49214@@ -615,7 +615,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
49215 add_wait_queue(&lis3->misc_wait, &wait);
49216 while (true) {
49217 set_current_state(TASK_INTERRUPTIBLE);
49218- data = atomic_xchg(&lis3->count, 0);
49219+ data = atomic_xchg_unchecked(&lis3->count, 0);
49220 if (data)
49221 break;
49222
49223@@ -656,7 +656,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
49224 struct lis3lv02d, miscdev);
49225
49226 poll_wait(file, &lis3->misc_wait, wait);
49227- if (atomic_read(&lis3->count))
49228+ if (atomic_read_unchecked(&lis3->count))
49229 return POLLIN | POLLRDNORM;
49230 return 0;
49231 }
49232diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
49233index c439c82..1f20f57 100644
49234--- a/drivers/misc/lis3lv02d/lis3lv02d.h
49235+++ b/drivers/misc/lis3lv02d/lis3lv02d.h
49236@@ -297,7 +297,7 @@ struct lis3lv02d {
49237 struct input_polled_dev *idev; /* input device */
49238 struct platform_device *pdev; /* platform device */
49239 struct regulator_bulk_data regulators[2];
49240- atomic_t count; /* interrupt count after last read */
49241+ atomic_unchecked_t count; /* interrupt count after last read */
49242 union axis_conversion ac; /* hw -> logical axis */
49243 int mapped_btns[3];
49244
49245diff --git a/drivers/misc/mic/scif/scif_rb.c b/drivers/misc/mic/scif/scif_rb.c
49246index 637cc46..4fb1267 100644
49247--- a/drivers/misc/mic/scif/scif_rb.c
49248+++ b/drivers/misc/mic/scif/scif_rb.c
49249@@ -138,7 +138,7 @@ void scif_rb_commit(struct scif_rb *rb)
49250 * the read barrier in scif_rb_count(..)
49251 */
49252 wmb();
49253- ACCESS_ONCE(*rb->write_ptr) = rb->current_write_offset;
49254+ ACCESS_ONCE_RW(*rb->write_ptr) = rb->current_write_offset;
49255 #ifdef CONFIG_INTEL_MIC_CARD
49256 /*
49257 * X100 Si bug: For the case where a Core is performing an EXT_WR
49258@@ -147,7 +147,7 @@ void scif_rb_commit(struct scif_rb *rb)
49259 * This way, if ordering is violated for the Interrupt Message, it will
49260 * fall just behind the first Posted associated with the first EXT_WR.
49261 */
49262- ACCESS_ONCE(*rb->write_ptr) = rb->current_write_offset;
49263+ ACCESS_ONCE_RW(*rb->write_ptr) = rb->current_write_offset;
49264 #endif
49265 }
49266
49267@@ -210,7 +210,7 @@ void scif_rb_update_read_ptr(struct scif_rb *rb)
49268 * scif_rb_space(..)
49269 */
49270 mb();
49271- ACCESS_ONCE(*rb->read_ptr) = new_offset;
49272+ ACCESS_ONCE_RW(*rb->read_ptr) = new_offset;
49273 #ifdef CONFIG_INTEL_MIC_CARD
49274 /*
49275 * X100 Si Bug: For the case where a Core is performing an EXT_WR
49276@@ -219,7 +219,7 @@ void scif_rb_update_read_ptr(struct scif_rb *rb)
49277 * This way, if ordering is violated for the Interrupt Message, it will
49278 * fall just behind the first Posted associated with the first EXT_WR.
49279 */
49280- ACCESS_ONCE(*rb->read_ptr) = new_offset;
49281+ ACCESS_ONCE_RW(*rb->read_ptr) = new_offset;
49282 #endif
49283 }
49284
49285diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
49286index 2f30bad..c4c13d0 100644
49287--- a/drivers/misc/sgi-gru/gruhandles.c
49288+++ b/drivers/misc/sgi-gru/gruhandles.c
49289@@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
49290 unsigned long nsec;
49291
49292 nsec = CLKS2NSEC(clks);
49293- atomic_long_inc(&mcs_op_statistics[op].count);
49294- atomic_long_add(nsec, &mcs_op_statistics[op].total);
49295+ atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
49296+ atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
49297 if (mcs_op_statistics[op].max < nsec)
49298 mcs_op_statistics[op].max = nsec;
49299 }
49300diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
49301index 4f76359..cdfcb2e 100644
49302--- a/drivers/misc/sgi-gru/gruprocfs.c
49303+++ b/drivers/misc/sgi-gru/gruprocfs.c
49304@@ -32,9 +32,9 @@
49305
49306 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
49307
49308-static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
49309+static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
49310 {
49311- unsigned long val = atomic_long_read(v);
49312+ unsigned long val = atomic_long_read_unchecked(v);
49313
49314 seq_printf(s, "%16lu %s\n", val, id);
49315 }
49316@@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
49317
49318 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
49319 for (op = 0; op < mcsop_last; op++) {
49320- count = atomic_long_read(&mcs_op_statistics[op].count);
49321- total = atomic_long_read(&mcs_op_statistics[op].total);
49322+ count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
49323+ total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
49324 max = mcs_op_statistics[op].max;
49325 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
49326 count ? total / count : 0, max);
49327diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
49328index 5c3ce24..4915ccb 100644
49329--- a/drivers/misc/sgi-gru/grutables.h
49330+++ b/drivers/misc/sgi-gru/grutables.h
49331@@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
49332 * GRU statistics.
49333 */
49334 struct gru_stats_s {
49335- atomic_long_t vdata_alloc;
49336- atomic_long_t vdata_free;
49337- atomic_long_t gts_alloc;
49338- atomic_long_t gts_free;
49339- atomic_long_t gms_alloc;
49340- atomic_long_t gms_free;
49341- atomic_long_t gts_double_allocate;
49342- atomic_long_t assign_context;
49343- atomic_long_t assign_context_failed;
49344- atomic_long_t free_context;
49345- atomic_long_t load_user_context;
49346- atomic_long_t load_kernel_context;
49347- atomic_long_t lock_kernel_context;
49348- atomic_long_t unlock_kernel_context;
49349- atomic_long_t steal_user_context;
49350- atomic_long_t steal_kernel_context;
49351- atomic_long_t steal_context_failed;
49352- atomic_long_t nopfn;
49353- atomic_long_t asid_new;
49354- atomic_long_t asid_next;
49355- atomic_long_t asid_wrap;
49356- atomic_long_t asid_reuse;
49357- atomic_long_t intr;
49358- atomic_long_t intr_cbr;
49359- atomic_long_t intr_tfh;
49360- atomic_long_t intr_spurious;
49361- atomic_long_t intr_mm_lock_failed;
49362- atomic_long_t call_os;
49363- atomic_long_t call_os_wait_queue;
49364- atomic_long_t user_flush_tlb;
49365- atomic_long_t user_unload_context;
49366- atomic_long_t user_exception;
49367- atomic_long_t set_context_option;
49368- atomic_long_t check_context_retarget_intr;
49369- atomic_long_t check_context_unload;
49370- atomic_long_t tlb_dropin;
49371- atomic_long_t tlb_preload_page;
49372- atomic_long_t tlb_dropin_fail_no_asid;
49373- atomic_long_t tlb_dropin_fail_upm;
49374- atomic_long_t tlb_dropin_fail_invalid;
49375- atomic_long_t tlb_dropin_fail_range_active;
49376- atomic_long_t tlb_dropin_fail_idle;
49377- atomic_long_t tlb_dropin_fail_fmm;
49378- atomic_long_t tlb_dropin_fail_no_exception;
49379- atomic_long_t tfh_stale_on_fault;
49380- atomic_long_t mmu_invalidate_range;
49381- atomic_long_t mmu_invalidate_page;
49382- atomic_long_t flush_tlb;
49383- atomic_long_t flush_tlb_gru;
49384- atomic_long_t flush_tlb_gru_tgh;
49385- atomic_long_t flush_tlb_gru_zero_asid;
49386+ atomic_long_unchecked_t vdata_alloc;
49387+ atomic_long_unchecked_t vdata_free;
49388+ atomic_long_unchecked_t gts_alloc;
49389+ atomic_long_unchecked_t gts_free;
49390+ atomic_long_unchecked_t gms_alloc;
49391+ atomic_long_unchecked_t gms_free;
49392+ atomic_long_unchecked_t gts_double_allocate;
49393+ atomic_long_unchecked_t assign_context;
49394+ atomic_long_unchecked_t assign_context_failed;
49395+ atomic_long_unchecked_t free_context;
49396+ atomic_long_unchecked_t load_user_context;
49397+ atomic_long_unchecked_t load_kernel_context;
49398+ atomic_long_unchecked_t lock_kernel_context;
49399+ atomic_long_unchecked_t unlock_kernel_context;
49400+ atomic_long_unchecked_t steal_user_context;
49401+ atomic_long_unchecked_t steal_kernel_context;
49402+ atomic_long_unchecked_t steal_context_failed;
49403+ atomic_long_unchecked_t nopfn;
49404+ atomic_long_unchecked_t asid_new;
49405+ atomic_long_unchecked_t asid_next;
49406+ atomic_long_unchecked_t asid_wrap;
49407+ atomic_long_unchecked_t asid_reuse;
49408+ atomic_long_unchecked_t intr;
49409+ atomic_long_unchecked_t intr_cbr;
49410+ atomic_long_unchecked_t intr_tfh;
49411+ atomic_long_unchecked_t intr_spurious;
49412+ atomic_long_unchecked_t intr_mm_lock_failed;
49413+ atomic_long_unchecked_t call_os;
49414+ atomic_long_unchecked_t call_os_wait_queue;
49415+ atomic_long_unchecked_t user_flush_tlb;
49416+ atomic_long_unchecked_t user_unload_context;
49417+ atomic_long_unchecked_t user_exception;
49418+ atomic_long_unchecked_t set_context_option;
49419+ atomic_long_unchecked_t check_context_retarget_intr;
49420+ atomic_long_unchecked_t check_context_unload;
49421+ atomic_long_unchecked_t tlb_dropin;
49422+ atomic_long_unchecked_t tlb_preload_page;
49423+ atomic_long_unchecked_t tlb_dropin_fail_no_asid;
49424+ atomic_long_unchecked_t tlb_dropin_fail_upm;
49425+ atomic_long_unchecked_t tlb_dropin_fail_invalid;
49426+ atomic_long_unchecked_t tlb_dropin_fail_range_active;
49427+ atomic_long_unchecked_t tlb_dropin_fail_idle;
49428+ atomic_long_unchecked_t tlb_dropin_fail_fmm;
49429+ atomic_long_unchecked_t tlb_dropin_fail_no_exception;
49430+ atomic_long_unchecked_t tfh_stale_on_fault;
49431+ atomic_long_unchecked_t mmu_invalidate_range;
49432+ atomic_long_unchecked_t mmu_invalidate_page;
49433+ atomic_long_unchecked_t flush_tlb;
49434+ atomic_long_unchecked_t flush_tlb_gru;
49435+ atomic_long_unchecked_t flush_tlb_gru_tgh;
49436+ atomic_long_unchecked_t flush_tlb_gru_zero_asid;
49437
49438- atomic_long_t copy_gpa;
49439- atomic_long_t read_gpa;
49440+ atomic_long_unchecked_t copy_gpa;
49441+ atomic_long_unchecked_t read_gpa;
49442
49443- atomic_long_t mesq_receive;
49444- atomic_long_t mesq_receive_none;
49445- atomic_long_t mesq_send;
49446- atomic_long_t mesq_send_failed;
49447- atomic_long_t mesq_noop;
49448- atomic_long_t mesq_send_unexpected_error;
49449- atomic_long_t mesq_send_lb_overflow;
49450- atomic_long_t mesq_send_qlimit_reached;
49451- atomic_long_t mesq_send_amo_nacked;
49452- atomic_long_t mesq_send_put_nacked;
49453- atomic_long_t mesq_page_overflow;
49454- atomic_long_t mesq_qf_locked;
49455- atomic_long_t mesq_qf_noop_not_full;
49456- atomic_long_t mesq_qf_switch_head_failed;
49457- atomic_long_t mesq_qf_unexpected_error;
49458- atomic_long_t mesq_noop_unexpected_error;
49459- atomic_long_t mesq_noop_lb_overflow;
49460- atomic_long_t mesq_noop_qlimit_reached;
49461- atomic_long_t mesq_noop_amo_nacked;
49462- atomic_long_t mesq_noop_put_nacked;
49463- atomic_long_t mesq_noop_page_overflow;
49464+ atomic_long_unchecked_t mesq_receive;
49465+ atomic_long_unchecked_t mesq_receive_none;
49466+ atomic_long_unchecked_t mesq_send;
49467+ atomic_long_unchecked_t mesq_send_failed;
49468+ atomic_long_unchecked_t mesq_noop;
49469+ atomic_long_unchecked_t mesq_send_unexpected_error;
49470+ atomic_long_unchecked_t mesq_send_lb_overflow;
49471+ atomic_long_unchecked_t mesq_send_qlimit_reached;
49472+ atomic_long_unchecked_t mesq_send_amo_nacked;
49473+ atomic_long_unchecked_t mesq_send_put_nacked;
49474+ atomic_long_unchecked_t mesq_page_overflow;
49475+ atomic_long_unchecked_t mesq_qf_locked;
49476+ atomic_long_unchecked_t mesq_qf_noop_not_full;
49477+ atomic_long_unchecked_t mesq_qf_switch_head_failed;
49478+ atomic_long_unchecked_t mesq_qf_unexpected_error;
49479+ atomic_long_unchecked_t mesq_noop_unexpected_error;
49480+ atomic_long_unchecked_t mesq_noop_lb_overflow;
49481+ atomic_long_unchecked_t mesq_noop_qlimit_reached;
49482+ atomic_long_unchecked_t mesq_noop_amo_nacked;
49483+ atomic_long_unchecked_t mesq_noop_put_nacked;
49484+ atomic_long_unchecked_t mesq_noop_page_overflow;
49485
49486 };
49487
49488@@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
49489 tghop_invalidate, mcsop_last};
49490
49491 struct mcs_op_statistic {
49492- atomic_long_t count;
49493- atomic_long_t total;
49494+ atomic_long_unchecked_t count;
49495+ atomic_long_unchecked_t total;
49496 unsigned long max;
49497 };
49498
49499@@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
49500
49501 #define STAT(id) do { \
49502 if (gru_options & OPT_STATS) \
49503- atomic_long_inc(&gru_stats.id); \
49504+ atomic_long_inc_unchecked(&gru_stats.id); \
49505 } while (0)
49506
49507 #ifdef CONFIG_SGI_GRU_DEBUG
49508diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
49509index c862cd4..0d176fe 100644
49510--- a/drivers/misc/sgi-xp/xp.h
49511+++ b/drivers/misc/sgi-xp/xp.h
49512@@ -288,7 +288,7 @@ struct xpc_interface {
49513 xpc_notify_func, void *);
49514 void (*received) (short, int, void *);
49515 enum xp_retval (*partid_to_nasids) (short, void *);
49516-};
49517+} __no_const;
49518
49519 extern struct xpc_interface xpc_interface;
49520
49521diff --git a/drivers/misc/sgi-xp/xp_main.c b/drivers/misc/sgi-xp/xp_main.c
49522index 01be66d..e3a0c7e 100644
49523--- a/drivers/misc/sgi-xp/xp_main.c
49524+++ b/drivers/misc/sgi-xp/xp_main.c
49525@@ -78,13 +78,13 @@ xpc_notloaded(void)
49526 }
49527
49528 struct xpc_interface xpc_interface = {
49529- (void (*)(int))xpc_notloaded,
49530- (void (*)(int))xpc_notloaded,
49531- (enum xp_retval(*)(short, int, u32, void *, u16))xpc_notloaded,
49532- (enum xp_retval(*)(short, int, u32, void *, u16, xpc_notify_func,
49533+ .connect = (void (*)(int))xpc_notloaded,
49534+ .disconnect = (void (*)(int))xpc_notloaded,
49535+ .send = (enum xp_retval(*)(short, int, u32, void *, u16))xpc_notloaded,
49536+ .send_notify = (enum xp_retval(*)(short, int, u32, void *, u16, xpc_notify_func,
49537 void *))xpc_notloaded,
49538- (void (*)(short, int, void *))xpc_notloaded,
49539- (enum xp_retval(*)(short, void *))xpc_notloaded
49540+ .received = (void (*)(short, int, void *))xpc_notloaded,
49541+ .partid_to_nasids = (enum xp_retval(*)(short, void *))xpc_notloaded
49542 };
49543 EXPORT_SYMBOL_GPL(xpc_interface);
49544
49545diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
49546index b94d5f7..7f494c5 100644
49547--- a/drivers/misc/sgi-xp/xpc.h
49548+++ b/drivers/misc/sgi-xp/xpc.h
49549@@ -835,6 +835,7 @@ struct xpc_arch_operations {
49550 void (*received_payload) (struct xpc_channel *, void *);
49551 void (*notify_senders_of_disconnect) (struct xpc_channel *);
49552 };
49553+typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
49554
49555 /* struct xpc_partition act_state values (for XPC HB) */
49556
49557@@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
49558 /* found in xpc_main.c */
49559 extern struct device *xpc_part;
49560 extern struct device *xpc_chan;
49561-extern struct xpc_arch_operations xpc_arch_ops;
49562+extern xpc_arch_operations_no_const xpc_arch_ops;
49563 extern int xpc_disengage_timelimit;
49564 extern int xpc_disengage_timedout;
49565 extern int xpc_activate_IRQ_rcvd;
49566diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
49567index 7f32712..8539ab2 100644
49568--- a/drivers/misc/sgi-xp/xpc_main.c
49569+++ b/drivers/misc/sgi-xp/xpc_main.c
49570@@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
49571 .notifier_call = xpc_system_die,
49572 };
49573
49574-struct xpc_arch_operations xpc_arch_ops;
49575+xpc_arch_operations_no_const xpc_arch_ops;
49576
49577 /*
49578 * Timer function to enforce the timelimit on the partition disengage.
49579diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
49580index a1b820f..e299c58 100644
49581--- a/drivers/mmc/card/block.c
49582+++ b/drivers/mmc/card/block.c
49583@@ -579,7 +579,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
49584 if (idata->ic.postsleep_min_us)
49585 usleep_range(idata->ic.postsleep_min_us, idata->ic.postsleep_max_us);
49586
49587- if (copy_to_user(&(ic_ptr->response), cmd.resp, sizeof(cmd.resp))) {
49588+ if (copy_to_user(ic_ptr->response, cmd.resp, sizeof(cmd.resp))) {
49589 err = -EFAULT;
49590 goto cmd_rel_host;
49591 }
49592diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
49593index 8ce4674..a23c858 100644
49594--- a/drivers/mmc/host/dw_mmc.h
49595+++ b/drivers/mmc/host/dw_mmc.h
49596@@ -286,5 +286,5 @@ struct dw_mci_drv_data {
49597 struct mmc_ios *ios);
49598 int (*switch_voltage)(struct mmc_host *mmc,
49599 struct mmc_ios *ios);
49600-};
49601+} __do_const;
49602 #endif /* _DW_MMC_H_ */
49603diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
49604index fb26674..3172c2b 100644
49605--- a/drivers/mmc/host/mmci.c
49606+++ b/drivers/mmc/host/mmci.c
49607@@ -1633,7 +1633,9 @@ static int mmci_probe(struct amba_device *dev,
49608 mmc->caps |= MMC_CAP_CMD23;
49609
49610 if (variant->busy_detect) {
49611- mmci_ops.card_busy = mmci_card_busy;
49612+ pax_open_kernel();
49613+ *(void **)&mmci_ops.card_busy = mmci_card_busy;
49614+ pax_close_kernel();
49615 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
49616 mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY;
49617 mmc->max_busy_timeout = 0;
49618diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
49619index 4d12032..2b0eb6d 100644
49620--- a/drivers/mmc/host/omap_hsmmc.c
49621+++ b/drivers/mmc/host/omap_hsmmc.c
49622@@ -1984,7 +1984,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
49623
49624 if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) {
49625 dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performance may suffer\n");
49626- omap_hsmmc_ops.multi_io_quirk = omap_hsmmc_multi_io_quirk;
49627+ pax_open_kernel();
49628+ *(void **)&omap_hsmmc_ops.multi_io_quirk = omap_hsmmc_multi_io_quirk;
49629+ pax_close_kernel();
49630 }
49631
49632 device_init_wakeup(&pdev->dev, true);
49633diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
49634index c6b9f64..00e656c 100644
49635--- a/drivers/mmc/host/sdhci-esdhc-imx.c
49636+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
49637@@ -1088,9 +1088,12 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
49638 host->ioaddr + 0x6c);
49639 }
49640
49641- if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING)
49642- sdhci_esdhc_ops.platform_execute_tuning =
49643+ if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
49644+ pax_open_kernel();
49645+ *(void **)&sdhci_esdhc_ops.platform_execute_tuning =
49646 esdhc_executing_tuning;
49647+ pax_close_kernel();
49648+ }
49649
49650 if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING)
49651 writel(readl(host->ioaddr + ESDHC_TUNING_CTRL) |
49652diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
49653index 70c724b..308aafc 100644
49654--- a/drivers/mmc/host/sdhci-s3c.c
49655+++ b/drivers/mmc/host/sdhci-s3c.c
49656@@ -598,9 +598,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
49657 * we can use overriding functions instead of default.
49658 */
49659 if (sc->no_divider) {
49660- sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
49661- sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
49662- sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
49663+ pax_open_kernel();
49664+ *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
49665+ *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
49666+ *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
49667+ pax_close_kernel();
49668 }
49669
49670 /* It supports additional host capabilities if needed */
49671diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
49672index 9a1a6ff..b8f1a57 100644
49673--- a/drivers/mtd/chips/cfi_cmdset_0020.c
49674+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
49675@@ -666,7 +666,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
49676 size_t totlen = 0, thislen;
49677 int ret = 0;
49678 size_t buflen = 0;
49679- static char *buffer;
49680+ char *buffer;
49681
49682 if (!ECCBUF_SIZE) {
49683 /* We should fall back to a general writev implementation.
49684diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
49685index 870c7fc..c7d6440 100644
49686--- a/drivers/mtd/nand/denali.c
49687+++ b/drivers/mtd/nand/denali.c
49688@@ -24,6 +24,7 @@
49689 #include <linux/slab.h>
49690 #include <linux/mtd/mtd.h>
49691 #include <linux/module.h>
49692+#include <linux/slab.h>
49693
49694 #include "denali.h"
49695
49696diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
49697index 1b8f350..990f2e9 100644
49698--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
49699+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
49700@@ -386,7 +386,7 @@ void prepare_data_dma(struct gpmi_nand_data *this, enum dma_data_direction dr)
49701
49702 /* first try to map the upper buffer directly */
49703 if (virt_addr_valid(this->upper_buf) &&
49704- !object_is_on_stack(this->upper_buf)) {
49705+ !object_starts_on_stack(this->upper_buf)) {
49706 sg_init_one(sgl, this->upper_buf, this->upper_len);
49707 ret = dma_map_sg(this->dev, sgl, 1, dr);
49708 if (ret == 0)
49709diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
49710index a5dfbfb..8042ab4 100644
49711--- a/drivers/mtd/nftlmount.c
49712+++ b/drivers/mtd/nftlmount.c
49713@@ -24,6 +24,7 @@
49714 #include <asm/errno.h>
49715 #include <linux/delay.h>
49716 #include <linux/slab.h>
49717+#include <linux/sched.h>
49718 #include <linux/mtd/mtd.h>
49719 #include <linux/mtd/nand.h>
49720 #include <linux/mtd/nftl.h>
49721diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
49722index c23184a..4115c41 100644
49723--- a/drivers/mtd/sm_ftl.c
49724+++ b/drivers/mtd/sm_ftl.c
49725@@ -56,7 +56,7 @@ static ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
49726 #define SM_CIS_VENDOR_OFFSET 0x59
49727 static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
49728 {
49729- struct attribute_group *attr_group;
49730+ attribute_group_no_const *attr_group;
49731 struct attribute **attributes;
49732 struct sm_sysfs_attribute *vendor_attribute;
49733 char *vendor;
49734diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
49735index 1bda292..3f4af40 100644
49736--- a/drivers/net/bonding/bond_netlink.c
49737+++ b/drivers/net/bonding/bond_netlink.c
49738@@ -649,7 +649,7 @@ nla_put_failure:
49739 return -EMSGSIZE;
49740 }
49741
49742-struct rtnl_link_ops bond_link_ops __read_mostly = {
49743+struct rtnl_link_ops bond_link_ops = {
49744 .kind = "bond",
49745 .priv_size = sizeof(struct bonding),
49746 .setup = bond_setup,
49747diff --git a/drivers/net/caif/caif_hsi.c b/drivers/net/caif/caif_hsi.c
49748index b3b922a..80bba38 100644
49749--- a/drivers/net/caif/caif_hsi.c
49750+++ b/drivers/net/caif/caif_hsi.c
49751@@ -1444,7 +1444,7 @@ err:
49752 return -ENODEV;
49753 }
49754
49755-static struct rtnl_link_ops caif_hsi_link_ops __read_mostly = {
49756+static struct rtnl_link_ops caif_hsi_link_ops = {
49757 .kind = "cfhsi",
49758 .priv_size = sizeof(struct cfhsi),
49759 .setup = cfhsi_setup,
49760diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
49761index e8c96b8..516a96c 100644
49762--- a/drivers/net/can/Kconfig
49763+++ b/drivers/net/can/Kconfig
49764@@ -98,7 +98,7 @@ config CAN_JANZ_ICAN3
49765
49766 config CAN_FLEXCAN
49767 tristate "Support for Freescale FLEXCAN based chips"
49768- depends on ARM || PPC
49769+ depends on (ARM && CPU_LITTLE_ENDIAN) || PPC
49770 ---help---
49771 Say Y here if you want to support for Freescale FlexCAN.
49772
49773diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
49774index aede704..b516b4d 100644
49775--- a/drivers/net/can/dev.c
49776+++ b/drivers/net/can/dev.c
49777@@ -961,7 +961,7 @@ static int can_newlink(struct net *src_net, struct net_device *dev,
49778 return -EOPNOTSUPP;
49779 }
49780
49781-static struct rtnl_link_ops can_link_ops __read_mostly = {
49782+static struct rtnl_link_ops can_link_ops = {
49783 .kind = "can",
49784 .maxtype = IFLA_CAN_MAX,
49785 .policy = can_policy,
49786diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c
49787index 674f367..ec3a31f 100644
49788--- a/drivers/net/can/vcan.c
49789+++ b/drivers/net/can/vcan.c
49790@@ -163,7 +163,7 @@ static void vcan_setup(struct net_device *dev)
49791 dev->destructor = free_netdev;
49792 }
49793
49794-static struct rtnl_link_ops vcan_link_ops __read_mostly = {
49795+static struct rtnl_link_ops vcan_link_ops = {
49796 .kind = "vcan",
49797 .setup = vcan_setup,
49798 };
49799diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
49800index 49adbf1..fff7ff8 100644
49801--- a/drivers/net/dummy.c
49802+++ b/drivers/net/dummy.c
49803@@ -164,7 +164,7 @@ static int dummy_validate(struct nlattr *tb[], struct nlattr *data[])
49804 return 0;
49805 }
49806
49807-static struct rtnl_link_ops dummy_link_ops __read_mostly = {
49808+static struct rtnl_link_ops dummy_link_ops = {
49809 .kind = DRV_NAME,
49810 .setup = dummy_setup,
49811 .validate = dummy_validate,
49812diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
49813index 0443654..4f0aa18 100644
49814--- a/drivers/net/ethernet/8390/ax88796.c
49815+++ b/drivers/net/ethernet/8390/ax88796.c
49816@@ -889,9 +889,11 @@ static int ax_probe(struct platform_device *pdev)
49817 if (ax->plat->reg_offsets)
49818 ei_local->reg_offset = ax->plat->reg_offsets;
49819 else {
49820+ resource_size_t _mem_size = mem_size;
49821+ do_div(_mem_size, 0x18);
49822 ei_local->reg_offset = ax->reg_offsets;
49823 for (ret = 0; ret < 0x18; ret++)
49824- ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
49825+ ax->reg_offsets[ret] = _mem_size * ret;
49826 }
49827
49828 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
49829diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
49830index 8207877..ce13e99 100644
49831--- a/drivers/net/ethernet/altera/altera_tse_main.c
49832+++ b/drivers/net/ethernet/altera/altera_tse_main.c
49833@@ -1255,7 +1255,7 @@ static int tse_shutdown(struct net_device *dev)
49834 return 0;
49835 }
49836
49837-static struct net_device_ops altera_tse_netdev_ops = {
49838+static net_device_ops_no_const altera_tse_netdev_ops __read_only = {
49839 .ndo_open = tse_open,
49840 .ndo_stop = tse_shutdown,
49841 .ndo_start_xmit = tse_start_xmit,
49842@@ -1492,11 +1492,13 @@ static int altera_tse_probe(struct platform_device *pdev)
49843 ndev->netdev_ops = &altera_tse_netdev_ops;
49844 altera_tse_set_ethtool_ops(ndev);
49845
49846+ pax_open_kernel();
49847 altera_tse_netdev_ops.ndo_set_rx_mode = tse_set_rx_mode;
49848
49849 if (priv->hash_filter)
49850 altera_tse_netdev_ops.ndo_set_rx_mode =
49851 tse_set_rx_mode_hashfilter;
49852+ pax_close_kernel();
49853
49854 /* Scatter/gather IO is not supported,
49855 * so it is turned off
49856diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-common.h b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
49857index b6fa891..31ef157 100644
49858--- a/drivers/net/ethernet/amd/xgbe/xgbe-common.h
49859+++ b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
49860@@ -1279,14 +1279,14 @@ do { \
49861 * operations, everything works on mask values.
49862 */
49863 #define XMDIO_READ(_pdata, _mmd, _reg) \
49864- ((_pdata)->hw_if.read_mmd_regs((_pdata), 0, \
49865+ ((_pdata)->hw_if->read_mmd_regs((_pdata), 0, \
49866 MII_ADDR_C45 | (_mmd << 16) | ((_reg) & 0xffff)))
49867
49868 #define XMDIO_READ_BITS(_pdata, _mmd, _reg, _mask) \
49869 (XMDIO_READ((_pdata), _mmd, _reg) & _mask)
49870
49871 #define XMDIO_WRITE(_pdata, _mmd, _reg, _val) \
49872- ((_pdata)->hw_if.write_mmd_regs((_pdata), 0, \
49873+ ((_pdata)->hw_if->write_mmd_regs((_pdata), 0, \
49874 MII_ADDR_C45 | (_mmd << 16) | ((_reg) & 0xffff), (_val)))
49875
49876 #define XMDIO_WRITE_BITS(_pdata, _mmd, _reg, _mask, _val) \
49877diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c b/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
49878index a6b9899..2e5e972 100644
49879--- a/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
49880+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
49881@@ -190,7 +190,7 @@ static int xgbe_dcb_ieee_setets(struct net_device *netdev,
49882
49883 memcpy(pdata->ets, ets, sizeof(*pdata->ets));
49884
49885- pdata->hw_if.config_dcb_tc(pdata);
49886+ pdata->hw_if->config_dcb_tc(pdata);
49887
49888 return 0;
49889 }
49890@@ -230,7 +230,7 @@ static int xgbe_dcb_ieee_setpfc(struct net_device *netdev,
49891
49892 memcpy(pdata->pfc, pfc, sizeof(*pdata->pfc));
49893
49894- pdata->hw_if.config_dcb_pfc(pdata);
49895+ pdata->hw_if->config_dcb_pfc(pdata);
49896
49897 return 0;
49898 }
49899diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
49900index b3bc87f..5bdfdd3 100644
49901--- a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
49902+++ b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
49903@@ -353,7 +353,7 @@ static int xgbe_map_rx_buffer(struct xgbe_prv_data *pdata,
49904
49905 static void xgbe_wrapper_tx_descriptor_init(struct xgbe_prv_data *pdata)
49906 {
49907- struct xgbe_hw_if *hw_if = &pdata->hw_if;
49908+ struct xgbe_hw_if *hw_if = pdata->hw_if;
49909 struct xgbe_channel *channel;
49910 struct xgbe_ring *ring;
49911 struct xgbe_ring_data *rdata;
49912@@ -394,7 +394,7 @@ static void xgbe_wrapper_tx_descriptor_init(struct xgbe_prv_data *pdata)
49913
49914 static void xgbe_wrapper_rx_descriptor_init(struct xgbe_prv_data *pdata)
49915 {
49916- struct xgbe_hw_if *hw_if = &pdata->hw_if;
49917+ struct xgbe_hw_if *hw_if = pdata->hw_if;
49918 struct xgbe_channel *channel;
49919 struct xgbe_ring *ring;
49920 struct xgbe_ring_desc *rdesc;
49921@@ -628,17 +628,12 @@ err_out:
49922 return 0;
49923 }
49924
49925-void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *desc_if)
49926-{
49927- DBGPR("-->xgbe_init_function_ptrs_desc\n");
49928-
49929- desc_if->alloc_ring_resources = xgbe_alloc_ring_resources;
49930- desc_if->free_ring_resources = xgbe_free_ring_resources;
49931- desc_if->map_tx_skb = xgbe_map_tx_skb;
49932- desc_if->map_rx_buffer = xgbe_map_rx_buffer;
49933- desc_if->unmap_rdata = xgbe_unmap_rdata;
49934- desc_if->wrapper_tx_desc_init = xgbe_wrapper_tx_descriptor_init;
49935- desc_if->wrapper_rx_desc_init = xgbe_wrapper_rx_descriptor_init;
49936-
49937- DBGPR("<--xgbe_init_function_ptrs_desc\n");
49938-}
49939+const struct xgbe_desc_if default_xgbe_desc_if = {
49940+ .alloc_ring_resources = xgbe_alloc_ring_resources,
49941+ .free_ring_resources = xgbe_free_ring_resources,
49942+ .map_tx_skb = xgbe_map_tx_skb,
49943+ .map_rx_buffer = xgbe_map_rx_buffer,
49944+ .unmap_rdata = xgbe_unmap_rdata,
49945+ .wrapper_tx_desc_init = xgbe_wrapper_tx_descriptor_init,
49946+ .wrapper_rx_desc_init = xgbe_wrapper_rx_descriptor_init,
49947+};
49948diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
49949index a4473d8..039a2ab 100644
49950--- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
49951+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
49952@@ -2776,7 +2776,7 @@ static void xgbe_powerdown_rx(struct xgbe_prv_data *pdata)
49953
49954 static int xgbe_init(struct xgbe_prv_data *pdata)
49955 {
49956- struct xgbe_desc_if *desc_if = &pdata->desc_if;
49957+ struct xgbe_desc_if *desc_if = pdata->desc_if;
49958 int ret;
49959
49960 DBGPR("-->xgbe_init\n");
49961@@ -2842,106 +2842,101 @@ static int xgbe_init(struct xgbe_prv_data *pdata)
49962 return 0;
49963 }
49964
49965-void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *hw_if)
49966-{
49967- DBGPR("-->xgbe_init_function_ptrs\n");
49968-
49969- hw_if->tx_complete = xgbe_tx_complete;
49970-
49971- hw_if->set_mac_address = xgbe_set_mac_address;
49972- hw_if->config_rx_mode = xgbe_config_rx_mode;
49973-
49974- hw_if->enable_rx_csum = xgbe_enable_rx_csum;
49975- hw_if->disable_rx_csum = xgbe_disable_rx_csum;
49976-
49977- hw_if->enable_rx_vlan_stripping = xgbe_enable_rx_vlan_stripping;
49978- hw_if->disable_rx_vlan_stripping = xgbe_disable_rx_vlan_stripping;
49979- hw_if->enable_rx_vlan_filtering = xgbe_enable_rx_vlan_filtering;
49980- hw_if->disable_rx_vlan_filtering = xgbe_disable_rx_vlan_filtering;
49981- hw_if->update_vlan_hash_table = xgbe_update_vlan_hash_table;
49982-
49983- hw_if->read_mmd_regs = xgbe_read_mmd_regs;
49984- hw_if->write_mmd_regs = xgbe_write_mmd_regs;
49985-
49986- hw_if->set_gmii_speed = xgbe_set_gmii_speed;
49987- hw_if->set_gmii_2500_speed = xgbe_set_gmii_2500_speed;
49988- hw_if->set_xgmii_speed = xgbe_set_xgmii_speed;
49989-
49990- hw_if->enable_tx = xgbe_enable_tx;
49991- hw_if->disable_tx = xgbe_disable_tx;
49992- hw_if->enable_rx = xgbe_enable_rx;
49993- hw_if->disable_rx = xgbe_disable_rx;
49994-
49995- hw_if->powerup_tx = xgbe_powerup_tx;
49996- hw_if->powerdown_tx = xgbe_powerdown_tx;
49997- hw_if->powerup_rx = xgbe_powerup_rx;
49998- hw_if->powerdown_rx = xgbe_powerdown_rx;
49999-
50000- hw_if->dev_xmit = xgbe_dev_xmit;
50001- hw_if->dev_read = xgbe_dev_read;
50002- hw_if->enable_int = xgbe_enable_int;
50003- hw_if->disable_int = xgbe_disable_int;
50004- hw_if->init = xgbe_init;
50005- hw_if->exit = xgbe_exit;
50006+const struct xgbe_hw_if default_xgbe_hw_if = {
50007+ .tx_complete = xgbe_tx_complete,
50008+
50009+ .set_mac_address = xgbe_set_mac_address,
50010+ .config_rx_mode = xgbe_config_rx_mode,
50011+
50012+ .enable_rx_csum = xgbe_enable_rx_csum,
50013+ .disable_rx_csum = xgbe_disable_rx_csum,
50014+
50015+ .enable_rx_vlan_stripping = xgbe_enable_rx_vlan_stripping,
50016+ .disable_rx_vlan_stripping = xgbe_disable_rx_vlan_stripping,
50017+ .enable_rx_vlan_filtering = xgbe_enable_rx_vlan_filtering,
50018+ .disable_rx_vlan_filtering = xgbe_disable_rx_vlan_filtering,
50019+ .update_vlan_hash_table = xgbe_update_vlan_hash_table,
50020+
50021+ .read_mmd_regs = xgbe_read_mmd_regs,
50022+ .write_mmd_regs = xgbe_write_mmd_regs,
50023+
50024+ .set_gmii_speed = xgbe_set_gmii_speed,
50025+ .set_gmii_2500_speed = xgbe_set_gmii_2500_speed,
50026+ .set_xgmii_speed = xgbe_set_xgmii_speed,
50027+
50028+ .enable_tx = xgbe_enable_tx,
50029+ .disable_tx = xgbe_disable_tx,
50030+ .enable_rx = xgbe_enable_rx,
50031+ .disable_rx = xgbe_disable_rx,
50032+
50033+ .powerup_tx = xgbe_powerup_tx,
50034+ .powerdown_tx = xgbe_powerdown_tx,
50035+ .powerup_rx = xgbe_powerup_rx,
50036+ .powerdown_rx = xgbe_powerdown_rx,
50037+
50038+ .dev_xmit = xgbe_dev_xmit,
50039+ .dev_read = xgbe_dev_read,
50040+ .enable_int = xgbe_enable_int,
50041+ .disable_int = xgbe_disable_int,
50042+ .init = xgbe_init,
50043+ .exit = xgbe_exit,
50044
50045 /* Descriptor related Sequences have to be initialized here */
50046- hw_if->tx_desc_init = xgbe_tx_desc_init;
50047- hw_if->rx_desc_init = xgbe_rx_desc_init;
50048- hw_if->tx_desc_reset = xgbe_tx_desc_reset;
50049- hw_if->rx_desc_reset = xgbe_rx_desc_reset;
50050- hw_if->is_last_desc = xgbe_is_last_desc;
50051- hw_if->is_context_desc = xgbe_is_context_desc;
50052- hw_if->tx_start_xmit = xgbe_tx_start_xmit;
50053+ .tx_desc_init = xgbe_tx_desc_init,
50054+ .rx_desc_init = xgbe_rx_desc_init,
50055+ .tx_desc_reset = xgbe_tx_desc_reset,
50056+ .rx_desc_reset = xgbe_rx_desc_reset,
50057+ .is_last_desc = xgbe_is_last_desc,
50058+ .is_context_desc = xgbe_is_context_desc,
50059+ .tx_start_xmit = xgbe_tx_start_xmit,
50060
50061 /* For FLOW ctrl */
50062- hw_if->config_tx_flow_control = xgbe_config_tx_flow_control;
50063- hw_if->config_rx_flow_control = xgbe_config_rx_flow_control;
50064+ .config_tx_flow_control = xgbe_config_tx_flow_control,
50065+ .config_rx_flow_control = xgbe_config_rx_flow_control,
50066
50067 /* For RX coalescing */
50068- hw_if->config_rx_coalesce = xgbe_config_rx_coalesce;
50069- hw_if->config_tx_coalesce = xgbe_config_tx_coalesce;
50070- hw_if->usec_to_riwt = xgbe_usec_to_riwt;
50071- hw_if->riwt_to_usec = xgbe_riwt_to_usec;
50072+ .config_rx_coalesce = xgbe_config_rx_coalesce,
50073+ .config_tx_coalesce = xgbe_config_tx_coalesce,
50074+ .usec_to_riwt = xgbe_usec_to_riwt,
50075+ .riwt_to_usec = xgbe_riwt_to_usec,
50076
50077 /* For RX and TX threshold config */
50078- hw_if->config_rx_threshold = xgbe_config_rx_threshold;
50079- hw_if->config_tx_threshold = xgbe_config_tx_threshold;
50080+ .config_rx_threshold = xgbe_config_rx_threshold,
50081+ .config_tx_threshold = xgbe_config_tx_threshold,
50082
50083 /* For RX and TX Store and Forward Mode config */
50084- hw_if->config_rsf_mode = xgbe_config_rsf_mode;
50085- hw_if->config_tsf_mode = xgbe_config_tsf_mode;
50086+ .config_rsf_mode = xgbe_config_rsf_mode,
50087+ .config_tsf_mode = xgbe_config_tsf_mode,
50088
50089 /* For TX DMA Operating on Second Frame config */
50090- hw_if->config_osp_mode = xgbe_config_osp_mode;
50091+ .config_osp_mode = xgbe_config_osp_mode,
50092
50093 /* For RX and TX PBL config */
50094- hw_if->config_rx_pbl_val = xgbe_config_rx_pbl_val;
50095- hw_if->get_rx_pbl_val = xgbe_get_rx_pbl_val;
50096- hw_if->config_tx_pbl_val = xgbe_config_tx_pbl_val;
50097- hw_if->get_tx_pbl_val = xgbe_get_tx_pbl_val;
50098- hw_if->config_pblx8 = xgbe_config_pblx8;
50099+ .config_rx_pbl_val = xgbe_config_rx_pbl_val,
50100+ .get_rx_pbl_val = xgbe_get_rx_pbl_val,
50101+ .config_tx_pbl_val = xgbe_config_tx_pbl_val,
50102+ .get_tx_pbl_val = xgbe_get_tx_pbl_val,
50103+ .config_pblx8 = xgbe_config_pblx8,
50104
50105 /* For MMC statistics support */
50106- hw_if->tx_mmc_int = xgbe_tx_mmc_int;
50107- hw_if->rx_mmc_int = xgbe_rx_mmc_int;
50108- hw_if->read_mmc_stats = xgbe_read_mmc_stats;
50109+ .tx_mmc_int = xgbe_tx_mmc_int,
50110+ .rx_mmc_int = xgbe_rx_mmc_int,
50111+ .read_mmc_stats = xgbe_read_mmc_stats,
50112
50113 /* For PTP config */
50114- hw_if->config_tstamp = xgbe_config_tstamp;
50115- hw_if->update_tstamp_addend = xgbe_update_tstamp_addend;
50116- hw_if->set_tstamp_time = xgbe_set_tstamp_time;
50117- hw_if->get_tstamp_time = xgbe_get_tstamp_time;
50118- hw_if->get_tx_tstamp = xgbe_get_tx_tstamp;
50119+ .config_tstamp = xgbe_config_tstamp,
50120+ .update_tstamp_addend = xgbe_update_tstamp_addend,
50121+ .set_tstamp_time = xgbe_set_tstamp_time,
50122+ .get_tstamp_time = xgbe_get_tstamp_time,
50123+ .get_tx_tstamp = xgbe_get_tx_tstamp,
50124
50125 /* For Data Center Bridging config */
50126- hw_if->config_dcb_tc = xgbe_config_dcb_tc;
50127- hw_if->config_dcb_pfc = xgbe_config_dcb_pfc;
50128+ .config_dcb_tc = xgbe_config_dcb_tc,
50129+ .config_dcb_pfc = xgbe_config_dcb_pfc,
50130
50131 /* For Receive Side Scaling */
50132- hw_if->enable_rss = xgbe_enable_rss;
50133- hw_if->disable_rss = xgbe_disable_rss;
50134- hw_if->set_rss_hash_key = xgbe_set_rss_hash_key;
50135- hw_if->set_rss_lookup_table = xgbe_set_rss_lookup_table;
50136-
50137- DBGPR("<--xgbe_init_function_ptrs\n");
50138-}
50139+ .enable_rss = xgbe_enable_rss,
50140+ .disable_rss = xgbe_disable_rss,
50141+ .set_rss_hash_key = xgbe_set_rss_hash_key,
50142+ .set_rss_lookup_table = xgbe_set_rss_lookup_table,
50143+};
50144diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
50145index aae9d5e..29ce58d 100644
50146--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
50147+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
50148@@ -245,7 +245,7 @@ static int xgbe_maybe_stop_tx_queue(struct xgbe_channel *channel,
50149 * support, tell it now
50150 */
50151 if (ring->tx.xmit_more)
50152- pdata->hw_if.tx_start_xmit(channel, ring);
50153+ pdata->hw_if->tx_start_xmit(channel, ring);
50154
50155 return NETDEV_TX_BUSY;
50156 }
50157@@ -273,7 +273,7 @@ static int xgbe_calc_rx_buf_size(struct net_device *netdev, unsigned int mtu)
50158
50159 static void xgbe_enable_rx_tx_ints(struct xgbe_prv_data *pdata)
50160 {
50161- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50162+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50163 struct xgbe_channel *channel;
50164 enum xgbe_int int_id;
50165 unsigned int i;
50166@@ -295,7 +295,7 @@ static void xgbe_enable_rx_tx_ints(struct xgbe_prv_data *pdata)
50167
50168 static void xgbe_disable_rx_tx_ints(struct xgbe_prv_data *pdata)
50169 {
50170- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50171+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50172 struct xgbe_channel *channel;
50173 enum xgbe_int int_id;
50174 unsigned int i;
50175@@ -318,7 +318,7 @@ static void xgbe_disable_rx_tx_ints(struct xgbe_prv_data *pdata)
50176 static irqreturn_t xgbe_isr(int irq, void *data)
50177 {
50178 struct xgbe_prv_data *pdata = data;
50179- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50180+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50181 struct xgbe_channel *channel;
50182 unsigned int dma_isr, dma_ch_isr;
50183 unsigned int mac_isr, mac_tssr;
50184@@ -443,7 +443,7 @@ static void xgbe_service(struct work_struct *work)
50185 struct xgbe_prv_data,
50186 service_work);
50187
50188- pdata->phy_if.phy_status(pdata);
50189+ pdata->phy_if->phy_status(pdata);
50190 }
50191
50192 static void xgbe_service_timer(unsigned long data)
50193@@ -702,7 +702,7 @@ static void xgbe_free_irqs(struct xgbe_prv_data *pdata)
50194
50195 void xgbe_init_tx_coalesce(struct xgbe_prv_data *pdata)
50196 {
50197- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50198+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50199
50200 DBGPR("-->xgbe_init_tx_coalesce\n");
50201
50202@@ -716,7 +716,7 @@ void xgbe_init_tx_coalesce(struct xgbe_prv_data *pdata)
50203
50204 void xgbe_init_rx_coalesce(struct xgbe_prv_data *pdata)
50205 {
50206- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50207+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50208
50209 DBGPR("-->xgbe_init_rx_coalesce\n");
50210
50211@@ -731,7 +731,7 @@ void xgbe_init_rx_coalesce(struct xgbe_prv_data *pdata)
50212
50213 static void xgbe_free_tx_data(struct xgbe_prv_data *pdata)
50214 {
50215- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50216+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50217 struct xgbe_channel *channel;
50218 struct xgbe_ring *ring;
50219 struct xgbe_ring_data *rdata;
50220@@ -756,7 +756,7 @@ static void xgbe_free_tx_data(struct xgbe_prv_data *pdata)
50221
50222 static void xgbe_free_rx_data(struct xgbe_prv_data *pdata)
50223 {
50224- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50225+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50226 struct xgbe_channel *channel;
50227 struct xgbe_ring *ring;
50228 struct xgbe_ring_data *rdata;
50229@@ -784,13 +784,13 @@ static int xgbe_phy_init(struct xgbe_prv_data *pdata)
50230 pdata->phy_link = -1;
50231 pdata->phy_speed = SPEED_UNKNOWN;
50232
50233- return pdata->phy_if.phy_reset(pdata);
50234+ return pdata->phy_if->phy_reset(pdata);
50235 }
50236
50237 int xgbe_powerdown(struct net_device *netdev, unsigned int caller)
50238 {
50239 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50240- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50241+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50242 unsigned long flags;
50243
50244 DBGPR("-->xgbe_powerdown\n");
50245@@ -829,7 +829,7 @@ int xgbe_powerdown(struct net_device *netdev, unsigned int caller)
50246 int xgbe_powerup(struct net_device *netdev, unsigned int caller)
50247 {
50248 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50249- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50250+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50251 unsigned long flags;
50252
50253 DBGPR("-->xgbe_powerup\n");
50254@@ -866,8 +866,8 @@ int xgbe_powerup(struct net_device *netdev, unsigned int caller)
50255
50256 static int xgbe_start(struct xgbe_prv_data *pdata)
50257 {
50258- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50259- struct xgbe_phy_if *phy_if = &pdata->phy_if;
50260+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50261+ struct xgbe_phy_if *phy_if = pdata->phy_if;
50262 struct net_device *netdev = pdata->netdev;
50263 int ret;
50264
50265@@ -910,8 +910,8 @@ err_phy:
50266
50267 static void xgbe_stop(struct xgbe_prv_data *pdata)
50268 {
50269- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50270- struct xgbe_phy_if *phy_if = &pdata->phy_if;
50271+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50272+ struct xgbe_phy_if *phy_if = pdata->phy_if;
50273 struct xgbe_channel *channel;
50274 struct net_device *netdev = pdata->netdev;
50275 struct netdev_queue *txq;
50276@@ -1139,7 +1139,7 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,
50277 return -ERANGE;
50278 }
50279
50280- pdata->hw_if.config_tstamp(pdata, mac_tscr);
50281+ pdata->hw_if->config_tstamp(pdata, mac_tscr);
50282
50283 memcpy(&pdata->tstamp_config, &config, sizeof(config));
50284
50285@@ -1288,7 +1288,7 @@ static void xgbe_packet_info(struct xgbe_prv_data *pdata,
50286 static int xgbe_open(struct net_device *netdev)
50287 {
50288 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50289- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50290+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50291 int ret;
50292
50293 DBGPR("-->xgbe_open\n");
50294@@ -1360,7 +1360,7 @@ err_sysclk:
50295 static int xgbe_close(struct net_device *netdev)
50296 {
50297 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50298- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50299+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50300
50301 DBGPR("-->xgbe_close\n");
50302
50303@@ -1387,8 +1387,8 @@ static int xgbe_close(struct net_device *netdev)
50304 static int xgbe_xmit(struct sk_buff *skb, struct net_device *netdev)
50305 {
50306 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50307- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50308- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50309+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50310+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50311 struct xgbe_channel *channel;
50312 struct xgbe_ring *ring;
50313 struct xgbe_packet_data *packet;
50314@@ -1457,7 +1457,7 @@ tx_netdev_return:
50315 static void xgbe_set_rx_mode(struct net_device *netdev)
50316 {
50317 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50318- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50319+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50320
50321 DBGPR("-->xgbe_set_rx_mode\n");
50322
50323@@ -1469,7 +1469,7 @@ static void xgbe_set_rx_mode(struct net_device *netdev)
50324 static int xgbe_set_mac_address(struct net_device *netdev, void *addr)
50325 {
50326 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50327- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50328+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50329 struct sockaddr *saddr = addr;
50330
50331 DBGPR("-->xgbe_set_mac_address\n");
50332@@ -1544,7 +1544,7 @@ static struct rtnl_link_stats64 *xgbe_get_stats64(struct net_device *netdev,
50333
50334 DBGPR("-->%s\n", __func__);
50335
50336- pdata->hw_if.read_mmc_stats(pdata);
50337+ pdata->hw_if->read_mmc_stats(pdata);
50338
50339 s->rx_packets = pstats->rxframecount_gb;
50340 s->rx_bytes = pstats->rxoctetcount_gb;
50341@@ -1571,7 +1571,7 @@ static int xgbe_vlan_rx_add_vid(struct net_device *netdev, __be16 proto,
50342 u16 vid)
50343 {
50344 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50345- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50346+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50347
50348 DBGPR("-->%s\n", __func__);
50349
50350@@ -1587,7 +1587,7 @@ static int xgbe_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto,
50351 u16 vid)
50352 {
50353 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50354- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50355+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50356
50357 DBGPR("-->%s\n", __func__);
50358
50359@@ -1654,7 +1654,7 @@ static int xgbe_set_features(struct net_device *netdev,
50360 netdev_features_t features)
50361 {
50362 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50363- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50364+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50365 netdev_features_t rxhash, rxcsum, rxvlan, rxvlan_filter;
50366 int ret = 0;
50367
50368@@ -1720,8 +1720,8 @@ struct net_device_ops *xgbe_get_netdev_ops(void)
50369 static void xgbe_rx_refresh(struct xgbe_channel *channel)
50370 {
50371 struct xgbe_prv_data *pdata = channel->pdata;
50372- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50373- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50374+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50375+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50376 struct xgbe_ring *ring = channel->rx_ring;
50377 struct xgbe_ring_data *rdata;
50378
50379@@ -1798,8 +1798,8 @@ static struct sk_buff *xgbe_create_skb(struct xgbe_prv_data *pdata,
50380 static int xgbe_tx_poll(struct xgbe_channel *channel)
50381 {
50382 struct xgbe_prv_data *pdata = channel->pdata;
50383- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50384- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50385+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50386+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50387 struct xgbe_ring *ring = channel->tx_ring;
50388 struct xgbe_ring_data *rdata;
50389 struct xgbe_ring_desc *rdesc;
50390@@ -1863,7 +1863,7 @@ static int xgbe_tx_poll(struct xgbe_channel *channel)
50391 static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
50392 {
50393 struct xgbe_prv_data *pdata = channel->pdata;
50394- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50395+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50396 struct xgbe_ring *ring = channel->rx_ring;
50397 struct xgbe_ring_data *rdata;
50398 struct xgbe_packet_data *packet;
50399diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
50400index 59e090e..90bc0b4 100644
50401--- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
50402+++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
50403@@ -211,7 +211,7 @@ static void xgbe_get_ethtool_stats(struct net_device *netdev,
50404
50405 DBGPR("-->%s\n", __func__);
50406
50407- pdata->hw_if.read_mmc_stats(pdata);
50408+ pdata->hw_if->read_mmc_stats(pdata);
50409 for (i = 0; i < XGBE_STATS_COUNT; i++) {
50410 stat = (u8 *)pdata + xgbe_gstring_stats[i].stat_offset;
50411 *data++ = *(u64 *)stat;
50412@@ -284,7 +284,7 @@ static int xgbe_set_pauseparam(struct net_device *netdev,
50413 pdata->phy.advertising ^= ADVERTISED_Asym_Pause;
50414
50415 if (netif_running(netdev))
50416- ret = pdata->phy_if.phy_config_aneg(pdata);
50417+ ret = pdata->phy_if->phy_config_aneg(pdata);
50418
50419 DBGPR("<--xgbe_set_pauseparam\n");
50420
50421@@ -364,7 +364,7 @@ static int xgbe_set_settings(struct net_device *netdev,
50422 pdata->phy.advertising &= ~ADVERTISED_Autoneg;
50423
50424 if (netif_running(netdev))
50425- ret = pdata->phy_if.phy_config_aneg(pdata);
50426+ ret = pdata->phy_if->phy_config_aneg(pdata);
50427
50428 DBGPR("<--xgbe_set_settings\n");
50429
50430@@ -411,7 +411,7 @@ static int xgbe_set_coalesce(struct net_device *netdev,
50431 struct ethtool_coalesce *ec)
50432 {
50433 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50434- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50435+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50436 unsigned int rx_frames, rx_riwt, rx_usecs;
50437 unsigned int tx_frames;
50438
50439@@ -536,7 +536,7 @@ static int xgbe_set_rxfh(struct net_device *netdev, const u32 *indir,
50440 const u8 *key, const u8 hfunc)
50441 {
50442 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50443- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50444+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50445 unsigned int ret;
50446
50447 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
50448diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
50449index e83bd76..f2d5d56 100644
50450--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
50451+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
50452@@ -202,13 +202,6 @@ static void xgbe_default_config(struct xgbe_prv_data *pdata)
50453 DBGPR("<--xgbe_default_config\n");
50454 }
50455
50456-static void xgbe_init_all_fptrs(struct xgbe_prv_data *pdata)
50457-{
50458- xgbe_init_function_ptrs_dev(&pdata->hw_if);
50459- xgbe_init_function_ptrs_phy(&pdata->phy_if);
50460- xgbe_init_function_ptrs_desc(&pdata->desc_if);
50461-}
50462-
50463 #ifdef CONFIG_ACPI
50464 static int xgbe_acpi_support(struct xgbe_prv_data *pdata)
50465 {
50466@@ -641,10 +634,12 @@ static int xgbe_probe(struct platform_device *pdev)
50467 memcpy(netdev->dev_addr, pdata->mac_addr, netdev->addr_len);
50468
50469 /* Set all the function pointers */
50470- xgbe_init_all_fptrs(pdata);
50471+ pdata->hw_if = &default_xgbe_hw_if;
50472+ pdata->phy_if = &default_xgbe_phy_if;
50473+ pdata->desc_if = &default_xgbe_desc_if;
50474
50475 /* Issue software reset to device */
50476- pdata->hw_if.exit(pdata);
50477+ pdata->hw_if->exit(pdata);
50478
50479 /* Populate the hardware features */
50480 xgbe_get_all_hw_features(pdata);
50481@@ -698,7 +693,7 @@ static int xgbe_probe(struct platform_device *pdev)
50482 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, UDP4TE, 1);
50483
50484 /* Call MDIO/PHY initialization routine */
50485- pdata->phy_if.phy_init(pdata);
50486+ pdata->phy_if->phy_init(pdata);
50487
50488 /* Set device operations */
50489 netdev->netdev_ops = xgbe_get_netdev_ops();
50490diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
50491index 9088c3a..2ffe7c4 100644
50492--- a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
50493+++ b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
50494@@ -202,7 +202,7 @@ static void xgbe_xgmii_mode(struct xgbe_prv_data *pdata)
50495 xgbe_an_enable_kr_training(pdata);
50496
50497 /* Set MAC to 10G speed */
50498- pdata->hw_if.set_xgmii_speed(pdata);
50499+ pdata->hw_if->set_xgmii_speed(pdata);
50500
50501 /* Set PCS to KR/10G speed */
50502 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_CTRL2);
50503@@ -250,7 +250,7 @@ static void xgbe_gmii_2500_mode(struct xgbe_prv_data *pdata)
50504 xgbe_an_disable_kr_training(pdata);
50505
50506 /* Set MAC to 2.5G speed */
50507- pdata->hw_if.set_gmii_2500_speed(pdata);
50508+ pdata->hw_if->set_gmii_2500_speed(pdata);
50509
50510 /* Set PCS to KX/1G speed */
50511 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_CTRL2);
50512@@ -298,7 +298,7 @@ static void xgbe_gmii_mode(struct xgbe_prv_data *pdata)
50513 xgbe_an_disable_kr_training(pdata);
50514
50515 /* Set MAC to 1G speed */
50516- pdata->hw_if.set_gmii_speed(pdata);
50517+ pdata->hw_if->set_gmii_speed(pdata);
50518
50519 /* Set PCS to KX/1G speed */
50520 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_CTRL2);
50521@@ -872,13 +872,13 @@ static void xgbe_phy_adjust_link(struct xgbe_prv_data *pdata)
50522
50523 if (pdata->tx_pause != pdata->phy.tx_pause) {
50524 new_state = 1;
50525- pdata->hw_if.config_tx_flow_control(pdata);
50526+ pdata->hw_if->config_tx_flow_control(pdata);
50527 pdata->tx_pause = pdata->phy.tx_pause;
50528 }
50529
50530 if (pdata->rx_pause != pdata->phy.rx_pause) {
50531 new_state = 1;
50532- pdata->hw_if.config_rx_flow_control(pdata);
50533+ pdata->hw_if->config_rx_flow_control(pdata);
50534 pdata->rx_pause = pdata->phy.rx_pause;
50535 }
50536
50537@@ -1351,14 +1351,13 @@ static void xgbe_phy_init(struct xgbe_prv_data *pdata)
50538 xgbe_dump_phy_registers(pdata);
50539 }
50540
50541-void xgbe_init_function_ptrs_phy(struct xgbe_phy_if *phy_if)
50542-{
50543- phy_if->phy_init = xgbe_phy_init;
50544+const struct xgbe_phy_if default_xgbe_phy_if = {
50545+ .phy_init = xgbe_phy_init,
50546
50547- phy_if->phy_reset = xgbe_phy_reset;
50548- phy_if->phy_start = xgbe_phy_start;
50549- phy_if->phy_stop = xgbe_phy_stop;
50550+ .phy_reset = xgbe_phy_reset,
50551+ .phy_start = xgbe_phy_start,
50552+ .phy_stop = xgbe_phy_stop,
50553
50554- phy_if->phy_status = xgbe_phy_status;
50555- phy_if->phy_config_aneg = xgbe_phy_config_aneg;
50556-}
50557+ .phy_status = xgbe_phy_status,
50558+ .phy_config_aneg = xgbe_phy_config_aneg,
50559+};
50560diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
50561index b03e4f5..78e4cc4 100644
50562--- a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
50563+++ b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
50564@@ -129,7 +129,7 @@ static cycle_t xgbe_cc_read(const struct cyclecounter *cc)
50565 tstamp_cc);
50566 u64 nsec;
50567
50568- nsec = pdata->hw_if.get_tstamp_time(pdata);
50569+ nsec = pdata->hw_if->get_tstamp_time(pdata);
50570
50571 return nsec;
50572 }
50573@@ -158,7 +158,7 @@ static int xgbe_adjfreq(struct ptp_clock_info *info, s32 delta)
50574
50575 spin_lock_irqsave(&pdata->tstamp_lock, flags);
50576
50577- pdata->hw_if.update_tstamp_addend(pdata, addend);
50578+ pdata->hw_if->update_tstamp_addend(pdata, addend);
50579
50580 spin_unlock_irqrestore(&pdata->tstamp_lock, flags);
50581
50582diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
50583index 717ce21..aacd1f3 100644
50584--- a/drivers/net/ethernet/amd/xgbe/xgbe.h
50585+++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
50586@@ -801,9 +801,9 @@ struct xgbe_prv_data {
50587 int dev_irq;
50588 unsigned int per_channel_irq;
50589
50590- struct xgbe_hw_if hw_if;
50591- struct xgbe_phy_if phy_if;
50592- struct xgbe_desc_if desc_if;
50593+ struct xgbe_hw_if *hw_if;
50594+ struct xgbe_phy_if *phy_if;
50595+ struct xgbe_desc_if *desc_if;
50596
50597 /* AXI DMA settings */
50598 unsigned int coherent;
50599@@ -964,6 +964,10 @@ struct xgbe_prv_data {
50600 #endif
50601 };
50602
50603+extern const struct xgbe_hw_if default_xgbe_hw_if;
50604+extern const struct xgbe_phy_if default_xgbe_phy_if;
50605+extern const struct xgbe_desc_if default_xgbe_desc_if;
50606+
50607 /* Function prototypes*/
50608
50609 void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *);
50610diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
50611index 03b7404..01ff3b3 100644
50612--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
50613+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
50614@@ -1082,7 +1082,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
50615 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
50616 {
50617 /* RX_MODE controlling object */
50618- bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
50619+ bnx2x_init_rx_mode_obj(bp);
50620
50621 /* multicast configuration controlling object */
50622 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
50623diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
50624index 4ad415a..8e0a040 100644
50625--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
50626+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
50627@@ -2329,15 +2329,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
50628 return rc;
50629 }
50630
50631-void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
50632- struct bnx2x_rx_mode_obj *o)
50633+void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
50634 {
50635 if (CHIP_IS_E1x(bp)) {
50636- o->wait_comp = bnx2x_empty_rx_mode_wait;
50637- o->config_rx_mode = bnx2x_set_rx_mode_e1x;
50638+ bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
50639+ bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
50640 } else {
50641- o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
50642- o->config_rx_mode = bnx2x_set_rx_mode_e2;
50643+ bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
50644+ bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
50645 }
50646 }
50647
50648diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
50649index 86baecb..ff3bb46 100644
50650--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
50651+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
50652@@ -1411,8 +1411,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
50653
50654 /********************* RX MODE ****************/
50655
50656-void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
50657- struct bnx2x_rx_mode_obj *o);
50658+void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
50659
50660 /**
50661 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
50662diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
50663index 31c9f82..e65e986 100644
50664--- a/drivers/net/ethernet/broadcom/tg3.h
50665+++ b/drivers/net/ethernet/broadcom/tg3.h
50666@@ -150,6 +150,7 @@
50667 #define CHIPREV_ID_5750_A0 0x4000
50668 #define CHIPREV_ID_5750_A1 0x4001
50669 #define CHIPREV_ID_5750_A3 0x4003
50670+#define CHIPREV_ID_5750_C1 0x4201
50671 #define CHIPREV_ID_5750_C2 0x4202
50672 #define CHIPREV_ID_5752_A0_HW 0x5000
50673 #define CHIPREV_ID_5752_A0 0x6000
50674diff --git a/drivers/net/ethernet/brocade/bna/bna_enet.c b/drivers/net/ethernet/brocade/bna/bna_enet.c
50675index 4e5c387..bba8173 100644
50676--- a/drivers/net/ethernet/brocade/bna/bna_enet.c
50677+++ b/drivers/net/ethernet/brocade/bna/bna_enet.c
50678@@ -1676,10 +1676,10 @@ bna_cb_ioceth_reset(void *arg)
50679 }
50680
50681 static struct bfa_ioc_cbfn bna_ioceth_cbfn = {
50682- bna_cb_ioceth_enable,
50683- bna_cb_ioceth_disable,
50684- bna_cb_ioceth_hbfail,
50685- bna_cb_ioceth_reset
50686+ .enable_cbfn = bna_cb_ioceth_enable,
50687+ .disable_cbfn = bna_cb_ioceth_disable,
50688+ .hbfail_cbfn = bna_cb_ioceth_hbfail,
50689+ .reset_cbfn = bna_cb_ioceth_reset
50690 };
50691
50692 static void bna_attr_init(struct bna_ioceth *ioceth)
50693diff --git a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
50694index 29f3308..b594c38 100644
50695--- a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
50696+++ b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
50697@@ -265,9 +265,9 @@ static void octnet_mdio_resp_callback(struct octeon_device *oct,
50698 if (status) {
50699 dev_err(&oct->pci_dev->dev, "MIDO instruction failed. Status: %llx\n",
50700 CVM_CAST64(status));
50701- ACCESS_ONCE(mdio_cmd_ctx->cond) = -1;
50702+ ACCESS_ONCE_RW(mdio_cmd_ctx->cond) = -1;
50703 } else {
50704- ACCESS_ONCE(mdio_cmd_ctx->cond) = 1;
50705+ ACCESS_ONCE_RW(mdio_cmd_ctx->cond) = 1;
50706 }
50707 wake_up_interruptible(&mdio_cmd_ctx->wc);
50708 }
50709@@ -298,7 +298,7 @@ octnet_mdio45_access(struct lio *lio, int op, int loc, int *value)
50710 mdio_cmd_rsp = (struct oct_mdio_cmd_resp *)sc->virtrptr;
50711 mdio_cmd = (struct oct_mdio_cmd *)sc->virtdptr;
50712
50713- ACCESS_ONCE(mdio_cmd_ctx->cond) = 0;
50714+ ACCESS_ONCE_RW(mdio_cmd_ctx->cond) = 0;
50715 mdio_cmd_ctx->octeon_id = lio_get_device_id(oct_dev);
50716 mdio_cmd->op = op;
50717 mdio_cmd->mdio_addr = loc;
50718diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
50719index 0660dee..e07895e 100644
50720--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
50721+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
50722@@ -1727,7 +1727,7 @@ static void if_cfg_callback(struct octeon_device *oct,
50723 if (resp->status)
50724 dev_err(&oct->pci_dev->dev, "nic if cfg instruction failed. Status: %llx\n",
50725 CVM_CAST64(resp->status));
50726- ACCESS_ONCE(ctx->cond) = 1;
50727+ ACCESS_ONCE_RW(ctx->cond) = 1;
50728
50729 /* This barrier is required to be sure that the response has been
50730 * written fully before waking up the handler
50731@@ -3177,7 +3177,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
50732 dev_dbg(&octeon_dev->pci_dev->dev,
50733 "requesting config for interface %d, iqs %d, oqs %d\n",
50734 i, num_iqueues, num_oqueues);
50735- ACCESS_ONCE(ctx->cond) = 0;
50736+ ACCESS_ONCE_RW(ctx->cond) = 0;
50737 ctx->octeon_id = lio_get_device_id(octeon_dev);
50738 init_waitqueue_head(&ctx->wc);
50739
50740@@ -3240,8 +3240,11 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
50741 props = &octeon_dev->props[i];
50742 props->netdev = netdev;
50743
50744- if (num_iqueues > 1)
50745- lionetdevops.ndo_select_queue = select_q;
50746+ if (num_iqueues > 1) {
50747+ pax_open_kernel();
50748+ *(void **)&lionetdevops.ndo_select_queue = select_q;
50749+ pax_close_kernel();
50750+ }
50751
50752 /* Associate the routines that will handle different
50753 * netdev tasks.
50754diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
50755index 8cffcdf..aadf043 100644
50756--- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
50757+++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
50758@@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
50759 */
50760 struct l2t_skb_cb {
50761 arp_failure_handler_func arp_failure_handler;
50762-};
50763+} __no_const;
50764
50765 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
50766
50767diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
50768index 8966f31..e15a101 100644
50769--- a/drivers/net/ethernet/dec/tulip/de4x5.c
50770+++ b/drivers/net/ethernet/dec/tulip/de4x5.c
50771@@ -5373,7 +5373,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
50772 for (i=0; i<ETH_ALEN; i++) {
50773 tmp.addr[i] = dev->dev_addr[i];
50774 }
50775- if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
50776+ if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
50777 break;
50778
50779 case DE4X5_SET_HWADDR: /* Set the hardware address */
50780@@ -5413,7 +5413,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
50781 spin_lock_irqsave(&lp->lock, flags);
50782 memcpy(&statbuf, &lp->pktStats, ioc->len);
50783 spin_unlock_irqrestore(&lp->lock, flags);
50784- if (copy_to_user(ioc->data, &statbuf, ioc->len))
50785+ if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
50786 return -EFAULT;
50787 break;
50788 }
50789diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
50790index 6ca693b..fa18c3f 100644
50791--- a/drivers/net/ethernet/emulex/benet/be_main.c
50792+++ b/drivers/net/ethernet/emulex/benet/be_main.c
50793@@ -551,7 +551,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
50794
50795 if (wrapped)
50796 newacc += 65536;
50797- ACCESS_ONCE(*acc) = newacc;
50798+ ACCESS_ONCE_RW(*acc) = newacc;
50799 }
50800
50801 static void populate_erx_stats(struct be_adapter *adapter,
50802diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
50803index 6d0c5d5..55be363 100644
50804--- a/drivers/net/ethernet/faraday/ftgmac100.c
50805+++ b/drivers/net/ethernet/faraday/ftgmac100.c
50806@@ -30,6 +30,8 @@
50807 #include <linux/netdevice.h>
50808 #include <linux/phy.h>
50809 #include <linux/platform_device.h>
50810+#include <linux/interrupt.h>
50811+#include <linux/irqreturn.h>
50812 #include <net/ip.h>
50813
50814 #include "ftgmac100.h"
50815diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
50816index dce5f7b..2433466 100644
50817--- a/drivers/net/ethernet/faraday/ftmac100.c
50818+++ b/drivers/net/ethernet/faraday/ftmac100.c
50819@@ -31,6 +31,8 @@
50820 #include <linux/module.h>
50821 #include <linux/netdevice.h>
50822 #include <linux/platform_device.h>
50823+#include <linux/interrupt.h>
50824+#include <linux/irqreturn.h>
50825
50826 #include "ftmac100.h"
50827
50828diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
50829index a92b772..250fe69 100644
50830--- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
50831+++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
50832@@ -419,7 +419,7 @@ void i40e_ptp_set_increment(struct i40e_pf *pf)
50833 wr32(hw, I40E_PRTTSYN_INC_H, incval >> 32);
50834
50835 /* Update the base adjustement value. */
50836- ACCESS_ONCE(pf->ptp_base_adj) = incval;
50837+ ACCESS_ONCE_RW(pf->ptp_base_adj) = incval;
50838 smp_mb(); /* Force the above update. */
50839 }
50840
50841diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
50842index e5ba040..d47531c 100644
50843--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
50844+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
50845@@ -782,7 +782,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
50846 }
50847
50848 /* update the base incval used to calculate frequency adjustment */
50849- ACCESS_ONCE(adapter->base_incval) = incval;
50850+ ACCESS_ONCE_RW(adapter->base_incval) = incval;
50851 smp_mb();
50852
50853 /* need lock to prevent incorrect read while modifying cyclecounter */
50854diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
50855index c10d98f..72914c6 100644
50856--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
50857+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
50858@@ -475,8 +475,8 @@ static bool mlx4_en_process_tx_cq(struct net_device *dev,
50859 wmb();
50860
50861 /* we want to dirty this cache line once */
50862- ACCESS_ONCE(ring->last_nr_txbb) = last_nr_txbb;
50863- ACCESS_ONCE(ring->cons) = ring_cons + txbbs_skipped;
50864+ ACCESS_ONCE_RW(ring->last_nr_txbb) = last_nr_txbb;
50865+ ACCESS_ONCE_RW(ring->cons) = ring_cons + txbbs_skipped;
50866
50867 netdev_tx_completed_queue(ring->tx_queue, packets, bytes);
50868
50869diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
50870index 40206da..9d94643 100644
50871--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
50872+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
50873@@ -1734,7 +1734,9 @@ static void mlx5e_build_netdev(struct net_device *netdev)
50874 SET_NETDEV_DEV(netdev, &mdev->pdev->dev);
50875
50876 if (priv->num_tc > 1) {
50877- mlx5e_netdev_ops.ndo_select_queue = mlx5e_select_queue;
50878+ pax_open_kernel();
50879+ *(void **)&mlx5e_netdev_ops.ndo_select_queue = mlx5e_select_queue;
50880+ pax_close_kernel();
50881 }
50882
50883 netdev->netdev_ops = &mlx5e_netdev_ops;
50884diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
50885index 6223930..975033d 100644
50886--- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
50887+++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
50888@@ -3457,7 +3457,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
50889 struct __vxge_hw_fifo *fifo;
50890 struct vxge_hw_fifo_config *config;
50891 u32 txdl_size, txdl_per_memblock;
50892- struct vxge_hw_mempool_cbs fifo_mp_callback;
50893+ static struct vxge_hw_mempool_cbs fifo_mp_callback = {
50894+ .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
50895+ };
50896+
50897 struct __vxge_hw_virtualpath *vpath;
50898
50899 if ((vp == NULL) || (attr == NULL)) {
50900@@ -3540,8 +3543,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
50901 goto exit;
50902 }
50903
50904- fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
50905-
50906 fifo->mempool =
50907 __vxge_hw_mempool_create(vpath->hldev,
50908 fifo->config->memblock_size,
50909diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
50910index 753ea8b..674c39a 100644
50911--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
50912+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
50913@@ -2324,7 +2324,9 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
50914 max_tx_rings = QLCNIC_MAX_VNIC_TX_RINGS;
50915 } else if (ret == QLC_83XX_DEFAULT_OPMODE) {
50916 ahw->nic_mode = QLCNIC_DEFAULT_MODE;
50917- adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
50918+ pax_open_kernel();
50919+ *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
50920+ pax_close_kernel();
50921 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
50922 max_sds_rings = QLCNIC_MAX_SDS_RINGS;
50923 max_tx_rings = QLCNIC_MAX_TX_RINGS;
50924diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
50925index be7d7a6..a8983f8 100644
50926--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
50927+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
50928@@ -207,17 +207,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
50929 case QLCNIC_NON_PRIV_FUNC:
50930 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
50931 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
50932- nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
50933+ pax_open_kernel();
50934+ *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
50935+ pax_close_kernel();
50936 break;
50937 case QLCNIC_PRIV_FUNC:
50938 ahw->op_mode = QLCNIC_PRIV_FUNC;
50939 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
50940- nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
50941+ pax_open_kernel();
50942+ *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
50943+ pax_close_kernel();
50944 break;
50945 case QLCNIC_MGMT_FUNC:
50946 ahw->op_mode = QLCNIC_MGMT_FUNC;
50947 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
50948- nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
50949+ pax_open_kernel();
50950+ *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
50951+ pax_close_kernel();
50952 break;
50953 default:
50954 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
50955diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
50956index 332bb8a..e6adcd1 100644
50957--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
50958+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
50959@@ -1285,7 +1285,7 @@ flash_temp:
50960 int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
50961 {
50962 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
50963- static const struct qlcnic_dump_operations *fw_dump_ops;
50964+ const struct qlcnic_dump_operations *fw_dump_ops;
50965 struct qlcnic_83xx_dump_template_hdr *hdr_83xx;
50966 u32 entry_offset, dump, no_entries, buf_offset = 0;
50967 int i, k, ops_cnt, ops_index, dump_size = 0;
50968diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
50969index f790f61..f1faafe 100644
50970--- a/drivers/net/ethernet/realtek/r8169.c
50971+++ b/drivers/net/ethernet/realtek/r8169.c
50972@@ -788,22 +788,22 @@ struct rtl8169_private {
50973 struct mdio_ops {
50974 void (*write)(struct rtl8169_private *, int, int);
50975 int (*read)(struct rtl8169_private *, int);
50976- } mdio_ops;
50977+ } __no_const mdio_ops;
50978
50979 struct pll_power_ops {
50980 void (*down)(struct rtl8169_private *);
50981 void (*up)(struct rtl8169_private *);
50982- } pll_power_ops;
50983+ } __no_const pll_power_ops;
50984
50985 struct jumbo_ops {
50986 void (*enable)(struct rtl8169_private *);
50987 void (*disable)(struct rtl8169_private *);
50988- } jumbo_ops;
50989+ } __no_const jumbo_ops;
50990
50991 struct csi_ops {
50992 void (*write)(struct rtl8169_private *, int, int);
50993 u32 (*read)(struct rtl8169_private *, int);
50994- } csi_ops;
50995+ } __no_const csi_ops;
50996
50997 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
50998 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
50999diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
51000index ad62615..a4c124d 100644
51001--- a/drivers/net/ethernet/sfc/ptp.c
51002+++ b/drivers/net/ethernet/sfc/ptp.c
51003@@ -832,7 +832,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
51004 ptp->start.dma_addr);
51005
51006 /* Clear flag that signals MC ready */
51007- ACCESS_ONCE(*start) = 0;
51008+ ACCESS_ONCE_RW(*start) = 0;
51009 rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
51010 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
51011 EFX_BUG_ON_PARANOID(rc);
51012diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
51013index 3f20bb1..59add41 100644
51014--- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
51015+++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
51016@@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
51017
51018 writel(value, ioaddr + MMC_CNTRL);
51019
51020- pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
51021- MMC_CNTRL, value);
51022+// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
51023+// MMC_CNTRL, value);
51024 }
51025
51026 /* To mask all all interrupts.*/
51027diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
51028index a832637..092da0a 100644
51029--- a/drivers/net/ethernet/via/via-rhine.c
51030+++ b/drivers/net/ethernet/via/via-rhine.c
51031@@ -2599,7 +2599,7 @@ static struct platform_driver rhine_driver_platform = {
51032 }
51033 };
51034
51035-static struct dmi_system_id rhine_dmi_table[] __initdata = {
51036+static const struct dmi_system_id rhine_dmi_table[] __initconst = {
51037 {
51038 .ident = "EPIA-M",
51039 .matches = {
51040diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
51041index dd45440..c5f3cae 100644
51042--- a/drivers/net/hyperv/hyperv_net.h
51043+++ b/drivers/net/hyperv/hyperv_net.h
51044@@ -177,7 +177,7 @@ struct rndis_device {
51045 enum rndis_device_state state;
51046 bool link_state;
51047 bool link_change;
51048- atomic_t new_req_id;
51049+ atomic_unchecked_t new_req_id;
51050
51051 spinlock_t request_lock;
51052 struct list_head req_list;
51053diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
51054index 236aeb7..fd695e2 100644
51055--- a/drivers/net/hyperv/rndis_filter.c
51056+++ b/drivers/net/hyperv/rndis_filter.c
51057@@ -101,7 +101,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
51058 * template
51059 */
51060 set = &rndis_msg->msg.set_req;
51061- set->req_id = atomic_inc_return(&dev->new_req_id);
51062+ set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
51063
51064 /* Add to the request list */
51065 spin_lock_irqsave(&dev->request_lock, flags);
51066@@ -924,7 +924,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
51067
51068 /* Setup the rndis set */
51069 halt = &request->request_msg.msg.halt_req;
51070- halt->req_id = atomic_inc_return(&dev->new_req_id);
51071+ halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
51072
51073 /* Ignore return since this msg is optional. */
51074 rndis_filter_send_request(dev, request);
51075diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
51076index 94570aa..1a798e1 100644
51077--- a/drivers/net/ifb.c
51078+++ b/drivers/net/ifb.c
51079@@ -253,7 +253,7 @@ static int ifb_validate(struct nlattr *tb[], struct nlattr *data[])
51080 return 0;
51081 }
51082
51083-static struct rtnl_link_ops ifb_link_ops __read_mostly = {
51084+static struct rtnl_link_ops ifb_link_ops = {
51085 .kind = "ifb",
51086 .priv_size = sizeof(struct ifb_private),
51087 .setup = ifb_setup,
51088diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
51089index 207f62e..af3f5e5 100644
51090--- a/drivers/net/ipvlan/ipvlan_core.c
51091+++ b/drivers/net/ipvlan/ipvlan_core.c
51092@@ -466,7 +466,7 @@ static void ipvlan_multicast_enqueue(struct ipvl_port *port,
51093 schedule_work(&port->wq);
51094 } else {
51095 spin_unlock(&port->backlog.lock);
51096- atomic_long_inc(&skb->dev->rx_dropped);
51097+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
51098 kfree_skb(skb);
51099 }
51100 }
51101diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
51102index 9f59f17..52cb38f 100644
51103--- a/drivers/net/macvlan.c
51104+++ b/drivers/net/macvlan.c
51105@@ -335,7 +335,7 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port,
51106 free_nskb:
51107 kfree_skb(nskb);
51108 err:
51109- atomic_long_inc(&skb->dev->rx_dropped);
51110+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
51111 }
51112
51113 static void macvlan_flush_sources(struct macvlan_port *port,
51114@@ -1480,13 +1480,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
51115 int macvlan_link_register(struct rtnl_link_ops *ops)
51116 {
51117 /* common fields */
51118- ops->priv_size = sizeof(struct macvlan_dev);
51119- ops->validate = macvlan_validate;
51120- ops->maxtype = IFLA_MACVLAN_MAX;
51121- ops->policy = macvlan_policy;
51122- ops->changelink = macvlan_changelink;
51123- ops->get_size = macvlan_get_size;
51124- ops->fill_info = macvlan_fill_info;
51125+ pax_open_kernel();
51126+ *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
51127+ *(void **)&ops->validate = macvlan_validate;
51128+ *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
51129+ *(const void **)&ops->policy = macvlan_policy;
51130+ *(void **)&ops->changelink = macvlan_changelink;
51131+ *(void **)&ops->get_size = macvlan_get_size;
51132+ *(void **)&ops->fill_info = macvlan_fill_info;
51133+ pax_close_kernel();
51134
51135 return rtnl_link_register(ops);
51136 };
51137@@ -1572,7 +1574,7 @@ static int macvlan_device_event(struct notifier_block *unused,
51138 return NOTIFY_DONE;
51139 }
51140
51141-static struct notifier_block macvlan_notifier_block __read_mostly = {
51142+static struct notifier_block macvlan_notifier_block = {
51143 .notifier_call = macvlan_device_event,
51144 };
51145
51146diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
51147index 248478c..05e8467 100644
51148--- a/drivers/net/macvtap.c
51149+++ b/drivers/net/macvtap.c
51150@@ -485,7 +485,7 @@ static void macvtap_setup(struct net_device *dev)
51151 dev->tx_queue_len = TUN_READQ_SIZE;
51152 }
51153
51154-static struct rtnl_link_ops macvtap_link_ops __read_mostly = {
51155+static struct rtnl_link_ops macvtap_link_ops = {
51156 .kind = "macvtap",
51157 .setup = macvtap_setup,
51158 .newlink = macvtap_newlink,
51159@@ -1090,7 +1090,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
51160
51161 ret = 0;
51162 u = q->flags;
51163- if (copy_to_user(&ifr->ifr_name, vlan->dev->name, IFNAMSIZ) ||
51164+ if (copy_to_user(ifr->ifr_name, vlan->dev->name, IFNAMSIZ) ||
51165 put_user(u, &ifr->ifr_flags))
51166 ret = -EFAULT;
51167 macvtap_put_vlan(vlan);
51168@@ -1308,7 +1308,7 @@ static int macvtap_device_event(struct notifier_block *unused,
51169 return NOTIFY_DONE;
51170 }
51171
51172-static struct notifier_block macvtap_notifier_block __read_mostly = {
51173+static struct notifier_block macvtap_notifier_block = {
51174 .notifier_call = macvtap_device_event,
51175 };
51176
51177diff --git a/drivers/net/nlmon.c b/drivers/net/nlmon.c
51178index 34924df..a747360 100644
51179--- a/drivers/net/nlmon.c
51180+++ b/drivers/net/nlmon.c
51181@@ -154,7 +154,7 @@ static int nlmon_validate(struct nlattr *tb[], struct nlattr *data[])
51182 return 0;
51183 }
51184
51185-static struct rtnl_link_ops nlmon_link_ops __read_mostly = {
51186+static struct rtnl_link_ops nlmon_link_ops = {
51187 .kind = "nlmon",
51188 .priv_size = sizeof(struct nlmon),
51189 .setup = nlmon_setup,
51190diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
51191index 55f0178..6220e93 100644
51192--- a/drivers/net/phy/phy_device.c
51193+++ b/drivers/net/phy/phy_device.c
51194@@ -218,7 +218,7 @@ EXPORT_SYMBOL(phy_device_create);
51195 * zero on success.
51196 *
51197 */
51198-static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
51199+static int get_phy_c45_ids(struct mii_bus *bus, int addr, int *phy_id,
51200 struct phy_c45_device_ids *c45_ids) {
51201 int phy_reg;
51202 int i, reg_addr;
51203@@ -296,7 +296,7 @@ retry: reg_addr = MII_ADDR_C45 | i << 16 | MDIO_DEVS2;
51204 * its return value is in turn returned.
51205 *
51206 */
51207-static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
51208+static int get_phy_id(struct mii_bus *bus, int addr, int *phy_id,
51209 bool is_c45, struct phy_c45_device_ids *c45_ids)
51210 {
51211 int phy_reg;
51212@@ -334,7 +334,7 @@ static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
51213 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
51214 {
51215 struct phy_c45_device_ids c45_ids = {0};
51216- u32 phy_id = 0;
51217+ int phy_id = 0;
51218 int r;
51219
51220 r = get_phy_id(bus, addr, &phy_id, is_c45, &c45_ids);
51221diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
51222index 487be20..f4c87bc 100644
51223--- a/drivers/net/ppp/ppp_generic.c
51224+++ b/drivers/net/ppp/ppp_generic.c
51225@@ -1035,7 +1035,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
51226 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
51227 struct ppp_stats stats;
51228 struct ppp_comp_stats cstats;
51229- char *vers;
51230
51231 switch (cmd) {
51232 case SIOCGPPPSTATS:
51233@@ -1057,8 +1056,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
51234 break;
51235
51236 case SIOCGPPPVER:
51237- vers = PPP_VERSION;
51238- if (copy_to_user(addr, vers, strlen(vers) + 1))
51239+ if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
51240 break;
51241 err = 0;
51242 break;
51243diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
51244index 079f7ad..7e59810 100644
51245--- a/drivers/net/slip/slhc.c
51246+++ b/drivers/net/slip/slhc.c
51247@@ -94,6 +94,9 @@ slhc_init(int rslots, int tslots)
51248 register struct cstate *ts;
51249 struct slcompress *comp;
51250
51251+ if (rslots <= 0 || tslots <= 0 || rslots >= 256 || tslots >= 256)
51252+ goto out_fail;
51253+
51254 comp = kzalloc(sizeof(struct slcompress), GFP_KERNEL);
51255 if (! comp)
51256 goto out_fail;
51257@@ -487,7 +490,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
51258 register struct tcphdr *thp;
51259 register struct iphdr *ip;
51260 register struct cstate *cs;
51261- int len, hdrlen;
51262+ long len, hdrlen;
51263 unsigned char *cp = icp;
51264
51265 /* We've got a compressed packet; read the change byte */
51266diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
51267index daa054b..07d6b98 100644
51268--- a/drivers/net/team/team.c
51269+++ b/drivers/net/team/team.c
51270@@ -2107,7 +2107,7 @@ static unsigned int team_get_num_rx_queues(void)
51271 return TEAM_DEFAULT_NUM_RX_QUEUES;
51272 }
51273
51274-static struct rtnl_link_ops team_link_ops __read_mostly = {
51275+static struct rtnl_link_ops team_link_ops = {
51276 .kind = DRV_NAME,
51277 .priv_size = sizeof(struct team),
51278 .setup = team_setup,
51279@@ -2897,7 +2897,7 @@ static int team_device_event(struct notifier_block *unused,
51280 return NOTIFY_DONE;
51281 }
51282
51283-static struct notifier_block team_notifier_block __read_mostly = {
51284+static struct notifier_block team_notifier_block = {
51285 .notifier_call = team_device_event,
51286 };
51287
51288diff --git a/drivers/net/tun.c b/drivers/net/tun.c
51289index 06a0394..1756d18 100644
51290--- a/drivers/net/tun.c
51291+++ b/drivers/net/tun.c
51292@@ -1472,7 +1472,7 @@ static int tun_validate(struct nlattr *tb[], struct nlattr *data[])
51293 return -EINVAL;
51294 }
51295
51296-static struct rtnl_link_ops tun_link_ops __read_mostly = {
51297+static struct rtnl_link_ops tun_link_ops = {
51298 .kind = DRV_NAME,
51299 .priv_size = sizeof(struct tun_struct),
51300 .setup = tun_setup,
51301@@ -1871,7 +1871,7 @@ unlock:
51302 }
51303
51304 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
51305- unsigned long arg, int ifreq_len)
51306+ unsigned long arg, size_t ifreq_len)
51307 {
51308 struct tun_file *tfile = file->private_data;
51309 struct tun_struct *tun;
51310@@ -1885,6 +1885,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
51311 int le;
51312 int ret;
51313
51314+ if (ifreq_len > sizeof ifr)
51315+ return -EFAULT;
51316+
51317 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
51318 if (copy_from_user(&ifr, argp, ifreq_len))
51319 return -EFAULT;
51320diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
51321index 111d907..1ee643e 100644
51322--- a/drivers/net/usb/hso.c
51323+++ b/drivers/net/usb/hso.c
51324@@ -70,7 +70,7 @@
51325 #include <asm/byteorder.h>
51326 #include <linux/serial_core.h>
51327 #include <linux/serial.h>
51328-
51329+#include <asm/local.h>
51330
51331 #define MOD_AUTHOR "Option Wireless"
51332 #define MOD_DESCRIPTION "USB High Speed Option driver"
51333@@ -1183,7 +1183,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
51334 struct urb *urb;
51335
51336 urb = serial->rx_urb[0];
51337- if (serial->port.count > 0) {
51338+ if (atomic_read(&serial->port.count) > 0) {
51339 count = put_rxbuf_data(urb, serial);
51340 if (count == -1)
51341 return;
51342@@ -1221,7 +1221,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
51343 DUMP1(urb->transfer_buffer, urb->actual_length);
51344
51345 /* Anyone listening? */
51346- if (serial->port.count == 0)
51347+ if (atomic_read(&serial->port.count) == 0)
51348 return;
51349
51350 if (serial->parent->port_spec & HSO_INFO_CRC_BUG)
51351@@ -1282,8 +1282,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
51352 tty_port_tty_set(&serial->port, tty);
51353
51354 /* check for port already opened, if not set the termios */
51355- serial->port.count++;
51356- if (serial->port.count == 1) {
51357+ if (atomic_inc_return(&serial->port.count) == 1) {
51358 serial->rx_state = RX_IDLE;
51359 /* Force default termio settings */
51360 _hso_serial_set_termios(tty, NULL);
51361@@ -1293,7 +1292,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
51362 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
51363 if (result) {
51364 hso_stop_serial_device(serial->parent);
51365- serial->port.count--;
51366+ atomic_dec(&serial->port.count);
51367 } else {
51368 kref_get(&serial->parent->ref);
51369 }
51370@@ -1331,10 +1330,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
51371
51372 /* reset the rts and dtr */
51373 /* do the actual close */
51374- serial->port.count--;
51375+ atomic_dec(&serial->port.count);
51376
51377- if (serial->port.count <= 0) {
51378- serial->port.count = 0;
51379+ if (atomic_read(&serial->port.count) <= 0) {
51380+ atomic_set(&serial->port.count, 0);
51381 tty_port_tty_set(&serial->port, NULL);
51382 if (!usb_gone)
51383 hso_stop_serial_device(serial->parent);
51384@@ -1417,7 +1416,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
51385
51386 /* the actual setup */
51387 spin_lock_irqsave(&serial->serial_lock, flags);
51388- if (serial->port.count)
51389+ if (atomic_read(&serial->port.count))
51390 _hso_serial_set_termios(tty, old);
51391 else
51392 tty->termios = *old;
51393@@ -1891,7 +1890,7 @@ static void intr_callback(struct urb *urb)
51394 D1("Pending read interrupt on port %d\n", i);
51395 spin_lock(&serial->serial_lock);
51396 if (serial->rx_state == RX_IDLE &&
51397- serial->port.count > 0) {
51398+ atomic_read(&serial->port.count) > 0) {
51399 /* Setup and send a ctrl req read on
51400 * port i */
51401 if (!serial->rx_urb_filled[0]) {
51402@@ -3058,7 +3057,7 @@ static int hso_resume(struct usb_interface *iface)
51403 /* Start all serial ports */
51404 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
51405 if (serial_table[i] && (serial_table[i]->interface == iface)) {
51406- if (dev2ser(serial_table[i])->port.count) {
51407+ if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
51408 result =
51409 hso_start_serial_device(serial_table[i], GFP_NOIO);
51410 hso_kick_transmit(dev2ser(serial_table[i]));
51411diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
51412index ad8cbc6..de80b09 100644
51413--- a/drivers/net/usb/r8152.c
51414+++ b/drivers/net/usb/r8152.c
51415@@ -603,7 +603,7 @@ struct r8152 {
51416 void (*unload)(struct r8152 *);
51417 int (*eee_get)(struct r8152 *, struct ethtool_eee *);
51418 int (*eee_set)(struct r8152 *, struct ethtool_eee *);
51419- } rtl_ops;
51420+ } __no_const rtl_ops;
51421
51422 int intr_interval;
51423 u32 saved_wolopts;
51424diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
51425index a2515887..6d13233 100644
51426--- a/drivers/net/usb/sierra_net.c
51427+++ b/drivers/net/usb/sierra_net.c
51428@@ -51,7 +51,7 @@ static const char driver_name[] = "sierra_net";
51429 /* atomic counter partially included in MAC address to make sure 2 devices
51430 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
51431 */
51432-static atomic_t iface_counter = ATOMIC_INIT(0);
51433+static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
51434
51435 /*
51436 * SYNC Timer Delay definition used to set the expiry time
51437@@ -697,7 +697,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
51438 dev->net->netdev_ops = &sierra_net_device_ops;
51439
51440 /* change MAC addr to include, ifacenum, and to be unique */
51441- dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
51442+ dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
51443 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
51444
51445 /* we will have to manufacture ethernet headers, prepare template */
51446diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
51447index 237f8e5..8dccb91 100644
51448--- a/drivers/net/virtio_net.c
51449+++ b/drivers/net/virtio_net.c
51450@@ -48,7 +48,7 @@ module_param(gso, bool, 0444);
51451 #define RECEIVE_AVG_WEIGHT 64
51452
51453 /* Minimum alignment for mergeable packet buffers. */
51454-#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, 256)
51455+#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, 256UL)
51456
51457 #define VIRTNET_DRIVER_VERSION "1.0.0"
51458
51459diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
51460index 5bc4b1e..d5769f5 100644
51461--- a/drivers/net/vxlan.c
51462+++ b/drivers/net/vxlan.c
51463@@ -2884,7 +2884,7 @@ static struct net *vxlan_get_link_net(const struct net_device *dev)
51464 return vxlan->net;
51465 }
51466
51467-static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
51468+static struct rtnl_link_ops vxlan_link_ops = {
51469 .kind = "vxlan",
51470 .maxtype = IFLA_VXLAN_MAX,
51471 .policy = vxlan_policy,
51472@@ -2932,7 +2932,7 @@ static int vxlan_lowerdev_event(struct notifier_block *unused,
51473 return NOTIFY_DONE;
51474 }
51475
51476-static struct notifier_block vxlan_notifier_block __read_mostly = {
51477+static struct notifier_block vxlan_notifier_block = {
51478 .notifier_call = vxlan_lowerdev_event,
51479 };
51480
51481diff --git a/drivers/net/wan/lmc/lmc_media.c b/drivers/net/wan/lmc/lmc_media.c
51482index 5920c99..ff2e4a5 100644
51483--- a/drivers/net/wan/lmc/lmc_media.c
51484+++ b/drivers/net/wan/lmc/lmc_media.c
51485@@ -95,62 +95,63 @@ static inline void write_av9110_bit (lmc_softc_t *, int);
51486 static void write_av9110(lmc_softc_t *, u32, u32, u32, u32, u32);
51487
51488 lmc_media_t lmc_ds3_media = {
51489- lmc_ds3_init, /* special media init stuff */
51490- lmc_ds3_default, /* reset to default state */
51491- lmc_ds3_set_status, /* reset status to state provided */
51492- lmc_dummy_set_1, /* set clock source */
51493- lmc_dummy_set2_1, /* set line speed */
51494- lmc_ds3_set_100ft, /* set cable length */
51495- lmc_ds3_set_scram, /* set scrambler */
51496- lmc_ds3_get_link_status, /* get link status */
51497- lmc_dummy_set_1, /* set link status */
51498- lmc_ds3_set_crc_length, /* set CRC length */
51499- lmc_dummy_set_1, /* set T1 or E1 circuit type */
51500- lmc_ds3_watchdog
51501+ .init = lmc_ds3_init, /* special media init stuff */
51502+ .defaults = lmc_ds3_default, /* reset to default state */
51503+ .set_status = lmc_ds3_set_status, /* reset status to state provided */
51504+ .set_clock_source = lmc_dummy_set_1, /* set clock source */
51505+ .set_speed = lmc_dummy_set2_1, /* set line speed */
51506+ .set_cable_length = lmc_ds3_set_100ft, /* set cable length */
51507+ .set_scrambler = lmc_ds3_set_scram, /* set scrambler */
51508+ .get_link_status = lmc_ds3_get_link_status, /* get link status */
51509+ .set_link_status = lmc_dummy_set_1, /* set link status */
51510+ .set_crc_length = lmc_ds3_set_crc_length, /* set CRC length */
51511+ .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
51512+ .watchdog = lmc_ds3_watchdog
51513 };
51514
51515 lmc_media_t lmc_hssi_media = {
51516- lmc_hssi_init, /* special media init stuff */
51517- lmc_hssi_default, /* reset to default state */
51518- lmc_hssi_set_status, /* reset status to state provided */
51519- lmc_hssi_set_clock, /* set clock source */
51520- lmc_dummy_set2_1, /* set line speed */
51521- lmc_dummy_set_1, /* set cable length */
51522- lmc_dummy_set_1, /* set scrambler */
51523- lmc_hssi_get_link_status, /* get link status */
51524- lmc_hssi_set_link_status, /* set link status */
51525- lmc_hssi_set_crc_length, /* set CRC length */
51526- lmc_dummy_set_1, /* set T1 or E1 circuit type */
51527- lmc_hssi_watchdog
51528+ .init = lmc_hssi_init, /* special media init stuff */
51529+ .defaults = lmc_hssi_default, /* reset to default state */
51530+ .set_status = lmc_hssi_set_status, /* reset status to state provided */
51531+ .set_clock_source = lmc_hssi_set_clock, /* set clock source */
51532+ .set_speed = lmc_dummy_set2_1, /* set line speed */
51533+ .set_cable_length = lmc_dummy_set_1, /* set cable length */
51534+ .set_scrambler = lmc_dummy_set_1, /* set scrambler */
51535+ .get_link_status = lmc_hssi_get_link_status, /* get link status */
51536+ .set_link_status = lmc_hssi_set_link_status, /* set link status */
51537+ .set_crc_length = lmc_hssi_set_crc_length, /* set CRC length */
51538+ .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
51539+ .watchdog = lmc_hssi_watchdog
51540 };
51541
51542-lmc_media_t lmc_ssi_media = { lmc_ssi_init, /* special media init stuff */
51543- lmc_ssi_default, /* reset to default state */
51544- lmc_ssi_set_status, /* reset status to state provided */
51545- lmc_ssi_set_clock, /* set clock source */
51546- lmc_ssi_set_speed, /* set line speed */
51547- lmc_dummy_set_1, /* set cable length */
51548- lmc_dummy_set_1, /* set scrambler */
51549- lmc_ssi_get_link_status, /* get link status */
51550- lmc_ssi_set_link_status, /* set link status */
51551- lmc_ssi_set_crc_length, /* set CRC length */
51552- lmc_dummy_set_1, /* set T1 or E1 circuit type */
51553- lmc_ssi_watchdog
51554+lmc_media_t lmc_ssi_media = {
51555+ .init = lmc_ssi_init, /* special media init stuff */
51556+ .defaults = lmc_ssi_default, /* reset to default state */
51557+ .set_status = lmc_ssi_set_status, /* reset status to state provided */
51558+ .set_clock_source = lmc_ssi_set_clock, /* set clock source */
51559+ .set_speed = lmc_ssi_set_speed, /* set line speed */
51560+ .set_cable_length = lmc_dummy_set_1, /* set cable length */
51561+ .set_scrambler = lmc_dummy_set_1, /* set scrambler */
51562+ .get_link_status = lmc_ssi_get_link_status, /* get link status */
51563+ .set_link_status = lmc_ssi_set_link_status, /* set link status */
51564+ .set_crc_length = lmc_ssi_set_crc_length, /* set CRC length */
51565+ .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
51566+ .watchdog = lmc_ssi_watchdog
51567 };
51568
51569 lmc_media_t lmc_t1_media = {
51570- lmc_t1_init, /* special media init stuff */
51571- lmc_t1_default, /* reset to default state */
51572- lmc_t1_set_status, /* reset status to state provided */
51573- lmc_t1_set_clock, /* set clock source */
51574- lmc_dummy_set2_1, /* set line speed */
51575- lmc_dummy_set_1, /* set cable length */
51576- lmc_dummy_set_1, /* set scrambler */
51577- lmc_t1_get_link_status, /* get link status */
51578- lmc_dummy_set_1, /* set link status */
51579- lmc_t1_set_crc_length, /* set CRC length */
51580- lmc_t1_set_circuit_type, /* set T1 or E1 circuit type */
51581- lmc_t1_watchdog
51582+ .init = lmc_t1_init, /* special media init stuff */
51583+ .defaults = lmc_t1_default, /* reset to default state */
51584+ .set_status = lmc_t1_set_status, /* reset status to state provided */
51585+ .set_clock_source = lmc_t1_set_clock, /* set clock source */
51586+ .set_speed = lmc_dummy_set2_1, /* set line speed */
51587+ .set_cable_length = lmc_dummy_set_1, /* set cable length */
51588+ .set_scrambler = lmc_dummy_set_1, /* set scrambler */
51589+ .get_link_status = lmc_t1_get_link_status, /* get link status */
51590+ .set_link_status = lmc_dummy_set_1, /* set link status */
51591+ .set_crc_length = lmc_t1_set_crc_length, /* set CRC length */
51592+ .set_circuit_type = lmc_t1_set_circuit_type, /* set T1 or E1 circuit type */
51593+ .watchdog = lmc_t1_watchdog
51594 };
51595
51596 static void
51597diff --git a/drivers/net/wan/z85230.c b/drivers/net/wan/z85230.c
51598index 2f0bd69..e46ed7b 100644
51599--- a/drivers/net/wan/z85230.c
51600+++ b/drivers/net/wan/z85230.c
51601@@ -485,9 +485,9 @@ static void z8530_status(struct z8530_channel *chan)
51602
51603 struct z8530_irqhandler z8530_sync =
51604 {
51605- z8530_rx,
51606- z8530_tx,
51607- z8530_status
51608+ .rx = z8530_rx,
51609+ .tx = z8530_tx,
51610+ .status = z8530_status
51611 };
51612
51613 EXPORT_SYMBOL(z8530_sync);
51614@@ -605,15 +605,15 @@ static void z8530_dma_status(struct z8530_channel *chan)
51615 }
51616
51617 static struct z8530_irqhandler z8530_dma_sync = {
51618- z8530_dma_rx,
51619- z8530_dma_tx,
51620- z8530_dma_status
51621+ .rx = z8530_dma_rx,
51622+ .tx = z8530_dma_tx,
51623+ .status = z8530_dma_status
51624 };
51625
51626 static struct z8530_irqhandler z8530_txdma_sync = {
51627- z8530_rx,
51628- z8530_dma_tx,
51629- z8530_dma_status
51630+ .rx = z8530_rx,
51631+ .tx = z8530_dma_tx,
51632+ .status = z8530_dma_status
51633 };
51634
51635 /**
51636@@ -680,9 +680,9 @@ static void z8530_status_clear(struct z8530_channel *chan)
51637
51638 struct z8530_irqhandler z8530_nop=
51639 {
51640- z8530_rx_clear,
51641- z8530_tx_clear,
51642- z8530_status_clear
51643+ .rx = z8530_rx_clear,
51644+ .tx = z8530_tx_clear,
51645+ .status = z8530_status_clear
51646 };
51647
51648
51649diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
51650index 0b60295..b8bfa5b 100644
51651--- a/drivers/net/wimax/i2400m/rx.c
51652+++ b/drivers/net/wimax/i2400m/rx.c
51653@@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
51654 if (i2400m->rx_roq == NULL)
51655 goto error_roq_alloc;
51656
51657- rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
51658+ rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
51659 GFP_KERNEL);
51660 if (rd == NULL) {
51661 result = -ENOMEM;
51662diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
51663index d0c97c2..108f59b 100644
51664--- a/drivers/net/wireless/airo.c
51665+++ b/drivers/net/wireless/airo.c
51666@@ -7846,7 +7846,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
51667 struct airo_info *ai = dev->ml_priv;
51668 int ridcode;
51669 int enabled;
51670- static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
51671+ int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
51672 unsigned char *iobuf;
51673
51674 /* Only super-user can write RIDs */
51675diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
51676index dab2513..4c4b65d 100644
51677--- a/drivers/net/wireless/at76c50x-usb.c
51678+++ b/drivers/net/wireless/at76c50x-usb.c
51679@@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
51680 }
51681
51682 /* Convert timeout from the DFU status to jiffies */
51683-static inline unsigned long at76_get_timeout(struct dfu_status *s)
51684+static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
51685 {
51686 return msecs_to_jiffies((s->poll_timeout[2] << 16)
51687 | (s->poll_timeout[1] << 8)
51688diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c
51689index e508c65..fb0dbae 100644
51690--- a/drivers/net/wireless/ath/ath10k/ce.c
51691+++ b/drivers/net/wireless/ath/ath10k/ce.c
51692@@ -896,7 +896,7 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar,
51693 return 0;
51694 }
51695
51696-static struct ath10k_ce_ring *
51697+static struct ath10k_ce_ring * __intentional_overflow(-1)
51698 ath10k_ce_alloc_src_ring(struct ath10k *ar, unsigned int ce_id,
51699 const struct ce_attr *attr)
51700 {
51701diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
51702index 32d9ff1..0952b33 100644
51703--- a/drivers/net/wireless/ath/ath10k/htc.c
51704+++ b/drivers/net/wireless/ath/ath10k/htc.c
51705@@ -841,7 +841,10 @@ int ath10k_htc_start(struct ath10k_htc *htc)
51706 /* registered target arrival callback from the HIF layer */
51707 int ath10k_htc_init(struct ath10k *ar)
51708 {
51709- struct ath10k_hif_cb htc_callbacks;
51710+ static struct ath10k_hif_cb htc_callbacks = {
51711+ .rx_completion = ath10k_htc_rx_completion_handler,
51712+ .tx_completion = ath10k_htc_tx_completion_handler,
51713+ };
51714 struct ath10k_htc_ep *ep = NULL;
51715 struct ath10k_htc *htc = &ar->htc;
51716
51717@@ -850,8 +853,6 @@ int ath10k_htc_init(struct ath10k *ar)
51718 ath10k_htc_reset_endpoint_states(htc);
51719
51720 /* setup HIF layer callbacks */
51721- htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
51722- htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
51723 htc->ar = ar;
51724
51725 /* Get HIF default pipe for HTC message exchange */
51726diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h
51727index 527179c..a890150 100644
51728--- a/drivers/net/wireless/ath/ath10k/htc.h
51729+++ b/drivers/net/wireless/ath/ath10k/htc.h
51730@@ -270,13 +270,13 @@ enum ath10k_htc_ep_id {
51731
51732 struct ath10k_htc_ops {
51733 void (*target_send_suspend_complete)(struct ath10k *ar);
51734-};
51735+} __no_const;
51736
51737 struct ath10k_htc_ep_ops {
51738 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *);
51739 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *);
51740 void (*ep_tx_credits)(struct ath10k *);
51741-};
51742+} __no_const;
51743
51744 /* service connection information */
51745 struct ath10k_htc_svc_conn_req {
51746diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
51747index fee0cad..a7a3b63 100644
51748--- a/drivers/net/wireless/ath/ath9k/Kconfig
51749+++ b/drivers/net/wireless/ath/ath9k/Kconfig
51750@@ -3,7 +3,6 @@ config ATH9K_HW
51751 config ATH9K_COMMON
51752 tristate
51753 select ATH_COMMON
51754- select DEBUG_FS
51755 select RELAY
51756 config ATH9K_DFS_DEBUGFS
51757 def_bool y
51758diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
51759index f816909..e56cd8b 100644
51760--- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
51761+++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
51762@@ -220,8 +220,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51763 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
51764 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
51765
51766- ACCESS_ONCE(ads->ds_link) = i->link;
51767- ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
51768+ ACCESS_ONCE_RW(ads->ds_link) = i->link;
51769+ ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
51770
51771 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
51772 ctl6 = SM(i->keytype, AR_EncrType);
51773@@ -235,26 +235,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51774
51775 if ((i->is_first || i->is_last) &&
51776 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
51777- ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
51778+ ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
51779 | set11nTries(i->rates, 1)
51780 | set11nTries(i->rates, 2)
51781 | set11nTries(i->rates, 3)
51782 | (i->dur_update ? AR_DurUpdateEna : 0)
51783 | SM(0, AR_BurstDur);
51784
51785- ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
51786+ ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
51787 | set11nRate(i->rates, 1)
51788 | set11nRate(i->rates, 2)
51789 | set11nRate(i->rates, 3);
51790 } else {
51791- ACCESS_ONCE(ads->ds_ctl2) = 0;
51792- ACCESS_ONCE(ads->ds_ctl3) = 0;
51793+ ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
51794+ ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
51795 }
51796
51797 if (!i->is_first) {
51798- ACCESS_ONCE(ads->ds_ctl0) = 0;
51799- ACCESS_ONCE(ads->ds_ctl1) = ctl1;
51800- ACCESS_ONCE(ads->ds_ctl6) = ctl6;
51801+ ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
51802+ ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
51803+ ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
51804 return;
51805 }
51806
51807@@ -279,7 +279,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51808 break;
51809 }
51810
51811- ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
51812+ ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
51813 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
51814 | SM(i->txpower[0], AR_XmitPower0)
51815 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
51816@@ -289,27 +289,27 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51817 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
51818 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
51819
51820- ACCESS_ONCE(ads->ds_ctl1) = ctl1;
51821- ACCESS_ONCE(ads->ds_ctl6) = ctl6;
51822+ ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
51823+ ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
51824
51825 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
51826 return;
51827
51828- ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
51829+ ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
51830 | set11nPktDurRTSCTS(i->rates, 1);
51831
51832- ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
51833+ ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
51834 | set11nPktDurRTSCTS(i->rates, 3);
51835
51836- ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
51837+ ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
51838 | set11nRateFlags(i->rates, 1)
51839 | set11nRateFlags(i->rates, 2)
51840 | set11nRateFlags(i->rates, 3)
51841 | SM(i->rtscts_rate, AR_RTSCTSRate);
51842
51843- ACCESS_ONCE(ads->ds_ctl9) = SM(i->txpower[1], AR_XmitPower1);
51844- ACCESS_ONCE(ads->ds_ctl10) = SM(i->txpower[2], AR_XmitPower2);
51845- ACCESS_ONCE(ads->ds_ctl11) = SM(i->txpower[3], AR_XmitPower3);
51846+ ACCESS_ONCE_RW(ads->ds_ctl9) = SM(i->txpower[1], AR_XmitPower1);
51847+ ACCESS_ONCE_RW(ads->ds_ctl10) = SM(i->txpower[2], AR_XmitPower2);
51848+ ACCESS_ONCE_RW(ads->ds_ctl11) = SM(i->txpower[3], AR_XmitPower3);
51849 }
51850
51851 static int ar9002_hw_proc_txdesc(struct ath_hw *ah, void *ds,
51852diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
51853index da84b70..83e4978 100644
51854--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
51855+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
51856@@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51857 (i->qcu << AR_TxQcuNum_S) | desc_len;
51858
51859 checksum += val;
51860- ACCESS_ONCE(ads->info) = val;
51861+ ACCESS_ONCE_RW(ads->info) = val;
51862
51863 checksum += i->link;
51864- ACCESS_ONCE(ads->link) = i->link;
51865+ ACCESS_ONCE_RW(ads->link) = i->link;
51866
51867 checksum += i->buf_addr[0];
51868- ACCESS_ONCE(ads->data0) = i->buf_addr[0];
51869+ ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
51870 checksum += i->buf_addr[1];
51871- ACCESS_ONCE(ads->data1) = i->buf_addr[1];
51872+ ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
51873 checksum += i->buf_addr[2];
51874- ACCESS_ONCE(ads->data2) = i->buf_addr[2];
51875+ ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
51876 checksum += i->buf_addr[3];
51877- ACCESS_ONCE(ads->data3) = i->buf_addr[3];
51878+ ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
51879
51880 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
51881- ACCESS_ONCE(ads->ctl3) = val;
51882+ ACCESS_ONCE_RW(ads->ctl3) = val;
51883 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
51884- ACCESS_ONCE(ads->ctl5) = val;
51885+ ACCESS_ONCE_RW(ads->ctl5) = val;
51886 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
51887- ACCESS_ONCE(ads->ctl7) = val;
51888+ ACCESS_ONCE_RW(ads->ctl7) = val;
51889 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
51890- ACCESS_ONCE(ads->ctl9) = val;
51891+ ACCESS_ONCE_RW(ads->ctl9) = val;
51892
51893 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
51894- ACCESS_ONCE(ads->ctl10) = checksum;
51895+ ACCESS_ONCE_RW(ads->ctl10) = checksum;
51896
51897 if (i->is_first || i->is_last) {
51898- ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
51899+ ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
51900 | set11nTries(i->rates, 1)
51901 | set11nTries(i->rates, 2)
51902 | set11nTries(i->rates, 3)
51903 | (i->dur_update ? AR_DurUpdateEna : 0)
51904 | SM(0, AR_BurstDur);
51905
51906- ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
51907+ ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
51908 | set11nRate(i->rates, 1)
51909 | set11nRate(i->rates, 2)
51910 | set11nRate(i->rates, 3);
51911 } else {
51912- ACCESS_ONCE(ads->ctl13) = 0;
51913- ACCESS_ONCE(ads->ctl14) = 0;
51914+ ACCESS_ONCE_RW(ads->ctl13) = 0;
51915+ ACCESS_ONCE_RW(ads->ctl14) = 0;
51916 }
51917
51918 ads->ctl20 = 0;
51919@@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51920
51921 ctl17 = SM(i->keytype, AR_EncrType);
51922 if (!i->is_first) {
51923- ACCESS_ONCE(ads->ctl11) = 0;
51924- ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
51925- ACCESS_ONCE(ads->ctl15) = 0;
51926- ACCESS_ONCE(ads->ctl16) = 0;
51927- ACCESS_ONCE(ads->ctl17) = ctl17;
51928- ACCESS_ONCE(ads->ctl18) = 0;
51929- ACCESS_ONCE(ads->ctl19) = 0;
51930+ ACCESS_ONCE_RW(ads->ctl11) = 0;
51931+ ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
51932+ ACCESS_ONCE_RW(ads->ctl15) = 0;
51933+ ACCESS_ONCE_RW(ads->ctl16) = 0;
51934+ ACCESS_ONCE_RW(ads->ctl17) = ctl17;
51935+ ACCESS_ONCE_RW(ads->ctl18) = 0;
51936+ ACCESS_ONCE_RW(ads->ctl19) = 0;
51937 return;
51938 }
51939
51940- ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
51941+ ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
51942 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
51943 | SM(i->txpower[0], AR_XmitPower0)
51944 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
51945@@ -135,26 +135,26 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51946 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
51947 ctl12 |= SM(val, AR_PAPRDChainMask);
51948
51949- ACCESS_ONCE(ads->ctl12) = ctl12;
51950- ACCESS_ONCE(ads->ctl17) = ctl17;
51951+ ACCESS_ONCE_RW(ads->ctl12) = ctl12;
51952+ ACCESS_ONCE_RW(ads->ctl17) = ctl17;
51953
51954- ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
51955+ ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
51956 | set11nPktDurRTSCTS(i->rates, 1);
51957
51958- ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
51959+ ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
51960 | set11nPktDurRTSCTS(i->rates, 3);
51961
51962- ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
51963+ ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
51964 | set11nRateFlags(i->rates, 1)
51965 | set11nRateFlags(i->rates, 2)
51966 | set11nRateFlags(i->rates, 3)
51967 | SM(i->rtscts_rate, AR_RTSCTSRate);
51968
51969- ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
51970+ ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
51971
51972- ACCESS_ONCE(ads->ctl20) = SM(i->txpower[1], AR_XmitPower1);
51973- ACCESS_ONCE(ads->ctl21) = SM(i->txpower[2], AR_XmitPower2);
51974- ACCESS_ONCE(ads->ctl22) = SM(i->txpower[3], AR_XmitPower3);
51975+ ACCESS_ONCE_RW(ads->ctl20) = SM(i->txpower[1], AR_XmitPower1);
51976+ ACCESS_ONCE_RW(ads->ctl21) = SM(i->txpower[2], AR_XmitPower2);
51977+ ACCESS_ONCE_RW(ads->ctl22) = SM(i->txpower[3], AR_XmitPower3);
51978 }
51979
51980 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
51981diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
51982index e8454db..c7b26fe 100644
51983--- a/drivers/net/wireless/ath/ath9k/hw.h
51984+++ b/drivers/net/wireless/ath/ath9k/hw.h
51985@@ -671,7 +671,7 @@ struct ath_hw_private_ops {
51986 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
51987 bool (*is_aic_enabled)(struct ath_hw *ah);
51988 #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */
51989-};
51990+} __no_const;
51991
51992 /**
51993 * struct ath_spec_scan - parameters for Atheros spectral scan
51994@@ -747,7 +747,7 @@ struct ath_hw_ops {
51995 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
51996 void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
51997 #endif
51998-};
51999+} __no_const;
52000
52001 struct ath_nf_limits {
52002 s16 max;
52003diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
52004index cfd45cb..6de2be6 100644
52005--- a/drivers/net/wireless/ath/ath9k/main.c
52006+++ b/drivers/net/wireless/ath/ath9k/main.c
52007@@ -2574,16 +2574,18 @@ void ath9k_fill_chanctx_ops(void)
52008 if (!ath9k_is_chanctx_enabled())
52009 return;
52010
52011- ath9k_ops.hw_scan = ath9k_hw_scan;
52012- ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan;
52013- ath9k_ops.remain_on_channel = ath9k_remain_on_channel;
52014- ath9k_ops.cancel_remain_on_channel = ath9k_cancel_remain_on_channel;
52015- ath9k_ops.add_chanctx = ath9k_add_chanctx;
52016- ath9k_ops.remove_chanctx = ath9k_remove_chanctx;
52017- ath9k_ops.change_chanctx = ath9k_change_chanctx;
52018- ath9k_ops.assign_vif_chanctx = ath9k_assign_vif_chanctx;
52019- ath9k_ops.unassign_vif_chanctx = ath9k_unassign_vif_chanctx;
52020- ath9k_ops.mgd_prepare_tx = ath9k_mgd_prepare_tx;
52021+ pax_open_kernel();
52022+ *(void **)&ath9k_ops.hw_scan = ath9k_hw_scan;
52023+ *(void **)&ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan;
52024+ *(void **)&ath9k_ops.remain_on_channel = ath9k_remain_on_channel;
52025+ *(void **)&ath9k_ops.cancel_remain_on_channel = ath9k_cancel_remain_on_channel;
52026+ *(void **)&ath9k_ops.add_chanctx = ath9k_add_chanctx;
52027+ *(void **)&ath9k_ops.remove_chanctx = ath9k_remove_chanctx;
52028+ *(void **)&ath9k_ops.change_chanctx = ath9k_change_chanctx;
52029+ *(void **)&ath9k_ops.assign_vif_chanctx = ath9k_assign_vif_chanctx;
52030+ *(void **)&ath9k_ops.unassign_vif_chanctx = ath9k_unassign_vif_chanctx;
52031+ *(void **)&ath9k_ops.mgd_prepare_tx = ath9k_mgd_prepare_tx;
52032+ pax_close_kernel();
52033 }
52034
52035 #endif
52036diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
52037index 058a9f2..d5cb1ba 100644
52038--- a/drivers/net/wireless/b43/phy_lp.c
52039+++ b/drivers/net/wireless/b43/phy_lp.c
52040@@ -2502,7 +2502,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
52041 {
52042 struct ssb_bus *bus = dev->dev->sdev->bus;
52043
52044- static const struct b206x_channel *chandata = NULL;
52045+ const struct b206x_channel *chandata = NULL;
52046 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
52047 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
52048 u16 old_comm15, scale;
52049diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
52050index 7f4cb69..16c0825 100644
52051--- a/drivers/net/wireless/iwlegacy/3945-mac.c
52052+++ b/drivers/net/wireless/iwlegacy/3945-mac.c
52053@@ -3633,7 +3633,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
52054 */
52055 if (il3945_mod_params.disable_hw_scan) {
52056 D_INFO("Disabling hw_scan\n");
52057- il3945_mac_ops.hw_scan = NULL;
52058+ pax_open_kernel();
52059+ *(void **)&il3945_mac_ops.hw_scan = NULL;
52060+ pax_close_kernel();
52061 }
52062
52063 D_INFO("*** LOAD DRIVER ***\n");
52064diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
52065index 0ffb6ff..c0b7f0e 100644
52066--- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
52067+++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
52068@@ -188,7 +188,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
52069 {
52070 struct iwl_priv *priv = file->private_data;
52071 char buf[64];
52072- int buf_size;
52073+ size_t buf_size;
52074 u32 offset, len;
52075
52076 memset(buf, 0, sizeof(buf));
52077@@ -458,7 +458,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
52078 struct iwl_priv *priv = file->private_data;
52079
52080 char buf[8];
52081- int buf_size;
52082+ size_t buf_size;
52083 u32 reset_flag;
52084
52085 memset(buf, 0, sizeof(buf));
52086@@ -539,7 +539,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
52087 {
52088 struct iwl_priv *priv = file->private_data;
52089 char buf[8];
52090- int buf_size;
52091+ size_t buf_size;
52092 int ht40;
52093
52094 memset(buf, 0, sizeof(buf));
52095@@ -591,7 +591,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
52096 {
52097 struct iwl_priv *priv = file->private_data;
52098 char buf[8];
52099- int buf_size;
52100+ size_t buf_size;
52101 int value;
52102
52103 memset(buf, 0, sizeof(buf));
52104@@ -683,10 +683,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
52105 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
52106 DEBUGFS_READ_FILE_OPS(current_sleep_command);
52107
52108-static const char *fmt_value = " %-30s %10u\n";
52109-static const char *fmt_hex = " %-30s 0x%02X\n";
52110-static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
52111-static const char *fmt_header =
52112+static const char fmt_value[] = " %-30s %10u\n";
52113+static const char fmt_hex[] = " %-30s 0x%02X\n";
52114+static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
52115+static const char fmt_header[] =
52116 "%-32s current cumulative delta max\n";
52117
52118 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
52119@@ -1856,7 +1856,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
52120 {
52121 struct iwl_priv *priv = file->private_data;
52122 char buf[8];
52123- int buf_size;
52124+ size_t buf_size;
52125 int clear;
52126
52127 memset(buf, 0, sizeof(buf));
52128@@ -1901,7 +1901,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
52129 {
52130 struct iwl_priv *priv = file->private_data;
52131 char buf[8];
52132- int buf_size;
52133+ size_t buf_size;
52134 int trace;
52135
52136 memset(buf, 0, sizeof(buf));
52137@@ -1972,7 +1972,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
52138 {
52139 struct iwl_priv *priv = file->private_data;
52140 char buf[8];
52141- int buf_size;
52142+ size_t buf_size;
52143 int missed;
52144
52145 memset(buf, 0, sizeof(buf));
52146@@ -2013,7 +2013,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
52147
52148 struct iwl_priv *priv = file->private_data;
52149 char buf[8];
52150- int buf_size;
52151+ size_t buf_size;
52152 int plcp;
52153
52154 memset(buf, 0, sizeof(buf));
52155@@ -2073,7 +2073,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
52156
52157 struct iwl_priv *priv = file->private_data;
52158 char buf[8];
52159- int buf_size;
52160+ size_t buf_size;
52161 int flush;
52162
52163 memset(buf, 0, sizeof(buf));
52164@@ -2163,7 +2163,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
52165
52166 struct iwl_priv *priv = file->private_data;
52167 char buf[8];
52168- int buf_size;
52169+ size_t buf_size;
52170 int rts;
52171
52172 if (!priv->cfg->ht_params)
52173@@ -2204,7 +2204,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
52174 {
52175 struct iwl_priv *priv = file->private_data;
52176 char buf[8];
52177- int buf_size;
52178+ size_t buf_size;
52179
52180 memset(buf, 0, sizeof(buf));
52181 buf_size = min(count, sizeof(buf) - 1);
52182@@ -2238,7 +2238,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
52183 struct iwl_priv *priv = file->private_data;
52184 u32 event_log_flag;
52185 char buf[8];
52186- int buf_size;
52187+ size_t buf_size;
52188
52189 /* check that the interface is up */
52190 if (!iwl_is_ready(priv))
52191@@ -2292,7 +2292,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
52192 struct iwl_priv *priv = file->private_data;
52193 char buf[8];
52194 u32 calib_disabled;
52195- int buf_size;
52196+ size_t buf_size;
52197
52198 memset(buf, 0, sizeof(buf));
52199 buf_size = min(count, sizeof(buf) - 1);
52200diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
52201index 9e144e7..2f5511a 100644
52202--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
52203+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
52204@@ -1950,7 +1950,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
52205 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
52206
52207 char buf[8];
52208- int buf_size;
52209+ size_t buf_size;
52210 u32 reset_flag;
52211
52212 memset(buf, 0, sizeof(buf));
52213@@ -1971,7 +1971,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
52214 {
52215 struct iwl_trans *trans = file->private_data;
52216 char buf[8];
52217- int buf_size;
52218+ size_t buf_size;
52219 int csr;
52220
52221 memset(buf, 0, sizeof(buf));
52222diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
52223index 99e873d..0d9aab2 100644
52224--- a/drivers/net/wireless/mac80211_hwsim.c
52225+++ b/drivers/net/wireless/mac80211_hwsim.c
52226@@ -3148,20 +3148,20 @@ static int __init init_mac80211_hwsim(void)
52227 if (channels < 1)
52228 return -EINVAL;
52229
52230- mac80211_hwsim_mchan_ops = mac80211_hwsim_ops;
52231- mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan;
52232- mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
52233- mac80211_hwsim_mchan_ops.sw_scan_start = NULL;
52234- mac80211_hwsim_mchan_ops.sw_scan_complete = NULL;
52235- mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc;
52236- mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
52237- mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx;
52238- mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
52239- mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx;
52240- mac80211_hwsim_mchan_ops.assign_vif_chanctx =
52241- mac80211_hwsim_assign_vif_chanctx;
52242- mac80211_hwsim_mchan_ops.unassign_vif_chanctx =
52243- mac80211_hwsim_unassign_vif_chanctx;
52244+ pax_open_kernel();
52245+ memcpy((void *)&mac80211_hwsim_mchan_ops, &mac80211_hwsim_ops, sizeof mac80211_hwsim_mchan_ops);
52246+ *(void **)&mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan;
52247+ *(void **)&mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
52248+ *(void **)&mac80211_hwsim_mchan_ops.sw_scan_start = NULL;
52249+ *(void **)&mac80211_hwsim_mchan_ops.sw_scan_complete = NULL;
52250+ *(void **)&mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc;
52251+ *(void **)&mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
52252+ *(void **)&mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx;
52253+ *(void **)&mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
52254+ *(void **)&mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx;
52255+ *(void **)&mac80211_hwsim_mchan_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
52256+ *(void **)&mac80211_hwsim_mchan_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
52257+ pax_close_kernel();
52258
52259 spin_lock_init(&hwsim_radio_lock);
52260 INIT_LIST_HEAD(&hwsim_radios);
52261diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
52262index 71a825c..ce7d6c3 100644
52263--- a/drivers/net/wireless/rndis_wlan.c
52264+++ b/drivers/net/wireless/rndis_wlan.c
52265@@ -1236,7 +1236,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
52266
52267 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
52268
52269- if (rts_threshold < 0 || rts_threshold > 2347)
52270+ if (rts_threshold > 2347)
52271 rts_threshold = 2347;
52272
52273 tmp = cpu_to_le32(rts_threshold);
52274diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
52275index 9bb398b..b0cc047 100644
52276--- a/drivers/net/wireless/rt2x00/rt2x00.h
52277+++ b/drivers/net/wireless/rt2x00/rt2x00.h
52278@@ -375,7 +375,7 @@ struct rt2x00_intf {
52279 * for hardware which doesn't support hardware
52280 * sequence counting.
52281 */
52282- atomic_t seqno;
52283+ atomic_unchecked_t seqno;
52284 };
52285
52286 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
52287diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
52288index 68b620b..92ecd9e 100644
52289--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
52290+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
52291@@ -224,9 +224,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
52292 * sequence counter given by mac80211.
52293 */
52294 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
52295- seqno = atomic_add_return(0x10, &intf->seqno);
52296+ seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
52297 else
52298- seqno = atomic_read(&intf->seqno);
52299+ seqno = atomic_read_unchecked(&intf->seqno);
52300
52301 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
52302 hdr->seq_ctrl |= cpu_to_le16(seqno);
52303diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
52304index b661f896..ddf7d2b 100644
52305--- a/drivers/net/wireless/ti/wl1251/sdio.c
52306+++ b/drivers/net/wireless/ti/wl1251/sdio.c
52307@@ -282,13 +282,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
52308
52309 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
52310
52311- wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
52312- wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
52313+ pax_open_kernel();
52314+ *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
52315+ *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
52316+ pax_close_kernel();
52317
52318 wl1251_info("using dedicated interrupt line");
52319 } else {
52320- wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
52321- wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
52322+ pax_open_kernel();
52323+ *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
52324+ *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
52325+ pax_close_kernel();
52326
52327 wl1251_info("using SDIO interrupt");
52328 }
52329diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
52330index af0fe2e..d04986b 100644
52331--- a/drivers/net/wireless/ti/wl12xx/main.c
52332+++ b/drivers/net/wireless/ti/wl12xx/main.c
52333@@ -655,7 +655,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
52334 sizeof(wl->conf.mem));
52335
52336 /* read data preparation is only needed by wl127x */
52337- wl->ops->prepare_read = wl127x_prepare_read;
52338+ pax_open_kernel();
52339+ *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
52340+ pax_close_kernel();
52341
52342 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
52343 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
52344@@ -680,7 +682,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
52345 sizeof(wl->conf.mem));
52346
52347 /* read data preparation is only needed by wl127x */
52348- wl->ops->prepare_read = wl127x_prepare_read;
52349+ pax_open_kernel();
52350+ *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
52351+ pax_close_kernel();
52352
52353 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
52354 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
52355diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
52356index 49aca2c..3b9c10c 100644
52357--- a/drivers/net/wireless/ti/wl18xx/main.c
52358+++ b/drivers/net/wireless/ti/wl18xx/main.c
52359@@ -1952,8 +1952,10 @@ static int wl18xx_setup(struct wl1271 *wl)
52360 }
52361
52362 if (!checksum_param) {
52363- wl18xx_ops.set_rx_csum = NULL;
52364- wl18xx_ops.init_vif = NULL;
52365+ pax_open_kernel();
52366+ *(void **)&wl18xx_ops.set_rx_csum = NULL;
52367+ *(void **)&wl18xx_ops.init_vif = NULL;
52368+ pax_close_kernel();
52369 }
52370
52371 /* Enable 11a Band only if we have 5G antennas */
52372diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
52373index a912dc0..a8225ba 100644
52374--- a/drivers/net/wireless/zd1211rw/zd_usb.c
52375+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
52376@@ -385,7 +385,7 @@ static inline void handle_regs_int(struct urb *urb)
52377 {
52378 struct zd_usb *usb = urb->context;
52379 struct zd_usb_interrupt *intr = &usb->intr;
52380- int len;
52381+ unsigned int len;
52382 u16 int_num;
52383
52384 ZD_ASSERT(in_interrupt());
52385diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
52386index ce2e2cf..f81e500 100644
52387--- a/drivers/nfc/nfcwilink.c
52388+++ b/drivers/nfc/nfcwilink.c
52389@@ -497,7 +497,7 @@ static struct nci_ops nfcwilink_ops = {
52390
52391 static int nfcwilink_probe(struct platform_device *pdev)
52392 {
52393- static struct nfcwilink *drv;
52394+ struct nfcwilink *drv;
52395 int rc;
52396 __u32 protocols;
52397
52398diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
52399index 6e82bc42..ab4145c 100644
52400--- a/drivers/of/fdt.c
52401+++ b/drivers/of/fdt.c
52402@@ -1161,7 +1161,9 @@ static int __init of_fdt_raw_init(void)
52403 pr_warn("fdt: not creating '/sys/firmware/fdt': CRC check failed\n");
52404 return 0;
52405 }
52406- of_fdt_raw_attr.size = fdt_totalsize(initial_boot_params);
52407+ pax_open_kernel();
52408+ *(size_t *)&of_fdt_raw_attr.size = fdt_totalsize(initial_boot_params);
52409+ pax_close_kernel();
52410 return sysfs_create_bin_file(firmware_kobj, &of_fdt_raw_attr);
52411 }
52412 late_initcall(of_fdt_raw_init);
52413diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
52414index 82f7000..d6d0447 100644
52415--- a/drivers/oprofile/buffer_sync.c
52416+++ b/drivers/oprofile/buffer_sync.c
52417@@ -345,7 +345,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
52418 if (cookie == NO_COOKIE)
52419 offset = pc;
52420 if (cookie == INVALID_COOKIE) {
52421- atomic_inc(&oprofile_stats.sample_lost_no_mapping);
52422+ atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
52423 offset = pc;
52424 }
52425 if (cookie != last_cookie) {
52426@@ -389,14 +389,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
52427 /* add userspace sample */
52428
52429 if (!mm) {
52430- atomic_inc(&oprofile_stats.sample_lost_no_mm);
52431+ atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
52432 return 0;
52433 }
52434
52435 cookie = lookup_dcookie(mm, s->eip, &offset);
52436
52437 if (cookie == INVALID_COOKIE) {
52438- atomic_inc(&oprofile_stats.sample_lost_no_mapping);
52439+ atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
52440 return 0;
52441 }
52442
52443@@ -554,7 +554,7 @@ void sync_buffer(int cpu)
52444 /* ignore backtraces if failed to add a sample */
52445 if (state == sb_bt_start) {
52446 state = sb_bt_ignore;
52447- atomic_inc(&oprofile_stats.bt_lost_no_mapping);
52448+ atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
52449 }
52450 }
52451 release_mm(mm);
52452diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
52453index c0cc4e7..44d4e54 100644
52454--- a/drivers/oprofile/event_buffer.c
52455+++ b/drivers/oprofile/event_buffer.c
52456@@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
52457 }
52458
52459 if (buffer_pos == buffer_size) {
52460- atomic_inc(&oprofile_stats.event_lost_overflow);
52461+ atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
52462 return;
52463 }
52464
52465diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
52466index ed2c3ec..deda85a 100644
52467--- a/drivers/oprofile/oprof.c
52468+++ b/drivers/oprofile/oprof.c
52469@@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
52470 if (oprofile_ops.switch_events())
52471 return;
52472
52473- atomic_inc(&oprofile_stats.multiplex_counter);
52474+ atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
52475 start_switch_worker();
52476 }
52477
52478diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
52479index 59659ce..6c860a0 100644
52480--- a/drivers/oprofile/oprofile_stats.c
52481+++ b/drivers/oprofile/oprofile_stats.c
52482@@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
52483 cpu_buf->sample_invalid_eip = 0;
52484 }
52485
52486- atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
52487- atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
52488- atomic_set(&oprofile_stats.event_lost_overflow, 0);
52489- atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
52490- atomic_set(&oprofile_stats.multiplex_counter, 0);
52491+ atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
52492+ atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
52493+ atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
52494+ atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
52495+ atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
52496 }
52497
52498
52499diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
52500index 1fc622b..8c48fc3 100644
52501--- a/drivers/oprofile/oprofile_stats.h
52502+++ b/drivers/oprofile/oprofile_stats.h
52503@@ -13,11 +13,11 @@
52504 #include <linux/atomic.h>
52505
52506 struct oprofile_stat_struct {
52507- atomic_t sample_lost_no_mm;
52508- atomic_t sample_lost_no_mapping;
52509- atomic_t bt_lost_no_mapping;
52510- atomic_t event_lost_overflow;
52511- atomic_t multiplex_counter;
52512+ atomic_unchecked_t sample_lost_no_mm;
52513+ atomic_unchecked_t sample_lost_no_mapping;
52514+ atomic_unchecked_t bt_lost_no_mapping;
52515+ atomic_unchecked_t event_lost_overflow;
52516+ atomic_unchecked_t multiplex_counter;
52517 };
52518
52519 extern struct oprofile_stat_struct oprofile_stats;
52520diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
52521index dd92c5e..dfc04b5 100644
52522--- a/drivers/oprofile/oprofilefs.c
52523+++ b/drivers/oprofile/oprofilefs.c
52524@@ -176,8 +176,8 @@ int oprofilefs_create_ro_ulong(struct dentry *root,
52525
52526 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
52527 {
52528- atomic_t *val = file->private_data;
52529- return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
52530+ atomic_unchecked_t *val = file->private_data;
52531+ return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
52532 }
52533
52534
52535@@ -189,7 +189,7 @@ static const struct file_operations atomic_ro_fops = {
52536
52537
52538 int oprofilefs_create_ro_atomic(struct dentry *root,
52539- char const *name, atomic_t *val)
52540+ char const *name, atomic_unchecked_t *val)
52541 {
52542 return __oprofilefs_create_file(root, name,
52543 &atomic_ro_fops, 0444, val);
52544diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
52545index bdef916..88c7dee 100644
52546--- a/drivers/oprofile/timer_int.c
52547+++ b/drivers/oprofile/timer_int.c
52548@@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
52549 return NOTIFY_OK;
52550 }
52551
52552-static struct notifier_block __refdata oprofile_cpu_notifier = {
52553+static struct notifier_block oprofile_cpu_notifier = {
52554 .notifier_call = oprofile_cpu_notify,
52555 };
52556
52557diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
52558index c776333..aa6b325 100644
52559--- a/drivers/parport/procfs.c
52560+++ b/drivers/parport/procfs.c
52561@@ -65,7 +65,7 @@ static int do_active_device(struct ctl_table *table, int write,
52562
52563 *ppos += len;
52564
52565- return copy_to_user(result, buffer, len) ? -EFAULT : 0;
52566+ return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
52567 }
52568
52569 #ifdef CONFIG_PARPORT_1284
52570@@ -107,7 +107,7 @@ static int do_autoprobe(struct ctl_table *table, int write,
52571
52572 *ppos += len;
52573
52574- return copy_to_user (result, buffer, len) ? -EFAULT : 0;
52575+ return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
52576 }
52577 #endif /* IEEE1284.3 support. */
52578
52579diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c
52580index ba46e58..90cfc24 100644
52581--- a/drivers/pci/host/pci-host-generic.c
52582+++ b/drivers/pci/host/pci-host-generic.c
52583@@ -26,9 +26,9 @@
52584 #include <linux/platform_device.h>
52585
52586 struct gen_pci_cfg_bus_ops {
52587+ struct pci_ops ops;
52588 u32 bus_shift;
52589- void __iomem *(*map_bus)(struct pci_bus *, unsigned int, int);
52590-};
52591+} __do_const;
52592
52593 struct gen_pci_cfg_windows {
52594 struct resource res;
52595@@ -56,8 +56,12 @@ static void __iomem *gen_pci_map_cfg_bus_cam(struct pci_bus *bus,
52596 }
52597
52598 static struct gen_pci_cfg_bus_ops gen_pci_cfg_cam_bus_ops = {
52599+ .ops = {
52600+ .map_bus = gen_pci_map_cfg_bus_cam,
52601+ .read = pci_generic_config_read,
52602+ .write = pci_generic_config_write,
52603+ },
52604 .bus_shift = 16,
52605- .map_bus = gen_pci_map_cfg_bus_cam,
52606 };
52607
52608 static void __iomem *gen_pci_map_cfg_bus_ecam(struct pci_bus *bus,
52609@@ -72,13 +76,12 @@ static void __iomem *gen_pci_map_cfg_bus_ecam(struct pci_bus *bus,
52610 }
52611
52612 static struct gen_pci_cfg_bus_ops gen_pci_cfg_ecam_bus_ops = {
52613+ .ops = {
52614+ .map_bus = gen_pci_map_cfg_bus_ecam,
52615+ .read = pci_generic_config_read,
52616+ .write = pci_generic_config_write,
52617+ },
52618 .bus_shift = 20,
52619- .map_bus = gen_pci_map_cfg_bus_ecam,
52620-};
52621-
52622-static struct pci_ops gen_pci_ops = {
52623- .read = pci_generic_config_read,
52624- .write = pci_generic_config_write,
52625 };
52626
52627 static const struct of_device_id gen_pci_of_match[] = {
52628@@ -219,7 +222,6 @@ static int gen_pci_probe(struct platform_device *pdev)
52629 .private_data = (void **)&pci,
52630 .setup = gen_pci_setup,
52631 .map_irq = of_irq_parse_and_map_pci,
52632- .ops = &gen_pci_ops,
52633 };
52634
52635 if (!pci)
52636@@ -241,7 +243,7 @@ static int gen_pci_probe(struct platform_device *pdev)
52637
52638 of_id = of_match_node(gen_pci_of_match, np);
52639 pci->cfg.ops = of_id->data;
52640- gen_pci_ops.map_bus = pci->cfg.ops->map_bus;
52641+ hw.ops = &pci->cfg.ops->ops;
52642 pci->host.dev.parent = dev;
52643 INIT_LIST_HEAD(&pci->host.windows);
52644 INIT_LIST_HEAD(&pci->resources);
52645diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
52646index 6ca2399..68d866b 100644
52647--- a/drivers/pci/hotplug/acpiphp_ibm.c
52648+++ b/drivers/pci/hotplug/acpiphp_ibm.c
52649@@ -452,7 +452,9 @@ static int __init ibm_acpiphp_init(void)
52650 goto init_cleanup;
52651 }
52652
52653- ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
52654+ pax_open_kernel();
52655+ *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
52656+ pax_close_kernel();
52657 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
52658
52659 return retval;
52660diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
52661index 66b7bbe..26bee78 100644
52662--- a/drivers/pci/hotplug/cpcihp_generic.c
52663+++ b/drivers/pci/hotplug/cpcihp_generic.c
52664@@ -73,7 +73,6 @@ static u16 port;
52665 static unsigned int enum_bit;
52666 static u8 enum_mask;
52667
52668-static struct cpci_hp_controller_ops generic_hpc_ops;
52669 static struct cpci_hp_controller generic_hpc;
52670
52671 static int __init validate_parameters(void)
52672@@ -139,6 +138,10 @@ static int query_enum(void)
52673 return ((value & enum_mask) == enum_mask);
52674 }
52675
52676+static struct cpci_hp_controller_ops generic_hpc_ops = {
52677+ .query_enum = query_enum,
52678+};
52679+
52680 static int __init cpcihp_generic_init(void)
52681 {
52682 int status;
52683@@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
52684 pci_dev_put(dev);
52685
52686 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
52687- generic_hpc_ops.query_enum = query_enum;
52688 generic_hpc.ops = &generic_hpc_ops;
52689
52690 status = cpci_hp_register_controller(&generic_hpc);
52691diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
52692index 7ecf34e..effed62 100644
52693--- a/drivers/pci/hotplug/cpcihp_zt5550.c
52694+++ b/drivers/pci/hotplug/cpcihp_zt5550.c
52695@@ -59,7 +59,6 @@
52696 /* local variables */
52697 static bool debug;
52698 static bool poll;
52699-static struct cpci_hp_controller_ops zt5550_hpc_ops;
52700 static struct cpci_hp_controller zt5550_hpc;
52701
52702 /* Primary cPCI bus bridge device */
52703@@ -204,6 +203,10 @@ static int zt5550_hc_disable_irq(void)
52704 return 0;
52705 }
52706
52707+static struct cpci_hp_controller_ops zt5550_hpc_ops = {
52708+ .query_enum = zt5550_hc_query_enum,
52709+};
52710+
52711 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
52712 {
52713 int status;
52714@@ -215,16 +218,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
52715 dbg("returned from zt5550_hc_config");
52716
52717 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
52718- zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
52719 zt5550_hpc.ops = &zt5550_hpc_ops;
52720 if (!poll) {
52721 zt5550_hpc.irq = hc_dev->irq;
52722 zt5550_hpc.irq_flags = IRQF_SHARED;
52723 zt5550_hpc.dev_id = hc_dev;
52724
52725- zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
52726- zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
52727- zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
52728+ pax_open_kernel();
52729+ *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
52730+ *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
52731+ *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
52732+ pax_open_kernel();
52733 } else {
52734 info("using ENUM# polling mode");
52735 }
52736diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
52737index 1e08ff8c..3cd145f 100644
52738--- a/drivers/pci/hotplug/cpqphp_nvram.c
52739+++ b/drivers/pci/hotplug/cpqphp_nvram.c
52740@@ -425,8 +425,10 @@ static u32 store_HRT (void __iomem *rom_start)
52741
52742 void compaq_nvram_init (void __iomem *rom_start)
52743 {
52744+#ifndef CONFIG_PAX_KERNEXEC
52745 if (rom_start)
52746 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
52747+#endif
52748
52749 dbg("int15 entry = %p\n", compaq_int15_entry_point);
52750
52751diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
52752index 56d8486..f26113f 100644
52753--- a/drivers/pci/hotplug/pci_hotplug_core.c
52754+++ b/drivers/pci/hotplug/pci_hotplug_core.c
52755@@ -436,8 +436,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
52756 return -EINVAL;
52757 }
52758
52759- slot->ops->owner = owner;
52760- slot->ops->mod_name = mod_name;
52761+ pax_open_kernel();
52762+ *(struct module **)&slot->ops->owner = owner;
52763+ *(const char **)&slot->ops->mod_name = mod_name;
52764+ pax_close_kernel();
52765
52766 mutex_lock(&pci_hp_mutex);
52767 /*
52768diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
52769index 612b21a..9494a5e 100644
52770--- a/drivers/pci/hotplug/pciehp_core.c
52771+++ b/drivers/pci/hotplug/pciehp_core.c
52772@@ -87,7 +87,7 @@ static int init_slot(struct controller *ctrl)
52773 struct slot *slot = ctrl->slot;
52774 struct hotplug_slot *hotplug = NULL;
52775 struct hotplug_slot_info *info = NULL;
52776- struct hotplug_slot_ops *ops = NULL;
52777+ hotplug_slot_ops_no_const *ops = NULL;
52778 char name[SLOT_NAME_SIZE];
52779 int retval = -ENOMEM;
52780
52781diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
52782index f66be86..6cbcabb 100644
52783--- a/drivers/pci/msi.c
52784+++ b/drivers/pci/msi.c
52785@@ -492,8 +492,8 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
52786 {
52787 struct attribute **msi_attrs;
52788 struct attribute *msi_attr;
52789- struct device_attribute *msi_dev_attr;
52790- struct attribute_group *msi_irq_group;
52791+ device_attribute_no_const *msi_dev_attr;
52792+ attribute_group_no_const *msi_irq_group;
52793 const struct attribute_group **msi_irq_groups;
52794 struct msi_desc *entry;
52795 int ret = -ENOMEM;
52796@@ -552,7 +552,7 @@ error_attrs:
52797 count = 0;
52798 msi_attr = msi_attrs[count];
52799 while (msi_attr) {
52800- msi_dev_attr = container_of(msi_attr, struct device_attribute, attr);
52801+ msi_dev_attr = container_of(msi_attr, device_attribute_no_const, attr);
52802 kfree(msi_attr->name);
52803 kfree(msi_dev_attr);
52804 ++count;
52805@@ -1236,12 +1236,14 @@ static void pci_msi_domain_update_dom_ops(struct msi_domain_info *info)
52806 if (ops == NULL) {
52807 info->ops = &pci_msi_domain_ops_default;
52808 } else {
52809+ pax_open_kernel();
52810 if (ops->set_desc == NULL)
52811- ops->set_desc = pci_msi_domain_set_desc;
52812+ *(void **)&ops->set_desc = pci_msi_domain_set_desc;
52813 if (ops->msi_check == NULL)
52814- ops->msi_check = pci_msi_domain_check_cap;
52815+ *(void **)&ops->msi_check = pci_msi_domain_check_cap;
52816 if (ops->handle_error == NULL)
52817- ops->handle_error = pci_msi_domain_handle_error;
52818+ *(void **)&ops->handle_error = pci_msi_domain_handle_error;
52819+ pax_close_kernel();
52820 }
52821 }
52822
52823@@ -1250,8 +1252,11 @@ static void pci_msi_domain_update_chip_ops(struct msi_domain_info *info)
52824 struct irq_chip *chip = info->chip;
52825
52826 BUG_ON(!chip);
52827- if (!chip->irq_write_msi_msg)
52828- chip->irq_write_msi_msg = pci_msi_domain_write_msg;
52829+ if (!chip->irq_write_msi_msg) {
52830+ pax_open_kernel();
52831+ *(void **)&chip->irq_write_msi_msg = pci_msi_domain_write_msg;
52832+ pax_close_kernel();
52833+ }
52834 }
52835
52836 /**
52837diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
52838index 312f23a..d21181c 100644
52839--- a/drivers/pci/pci-sysfs.c
52840+++ b/drivers/pci/pci-sysfs.c
52841@@ -1140,7 +1140,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
52842 {
52843 /* allocate attribute structure, piggyback attribute name */
52844 int name_len = write_combine ? 13 : 10;
52845- struct bin_attribute *res_attr;
52846+ bin_attribute_no_const *res_attr;
52847 int retval;
52848
52849 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
52850@@ -1317,7 +1317,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
52851 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
52852 {
52853 int retval;
52854- struct bin_attribute *attr;
52855+ bin_attribute_no_const *attr;
52856
52857 /* If the device has VPD, try to expose it in sysfs. */
52858 if (dev->vpd) {
52859@@ -1364,7 +1364,7 @@ int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
52860 {
52861 int retval;
52862 int rom_size = 0;
52863- struct bin_attribute *attr;
52864+ bin_attribute_no_const *attr;
52865
52866 if (!sysfs_initialized)
52867 return -EACCES;
52868diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
52869index 4ff0ff1..e309fb0 100644
52870--- a/drivers/pci/pci.h
52871+++ b/drivers/pci/pci.h
52872@@ -99,7 +99,7 @@ struct pci_vpd_ops {
52873 struct pci_vpd {
52874 unsigned int len;
52875 const struct pci_vpd_ops *ops;
52876- struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
52877+ bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
52878 };
52879
52880 int pci_vpd_pci22_init(struct pci_dev *dev);
52881diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
52882index 317e355..21f7b91 100644
52883--- a/drivers/pci/pcie/aspm.c
52884+++ b/drivers/pci/pcie/aspm.c
52885@@ -27,9 +27,9 @@
52886 #define MODULE_PARAM_PREFIX "pcie_aspm."
52887
52888 /* Note: those are not register definitions */
52889-#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
52890-#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
52891-#define ASPM_STATE_L1 (4) /* L1 state */
52892+#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
52893+#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
52894+#define ASPM_STATE_L1 (4U) /* L1 state */
52895 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
52896 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
52897
52898diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
52899index be35da2..ec16cdb 100644
52900--- a/drivers/pci/pcie/portdrv_pci.c
52901+++ b/drivers/pci/pcie/portdrv_pci.c
52902@@ -324,7 +324,7 @@ static int __init dmi_pcie_pme_disable_msi(const struct dmi_system_id *d)
52903 return 0;
52904 }
52905
52906-static struct dmi_system_id __initdata pcie_portdrv_dmi_table[] = {
52907+static const struct dmi_system_id __initconst pcie_portdrv_dmi_table[] = {
52908 /*
52909 * Boxes that should not use MSI for PCIe PME signaling.
52910 */
52911diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
52912index f6ae0d0..af897bc 100644
52913--- a/drivers/pci/probe.c
52914+++ b/drivers/pci/probe.c
52915@@ -176,7 +176,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
52916 u16 orig_cmd;
52917 struct pci_bus_region region, inverted_region;
52918
52919- mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
52920+ mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
52921
52922 /* No printks while decoding is disabled! */
52923 if (!dev->mmio_always_on) {
52924diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
52925index 3f155e7..0f4b1f0 100644
52926--- a/drivers/pci/proc.c
52927+++ b/drivers/pci/proc.c
52928@@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
52929 static int __init pci_proc_init(void)
52930 {
52931 struct pci_dev *dev = NULL;
52932+
52933+#ifdef CONFIG_GRKERNSEC_PROC_ADD
52934+#ifdef CONFIG_GRKERNSEC_PROC_USER
52935+ proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
52936+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
52937+ proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
52938+#endif
52939+#else
52940 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
52941+#endif
52942 proc_create("devices", 0, proc_bus_pci_dir,
52943 &proc_bus_pci_dev_operations);
52944 proc_initialized = 1;
52945diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
52946index 2deb130..8194e13 100644
52947--- a/drivers/pinctrl/pinctrl-at91.c
52948+++ b/drivers/pinctrl/pinctrl-at91.c
52949@@ -24,6 +24,7 @@
52950 #include <linux/pinctrl/pinmux.h>
52951 /* Since we request GPIOs from ourself */
52952 #include <linux/pinctrl/consumer.h>
52953+#include <asm/pgtable.h>
52954
52955 #include "pinctrl-at91.h"
52956 #include "core.h"
52957@@ -1656,7 +1657,9 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev,
52958 at91_gpio->pioc_hwirq = irqd_to_hwirq(d);
52959
52960 /* Setup proper .irq_set_type function */
52961- gpio_irqchip.irq_set_type = at91_gpio->ops->irq_type;
52962+ pax_open_kernel();
52963+ *(void **)&gpio_irqchip.irq_set_type = at91_gpio->ops->irq_type;
52964+ pax_close_kernel();
52965
52966 /* Disable irqs of this PIO controller */
52967 writel_relaxed(~0, at91_gpio->regbase + PIO_IDR);
52968diff --git a/drivers/platform/chrome/chromeos_pstore.c b/drivers/platform/chrome/chromeos_pstore.c
52969index 3474920..acc9581 100644
52970--- a/drivers/platform/chrome/chromeos_pstore.c
52971+++ b/drivers/platform/chrome/chromeos_pstore.c
52972@@ -13,7 +13,7 @@
52973 #include <linux/platform_device.h>
52974 #include <linux/pstore_ram.h>
52975
52976-static struct dmi_system_id chromeos_pstore_dmi_table[] __initdata = {
52977+static const struct dmi_system_id chromeos_pstore_dmi_table[] __initconst = {
52978 {
52979 /*
52980 * Today all Chromebooks/boxes ship with Google_* as version and
52981diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c
52982index 1e1e594..8fe59c5 100644
52983--- a/drivers/platform/x86/alienware-wmi.c
52984+++ b/drivers/platform/x86/alienware-wmi.c
52985@@ -150,7 +150,7 @@ struct wmax_led_args {
52986 } __packed;
52987
52988 static struct platform_device *platform_device;
52989-static struct device_attribute *zone_dev_attrs;
52990+static device_attribute_no_const *zone_dev_attrs;
52991 static struct attribute **zone_attrs;
52992 static struct platform_zone *zone_data;
52993
52994@@ -160,7 +160,7 @@ static struct platform_driver platform_driver = {
52995 }
52996 };
52997
52998-static struct attribute_group zone_attribute_group = {
52999+static attribute_group_no_const zone_attribute_group = {
53000 .name = "rgb_zones",
53001 };
53002
53003diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
53004index efbc3f0..18ae682 100644
53005--- a/drivers/platform/x86/asus-wmi.c
53006+++ b/drivers/platform/x86/asus-wmi.c
53007@@ -1868,6 +1868,10 @@ static int show_dsts(struct seq_file *m, void *data)
53008 int err;
53009 u32 retval = -1;
53010
53011+#ifdef CONFIG_GRKERNSEC_KMEM
53012+ return -EPERM;
53013+#endif
53014+
53015 err = asus_wmi_get_devstate(asus, asus->debug.dev_id, &retval);
53016
53017 if (err < 0)
53018@@ -1884,6 +1888,10 @@ static int show_devs(struct seq_file *m, void *data)
53019 int err;
53020 u32 retval = -1;
53021
53022+#ifdef CONFIG_GRKERNSEC_KMEM
53023+ return -EPERM;
53024+#endif
53025+
53026 err = asus_wmi_set_devstate(asus->debug.dev_id, asus->debug.ctrl_param,
53027 &retval);
53028
53029@@ -1908,6 +1916,10 @@ static int show_call(struct seq_file *m, void *data)
53030 union acpi_object *obj;
53031 acpi_status status;
53032
53033+#ifdef CONFIG_GRKERNSEC_KMEM
53034+ return -EPERM;
53035+#endif
53036+
53037 status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID,
53038 1, asus->debug.method_id,
53039 &input, &output);
53040diff --git a/drivers/platform/x86/compal-laptop.c b/drivers/platform/x86/compal-laptop.c
53041index f2706d2..850edfa4 100644
53042--- a/drivers/platform/x86/compal-laptop.c
53043+++ b/drivers/platform/x86/compal-laptop.c
53044@@ -765,7 +765,7 @@ static int dmi_check_cb_extra(const struct dmi_system_id *id)
53045 return 1;
53046 }
53047
53048-static struct dmi_system_id __initdata compal_dmi_table[] = {
53049+static const struct dmi_system_id __initconst compal_dmi_table[] = {
53050 {
53051 .ident = "FL90/IFL90",
53052 .matches = {
53053diff --git a/drivers/platform/x86/hdaps.c b/drivers/platform/x86/hdaps.c
53054index 458e6c9..089aee7 100644
53055--- a/drivers/platform/x86/hdaps.c
53056+++ b/drivers/platform/x86/hdaps.c
53057@@ -514,7 +514,7 @@ static int __init hdaps_dmi_match_invert(const struct dmi_system_id *id)
53058 "ThinkPad T42p", so the order of the entries matters.
53059 If your ThinkPad is not recognized, please update to latest
53060 BIOS. This is especially the case for some R52 ThinkPads. */
53061-static struct dmi_system_id __initdata hdaps_whitelist[] = {
53062+static const struct dmi_system_id __initconst hdaps_whitelist[] = {
53063 HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad R50p", HDAPS_BOTH_AXES),
53064 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R50"),
53065 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R51"),
53066diff --git a/drivers/platform/x86/ibm_rtl.c b/drivers/platform/x86/ibm_rtl.c
53067index 97c2be1..2ee50ce 100644
53068--- a/drivers/platform/x86/ibm_rtl.c
53069+++ b/drivers/platform/x86/ibm_rtl.c
53070@@ -227,7 +227,7 @@ static void rtl_teardown_sysfs(void) {
53071 }
53072
53073
53074-static struct dmi_system_id __initdata ibm_rtl_dmi_table[] = {
53075+static const struct dmi_system_id __initconst ibm_rtl_dmi_table[] = {
53076 { \
53077 .matches = { \
53078 DMI_MATCH(DMI_SYS_VENDOR, "IBM"), \
53079diff --git a/drivers/platform/x86/intel_oaktrail.c b/drivers/platform/x86/intel_oaktrail.c
53080index 6aa33c4..cfb5425 100644
53081--- a/drivers/platform/x86/intel_oaktrail.c
53082+++ b/drivers/platform/x86/intel_oaktrail.c
53083@@ -299,7 +299,7 @@ static int dmi_check_cb(const struct dmi_system_id *id)
53084 return 0;
53085 }
53086
53087-static struct dmi_system_id __initdata oaktrail_dmi_table[] = {
53088+static const struct dmi_system_id __initconst oaktrail_dmi_table[] = {
53089 {
53090 .ident = "OakTrail platform",
53091 .matches = {
53092diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
53093index 4231770..10a6caf 100644
53094--- a/drivers/platform/x86/msi-laptop.c
53095+++ b/drivers/platform/x86/msi-laptop.c
53096@@ -605,7 +605,7 @@ static int dmi_check_cb(const struct dmi_system_id *dmi)
53097 return 1;
53098 }
53099
53100-static struct dmi_system_id __initdata msi_dmi_table[] = {
53101+static const struct dmi_system_id __initconst msi_dmi_table[] = {
53102 {
53103 .ident = "MSI S270",
53104 .matches = {
53105@@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
53106
53107 if (!quirks->ec_read_only) {
53108 /* allow userland write sysfs file */
53109- dev_attr_bluetooth.store = store_bluetooth;
53110- dev_attr_wlan.store = store_wlan;
53111- dev_attr_threeg.store = store_threeg;
53112- dev_attr_bluetooth.attr.mode |= S_IWUSR;
53113- dev_attr_wlan.attr.mode |= S_IWUSR;
53114- dev_attr_threeg.attr.mode |= S_IWUSR;
53115+ pax_open_kernel();
53116+ *(void **)&dev_attr_bluetooth.store = store_bluetooth;
53117+ *(void **)&dev_attr_wlan.store = store_wlan;
53118+ *(void **)&dev_attr_threeg.store = store_threeg;
53119+ *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
53120+ *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
53121+ *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
53122+ pax_close_kernel();
53123 }
53124
53125 /* disable hardware control by fn key */
53126diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
53127index 978e6d6..1f0b37d 100644
53128--- a/drivers/platform/x86/msi-wmi.c
53129+++ b/drivers/platform/x86/msi-wmi.c
53130@@ -184,7 +184,7 @@ static const struct backlight_ops msi_backlight_ops = {
53131 static void msi_wmi_notify(u32 value, void *context)
53132 {
53133 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
53134- static struct key_entry *key;
53135+ struct key_entry *key;
53136 union acpi_object *obj;
53137 acpi_status status;
53138
53139diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
53140index 8c146e2..356c62e 100644
53141--- a/drivers/platform/x86/samsung-laptop.c
53142+++ b/drivers/platform/x86/samsung-laptop.c
53143@@ -1567,7 +1567,7 @@ static int __init samsung_dmi_matched(const struct dmi_system_id *d)
53144 return 0;
53145 }
53146
53147-static struct dmi_system_id __initdata samsung_dmi_table[] = {
53148+static const struct dmi_system_id __initconst samsung_dmi_table[] = {
53149 {
53150 .matches = {
53151 DMI_MATCH(DMI_SYS_VENDOR,
53152diff --git a/drivers/platform/x86/samsung-q10.c b/drivers/platform/x86/samsung-q10.c
53153index e6aac72..e11ff24 100644
53154--- a/drivers/platform/x86/samsung-q10.c
53155+++ b/drivers/platform/x86/samsung-q10.c
53156@@ -95,7 +95,7 @@ static int __init dmi_check_callback(const struct dmi_system_id *id)
53157 return 1;
53158 }
53159
53160-static struct dmi_system_id __initdata samsungq10_dmi_table[] = {
53161+static const struct dmi_system_id __initconst samsungq10_dmi_table[] = {
53162 {
53163 .ident = "Samsung Q10",
53164 .matches = {
53165diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
53166index aeb80d1..3eb376b 100644
53167--- a/drivers/platform/x86/sony-laptop.c
53168+++ b/drivers/platform/x86/sony-laptop.c
53169@@ -2527,7 +2527,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
53170 }
53171
53172 /* High speed charging function */
53173-static struct device_attribute *hsc_handle;
53174+static device_attribute_no_const *hsc_handle;
53175
53176 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
53177 struct device_attribute *attr,
53178@@ -2601,7 +2601,7 @@ static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd)
53179 }
53180
53181 /* low battery function */
53182-static struct device_attribute *lowbatt_handle;
53183+static device_attribute_no_const *lowbatt_handle;
53184
53185 static ssize_t sony_nc_lowbatt_store(struct device *dev,
53186 struct device_attribute *attr,
53187@@ -2667,7 +2667,7 @@ static void sony_nc_lowbatt_cleanup(struct platform_device *pd)
53188 }
53189
53190 /* fan speed function */
53191-static struct device_attribute *fan_handle, *hsf_handle;
53192+static device_attribute_no_const *fan_handle, *hsf_handle;
53193
53194 static ssize_t sony_nc_hsfan_store(struct device *dev,
53195 struct device_attribute *attr,
53196@@ -2774,7 +2774,7 @@ static void sony_nc_fanspeed_cleanup(struct platform_device *pd)
53197 }
53198
53199 /* USB charge function */
53200-static struct device_attribute *uc_handle;
53201+static device_attribute_no_const *uc_handle;
53202
53203 static ssize_t sony_nc_usb_charge_store(struct device *dev,
53204 struct device_attribute *attr,
53205@@ -2848,7 +2848,7 @@ static void sony_nc_usb_charge_cleanup(struct platform_device *pd)
53206 }
53207
53208 /* Panel ID function */
53209-static struct device_attribute *panel_handle;
53210+static device_attribute_no_const *panel_handle;
53211
53212 static ssize_t sony_nc_panelid_show(struct device *dev,
53213 struct device_attribute *attr, char *buffer)
53214@@ -2895,7 +2895,7 @@ static void sony_nc_panelid_cleanup(struct platform_device *pd)
53215 }
53216
53217 /* smart connect function */
53218-static struct device_attribute *sc_handle;
53219+static device_attribute_no_const *sc_handle;
53220
53221 static ssize_t sony_nc_smart_conn_store(struct device *dev,
53222 struct device_attribute *attr,
53223@@ -4851,7 +4851,7 @@ static struct acpi_driver sony_pic_driver = {
53224 .drv.pm = &sony_pic_pm,
53225 };
53226
53227-static struct dmi_system_id __initdata sonypi_dmi_table[] = {
53228+static const struct dmi_system_id __initconst sonypi_dmi_table[] = {
53229 {
53230 .ident = "Sony Vaio",
53231 .matches = {
53232diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
53233index 33e488c..417aaea 100644
53234--- a/drivers/platform/x86/thinkpad_acpi.c
53235+++ b/drivers/platform/x86/thinkpad_acpi.c
53236@@ -2460,10 +2460,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
53237 && !tp_features.bright_unkfw)
53238 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
53239 }
53240+}
53241
53242 #undef TPACPI_COMPARE_KEY
53243 #undef TPACPI_MAY_SEND_KEY
53244-}
53245
53246 /*
53247 * Polling driver
53248diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
53249index 438d4c7..ca8a2fb 100644
53250--- a/drivers/pnp/pnpbios/bioscalls.c
53251+++ b/drivers/pnp/pnpbios/bioscalls.c
53252@@ -59,7 +59,7 @@ do { \
53253 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
53254 } while(0)
53255
53256-static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
53257+static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
53258 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
53259
53260 /*
53261@@ -96,7 +96,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
53262
53263 cpu = get_cpu();
53264 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
53265+
53266+ pax_open_kernel();
53267 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
53268+ pax_close_kernel();
53269
53270 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
53271 spin_lock_irqsave(&pnp_bios_lock, flags);
53272@@ -134,7 +137,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
53273 :"memory");
53274 spin_unlock_irqrestore(&pnp_bios_lock, flags);
53275
53276+ pax_open_kernel();
53277 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
53278+ pax_close_kernel();
53279+
53280 put_cpu();
53281
53282 /* If we get here and this is set then the PnP BIOS faulted on us. */
53283@@ -468,7 +474,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
53284 return status;
53285 }
53286
53287-void pnpbios_calls_init(union pnp_bios_install_struct *header)
53288+void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
53289 {
53290 int i;
53291
53292@@ -476,6 +482,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
53293 pnp_bios_callpoint.offset = header->fields.pm16offset;
53294 pnp_bios_callpoint.segment = PNP_CS16;
53295
53296+ pax_open_kernel();
53297+
53298 for_each_possible_cpu(i) {
53299 struct desc_struct *gdt = get_cpu_gdt_table(i);
53300 if (!gdt)
53301@@ -487,4 +495,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
53302 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
53303 (unsigned long)__va(header->fields.pm16dseg));
53304 }
53305+
53306+ pax_close_kernel();
53307 }
53308diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
53309index facd43b..b291260 100644
53310--- a/drivers/pnp/pnpbios/core.c
53311+++ b/drivers/pnp/pnpbios/core.c
53312@@ -494,7 +494,7 @@ static int __init exploding_pnp_bios(const struct dmi_system_id *d)
53313 return 0;
53314 }
53315
53316-static struct dmi_system_id pnpbios_dmi_table[] __initdata = {
53317+static const struct dmi_system_id pnpbios_dmi_table[] __initconst = {
53318 { /* PnPBIOS GPF on boot */
53319 .callback = exploding_pnp_bios,
53320 .ident = "Higraded P14H",
53321diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
53322index dfe1ee8..67e820c 100644
53323--- a/drivers/power/pda_power.c
53324+++ b/drivers/power/pda_power.c
53325@@ -38,7 +38,11 @@ static struct power_supply *pda_psy_ac, *pda_psy_usb;
53326
53327 #if IS_ENABLED(CONFIG_USB_PHY)
53328 static struct usb_phy *transceiver;
53329-static struct notifier_block otg_nb;
53330+static int otg_handle_notification(struct notifier_block *nb,
53331+ unsigned long event, void *unused);
53332+static struct notifier_block otg_nb = {
53333+ .notifier_call = otg_handle_notification
53334+};
53335 #endif
53336
53337 static struct regulator *ac_draw;
53338@@ -373,7 +377,6 @@ static int pda_power_probe(struct platform_device *pdev)
53339
53340 #if IS_ENABLED(CONFIG_USB_PHY)
53341 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
53342- otg_nb.notifier_call = otg_handle_notification;
53343 ret = usb_register_notifier(transceiver, &otg_nb);
53344 if (ret) {
53345 dev_err(dev, "failure to register otg notifier\n");
53346diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
53347index cc439fd..8fa30df 100644
53348--- a/drivers/power/power_supply.h
53349+++ b/drivers/power/power_supply.h
53350@@ -16,12 +16,12 @@ struct power_supply;
53351
53352 #ifdef CONFIG_SYSFS
53353
53354-extern void power_supply_init_attrs(struct device_type *dev_type);
53355+extern void power_supply_init_attrs(void);
53356 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
53357
53358 #else
53359
53360-static inline void power_supply_init_attrs(struct device_type *dev_type) {}
53361+static inline void power_supply_init_attrs(void) {}
53362 #define power_supply_uevent NULL
53363
53364 #endif /* CONFIG_SYSFS */
53365diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
53366index 869284c..38a812b 100644
53367--- a/drivers/power/power_supply_core.c
53368+++ b/drivers/power/power_supply_core.c
53369@@ -28,7 +28,10 @@ EXPORT_SYMBOL_GPL(power_supply_class);
53370 ATOMIC_NOTIFIER_HEAD(power_supply_notifier);
53371 EXPORT_SYMBOL_GPL(power_supply_notifier);
53372
53373-static struct device_type power_supply_dev_type;
53374+extern const struct attribute_group *power_supply_attr_groups[];
53375+static struct device_type power_supply_dev_type = {
53376+ .groups = power_supply_attr_groups,
53377+};
53378
53379 #define POWER_SUPPLY_DEFERRED_REGISTER_TIME msecs_to_jiffies(10)
53380
53381@@ -960,7 +963,7 @@ static int __init power_supply_class_init(void)
53382 return PTR_ERR(power_supply_class);
53383
53384 power_supply_class->dev_uevent = power_supply_uevent;
53385- power_supply_init_attrs(&power_supply_dev_type);
53386+ power_supply_init_attrs();
53387
53388 return 0;
53389 }
53390diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
53391index ed2d7fd..266b28f 100644
53392--- a/drivers/power/power_supply_sysfs.c
53393+++ b/drivers/power/power_supply_sysfs.c
53394@@ -238,17 +238,15 @@ static struct attribute_group power_supply_attr_group = {
53395 .is_visible = power_supply_attr_is_visible,
53396 };
53397
53398-static const struct attribute_group *power_supply_attr_groups[] = {
53399+const struct attribute_group *power_supply_attr_groups[] = {
53400 &power_supply_attr_group,
53401 NULL,
53402 };
53403
53404-void power_supply_init_attrs(struct device_type *dev_type)
53405+void power_supply_init_attrs(void)
53406 {
53407 int i;
53408
53409- dev_type->groups = power_supply_attr_groups;
53410-
53411 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
53412 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
53413 }
53414diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c
53415index 36dc52f..e2e8a4b 100644
53416--- a/drivers/power/reset/at91-reset.c
53417+++ b/drivers/power/reset/at91-reset.c
53418@@ -16,6 +16,7 @@
53419 #include <linux/of_address.h>
53420 #include <linux/platform_device.h>
53421 #include <linux/reboot.h>
53422+#include <asm/pgtable.h>
53423
53424 #include <soc/at91/at91sam9_ddrsdr.h>
53425 #include <soc/at91/at91sam9_sdramc.h>
53426@@ -191,7 +192,9 @@ static int at91_reset_of_probe(struct platform_device *pdev)
53427 }
53428
53429 match = of_match_node(at91_reset_of_match, pdev->dev.of_node);
53430- at91_restart_nb.notifier_call = match->data;
53431+ pax_open_kernel();
53432+ *(void **)&at91_restart_nb.notifier_call = match->data;
53433+ pax_close_kernel();
53434 return register_restart_handler(&at91_restart_nb);
53435 }
53436
53437@@ -219,9 +222,11 @@ static int at91_reset_platform_probe(struct platform_device *pdev)
53438 }
53439
53440 match = platform_get_device_id(pdev);
53441- at91_restart_nb.notifier_call =
53442+ pax_open_kernel();
53443+ *(void **)&at91_restart_nb.notifier_call =
53444 (int (*)(struct notifier_block *,
53445 unsigned long, void *)) match->driver_data;
53446+ pax_close_kernel();
53447
53448 return register_restart_handler(&at91_restart_nb);
53449 }
53450diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c
53451index 84419af..268ede8 100644
53452--- a/drivers/powercap/powercap_sys.c
53453+++ b/drivers/powercap/powercap_sys.c
53454@@ -154,8 +154,77 @@ struct powercap_constraint_attr {
53455 struct device_attribute name_attr;
53456 };
53457
53458+static ssize_t show_constraint_name(struct device *dev,
53459+ struct device_attribute *dev_attr,
53460+ char *buf);
53461+
53462 static struct powercap_constraint_attr
53463- constraint_attrs[MAX_CONSTRAINTS_PER_ZONE];
53464+ constraint_attrs[MAX_CONSTRAINTS_PER_ZONE] = {
53465+ [0 ... MAX_CONSTRAINTS_PER_ZONE - 1] = {
53466+ .power_limit_attr = {
53467+ .attr = {
53468+ .name = NULL,
53469+ .mode = S_IWUSR | S_IRUGO
53470+ },
53471+ .show = show_constraint_power_limit_uw,
53472+ .store = store_constraint_power_limit_uw
53473+ },
53474+
53475+ .time_window_attr = {
53476+ .attr = {
53477+ .name = NULL,
53478+ .mode = S_IWUSR | S_IRUGO
53479+ },
53480+ .show = show_constraint_time_window_us,
53481+ .store = store_constraint_time_window_us
53482+ },
53483+
53484+ .max_power_attr = {
53485+ .attr = {
53486+ .name = NULL,
53487+ .mode = S_IRUGO
53488+ },
53489+ .show = show_constraint_max_power_uw,
53490+ .store = NULL
53491+ },
53492+
53493+ .min_power_attr = {
53494+ .attr = {
53495+ .name = NULL,
53496+ .mode = S_IRUGO
53497+ },
53498+ .show = show_constraint_min_power_uw,
53499+ .store = NULL
53500+ },
53501+
53502+ .max_time_window_attr = {
53503+ .attr = {
53504+ .name = NULL,
53505+ .mode = S_IRUGO
53506+ },
53507+ .show = show_constraint_max_time_window_us,
53508+ .store = NULL
53509+ },
53510+
53511+ .min_time_window_attr = {
53512+ .attr = {
53513+ .name = NULL,
53514+ .mode = S_IRUGO
53515+ },
53516+ .show = show_constraint_min_time_window_us,
53517+ .store = NULL
53518+ },
53519+
53520+ .name_attr = {
53521+ .attr = {
53522+ .name = NULL,
53523+ .mode = S_IRUGO
53524+ },
53525+ .show = show_constraint_name,
53526+ .store = NULL
53527+ }
53528+ }
53529+};
53530
53531 /* A list of powercap control_types */
53532 static LIST_HEAD(powercap_cntrl_list);
53533@@ -193,23 +262,16 @@ static ssize_t show_constraint_name(struct device *dev,
53534 }
53535
53536 static int create_constraint_attribute(int id, const char *name,
53537- int mode,
53538- struct device_attribute *dev_attr,
53539- ssize_t (*show)(struct device *,
53540- struct device_attribute *, char *),
53541- ssize_t (*store)(struct device *,
53542- struct device_attribute *,
53543- const char *, size_t)
53544- )
53545+ struct device_attribute *dev_attr)
53546 {
53547+ name = kasprintf(GFP_KERNEL, "constraint_%d_%s", id, name);
53548
53549- dev_attr->attr.name = kasprintf(GFP_KERNEL, "constraint_%d_%s",
53550- id, name);
53551- if (!dev_attr->attr.name)
53552+ if (!name)
53553 return -ENOMEM;
53554- dev_attr->attr.mode = mode;
53555- dev_attr->show = show;
53556- dev_attr->store = store;
53557+
53558+ pax_open_kernel();
53559+ *(const char **)&dev_attr->attr.name = name;
53560+ pax_close_kernel();
53561
53562 return 0;
53563 }
53564@@ -236,49 +298,31 @@ static int seed_constraint_attributes(void)
53565
53566 for (i = 0; i < MAX_CONSTRAINTS_PER_ZONE; ++i) {
53567 ret = create_constraint_attribute(i, "power_limit_uw",
53568- S_IWUSR | S_IRUGO,
53569- &constraint_attrs[i].power_limit_attr,
53570- show_constraint_power_limit_uw,
53571- store_constraint_power_limit_uw);
53572+ &constraint_attrs[i].power_limit_attr);
53573 if (ret)
53574 goto err_alloc;
53575 ret = create_constraint_attribute(i, "time_window_us",
53576- S_IWUSR | S_IRUGO,
53577- &constraint_attrs[i].time_window_attr,
53578- show_constraint_time_window_us,
53579- store_constraint_time_window_us);
53580+ &constraint_attrs[i].time_window_attr);
53581 if (ret)
53582 goto err_alloc;
53583- ret = create_constraint_attribute(i, "name", S_IRUGO,
53584- &constraint_attrs[i].name_attr,
53585- show_constraint_name,
53586- NULL);
53587+ ret = create_constraint_attribute(i, "name",
53588+ &constraint_attrs[i].name_attr);
53589 if (ret)
53590 goto err_alloc;
53591- ret = create_constraint_attribute(i, "max_power_uw", S_IRUGO,
53592- &constraint_attrs[i].max_power_attr,
53593- show_constraint_max_power_uw,
53594- NULL);
53595+ ret = create_constraint_attribute(i, "max_power_uw",
53596+ &constraint_attrs[i].max_power_attr);
53597 if (ret)
53598 goto err_alloc;
53599- ret = create_constraint_attribute(i, "min_power_uw", S_IRUGO,
53600- &constraint_attrs[i].min_power_attr,
53601- show_constraint_min_power_uw,
53602- NULL);
53603+ ret = create_constraint_attribute(i, "min_power_uw",
53604+ &constraint_attrs[i].min_power_attr);
53605 if (ret)
53606 goto err_alloc;
53607 ret = create_constraint_attribute(i, "max_time_window_us",
53608- S_IRUGO,
53609- &constraint_attrs[i].max_time_window_attr,
53610- show_constraint_max_time_window_us,
53611- NULL);
53612+ &constraint_attrs[i].max_time_window_attr);
53613 if (ret)
53614 goto err_alloc;
53615 ret = create_constraint_attribute(i, "min_time_window_us",
53616- S_IRUGO,
53617- &constraint_attrs[i].min_time_window_attr,
53618- show_constraint_min_time_window_us,
53619- NULL);
53620+ &constraint_attrs[i].min_time_window_attr);
53621 if (ret)
53622 goto err_alloc;
53623
53624@@ -378,10 +422,12 @@ static void create_power_zone_common_attributes(
53625 power_zone->zone_dev_attrs[count++] =
53626 &dev_attr_max_energy_range_uj.attr;
53627 if (power_zone->ops->get_energy_uj) {
53628+ pax_open_kernel();
53629 if (power_zone->ops->reset_energy_uj)
53630- dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO;
53631+ *(umode_t *)&dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO;
53632 else
53633- dev_attr_energy_uj.attr.mode = S_IRUGO;
53634+ *(umode_t *)&dev_attr_energy_uj.attr.mode = S_IRUGO;
53635+ pax_close_kernel();
53636 power_zone->zone_dev_attrs[count++] =
53637 &dev_attr_energy_uj.attr;
53638 }
53639diff --git a/drivers/ptp/ptp_private.h b/drivers/ptp/ptp_private.h
53640index 9c5d414..c7900ce 100644
53641--- a/drivers/ptp/ptp_private.h
53642+++ b/drivers/ptp/ptp_private.h
53643@@ -51,7 +51,7 @@ struct ptp_clock {
53644 struct mutex pincfg_mux; /* protect concurrent info->pin_config access */
53645 wait_queue_head_t tsev_wq;
53646 int defunct; /* tells readers to go away when clock is being removed */
53647- struct device_attribute *pin_dev_attr;
53648+ device_attribute_no_const *pin_dev_attr;
53649 struct attribute **pin_attr;
53650 struct attribute_group pin_attr_group;
53651 };
53652diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
53653index 302e626..12579af 100644
53654--- a/drivers/ptp/ptp_sysfs.c
53655+++ b/drivers/ptp/ptp_sysfs.c
53656@@ -280,7 +280,7 @@ static int ptp_populate_pins(struct ptp_clock *ptp)
53657 goto no_pin_attr;
53658
53659 for (i = 0; i < n_pins; i++) {
53660- struct device_attribute *da = &ptp->pin_dev_attr[i];
53661+ device_attribute_no_const *da = &ptp->pin_dev_attr[i];
53662 sysfs_attr_init(&da->attr);
53663 da->attr.name = info->pin_config[i].name;
53664 da->attr.mode = 0644;
53665diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
53666index 5081533..794deb2 100644
53667--- a/drivers/regulator/core.c
53668+++ b/drivers/regulator/core.c
53669@@ -3650,7 +3650,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
53670 const struct regulation_constraints *constraints = NULL;
53671 const struct regulator_init_data *init_data;
53672 struct regulator_config *config = NULL;
53673- static atomic_t regulator_no = ATOMIC_INIT(-1);
53674+ static atomic_unchecked_t regulator_no = ATOMIC_INIT(-1);
53675 struct regulator_dev *rdev;
53676 struct device *dev;
53677 int ret, i;
53678@@ -3733,7 +3733,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
53679 rdev->dev.class = &regulator_class;
53680 rdev->dev.parent = dev;
53681 dev_set_name(&rdev->dev, "regulator.%lu",
53682- (unsigned long) atomic_inc_return(&regulator_no));
53683+ (unsigned long) atomic_inc_return_unchecked(&regulator_no));
53684 ret = device_register(&rdev->dev);
53685 if (ret != 0) {
53686 put_device(&rdev->dev);
53687diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
53688index 4071d74..260b15a 100644
53689--- a/drivers/regulator/max8660.c
53690+++ b/drivers/regulator/max8660.c
53691@@ -423,8 +423,10 @@ static int max8660_probe(struct i2c_client *client,
53692 max8660->shadow_regs[MAX8660_OVER1] = 5;
53693 } else {
53694 /* Otherwise devices can be toggled via software */
53695- max8660_dcdc_ops.enable = max8660_dcdc_enable;
53696- max8660_dcdc_ops.disable = max8660_dcdc_disable;
53697+ pax_open_kernel();
53698+ *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
53699+ *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
53700+ pax_close_kernel();
53701 }
53702
53703 /*
53704diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
53705index e94ddcf..bad33ad 100644
53706--- a/drivers/regulator/max8973-regulator.c
53707+++ b/drivers/regulator/max8973-regulator.c
53708@@ -580,9 +580,11 @@ static int max8973_probe(struct i2c_client *client,
53709 if (!pdata->enable_ext_control) {
53710 max->desc.enable_reg = MAX8973_VOUT;
53711 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
53712- max->ops.enable = regulator_enable_regmap;
53713- max->ops.disable = regulator_disable_regmap;
53714- max->ops.is_enabled = regulator_is_enabled_regmap;
53715+ pax_open_kernel();
53716+ *(void **)&max->ops.enable = regulator_enable_regmap;
53717+ *(void **)&max->ops.disable = regulator_disable_regmap;
53718+ *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
53719+ pax_close_kernel();
53720 break;
53721 }
53722
53723@@ -610,9 +612,11 @@ static int max8973_probe(struct i2c_client *client,
53724
53725 max->desc.enable_reg = MAX8973_VOUT;
53726 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
53727- max->ops.enable = regulator_enable_regmap;
53728- max->ops.disable = regulator_disable_regmap;
53729- max->ops.is_enabled = regulator_is_enabled_regmap;
53730+ pax_open_kernel();
53731+ *(void **)&max->ops.enable = regulator_enable_regmap;
53732+ *(void **)&max->ops.disable = regulator_disable_regmap;
53733+ *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
53734+ pax_close_kernel();
53735 break;
53736 default:
53737 break;
53738diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
53739index 0d17c92..a29f627 100644
53740--- a/drivers/regulator/mc13892-regulator.c
53741+++ b/drivers/regulator/mc13892-regulator.c
53742@@ -584,10 +584,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
53743 mc13xxx_unlock(mc13892);
53744
53745 /* update mc13892_vcam ops */
53746- memcpy(&mc13892_vcam_ops, mc13892_regulators[MC13892_VCAM].desc.ops,
53747+ pax_open_kernel();
53748+ memcpy((void *)&mc13892_vcam_ops, mc13892_regulators[MC13892_VCAM].desc.ops,
53749 sizeof(struct regulator_ops));
53750- mc13892_vcam_ops.set_mode = mc13892_vcam_set_mode,
53751- mc13892_vcam_ops.get_mode = mc13892_vcam_get_mode,
53752+ *(void **)&mc13892_vcam_ops.set_mode = mc13892_vcam_set_mode,
53753+ *(void **)&mc13892_vcam_ops.get_mode = mc13892_vcam_get_mode,
53754+ pax_close_kernel();
53755 mc13892_regulators[MC13892_VCAM].desc.ops = &mc13892_vcam_ops;
53756
53757 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
53758diff --git a/drivers/rtc/rtc-armada38x.c b/drivers/rtc/rtc-armada38x.c
53759index 2b08cac..8942201 100644
53760--- a/drivers/rtc/rtc-armada38x.c
53761+++ b/drivers/rtc/rtc-armada38x.c
53762@@ -18,6 +18,7 @@
53763 #include <linux/of.h>
53764 #include <linux/platform_device.h>
53765 #include <linux/rtc.h>
53766+#include <asm/pgtable.h>
53767
53768 #define RTC_STATUS 0x0
53769 #define RTC_STATUS_ALARM1 BIT(0)
53770@@ -254,8 +255,10 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
53771 * If there is no interrupt available then we can't
53772 * use the alarm
53773 */
53774- armada38x_rtc_ops.set_alarm = NULL;
53775- armada38x_rtc_ops.alarm_irq_enable = NULL;
53776+ pax_open_kernel();
53777+ *(void **)&armada38x_rtc_ops.set_alarm = NULL;
53778+ *(void **)&armada38x_rtc_ops.alarm_irq_enable = NULL;
53779+ pax_close_kernel();
53780 }
53781 platform_set_drvdata(pdev, rtc);
53782 if (rtc->irq != -1)
53783diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
53784index a82556a0..e842923 100644
53785--- a/drivers/rtc/rtc-cmos.c
53786+++ b/drivers/rtc/rtc-cmos.c
53787@@ -793,7 +793,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
53788 hpet_rtc_timer_init();
53789
53790 /* export at least the first block of NVRAM */
53791- nvram.size = address_space - NVRAM_OFFSET;
53792+ pax_open_kernel();
53793+ *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
53794+ pax_close_kernel();
53795 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
53796 if (retval < 0) {
53797 dev_dbg(dev, "can't create nvram file? %d\n", retval);
53798diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
53799index 799c34b..8e9786a 100644
53800--- a/drivers/rtc/rtc-dev.c
53801+++ b/drivers/rtc/rtc-dev.c
53802@@ -16,6 +16,7 @@
53803 #include <linux/module.h>
53804 #include <linux/rtc.h>
53805 #include <linux/sched.h>
53806+#include <linux/grsecurity.h>
53807 #include "rtc-core.h"
53808
53809 static dev_t rtc_devt;
53810@@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
53811 if (copy_from_user(&tm, uarg, sizeof(tm)))
53812 return -EFAULT;
53813
53814+ gr_log_timechange();
53815+
53816 return rtc_set_time(rtc, &tm);
53817
53818 case RTC_PIE_ON:
53819diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
53820index 6e76de1..d38a1e0 100644
53821--- a/drivers/rtc/rtc-ds1307.c
53822+++ b/drivers/rtc/rtc-ds1307.c
53823@@ -107,7 +107,7 @@ struct ds1307 {
53824 u8 offset; /* register's offset */
53825 u8 regs[11];
53826 u16 nvram_offset;
53827- struct bin_attribute *nvram;
53828+ bin_attribute_no_const *nvram;
53829 enum ds_type type;
53830 unsigned long flags;
53831 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
53832diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
53833index 90abb5b..e0bf6dd 100644
53834--- a/drivers/rtc/rtc-m48t59.c
53835+++ b/drivers/rtc/rtc-m48t59.c
53836@@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
53837 if (IS_ERR(m48t59->rtc))
53838 return PTR_ERR(m48t59->rtc);
53839
53840- m48t59_nvram_attr.size = pdata->offset;
53841+ pax_open_kernel();
53842+ *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
53843+ pax_close_kernel();
53844
53845 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
53846 if (ret)
53847diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
53848index 3a2da4c..e88493c 100644
53849--- a/drivers/rtc/rtc-test.c
53850+++ b/drivers/rtc/rtc-test.c
53851@@ -112,8 +112,10 @@ static int test_probe(struct platform_device *plat_dev)
53852 struct rtc_device *rtc;
53853
53854 if (test_mmss64) {
53855- test_rtc_ops.set_mmss64 = test_rtc_set_mmss64;
53856- test_rtc_ops.set_mmss = NULL;
53857+ pax_open_kernel();
53858+ *(void **)&test_rtc_ops.set_mmss64 = test_rtc_set_mmss64;
53859+ *(void **)&test_rtc_ops.set_mmss = NULL;
53860+ pax_close_kernel();
53861 }
53862
53863 rtc = devm_rtc_device_register(&plat_dev->dev, "test",
53864diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
53865index 7a6dbfb..5cdcd29 100644
53866--- a/drivers/scsi/be2iscsi/be_main.c
53867+++ b/drivers/scsi/be2iscsi/be_main.c
53868@@ -3184,7 +3184,7 @@ be_sgl_create_contiguous(void *virtual_address,
53869 {
53870 WARN_ON(!virtual_address);
53871 WARN_ON(!physical_address);
53872- WARN_ON(!length > 0);
53873+ WARN_ON(!length);
53874 WARN_ON(!sgl);
53875
53876 sgl->va = virtual_address;
53877diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
53878index e693af6..2e525b6 100644
53879--- a/drivers/scsi/bfa/bfa_fcpim.h
53880+++ b/drivers/scsi/bfa/bfa_fcpim.h
53881@@ -36,7 +36,7 @@ struct bfa_iotag_s {
53882
53883 struct bfa_itn_s {
53884 bfa_isr_func_t isr;
53885-};
53886+} __no_const;
53887
53888 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
53889 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
53890diff --git a/drivers/scsi/bfa/bfa_fcs.c b/drivers/scsi/bfa/bfa_fcs.c
53891index 0f19455..ef7adb5 100644
53892--- a/drivers/scsi/bfa/bfa_fcs.c
53893+++ b/drivers/scsi/bfa/bfa_fcs.c
53894@@ -38,10 +38,21 @@ struct bfa_fcs_mod_s {
53895 #define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit }
53896
53897 static struct bfa_fcs_mod_s fcs_modules[] = {
53898- { bfa_fcs_port_attach, NULL, NULL },
53899- { bfa_fcs_uf_attach, NULL, NULL },
53900- { bfa_fcs_fabric_attach, bfa_fcs_fabric_modinit,
53901- bfa_fcs_fabric_modexit },
53902+ {
53903+ .attach = bfa_fcs_port_attach,
53904+ .modinit = NULL,
53905+ .modexit = NULL
53906+ },
53907+ {
53908+ .attach = bfa_fcs_uf_attach,
53909+ .modinit = NULL,
53910+ .modexit = NULL
53911+ },
53912+ {
53913+ .attach = bfa_fcs_fabric_attach,
53914+ .modinit = bfa_fcs_fabric_modinit,
53915+ .modexit = bfa_fcs_fabric_modexit
53916+ },
53917 };
53918
53919 /*
53920diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
53921index ff75ef8..2dfe00a 100644
53922--- a/drivers/scsi/bfa/bfa_fcs_lport.c
53923+++ b/drivers/scsi/bfa/bfa_fcs_lport.c
53924@@ -89,15 +89,26 @@ static struct {
53925 void (*offline) (struct bfa_fcs_lport_s *port);
53926 } __port_action[] = {
53927 {
53928- bfa_fcs_lport_unknown_init, bfa_fcs_lport_unknown_online,
53929- bfa_fcs_lport_unknown_offline}, {
53930- bfa_fcs_lport_fab_init, bfa_fcs_lport_fab_online,
53931- bfa_fcs_lport_fab_offline}, {
53932- bfa_fcs_lport_n2n_init, bfa_fcs_lport_n2n_online,
53933- bfa_fcs_lport_n2n_offline}, {
53934- bfa_fcs_lport_loop_init, bfa_fcs_lport_loop_online,
53935- bfa_fcs_lport_loop_offline},
53936- };
53937+ .init = bfa_fcs_lport_unknown_init,
53938+ .online = bfa_fcs_lport_unknown_online,
53939+ .offline = bfa_fcs_lport_unknown_offline
53940+ },
53941+ {
53942+ .init = bfa_fcs_lport_fab_init,
53943+ .online = bfa_fcs_lport_fab_online,
53944+ .offline = bfa_fcs_lport_fab_offline
53945+ },
53946+ {
53947+ .init = bfa_fcs_lport_n2n_init,
53948+ .online = bfa_fcs_lport_n2n_online,
53949+ .offline = bfa_fcs_lport_n2n_offline
53950+ },
53951+ {
53952+ .init = bfa_fcs_lport_loop_init,
53953+ .online = bfa_fcs_lport_loop_online,
53954+ .offline = bfa_fcs_lport_loop_offline
53955+ },
53956+};
53957
53958 /*
53959 * fcs_port_sm FCS logical port state machine
53960diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
53961index a38aafa0..fe8f03b 100644
53962--- a/drivers/scsi/bfa/bfa_ioc.h
53963+++ b/drivers/scsi/bfa/bfa_ioc.h
53964@@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
53965 bfa_ioc_disable_cbfn_t disable_cbfn;
53966 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
53967 bfa_ioc_reset_cbfn_t reset_cbfn;
53968-};
53969+} __no_const;
53970
53971 /*
53972 * IOC event notification mechanism.
53973@@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
53974 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
53975 enum bfi_ioc_state fwstate);
53976 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
53977-};
53978+} __no_const;
53979
53980 /*
53981 * Queue element to wait for room in request queue. FIFO order is
53982diff --git a/drivers/scsi/bfa/bfa_modules.h b/drivers/scsi/bfa/bfa_modules.h
53983index a14c784..6de6790 100644
53984--- a/drivers/scsi/bfa/bfa_modules.h
53985+++ b/drivers/scsi/bfa/bfa_modules.h
53986@@ -78,12 +78,12 @@ enum {
53987 \
53988 extern struct bfa_module_s hal_mod_ ## __mod; \
53989 struct bfa_module_s hal_mod_ ## __mod = { \
53990- bfa_ ## __mod ## _meminfo, \
53991- bfa_ ## __mod ## _attach, \
53992- bfa_ ## __mod ## _detach, \
53993- bfa_ ## __mod ## _start, \
53994- bfa_ ## __mod ## _stop, \
53995- bfa_ ## __mod ## _iocdisable, \
53996+ .meminfo = bfa_ ## __mod ## _meminfo, \
53997+ .attach = bfa_ ## __mod ## _attach, \
53998+ .detach = bfa_ ## __mod ## _detach, \
53999+ .start = bfa_ ## __mod ## _start, \
54000+ .stop = bfa_ ## __mod ## _stop, \
54001+ .iocdisable = bfa_ ## __mod ## _iocdisable, \
54002 }
54003
54004 #define BFA_CACHELINE_SZ (256)
54005diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
54006index 045c4e1..13de803 100644
54007--- a/drivers/scsi/fcoe/fcoe_sysfs.c
54008+++ b/drivers/scsi/fcoe/fcoe_sysfs.c
54009@@ -33,8 +33,8 @@
54010 */
54011 #include "libfcoe.h"
54012
54013-static atomic_t ctlr_num;
54014-static atomic_t fcf_num;
54015+static atomic_unchecked_t ctlr_num;
54016+static atomic_unchecked_t fcf_num;
54017
54018 /*
54019 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
54020@@ -685,7 +685,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
54021 if (!ctlr)
54022 goto out;
54023
54024- ctlr->id = atomic_inc_return(&ctlr_num) - 1;
54025+ ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
54026 ctlr->f = f;
54027 ctlr->mode = FIP_CONN_TYPE_FABRIC;
54028 INIT_LIST_HEAD(&ctlr->fcfs);
54029@@ -902,7 +902,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
54030 fcf->dev.parent = &ctlr->dev;
54031 fcf->dev.bus = &fcoe_bus_type;
54032 fcf->dev.type = &fcoe_fcf_device_type;
54033- fcf->id = atomic_inc_return(&fcf_num) - 1;
54034+ fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
54035 fcf->state = FCOE_FCF_STATE_UNKNOWN;
54036
54037 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
54038@@ -938,8 +938,8 @@ int __init fcoe_sysfs_setup(void)
54039 {
54040 int error;
54041
54042- atomic_set(&ctlr_num, 0);
54043- atomic_set(&fcf_num, 0);
54044+ atomic_set_unchecked(&ctlr_num, 0);
54045+ atomic_set_unchecked(&fcf_num, 0);
54046
54047 error = bus_register(&fcoe_bus_type);
54048 if (error)
54049diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
54050index 8bb173e..20236b4 100644
54051--- a/drivers/scsi/hosts.c
54052+++ b/drivers/scsi/hosts.c
54053@@ -42,7 +42,7 @@
54054 #include "scsi_logging.h"
54055
54056
54057-static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
54058+static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
54059
54060
54061 static void scsi_host_cls_release(struct device *dev)
54062@@ -392,7 +392,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
54063 * subtract one because we increment first then return, but we need to
54064 * know what the next host number was before increment
54065 */
54066- shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
54067+ shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
54068 shost->dma_channel = 0xff;
54069
54070 /* These three are default values which can be overridden */
54071diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
54072index cab4e98..31323f6 100644
54073--- a/drivers/scsi/hpsa.c
54074+++ b/drivers/scsi/hpsa.c
54075@@ -793,10 +793,10 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
54076 struct reply_queue_buffer *rq = &h->reply_queue[q];
54077
54078 if (h->transMethod & CFGTBL_Trans_io_accel1)
54079- return h->access.command_completed(h, q);
54080+ return h->access->command_completed(h, q);
54081
54082 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
54083- return h->access.command_completed(h, q);
54084+ return h->access->command_completed(h, q);
54085
54086 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
54087 a = rq->head[rq->current_entry];
54088@@ -978,7 +978,7 @@ static void __enqueue_cmd_and_start_io(struct ctlr_info *h,
54089 break;
54090 default:
54091 set_performant_mode(h, c, reply_queue);
54092- h->access.submit_command(h, c);
54093+ h->access->submit_command(h, c);
54094 }
54095 }
54096
54097@@ -6343,17 +6343,17 @@ static void __iomem *remap_pci_mem(ulong base, ulong size)
54098
54099 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
54100 {
54101- return h->access.command_completed(h, q);
54102+ return h->access->command_completed(h, q);
54103 }
54104
54105 static inline bool interrupt_pending(struct ctlr_info *h)
54106 {
54107- return h->access.intr_pending(h);
54108+ return h->access->intr_pending(h);
54109 }
54110
54111 static inline long interrupt_not_for_us(struct ctlr_info *h)
54112 {
54113- return (h->access.intr_pending(h) == 0) ||
54114+ return (h->access->intr_pending(h) == 0) ||
54115 (h->interrupts_enabled == 0);
54116 }
54117
54118@@ -7291,7 +7291,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
54119 if (prod_index < 0)
54120 return prod_index;
54121 h->product_name = products[prod_index].product_name;
54122- h->access = *(products[prod_index].access);
54123+ h->access = products[prod_index].access;
54124
54125 h->needs_abort_tags_swizzled =
54126 ctlr_needs_abort_tags_swizzled(h->board_id);
54127@@ -7690,7 +7690,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
54128 unsigned long flags;
54129 u32 lockup_detected;
54130
54131- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54132+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54133 spin_lock_irqsave(&h->lock, flags);
54134 lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
54135 if (!lockup_detected) {
54136@@ -7973,7 +7973,7 @@ reinit_after_soft_reset:
54137 }
54138
54139 /* make sure the board interrupts are off */
54140- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54141+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54142
54143 rc = hpsa_request_irqs(h, do_hpsa_intr_msi, do_hpsa_intr_intx);
54144 if (rc)
54145@@ -8032,7 +8032,7 @@ reinit_after_soft_reset:
54146 * fake ones to scoop up any residual completions.
54147 */
54148 spin_lock_irqsave(&h->lock, flags);
54149- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54150+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54151 spin_unlock_irqrestore(&h->lock, flags);
54152 hpsa_free_irqs(h);
54153 rc = hpsa_request_irqs(h, hpsa_msix_discard_completions,
54154@@ -8062,9 +8062,9 @@ reinit_after_soft_reset:
54155 dev_info(&h->pdev->dev, "Board READY.\n");
54156 dev_info(&h->pdev->dev,
54157 "Waiting for stale completions to drain.\n");
54158- h->access.set_intr_mask(h, HPSA_INTR_ON);
54159+ h->access->set_intr_mask(h, HPSA_INTR_ON);
54160 msleep(10000);
54161- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54162+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54163
54164 rc = controller_reset_failed(h->cfgtable);
54165 if (rc)
54166@@ -8089,7 +8089,7 @@ reinit_after_soft_reset:
54167
54168
54169 /* Turn the interrupts on so we can service requests */
54170- h->access.set_intr_mask(h, HPSA_INTR_ON);
54171+ h->access->set_intr_mask(h, HPSA_INTR_ON);
54172
54173 hpsa_hba_inquiry(h);
54174
54175@@ -8107,7 +8107,7 @@ clean9: /* wq, sh, perf, sg, cmd, irq, shost, pci, lu, aer/h */
54176 kfree(h->hba_inquiry_data);
54177 clean7: /* perf, sg, cmd, irq, shost, pci, lu, aer/h */
54178 hpsa_free_performant_mode(h);
54179- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54180+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54181 clean6: /* sg, cmd, irq, pci, lockup, wq/aer/h */
54182 hpsa_free_sg_chain_blocks(h);
54183 clean5: /* cmd, irq, shost, pci, lu, aer/h */
54184@@ -8177,7 +8177,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
54185 * To write all data in the battery backed cache to disks
54186 */
54187 hpsa_flush_cache(h);
54188- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54189+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54190 hpsa_free_irqs(h); /* init_one 4 */
54191 hpsa_disable_interrupt_mode(h); /* pci_init 2 */
54192 }
54193@@ -8309,7 +8309,7 @@ static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
54194 CFGTBL_Trans_enable_directed_msix |
54195 (trans_support & (CFGTBL_Trans_io_accel1 |
54196 CFGTBL_Trans_io_accel2));
54197- struct access_method access = SA5_performant_access;
54198+ struct access_method *access = &SA5_performant_access;
54199
54200 /* This is a bit complicated. There are 8 registers on
54201 * the controller which we write to to tell it 8 different
54202@@ -8351,7 +8351,7 @@ static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
54203 * perform the superfluous readl() after each command submission.
54204 */
54205 if (trans_support & (CFGTBL_Trans_io_accel1 | CFGTBL_Trans_io_accel2))
54206- access = SA5_performant_access_no_read;
54207+ access = &SA5_performant_access_no_read;
54208
54209 /* Controller spec: zero out this buffer. */
54210 for (i = 0; i < h->nreply_queues; i++)
54211@@ -8381,12 +8381,12 @@ static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
54212 * enable outbound interrupt coalescing in accelerator mode;
54213 */
54214 if (trans_support & CFGTBL_Trans_io_accel1) {
54215- access = SA5_ioaccel_mode1_access;
54216+ access = &SA5_ioaccel_mode1_access;
54217 writel(10, &h->cfgtable->HostWrite.CoalIntDelay);
54218 writel(4, &h->cfgtable->HostWrite.CoalIntCount);
54219 } else {
54220 if (trans_support & CFGTBL_Trans_io_accel2) {
54221- access = SA5_ioaccel_mode2_access;
54222+ access = &SA5_ioaccel_mode2_access;
54223 writel(10, &h->cfgtable->HostWrite.CoalIntDelay);
54224 writel(4, &h->cfgtable->HostWrite.CoalIntCount);
54225 }
54226diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
54227index 6ee4da6..dfafb48 100644
54228--- a/drivers/scsi/hpsa.h
54229+++ b/drivers/scsi/hpsa.h
54230@@ -152,7 +152,7 @@ struct ctlr_info {
54231 unsigned int msix_vector;
54232 unsigned int msi_vector;
54233 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
54234- struct access_method access;
54235+ struct access_method *access;
54236 char hba_mode_enabled;
54237
54238 /* queue and queue Info */
54239@@ -542,38 +542,38 @@ static unsigned long SA5_ioaccel_mode1_completed(struct ctlr_info *h, u8 q)
54240 }
54241
54242 static struct access_method SA5_access = {
54243- SA5_submit_command,
54244- SA5_intr_mask,
54245- SA5_intr_pending,
54246- SA5_completed,
54247+ .submit_command = SA5_submit_command,
54248+ .set_intr_mask = SA5_intr_mask,
54249+ .intr_pending = SA5_intr_pending,
54250+ .command_completed = SA5_completed,
54251 };
54252
54253 static struct access_method SA5_ioaccel_mode1_access = {
54254- SA5_submit_command,
54255- SA5_performant_intr_mask,
54256- SA5_ioaccel_mode1_intr_pending,
54257- SA5_ioaccel_mode1_completed,
54258+ .submit_command = SA5_submit_command,
54259+ .set_intr_mask = SA5_performant_intr_mask,
54260+ .intr_pending = SA5_ioaccel_mode1_intr_pending,
54261+ .command_completed = SA5_ioaccel_mode1_completed,
54262 };
54263
54264 static struct access_method SA5_ioaccel_mode2_access = {
54265- SA5_submit_command_ioaccel2,
54266- SA5_performant_intr_mask,
54267- SA5_performant_intr_pending,
54268- SA5_performant_completed,
54269+ .submit_command = SA5_submit_command_ioaccel2,
54270+ .set_intr_mask = SA5_performant_intr_mask,
54271+ .intr_pending = SA5_performant_intr_pending,
54272+ .command_completed = SA5_performant_completed,
54273 };
54274
54275 static struct access_method SA5_performant_access = {
54276- SA5_submit_command,
54277- SA5_performant_intr_mask,
54278- SA5_performant_intr_pending,
54279- SA5_performant_completed,
54280+ .submit_command = SA5_submit_command,
54281+ .set_intr_mask = SA5_performant_intr_mask,
54282+ .intr_pending = SA5_performant_intr_pending,
54283+ .command_completed = SA5_performant_completed,
54284 };
54285
54286 static struct access_method SA5_performant_access_no_read = {
54287- SA5_submit_command_no_read,
54288- SA5_performant_intr_mask,
54289- SA5_performant_intr_pending,
54290- SA5_performant_completed,
54291+ .submit_command = SA5_submit_command_no_read,
54292+ .set_intr_mask = SA5_performant_intr_mask,
54293+ .intr_pending = SA5_performant_intr_pending,
54294+ .command_completed = SA5_performant_completed,
54295 };
54296
54297 struct board_type {
54298diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
54299index 30f9ef0..a1e29ac 100644
54300--- a/drivers/scsi/libfc/fc_exch.c
54301+++ b/drivers/scsi/libfc/fc_exch.c
54302@@ -101,12 +101,12 @@ struct fc_exch_mgr {
54303 u16 pool_max_index;
54304
54305 struct {
54306- atomic_t no_free_exch;
54307- atomic_t no_free_exch_xid;
54308- atomic_t xid_not_found;
54309- atomic_t xid_busy;
54310- atomic_t seq_not_found;
54311- atomic_t non_bls_resp;
54312+ atomic_unchecked_t no_free_exch;
54313+ atomic_unchecked_t no_free_exch_xid;
54314+ atomic_unchecked_t xid_not_found;
54315+ atomic_unchecked_t xid_busy;
54316+ atomic_unchecked_t seq_not_found;
54317+ atomic_unchecked_t non_bls_resp;
54318 } stats;
54319 };
54320
54321@@ -809,7 +809,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
54322 /* allocate memory for exchange */
54323 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
54324 if (!ep) {
54325- atomic_inc(&mp->stats.no_free_exch);
54326+ atomic_inc_unchecked(&mp->stats.no_free_exch);
54327 goto out;
54328 }
54329 memset(ep, 0, sizeof(*ep));
54330@@ -872,7 +872,7 @@ out:
54331 return ep;
54332 err:
54333 spin_unlock_bh(&pool->lock);
54334- atomic_inc(&mp->stats.no_free_exch_xid);
54335+ atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
54336 mempool_free(ep, mp->ep_pool);
54337 return NULL;
54338 }
54339@@ -1021,7 +1021,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
54340 xid = ntohs(fh->fh_ox_id); /* we originated exch */
54341 ep = fc_exch_find(mp, xid);
54342 if (!ep) {
54343- atomic_inc(&mp->stats.xid_not_found);
54344+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54345 reject = FC_RJT_OX_ID;
54346 goto out;
54347 }
54348@@ -1051,7 +1051,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
54349 ep = fc_exch_find(mp, xid);
54350 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
54351 if (ep) {
54352- atomic_inc(&mp->stats.xid_busy);
54353+ atomic_inc_unchecked(&mp->stats.xid_busy);
54354 reject = FC_RJT_RX_ID;
54355 goto rel;
54356 }
54357@@ -1062,7 +1062,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
54358 }
54359 xid = ep->xid; /* get our XID */
54360 } else if (!ep) {
54361- atomic_inc(&mp->stats.xid_not_found);
54362+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54363 reject = FC_RJT_RX_ID; /* XID not found */
54364 goto out;
54365 }
54366@@ -1080,7 +1080,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
54367 } else {
54368 sp = &ep->seq;
54369 if (sp->id != fh->fh_seq_id) {
54370- atomic_inc(&mp->stats.seq_not_found);
54371+ atomic_inc_unchecked(&mp->stats.seq_not_found);
54372 if (f_ctl & FC_FC_END_SEQ) {
54373 /*
54374 * Update sequence_id based on incoming last
54375@@ -1531,22 +1531,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
54376
54377 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
54378 if (!ep) {
54379- atomic_inc(&mp->stats.xid_not_found);
54380+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54381 goto out;
54382 }
54383 if (ep->esb_stat & ESB_ST_COMPLETE) {
54384- atomic_inc(&mp->stats.xid_not_found);
54385+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54386 goto rel;
54387 }
54388 if (ep->rxid == FC_XID_UNKNOWN)
54389 ep->rxid = ntohs(fh->fh_rx_id);
54390 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
54391- atomic_inc(&mp->stats.xid_not_found);
54392+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54393 goto rel;
54394 }
54395 if (ep->did != ntoh24(fh->fh_s_id) &&
54396 ep->did != FC_FID_FLOGI) {
54397- atomic_inc(&mp->stats.xid_not_found);
54398+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54399 goto rel;
54400 }
54401 sof = fr_sof(fp);
54402@@ -1555,7 +1555,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
54403 sp->ssb_stat |= SSB_ST_RESP;
54404 sp->id = fh->fh_seq_id;
54405 } else if (sp->id != fh->fh_seq_id) {
54406- atomic_inc(&mp->stats.seq_not_found);
54407+ atomic_inc_unchecked(&mp->stats.seq_not_found);
54408 goto rel;
54409 }
54410
54411@@ -1618,9 +1618,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
54412 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
54413
54414 if (!sp)
54415- atomic_inc(&mp->stats.xid_not_found);
54416+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54417 else
54418- atomic_inc(&mp->stats.non_bls_resp);
54419+ atomic_inc_unchecked(&mp->stats.non_bls_resp);
54420
54421 fc_frame_free(fp);
54422 }
54423@@ -2261,13 +2261,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
54424
54425 list_for_each_entry(ema, &lport->ema_list, ema_list) {
54426 mp = ema->mp;
54427- st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
54428+ st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
54429 st->fc_no_free_exch_xid +=
54430- atomic_read(&mp->stats.no_free_exch_xid);
54431- st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
54432- st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
54433- st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
54434- st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
54435+ atomic_read_unchecked(&mp->stats.no_free_exch_xid);
54436+ st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
54437+ st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
54438+ st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
54439+ st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
54440 }
54441 }
54442 EXPORT_SYMBOL(fc_exch_update_stats);
54443diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
54444index 9c706d8..d3e3ed2 100644
54445--- a/drivers/scsi/libsas/sas_ata.c
54446+++ b/drivers/scsi/libsas/sas_ata.c
54447@@ -535,7 +535,7 @@ static struct ata_port_operations sas_sata_ops = {
54448 .postreset = ata_std_postreset,
54449 .error_handler = ata_std_error_handler,
54450 .post_internal_cmd = sas_ata_post_internal,
54451- .qc_defer = ata_std_qc_defer,
54452+ .qc_defer = ata_std_qc_defer,
54453 .qc_prep = ata_noop_qc_prep,
54454 .qc_issue = sas_ata_qc_issue,
54455 .qc_fill_rtf = sas_ata_qc_fill_rtf,
54456diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
54457index a5a56fa..43499fd 100644
54458--- a/drivers/scsi/lpfc/lpfc.h
54459+++ b/drivers/scsi/lpfc/lpfc.h
54460@@ -435,7 +435,7 @@ struct lpfc_vport {
54461 struct dentry *debug_nodelist;
54462 struct dentry *vport_debugfs_root;
54463 struct lpfc_debugfs_trc *disc_trc;
54464- atomic_t disc_trc_cnt;
54465+ atomic_unchecked_t disc_trc_cnt;
54466 #endif
54467 uint8_t stat_data_enabled;
54468 uint8_t stat_data_blocked;
54469@@ -885,8 +885,8 @@ struct lpfc_hba {
54470 struct timer_list fabric_block_timer;
54471 unsigned long bit_flags;
54472 #define FABRIC_COMANDS_BLOCKED 0
54473- atomic_t num_rsrc_err;
54474- atomic_t num_cmd_success;
54475+ atomic_unchecked_t num_rsrc_err;
54476+ atomic_unchecked_t num_cmd_success;
54477 unsigned long last_rsrc_error_time;
54478 unsigned long last_ramp_down_time;
54479 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
54480@@ -921,7 +921,7 @@ struct lpfc_hba {
54481
54482 struct dentry *debug_slow_ring_trc;
54483 struct lpfc_debugfs_trc *slow_ring_trc;
54484- atomic_t slow_ring_trc_cnt;
54485+ atomic_unchecked_t slow_ring_trc_cnt;
54486 /* iDiag debugfs sub-directory */
54487 struct dentry *idiag_root;
54488 struct dentry *idiag_pci_cfg;
54489diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
54490index 25aa9b9..d700a65 100644
54491--- a/drivers/scsi/lpfc/lpfc_debugfs.c
54492+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
54493@@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
54494
54495 #include <linux/debugfs.h>
54496
54497-static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
54498+static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
54499 static unsigned long lpfc_debugfs_start_time = 0L;
54500
54501 /* iDiag */
54502@@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
54503 lpfc_debugfs_enable = 0;
54504
54505 len = 0;
54506- index = (atomic_read(&vport->disc_trc_cnt) + 1) &
54507+ index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
54508 (lpfc_debugfs_max_disc_trc - 1);
54509 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
54510 dtp = vport->disc_trc + i;
54511@@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
54512 lpfc_debugfs_enable = 0;
54513
54514 len = 0;
54515- index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
54516+ index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
54517 (lpfc_debugfs_max_slow_ring_trc - 1);
54518 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
54519 dtp = phba->slow_ring_trc + i;
54520@@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
54521 !vport || !vport->disc_trc)
54522 return;
54523
54524- index = atomic_inc_return(&vport->disc_trc_cnt) &
54525+ index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
54526 (lpfc_debugfs_max_disc_trc - 1);
54527 dtp = vport->disc_trc + index;
54528 dtp->fmt = fmt;
54529 dtp->data1 = data1;
54530 dtp->data2 = data2;
54531 dtp->data3 = data3;
54532- dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
54533+ dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
54534 dtp->jif = jiffies;
54535 #endif
54536 return;
54537@@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
54538 !phba || !phba->slow_ring_trc)
54539 return;
54540
54541- index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
54542+ index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
54543 (lpfc_debugfs_max_slow_ring_trc - 1);
54544 dtp = phba->slow_ring_trc + index;
54545 dtp->fmt = fmt;
54546 dtp->data1 = data1;
54547 dtp->data2 = data2;
54548 dtp->data3 = data3;
54549- dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
54550+ dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
54551 dtp->jif = jiffies;
54552 #endif
54553 return;
54554@@ -4268,7 +4268,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
54555 "slow_ring buffer\n");
54556 goto debug_failed;
54557 }
54558- atomic_set(&phba->slow_ring_trc_cnt, 0);
54559+ atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
54560 memset(phba->slow_ring_trc, 0,
54561 (sizeof(struct lpfc_debugfs_trc) *
54562 lpfc_debugfs_max_slow_ring_trc));
54563@@ -4314,7 +4314,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
54564 "buffer\n");
54565 goto debug_failed;
54566 }
54567- atomic_set(&vport->disc_trc_cnt, 0);
54568+ atomic_set_unchecked(&vport->disc_trc_cnt, 0);
54569
54570 snprintf(name, sizeof(name), "discovery_trace");
54571 vport->debug_disc_trc =
54572diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
54573index f962118..6706983 100644
54574--- a/drivers/scsi/lpfc/lpfc_init.c
54575+++ b/drivers/scsi/lpfc/lpfc_init.c
54576@@ -11416,8 +11416,10 @@ lpfc_init(void)
54577 "misc_register returned with status %d", error);
54578
54579 if (lpfc_enable_npiv) {
54580- lpfc_transport_functions.vport_create = lpfc_vport_create;
54581- lpfc_transport_functions.vport_delete = lpfc_vport_delete;
54582+ pax_open_kernel();
54583+ *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
54584+ *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
54585+ pax_close_kernel();
54586 }
54587 lpfc_transport_template =
54588 fc_attach_transport(&lpfc_transport_functions);
54589diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
54590index e5eb40d..056dcd4 100644
54591--- a/drivers/scsi/lpfc/lpfc_scsi.c
54592+++ b/drivers/scsi/lpfc/lpfc_scsi.c
54593@@ -261,7 +261,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
54594 unsigned long expires;
54595
54596 spin_lock_irqsave(&phba->hbalock, flags);
54597- atomic_inc(&phba->num_rsrc_err);
54598+ atomic_inc_unchecked(&phba->num_rsrc_err);
54599 phba->last_rsrc_error_time = jiffies;
54600
54601 expires = phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL;
54602@@ -303,8 +303,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
54603 unsigned long num_rsrc_err, num_cmd_success;
54604 int i;
54605
54606- num_rsrc_err = atomic_read(&phba->num_rsrc_err);
54607- num_cmd_success = atomic_read(&phba->num_cmd_success);
54608+ num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
54609+ num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
54610
54611 /*
54612 * The error and success command counters are global per
54613@@ -331,8 +331,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
54614 }
54615 }
54616 lpfc_destroy_vport_work_array(phba, vports);
54617- atomic_set(&phba->num_rsrc_err, 0);
54618- atomic_set(&phba->num_cmd_success, 0);
54619+ atomic_set_unchecked(&phba->num_rsrc_err, 0);
54620+ atomic_set_unchecked(&phba->num_cmd_success, 0);
54621 }
54622
54623 /**
54624diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
54625index 20c3754..1b05e727 100644
54626--- a/drivers/scsi/megaraid/megaraid_sas.h
54627+++ b/drivers/scsi/megaraid/megaraid_sas.h
54628@@ -1700,7 +1700,7 @@ struct megasas_instance {
54629 s8 init_id;
54630
54631 u16 max_num_sge;
54632- u16 max_fw_cmds;
54633+ u16 max_fw_cmds __intentional_overflow(-1);
54634 u16 max_mfi_cmds;
54635 u16 max_scsi_cmds;
54636 u32 max_sectors_per_req;
54637diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
54638index 3f26147..ee8efd1 100644
54639--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
54640+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
54641@@ -1509,7 +1509,7 @@ _scsih_get_resync(struct device *dev)
54642 {
54643 struct scsi_device *sdev = to_scsi_device(dev);
54644 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
54645- static struct _raid_device *raid_device;
54646+ struct _raid_device *raid_device;
54647 unsigned long flags;
54648 Mpi2RaidVolPage0_t vol_pg0;
54649 Mpi2ConfigReply_t mpi_reply;
54650@@ -1561,7 +1561,7 @@ _scsih_get_state(struct device *dev)
54651 {
54652 struct scsi_device *sdev = to_scsi_device(dev);
54653 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
54654- static struct _raid_device *raid_device;
54655+ struct _raid_device *raid_device;
54656 unsigned long flags;
54657 Mpi2RaidVolPage0_t vol_pg0;
54658 Mpi2ConfigReply_t mpi_reply;
54659@@ -6641,7 +6641,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
54660 Mpi2EventDataIrOperationStatus_t *event_data =
54661 (Mpi2EventDataIrOperationStatus_t *)
54662 fw_event->event_data;
54663- static struct _raid_device *raid_device;
54664+ struct _raid_device *raid_device;
54665 unsigned long flags;
54666 u16 handle;
54667
54668@@ -7112,7 +7112,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
54669 u64 sas_address;
54670 struct _sas_device *sas_device;
54671 struct _sas_node *expander_device;
54672- static struct _raid_device *raid_device;
54673+ struct _raid_device *raid_device;
54674 u8 retry_count;
54675 unsigned long flags;
54676
54677diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
54678index ed31d8c..ab856b3 100644
54679--- a/drivers/scsi/pmcraid.c
54680+++ b/drivers/scsi/pmcraid.c
54681@@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
54682 res->scsi_dev = scsi_dev;
54683 scsi_dev->hostdata = res;
54684 res->change_detected = 0;
54685- atomic_set(&res->read_failures, 0);
54686- atomic_set(&res->write_failures, 0);
54687+ atomic_set_unchecked(&res->read_failures, 0);
54688+ atomic_set_unchecked(&res->write_failures, 0);
54689 rc = 0;
54690 }
54691 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
54692@@ -2640,9 +2640,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
54693
54694 /* If this was a SCSI read/write command keep count of errors */
54695 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
54696- atomic_inc(&res->read_failures);
54697+ atomic_inc_unchecked(&res->read_failures);
54698 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
54699- atomic_inc(&res->write_failures);
54700+ atomic_inc_unchecked(&res->write_failures);
54701
54702 if (!RES_IS_GSCSI(res->cfg_entry) &&
54703 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
54704@@ -3468,7 +3468,7 @@ static int pmcraid_queuecommand_lck(
54705 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
54706 * hrrq_id assigned here in queuecommand
54707 */
54708- ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
54709+ ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
54710 pinstance->num_hrrq;
54711 cmd->cmd_done = pmcraid_io_done;
54712
54713@@ -3782,7 +3782,7 @@ static long pmcraid_ioctl_passthrough(
54714 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
54715 * hrrq_id assigned here in queuecommand
54716 */
54717- ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
54718+ ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
54719 pinstance->num_hrrq;
54720
54721 if (request_size) {
54722@@ -4420,7 +4420,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
54723
54724 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
54725 /* add resources only after host is added into system */
54726- if (!atomic_read(&pinstance->expose_resources))
54727+ if (!atomic_read_unchecked(&pinstance->expose_resources))
54728 return;
54729
54730 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
54731@@ -5237,8 +5237,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
54732 init_waitqueue_head(&pinstance->reset_wait_q);
54733
54734 atomic_set(&pinstance->outstanding_cmds, 0);
54735- atomic_set(&pinstance->last_message_id, 0);
54736- atomic_set(&pinstance->expose_resources, 0);
54737+ atomic_set_unchecked(&pinstance->last_message_id, 0);
54738+ atomic_set_unchecked(&pinstance->expose_resources, 0);
54739
54740 INIT_LIST_HEAD(&pinstance->free_res_q);
54741 INIT_LIST_HEAD(&pinstance->used_res_q);
54742@@ -5951,7 +5951,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
54743 /* Schedule worker thread to handle CCN and take care of adding and
54744 * removing devices to OS
54745 */
54746- atomic_set(&pinstance->expose_resources, 1);
54747+ atomic_set_unchecked(&pinstance->expose_resources, 1);
54748 schedule_work(&pinstance->worker_q);
54749 return rc;
54750
54751diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
54752index e1d150f..6c6df44 100644
54753--- a/drivers/scsi/pmcraid.h
54754+++ b/drivers/scsi/pmcraid.h
54755@@ -748,7 +748,7 @@ struct pmcraid_instance {
54756 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
54757
54758 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
54759- atomic_t last_message_id;
54760+ atomic_unchecked_t last_message_id;
54761
54762 /* configuration table */
54763 struct pmcraid_config_table *cfg_table;
54764@@ -777,7 +777,7 @@ struct pmcraid_instance {
54765 atomic_t outstanding_cmds;
54766
54767 /* should add/delete resources to mid-layer now ?*/
54768- atomic_t expose_resources;
54769+ atomic_unchecked_t expose_resources;
54770
54771
54772
54773@@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
54774 struct pmcraid_config_table_entry_ext cfg_entry_ext;
54775 };
54776 struct scsi_device *scsi_dev; /* Link scsi_device structure */
54777- atomic_t read_failures; /* count of failed READ commands */
54778- atomic_t write_failures; /* count of failed WRITE commands */
54779+ atomic_unchecked_t read_failures; /* count of failed READ commands */
54780+ atomic_unchecked_t write_failures; /* count of failed WRITE commands */
54781
54782 /* To indicate add/delete/modify during CCN */
54783 u8 change_detected;
54784diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
54785index 437254e..a66eb82 100644
54786--- a/drivers/scsi/qla2xxx/qla_attr.c
54787+++ b/drivers/scsi/qla2xxx/qla_attr.c
54788@@ -2192,7 +2192,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
54789 return 0;
54790 }
54791
54792-struct fc_function_template qla2xxx_transport_functions = {
54793+fc_function_template_no_const qla2xxx_transport_functions = {
54794
54795 .show_host_node_name = 1,
54796 .show_host_port_name = 1,
54797@@ -2240,7 +2240,7 @@ struct fc_function_template qla2xxx_transport_functions = {
54798 .bsg_timeout = qla24xx_bsg_timeout,
54799 };
54800
54801-struct fc_function_template qla2xxx_transport_vport_functions = {
54802+fc_function_template_no_const qla2xxx_transport_vport_functions = {
54803
54804 .show_host_node_name = 1,
54805 .show_host_port_name = 1,
54806diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
54807index 7686bfe..4710893 100644
54808--- a/drivers/scsi/qla2xxx/qla_gbl.h
54809+++ b/drivers/scsi/qla2xxx/qla_gbl.h
54810@@ -571,8 +571,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *, size_t);
54811 struct device_attribute;
54812 extern struct device_attribute *qla2x00_host_attrs[];
54813 struct fc_function_template;
54814-extern struct fc_function_template qla2xxx_transport_functions;
54815-extern struct fc_function_template qla2xxx_transport_vport_functions;
54816+extern fc_function_template_no_const qla2xxx_transport_functions;
54817+extern fc_function_template_no_const qla2xxx_transport_vport_functions;
54818 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
54819 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *, bool);
54820 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
54821diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
54822index 8a5cac8..4eba6ab 100644
54823--- a/drivers/scsi/qla2xxx/qla_os.c
54824+++ b/drivers/scsi/qla2xxx/qla_os.c
54825@@ -1435,8 +1435,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
54826 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
54827 /* Ok, a 64bit DMA mask is applicable. */
54828 ha->flags.enable_64bit_addressing = 1;
54829- ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
54830- ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
54831+ pax_open_kernel();
54832+ *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
54833+ *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
54834+ pax_close_kernel();
54835 return;
54836 }
54837 }
54838diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
54839index a7cfc27..151f483 100644
54840--- a/drivers/scsi/qla4xxx/ql4_def.h
54841+++ b/drivers/scsi/qla4xxx/ql4_def.h
54842@@ -306,7 +306,7 @@ struct ddb_entry {
54843 * (4000 only) */
54844 atomic_t relogin_timer; /* Max Time to wait for
54845 * relogin to complete */
54846- atomic_t relogin_retry_count; /* Num of times relogin has been
54847+ atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
54848 * retried */
54849 uint32_t default_time2wait; /* Default Min time between
54850 * relogins (+aens) */
54851diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
54852index 6d25879..3031a9f 100644
54853--- a/drivers/scsi/qla4xxx/ql4_os.c
54854+++ b/drivers/scsi/qla4xxx/ql4_os.c
54855@@ -4491,12 +4491,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
54856 */
54857 if (!iscsi_is_session_online(cls_sess)) {
54858 /* Reset retry relogin timer */
54859- atomic_inc(&ddb_entry->relogin_retry_count);
54860+ atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
54861 DEBUG2(ql4_printk(KERN_INFO, ha,
54862 "%s: index[%d] relogin timed out-retrying"
54863 " relogin (%d), retry (%d)\n", __func__,
54864 ddb_entry->fw_ddb_index,
54865- atomic_read(&ddb_entry->relogin_retry_count),
54866+ atomic_read_unchecked(&ddb_entry->relogin_retry_count),
54867 ddb_entry->default_time2wait + 4));
54868 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
54869 atomic_set(&ddb_entry->retry_relogin_timer,
54870@@ -6604,7 +6604,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
54871
54872 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
54873 atomic_set(&ddb_entry->relogin_timer, 0);
54874- atomic_set(&ddb_entry->relogin_retry_count, 0);
54875+ atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
54876 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
54877 ddb_entry->default_relogin_timeout =
54878 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
54879diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
54880index 207d6a7..bf155b5 100644
54881--- a/drivers/scsi/scsi.c
54882+++ b/drivers/scsi/scsi.c
54883@@ -591,7 +591,7 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
54884
54885 good_bytes = scsi_bufflen(cmd);
54886 if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) {
54887- int old_good_bytes = good_bytes;
54888+ unsigned int old_good_bytes = good_bytes;
54889 drv = scsi_cmd_to_driver(cmd);
54890 if (drv->done)
54891 good_bytes = drv->done(cmd);
54892diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
54893index 448ebda..9bd345f 100644
54894--- a/drivers/scsi/scsi_lib.c
54895+++ b/drivers/scsi/scsi_lib.c
54896@@ -1597,7 +1597,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
54897 shost = sdev->host;
54898 scsi_init_cmd_errh(cmd);
54899 cmd->result = DID_NO_CONNECT << 16;
54900- atomic_inc(&cmd->device->iorequest_cnt);
54901+ atomic_inc_unchecked(&cmd->device->iorequest_cnt);
54902
54903 /*
54904 * SCSI request completion path will do scsi_device_unbusy(),
54905@@ -1620,9 +1620,9 @@ static void scsi_softirq_done(struct request *rq)
54906
54907 INIT_LIST_HEAD(&cmd->eh_entry);
54908
54909- atomic_inc(&cmd->device->iodone_cnt);
54910+ atomic_inc_unchecked(&cmd->device->iodone_cnt);
54911 if (cmd->result)
54912- atomic_inc(&cmd->device->ioerr_cnt);
54913+ atomic_inc_unchecked(&cmd->device->ioerr_cnt);
54914
54915 disposition = scsi_decide_disposition(cmd);
54916 if (disposition != SUCCESS &&
54917@@ -1663,7 +1663,7 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
54918 struct Scsi_Host *host = cmd->device->host;
54919 int rtn = 0;
54920
54921- atomic_inc(&cmd->device->iorequest_cnt);
54922+ atomic_inc_unchecked(&cmd->device->iorequest_cnt);
54923
54924 /* check if the device is still usable */
54925 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
54926diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
54927index 9ad4116..4e736fc 100644
54928--- a/drivers/scsi/scsi_sysfs.c
54929+++ b/drivers/scsi/scsi_sysfs.c
54930@@ -788,7 +788,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
54931 char *buf) \
54932 { \
54933 struct scsi_device *sdev = to_scsi_device(dev); \
54934- unsigned long long count = atomic_read(&sdev->field); \
54935+ unsigned long long count = atomic_read_unchecked(&sdev->field); \
54936 return snprintf(buf, 20, "0x%llx\n", count); \
54937 } \
54938 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
54939diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
54940index 24eaaf6..de30ec9 100644
54941--- a/drivers/scsi/scsi_transport_fc.c
54942+++ b/drivers/scsi/scsi_transport_fc.c
54943@@ -502,7 +502,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
54944 * Netlink Infrastructure
54945 */
54946
54947-static atomic_t fc_event_seq;
54948+static atomic_unchecked_t fc_event_seq;
54949
54950 /**
54951 * fc_get_event_number - Obtain the next sequential FC event number
54952@@ -515,7 +515,7 @@ static atomic_t fc_event_seq;
54953 u32
54954 fc_get_event_number(void)
54955 {
54956- return atomic_add_return(1, &fc_event_seq);
54957+ return atomic_add_return_unchecked(1, &fc_event_seq);
54958 }
54959 EXPORT_SYMBOL(fc_get_event_number);
54960
54961@@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
54962 {
54963 int error;
54964
54965- atomic_set(&fc_event_seq, 0);
54966+ atomic_set_unchecked(&fc_event_seq, 0);
54967
54968 error = transport_class_register(&fc_host_class);
54969 if (error)
54970@@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
54971 char *cp;
54972
54973 *val = simple_strtoul(buf, &cp, 0);
54974- if ((*cp && (*cp != '\n')) || (*val < 0))
54975+ if (*cp && (*cp != '\n'))
54976 return -EINVAL;
54977 /*
54978 * Check for overflow; dev_loss_tmo is u32
54979diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
54980index 55647aa..b647d05 100644
54981--- a/drivers/scsi/scsi_transport_iscsi.c
54982+++ b/drivers/scsi/scsi_transport_iscsi.c
54983@@ -79,7 +79,7 @@ struct iscsi_internal {
54984 struct transport_container session_cont;
54985 };
54986
54987-static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
54988+static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
54989 static struct workqueue_struct *iscsi_eh_timer_workq;
54990
54991 static DEFINE_IDA(iscsi_sess_ida);
54992@@ -2073,7 +2073,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
54993 int err;
54994
54995 ihost = shost->shost_data;
54996- session->sid = atomic_add_return(1, &iscsi_session_nr);
54997+ session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
54998
54999 if (target_id == ISCSI_MAX_TARGET) {
55000 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
55001@@ -4517,7 +4517,7 @@ static __init int iscsi_transport_init(void)
55002 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
55003 ISCSI_TRANSPORT_VERSION);
55004
55005- atomic_set(&iscsi_session_nr, 0);
55006+ atomic_set_unchecked(&iscsi_session_nr, 0);
55007
55008 err = class_register(&iscsi_transport_class);
55009 if (err)
55010diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
55011index e3cd3ec..00560ec 100644
55012--- a/drivers/scsi/scsi_transport_srp.c
55013+++ b/drivers/scsi/scsi_transport_srp.c
55014@@ -35,7 +35,7 @@
55015 #include "scsi_priv.h"
55016
55017 struct srp_host_attrs {
55018- atomic_t next_port_id;
55019+ atomic_unchecked_t next_port_id;
55020 };
55021 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
55022
55023@@ -105,7 +105,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
55024 struct Scsi_Host *shost = dev_to_shost(dev);
55025 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
55026
55027- atomic_set(&srp_host->next_port_id, 0);
55028+ atomic_set_unchecked(&srp_host->next_port_id, 0);
55029 return 0;
55030 }
55031
55032@@ -752,7 +752,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
55033 rport_fast_io_fail_timedout);
55034 INIT_DELAYED_WORK(&rport->dev_loss_work, rport_dev_loss_timedout);
55035
55036- id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
55037+ id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
55038 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
55039
55040 transport_setup_device(&rport->dev);
55041diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
55042index a20da8c..7f47bac 100644
55043--- a/drivers/scsi/sd.c
55044+++ b/drivers/scsi/sd.c
55045@@ -111,7 +111,7 @@ static int sd_resume(struct device *);
55046 static void sd_rescan(struct device *);
55047 static int sd_init_command(struct scsi_cmnd *SCpnt);
55048 static void sd_uninit_command(struct scsi_cmnd *SCpnt);
55049-static int sd_done(struct scsi_cmnd *);
55050+static unsigned int sd_done(struct scsi_cmnd *);
55051 static int sd_eh_action(struct scsi_cmnd *, int);
55052 static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
55053 static void scsi_disk_release(struct device *cdev);
55054@@ -1646,7 +1646,7 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
55055 *
55056 * Note: potentially run from within an ISR. Must not block.
55057 **/
55058-static int sd_done(struct scsi_cmnd *SCpnt)
55059+static unsigned int sd_done(struct scsi_cmnd *SCpnt)
55060 {
55061 int result = SCpnt->result;
55062 unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt);
55063@@ -2973,7 +2973,7 @@ static int sd_probe(struct device *dev)
55064 sdkp->disk = gd;
55065 sdkp->index = index;
55066 atomic_set(&sdkp->openers, 0);
55067- atomic_set(&sdkp->device->ioerr_cnt, 0);
55068+ atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
55069
55070 if (!sdp->request_queue->rq_timeout) {
55071 if (sdp->type != TYPE_MOD)
55072diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
55073index 9d7b7db..33ecc51 100644
55074--- a/drivers/scsi/sg.c
55075+++ b/drivers/scsi/sg.c
55076@@ -1083,7 +1083,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
55077 sdp->disk->disk_name,
55078 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
55079 NULL,
55080- (char *)arg);
55081+ (char __user *)arg);
55082 case BLKTRACESTART:
55083 return blk_trace_startstop(sdp->device->request_queue, 1);
55084 case BLKTRACESTOP:
55085diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
55086index 8bd54a6..58fa0d6 100644
55087--- a/drivers/scsi/sr.c
55088+++ b/drivers/scsi/sr.c
55089@@ -80,7 +80,7 @@ static DEFINE_MUTEX(sr_mutex);
55090 static int sr_probe(struct device *);
55091 static int sr_remove(struct device *);
55092 static int sr_init_command(struct scsi_cmnd *SCpnt);
55093-static int sr_done(struct scsi_cmnd *);
55094+static unsigned int sr_done(struct scsi_cmnd *);
55095 static int sr_runtime_suspend(struct device *dev);
55096
55097 static struct dev_pm_ops sr_pm_ops = {
55098@@ -312,13 +312,13 @@ do_tur:
55099 * It will be notified on the end of a SCSI read / write, and will take one
55100 * of several actions based on success or failure.
55101 */
55102-static int sr_done(struct scsi_cmnd *SCpnt)
55103+static unsigned int sr_done(struct scsi_cmnd *SCpnt)
55104 {
55105 int result = SCpnt->result;
55106- int this_count = scsi_bufflen(SCpnt);
55107- int good_bytes = (result == 0 ? this_count : 0);
55108- int block_sectors = 0;
55109- long error_sector;
55110+ unsigned int this_count = scsi_bufflen(SCpnt);
55111+ unsigned int good_bytes = (result == 0 ? this_count : 0);
55112+ unsigned int block_sectors = 0;
55113+ sector_t error_sector;
55114 struct scsi_cd *cd = scsi_cd(SCpnt->request->rq_disk);
55115
55116 #ifdef DEBUG
55117@@ -351,9 +351,12 @@ static int sr_done(struct scsi_cmnd *SCpnt)
55118 if (cd->device->sector_size == 2048)
55119 error_sector <<= 2;
55120 error_sector &= ~(block_sectors - 1);
55121- good_bytes = (error_sector -
55122- blk_rq_pos(SCpnt->request)) << 9;
55123- if (good_bytes < 0 || good_bytes >= this_count)
55124+ if (error_sector >= blk_rq_pos(SCpnt->request)) {
55125+ good_bytes = (error_sector -
55126+ blk_rq_pos(SCpnt->request)) << 9;
55127+ if (good_bytes >= this_count)
55128+ good_bytes = 0;
55129+ } else
55130 good_bytes = 0;
55131 /*
55132 * The SCSI specification allows for the value
55133diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
55134index c0d660f..24a5854 100644
55135--- a/drivers/soc/tegra/fuse/fuse-tegra.c
55136+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
55137@@ -71,7 +71,7 @@ static ssize_t fuse_read(struct file *fd, struct kobject *kobj,
55138 return i;
55139 }
55140
55141-static struct bin_attribute fuse_bin_attr = {
55142+static bin_attribute_no_const fuse_bin_attr = {
55143 .attr = { .name = "fuse", .mode = S_IRUGO, },
55144 .read = fuse_read,
55145 };
55146diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
55147index 9ce2f15..1ff9b36 100644
55148--- a/drivers/spi/spi.c
55149+++ b/drivers/spi/spi.c
55150@@ -2215,7 +2215,7 @@ int spi_bus_unlock(struct spi_master *master)
55151 EXPORT_SYMBOL_GPL(spi_bus_unlock);
55152
55153 /* portable code must never pass more than 32 bytes */
55154-#define SPI_BUFSIZ max(32, SMP_CACHE_BYTES)
55155+#define SPI_BUFSIZ max(32UL, SMP_CACHE_BYTES)
55156
55157 static u8 *buf;
55158
55159diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
55160index b41429f..2de5373 100644
55161--- a/drivers/staging/android/timed_output.c
55162+++ b/drivers/staging/android/timed_output.c
55163@@ -25,7 +25,7 @@
55164 #include "timed_output.h"
55165
55166 static struct class *timed_output_class;
55167-static atomic_t device_count;
55168+static atomic_unchecked_t device_count;
55169
55170 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
55171 char *buf)
55172@@ -65,7 +65,7 @@ static int create_timed_output_class(void)
55173 timed_output_class = class_create(THIS_MODULE, "timed_output");
55174 if (IS_ERR(timed_output_class))
55175 return PTR_ERR(timed_output_class);
55176- atomic_set(&device_count, 0);
55177+ atomic_set_unchecked(&device_count, 0);
55178 timed_output_class->dev_groups = timed_output_groups;
55179 }
55180
55181@@ -83,7 +83,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
55182 if (ret < 0)
55183 return ret;
55184
55185- tdev->index = atomic_inc_return(&device_count);
55186+ tdev->index = atomic_inc_return_unchecked(&device_count);
55187 tdev->dev = device_create(timed_output_class, NULL,
55188 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
55189 if (IS_ERR(tdev->dev))
55190diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
55191index 985d94b..49c59fb 100644
55192--- a/drivers/staging/comedi/comedi_fops.c
55193+++ b/drivers/staging/comedi/comedi_fops.c
55194@@ -314,8 +314,8 @@ static void comedi_file_reset(struct file *file)
55195 }
55196 cfp->last_attached = dev->attached;
55197 cfp->last_detach_count = dev->detach_count;
55198- ACCESS_ONCE(cfp->read_subdev) = read_s;
55199- ACCESS_ONCE(cfp->write_subdev) = write_s;
55200+ ACCESS_ONCE_RW(cfp->read_subdev) = read_s;
55201+ ACCESS_ONCE_RW(cfp->write_subdev) = write_s;
55202 }
55203
55204 static void comedi_file_check(struct file *file)
55205@@ -1983,7 +1983,7 @@ static int do_setrsubd_ioctl(struct comedi_device *dev, unsigned long arg,
55206 !(s_old->async->cmd.flags & CMDF_WRITE))
55207 return -EBUSY;
55208
55209- ACCESS_ONCE(cfp->read_subdev) = s_new;
55210+ ACCESS_ONCE_RW(cfp->read_subdev) = s_new;
55211 return 0;
55212 }
55213
55214@@ -2025,7 +2025,7 @@ static int do_setwsubd_ioctl(struct comedi_device *dev, unsigned long arg,
55215 (s_old->async->cmd.flags & CMDF_WRITE))
55216 return -EBUSY;
55217
55218- ACCESS_ONCE(cfp->write_subdev) = s_new;
55219+ ACCESS_ONCE_RW(cfp->write_subdev) = s_new;
55220 return 0;
55221 }
55222
55223diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
55224index b13318a..883e2a8 100644
55225--- a/drivers/staging/dgnc/dgnc_mgmt.c
55226+++ b/drivers/staging/dgnc/dgnc_mgmt.c
55227@@ -115,6 +115,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
55228
55229 spin_lock_irqsave(&dgnc_global_lock, flags);
55230
55231+ memset(&ddi, 0, sizeof(ddi));
55232 ddi.dinfo_nboards = dgnc_NumBoards;
55233 sprintf(ddi.dinfo_version, "%s", DG_PART);
55234
55235diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
55236index 9cc8141..ffd5039 100644
55237--- a/drivers/staging/fbtft/fbtft-core.c
55238+++ b/drivers/staging/fbtft/fbtft-core.c
55239@@ -681,7 +681,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
55240 {
55241 struct fb_info *info;
55242 struct fbtft_par *par;
55243- struct fb_ops *fbops = NULL;
55244+ fb_ops_no_const *fbops = NULL;
55245 struct fb_deferred_io *fbdefio = NULL;
55246 struct fbtft_platform_data *pdata = dev->platform_data;
55247 u8 *vmem = NULL;
55248diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h
55249index 7d817eb..d22e49e 100644
55250--- a/drivers/staging/fbtft/fbtft.h
55251+++ b/drivers/staging/fbtft/fbtft.h
55252@@ -106,7 +106,7 @@ struct fbtft_ops {
55253
55254 int (*set_var)(struct fbtft_par *par);
55255 int (*set_gamma)(struct fbtft_par *par, unsigned long *curves);
55256-};
55257+} __no_const;
55258
55259 /**
55260 * struct fbtft_display - Describes the display properties
55261diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
55262index 001348c..cfaac8a 100644
55263--- a/drivers/staging/gdm724x/gdm_tty.c
55264+++ b/drivers/staging/gdm724x/gdm_tty.c
55265@@ -44,7 +44,7 @@
55266 #define gdm_tty_send_control(n, r, v, d, l) (\
55267 n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l))
55268
55269-#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
55270+#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && atomic_read(&gdm->port.count))
55271
55272 static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
55273 static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
55274diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
55275index b892f2c..9b4898a 100644
55276--- a/drivers/staging/iio/accel/lis3l02dq_ring.c
55277+++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
55278@@ -118,7 +118,7 @@ static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev,
55279 int scan_count = bitmap_weight(indio_dev->active_scan_mask,
55280 indio_dev->masklength);
55281
55282- rx_array = kcalloc(4, scan_count, GFP_KERNEL);
55283+ rx_array = kcalloc(scan_count, 4, GFP_KERNEL);
55284 if (!rx_array)
55285 return -ENOMEM;
55286 ret = lis3l02dq_read_all(indio_dev, rx_array);
55287diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
55288index d98e229..9c59bc2 100644
55289--- a/drivers/staging/iio/adc/ad7280a.c
55290+++ b/drivers/staging/iio/adc/ad7280a.c
55291@@ -547,8 +547,8 @@ static int ad7280_attr_init(struct ad7280_state *st)
55292 {
55293 int dev, ch, cnt;
55294
55295- st->iio_attr = kcalloc(2, sizeof(*st->iio_attr) *
55296- (st->slave_num + 1) * AD7280A_CELLS_PER_DEV,
55297+ st->iio_attr = kcalloc(sizeof(*st->iio_attr) *
55298+ (st->slave_num + 1) * AD7280A_CELLS_PER_DEV, 2,
55299 GFP_KERNEL);
55300 if (st->iio_attr == NULL)
55301 return -ENOMEM;
55302diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
55303index de11f1b..f7181cf 100644
55304--- a/drivers/staging/lustre/lnet/selftest/brw_test.c
55305+++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
55306@@ -487,13 +487,11 @@ brw_server_handle(struct srpc_server_rpc *rpc)
55307 return 0;
55308 }
55309
55310-sfw_test_client_ops_t brw_test_client;
55311-void brw_init_test_client(void)
55312-{
55313- brw_test_client.tso_init = brw_client_init;
55314- brw_test_client.tso_fini = brw_client_fini;
55315- brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
55316- brw_test_client.tso_done_rpc = brw_client_done_rpc;
55317+sfw_test_client_ops_t brw_test_client = {
55318+ .tso_init = brw_client_init,
55319+ .tso_fini = brw_client_fini,
55320+ .tso_prep_rpc = brw_client_prep_rpc,
55321+ .tso_done_rpc = brw_client_done_rpc,
55322 };
55323
55324 srpc_service_t brw_test_service;
55325diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
55326index 7c5185a..51c2ae7 100644
55327--- a/drivers/staging/lustre/lnet/selftest/framework.c
55328+++ b/drivers/staging/lustre/lnet/selftest/framework.c
55329@@ -1628,12 +1628,10 @@ static srpc_service_t sfw_services[] = {
55330
55331 extern sfw_test_client_ops_t ping_test_client;
55332 extern srpc_service_t ping_test_service;
55333-extern void ping_init_test_client(void);
55334 extern void ping_init_test_service(void);
55335
55336 extern sfw_test_client_ops_t brw_test_client;
55337 extern srpc_service_t brw_test_service;
55338-extern void brw_init_test_client(void);
55339 extern void brw_init_test_service(void);
55340
55341
55342@@ -1675,12 +1673,10 @@ sfw_startup(void)
55343 INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs);
55344 INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions);
55345
55346- brw_init_test_client();
55347 brw_init_test_service();
55348 rc = sfw_register_test(&brw_test_service, &brw_test_client);
55349 LASSERT(rc == 0);
55350
55351- ping_init_test_client();
55352 ping_init_test_service();
55353 rc = sfw_register_test(&ping_test_service, &ping_test_client);
55354 LASSERT(rc == 0);
55355diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
55356index 1dab998..edfe0ac 100644
55357--- a/drivers/staging/lustre/lnet/selftest/ping_test.c
55358+++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
55359@@ -211,14 +211,12 @@ ping_server_handle(struct srpc_server_rpc *rpc)
55360 return 0;
55361 }
55362
55363-sfw_test_client_ops_t ping_test_client;
55364-void ping_init_test_client(void)
55365-{
55366- ping_test_client.tso_init = ping_client_init;
55367- ping_test_client.tso_fini = ping_client_fini;
55368- ping_test_client.tso_prep_rpc = ping_client_prep_rpc;
55369- ping_test_client.tso_done_rpc = ping_client_done_rpc;
55370-}
55371+sfw_test_client_ops_t ping_test_client = {
55372+ .tso_init = ping_client_init,
55373+ .tso_fini = ping_client_fini,
55374+ .tso_prep_rpc = ping_client_prep_rpc,
55375+ .tso_done_rpc = ping_client_done_rpc,
55376+};
55377
55378 srpc_service_t ping_test_service;
55379 void ping_init_test_service(void)
55380diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
55381index f6f4c03..cdc3556 100644
55382--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
55383+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
55384@@ -1107,7 +1107,7 @@ struct ldlm_callback_suite {
55385 ldlm_completion_callback lcs_completion;
55386 ldlm_blocking_callback lcs_blocking;
55387 ldlm_glimpse_callback lcs_glimpse;
55388-};
55389+} __no_const;
55390
55391 /* ldlm_lockd.c */
55392 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
55393diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
55394index 55452e5..43b0f2f 100644
55395--- a/drivers/staging/lustre/lustre/include/obd.h
55396+++ b/drivers/staging/lustre/lustre/include/obd.h
55397@@ -1364,7 +1364,7 @@ struct md_ops {
55398 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
55399 * wrapper function in include/linux/obd_class.h.
55400 */
55401-};
55402+} __no_const;
55403
55404 struct lsm_operations {
55405 void (*lsm_free)(struct lov_stripe_md *);
55406diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
55407index a4c252f..b21acac 100644
55408--- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
55409+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
55410@@ -258,7 +258,7 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq,
55411 int added = (mode == LCK_NL);
55412 int overlaps = 0;
55413 int splitted = 0;
55414- const struct ldlm_callback_suite null_cbs = { NULL };
55415+ const struct ldlm_callback_suite null_cbs = { };
55416
55417 CDEBUG(D_DLMTRACE,
55418 "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n",
55419diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
55420index e60b2e9..ad9ceb3 100644
55421--- a/drivers/staging/lustre/lustre/libcfs/module.c
55422+++ b/drivers/staging/lustre/lustre/libcfs/module.c
55423@@ -377,11 +377,11 @@ out:
55424
55425
55426 struct cfs_psdev_ops libcfs_psdev_ops = {
55427- libcfs_psdev_open,
55428- libcfs_psdev_release,
55429- NULL,
55430- NULL,
55431- libcfs_ioctl
55432+ .p_open = libcfs_psdev_open,
55433+ .p_close = libcfs_psdev_release,
55434+ .p_read = NULL,
55435+ .p_write = NULL,
55436+ .p_ioctl = libcfs_ioctl
55437 };
55438
55439 static int init_libcfs_module(void)
55440@@ -623,7 +623,7 @@ static int proc_console_max_delay_cs(struct ctl_table *table, int write,
55441 loff_t *ppos)
55442 {
55443 int rc, max_delay_cs;
55444- struct ctl_table dummy = *table;
55445+ ctl_table_no_const dummy = *table;
55446 long d;
55447
55448 dummy.data = &max_delay_cs;
55449@@ -656,7 +656,7 @@ static int proc_console_min_delay_cs(struct ctl_table *table, int write,
55450 loff_t *ppos)
55451 {
55452 int rc, min_delay_cs;
55453- struct ctl_table dummy = *table;
55454+ ctl_table_no_const dummy = *table;
55455 long d;
55456
55457 dummy.data = &min_delay_cs;
55458@@ -688,7 +688,7 @@ static int proc_console_backoff(struct ctl_table *table, int write,
55459 void __user *buffer, size_t *lenp, loff_t *ppos)
55460 {
55461 int rc, backoff;
55462- struct ctl_table dummy = *table;
55463+ ctl_table_no_const dummy = *table;
55464
55465 dummy.data = &backoff;
55466 dummy.proc_handler = &proc_dointvec;
55467diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
55468index 22853d3..cfa3c49 100644
55469--- a/drivers/staging/octeon/ethernet-rx.c
55470+++ b/drivers/staging/octeon/ethernet-rx.c
55471@@ -335,14 +335,14 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
55472 /* Increment RX stats for virtual ports */
55473 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
55474 #ifdef CONFIG_64BIT
55475- atomic64_add(1,
55476+ atomic64_add_unchecked(1,
55477 (atomic64_t *)&priv->stats.rx_packets);
55478- atomic64_add(skb->len,
55479+ atomic64_add_unchecked(skb->len,
55480 (atomic64_t *)&priv->stats.rx_bytes);
55481 #else
55482- atomic_add(1,
55483+ atomic_add_unchecked(1,
55484 (atomic_t *)&priv->stats.rx_packets);
55485- atomic_add(skb->len,
55486+ atomic_add_unchecked(skb->len,
55487 (atomic_t *)&priv->stats.rx_bytes);
55488 #endif
55489 }
55490@@ -354,10 +354,10 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
55491 dev->name);
55492 */
55493 #ifdef CONFIG_64BIT
55494- atomic64_add(1,
55495+ atomic64_add_unchecked(1,
55496 (atomic64_t *)&priv->stats.rx_dropped);
55497 #else
55498- atomic_add(1,
55499+ atomic_add_unchecked(1,
55500 (atomic_t *)&priv->stats.rx_dropped);
55501 #endif
55502 dev_kfree_skb_irq(skb);
55503diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
55504index f9dba23..7bc0ef3 100644
55505--- a/drivers/staging/octeon/ethernet.c
55506+++ b/drivers/staging/octeon/ethernet.c
55507@@ -231,11 +231,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
55508 * since the RX tasklet also increments it.
55509 */
55510 #ifdef CONFIG_64BIT
55511- atomic64_add(rx_status.dropped_packets,
55512- (atomic64_t *)&priv->stats.rx_dropped);
55513+ atomic64_add_unchecked(rx_status.dropped_packets,
55514+ (atomic64_unchecked_t *)&priv->stats.rx_dropped);
55515 #else
55516- atomic_add(rx_status.dropped_packets,
55517- (atomic_t *)&priv->stats.rx_dropped);
55518+ atomic_add_unchecked(rx_status.dropped_packets,
55519+ (atomic_unchecked_t *)&priv->stats.rx_dropped);
55520 #endif
55521 }
55522
55523diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h
55524index 3b476d8..f522d68 100644
55525--- a/drivers/staging/rtl8188eu/include/hal_intf.h
55526+++ b/drivers/staging/rtl8188eu/include/hal_intf.h
55527@@ -225,7 +225,7 @@ struct hal_ops {
55528
55529 void (*hal_notch_filter)(struct adapter *adapter, bool enable);
55530 void (*hal_reset_security_engine)(struct adapter *adapter);
55531-};
55532+} __no_const;
55533
55534 enum rt_eeprom_type {
55535 EEPROM_93C46,
55536diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
55537index 070cc03..6806e37 100644
55538--- a/drivers/staging/rtl8712/rtl871x_io.h
55539+++ b/drivers/staging/rtl8712/rtl871x_io.h
55540@@ -108,7 +108,7 @@ struct _io_ops {
55541 u8 *pmem);
55542 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
55543 u8 *pmem);
55544-};
55545+} __no_const;
55546
55547 struct io_req {
55548 struct list_head list;
55549diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
55550index 8e201f1..bf2a28d 100644
55551--- a/drivers/staging/sm750fb/sm750.c
55552+++ b/drivers/staging/sm750fb/sm750.c
55553@@ -775,6 +775,7 @@ static struct fb_ops lynxfb_ops = {
55554 .fb_set_par = lynxfb_ops_set_par,
55555 .fb_setcolreg = lynxfb_ops_setcolreg,
55556 .fb_blank = lynxfb_ops_blank,
55557+ .fb_pan_display = lynxfb_ops_pan_display,
55558 .fb_fillrect = cfb_fillrect,
55559 .fb_imageblit = cfb_imageblit,
55560 .fb_copyarea = cfb_copyarea,
55561@@ -822,8 +823,10 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
55562 par->index = index;
55563 output->channel = &crtc->channel;
55564 sm750fb_set_drv(par);
55565- lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display;
55566
55567+ pax_open_kernel();
55568+ *(void **)&lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display;
55569+ pax_close_kernel();
55570
55571 /* set current cursor variable and proc pointer,
55572 * must be set after crtc member initialized */
55573@@ -845,7 +848,9 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
55574 crtc->cursor.share = share;
55575 memset_io(crtc->cursor.vstart, 0, crtc->cursor.size);
55576 if (!g_hwcursor) {
55577- lynxfb_ops.fb_cursor = NULL;
55578+ pax_open_kernel();
55579+ *(void **)&lynxfb_ops.fb_cursor = NULL;
55580+ pax_close_kernel();
55581 crtc->cursor.disable(&crtc->cursor);
55582 }
55583
55584@@ -853,9 +858,11 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
55585 /* set info->fbops, must be set before fb_find_mode */
55586 if (!share->accel_off) {
55587 /* use 2d acceleration */
55588- lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect;
55589- lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea;
55590- lynxfb_ops.fb_imageblit = lynxfb_ops_imageblit;
55591+ pax_open_kernel();
55592+ *(void **)&lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect;
55593+ *(void **)&lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea;
55594+ *(void **)&lynxfb_ops.fb_imageblit = lynxfb_ops_imageblit;
55595+ pax_close_kernel();
55596 }
55597 info->fbops = &lynxfb_ops;
55598
55599diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
55600index 2f12483..6e1b50a 100644
55601--- a/drivers/staging/unisys/visorbus/visorbus_private.h
55602+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
55603@@ -35,7 +35,7 @@ struct visorchipset_busdev_notifiers {
55604 void (*device_destroy)(struct visor_device *bus_info);
55605 void (*device_pause)(struct visor_device *bus_info);
55606 void (*device_resume)(struct visor_device *bus_info);
55607-};
55608+} __no_const;
55609
55610 /* These functions live inside visorchipset, and will be called to indicate
55611 * responses to specific events (by code outside of visorchipset).
55612@@ -50,7 +50,7 @@ struct visorchipset_busdev_responders {
55613 void (*device_destroy)(struct visor_device *p, int response);
55614 void (*device_pause)(struct visor_device *p, int response);
55615 void (*device_resume)(struct visor_device *p, int response);
55616-};
55617+} __no_const;
55618
55619 /** Register functions (in the bus driver) to get called by visorchipset
55620 * whenever a bus or device appears for which this guest is to be the
55621diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
55622index 0edf320..49afe95 100644
55623--- a/drivers/target/sbp/sbp_target.c
55624+++ b/drivers/target/sbp/sbp_target.c
55625@@ -60,7 +60,7 @@ static const u32 sbp_unit_directory_template[] = {
55626
55627 #define SESSION_MAINTENANCE_INTERVAL HZ
55628
55629-static atomic_t login_id = ATOMIC_INIT(0);
55630+static atomic_unchecked_t login_id = ATOMIC_INIT(0);
55631
55632 static void session_maintenance_work(struct work_struct *);
55633 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
55634@@ -441,7 +441,7 @@ static void sbp_management_request_login(
55635 login->login_lun = unpacked_lun;
55636 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
55637 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
55638- login->login_id = atomic_inc_return(&login_id);
55639+ login->login_id = atomic_inc_return_unchecked(&login_id);
55640
55641 login->tgt_agt = sbp_target_agent_register(login);
55642 if (IS_ERR(login->tgt_agt)) {
55643diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
55644index 8f1cd19..ba7a8f1 100644
55645--- a/drivers/target/target_core_device.c
55646+++ b/drivers/target/target_core_device.c
55647@@ -772,7 +772,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
55648 spin_lock_init(&dev->se_tmr_lock);
55649 spin_lock_init(&dev->qf_cmd_lock);
55650 sema_init(&dev->caw_sem, 1);
55651- atomic_set(&dev->dev_ordered_id, 0);
55652+ atomic_set_unchecked(&dev->dev_ordered_id, 0);
55653 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
55654 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
55655 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
55656diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
55657index ce8574b..98d6199 100644
55658--- a/drivers/target/target_core_transport.c
55659+++ b/drivers/target/target_core_transport.c
55660@@ -1181,7 +1181,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
55661 * Used to determine when ORDERED commands should go from
55662 * Dormant to Active status.
55663 */
55664- cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
55665+ cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
55666 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
55667 cmd->se_ordered_id, cmd->sam_task_attr,
55668 dev->transport->name);
55669diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
55670index 42c6f71..1c64309 100644
55671--- a/drivers/thermal/cpu_cooling.c
55672+++ b/drivers/thermal/cpu_cooling.c
55673@@ -838,10 +838,11 @@ __cpufreq_cooling_register(struct device_node *np,
55674 cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus);
55675
55676 if (capacitance) {
55677- cpufreq_cooling_ops.get_requested_power =
55678- cpufreq_get_requested_power;
55679- cpufreq_cooling_ops.state2power = cpufreq_state2power;
55680- cpufreq_cooling_ops.power2state = cpufreq_power2state;
55681+ pax_open_kernel();
55682+ *(void **)&cpufreq_cooling_ops.get_requested_power = cpufreq_get_requested_power;
55683+ *(void **)&cpufreq_cooling_ops.state2power = cpufreq_state2power;
55684+ *(void **)&cpufreq_cooling_ops.power2state = cpufreq_power2state;
55685+ pax_close_kernel();
55686 cpufreq_dev->plat_get_static_power = plat_static_func;
55687
55688 ret = build_dyn_power_table(cpufreq_dev, capacitance);
55689diff --git a/drivers/thermal/int340x_thermal/int3400_thermal.c b/drivers/thermal/int340x_thermal/int3400_thermal.c
55690index 031018e..90981a1 100644
55691--- a/drivers/thermal/int340x_thermal/int3400_thermal.c
55692+++ b/drivers/thermal/int340x_thermal/int3400_thermal.c
55693@@ -272,8 +272,10 @@ static int int3400_thermal_probe(struct platform_device *pdev)
55694 platform_set_drvdata(pdev, priv);
55695
55696 if (priv->uuid_bitmap & 1 << INT3400_THERMAL_PASSIVE_1) {
55697- int3400_thermal_ops.get_mode = int3400_thermal_get_mode;
55698- int3400_thermal_ops.set_mode = int3400_thermal_set_mode;
55699+ pax_open_kernel();
55700+ *(void **)&int3400_thermal_ops.get_mode = int3400_thermal_get_mode;
55701+ *(void **)&int3400_thermal_ops.set_mode = int3400_thermal_set_mode;
55702+ pax_close_kernel();
55703 }
55704 priv->thermal = thermal_zone_device_register("INT3400 Thermal", 0, 0,
55705 priv, &int3400_thermal_ops,
55706diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
55707index b295b2b..f7e2a30 100644
55708--- a/drivers/thermal/of-thermal.c
55709+++ b/drivers/thermal/of-thermal.c
55710@@ -31,6 +31,7 @@
55711 #include <linux/export.h>
55712 #include <linux/string.h>
55713 #include <linux/thermal.h>
55714+#include <linux/mm.h>
55715
55716 #include "thermal_core.h"
55717
55718@@ -417,9 +418,11 @@ thermal_zone_of_add_sensor(struct device_node *zone,
55719 tz->ops = ops;
55720 tz->sensor_data = data;
55721
55722- tzd->ops->get_temp = of_thermal_get_temp;
55723- tzd->ops->get_trend = of_thermal_get_trend;
55724- tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
55725+ pax_open_kernel();
55726+ *(void **)&tzd->ops->get_temp = of_thermal_get_temp;
55727+ *(void **)&tzd->ops->get_trend = of_thermal_get_trend;
55728+ *(void **)&tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
55729+ pax_close_kernel();
55730 mutex_unlock(&tzd->lock);
55731
55732 return tzd;
55733@@ -549,9 +552,11 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
55734 return;
55735
55736 mutex_lock(&tzd->lock);
55737- tzd->ops->get_temp = NULL;
55738- tzd->ops->get_trend = NULL;
55739- tzd->ops->set_emul_temp = NULL;
55740+ pax_open_kernel();
55741+ *(void **)&tzd->ops->get_temp = NULL;
55742+ *(void **)&tzd->ops->get_trend = NULL;
55743+ *(void **)&tzd->ops->set_emul_temp = NULL;
55744+ pax_close_kernel();
55745
55746 tz->ops = NULL;
55747 tz->sensor_data = NULL;
55748diff --git a/drivers/thermal/x86_pkg_temp_thermal.c b/drivers/thermal/x86_pkg_temp_thermal.c
55749index 50d1d2c..39c5ce0 100644
55750--- a/drivers/thermal/x86_pkg_temp_thermal.c
55751+++ b/drivers/thermal/x86_pkg_temp_thermal.c
55752@@ -567,7 +567,7 @@ static int pkg_temp_thermal_cpu_callback(struct notifier_block *nfb,
55753 return NOTIFY_OK;
55754 }
55755
55756-static struct notifier_block pkg_temp_thermal_notifier __refdata = {
55757+static struct notifier_block pkg_temp_thermal_notifier __refconst = {
55758 .notifier_call = pkg_temp_thermal_cpu_callback,
55759 };
55760
55761diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
55762index 87f6578..905c8f8 100644
55763--- a/drivers/tty/cyclades.c
55764+++ b/drivers/tty/cyclades.c
55765@@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
55766 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
55767 info->port.count);
55768 #endif
55769- info->port.count++;
55770+ atomic_inc(&info->port.count);
55771 #ifdef CY_DEBUG_COUNT
55772 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
55773- current->pid, info->port.count);
55774+ current->pid, atomic_read(&info->port.count));
55775 #endif
55776
55777 /*
55778@@ -3970,7 +3970,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
55779 for (j = 0; j < cy_card[i].nports; j++) {
55780 info = &cy_card[i].ports[j];
55781
55782- if (info->port.count) {
55783+ if (atomic_read(&info->port.count)) {
55784 /* XXX is the ldisc num worth this? */
55785 struct tty_struct *tty;
55786 struct tty_ldisc *ld;
55787diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
55788index 4e9c4cc..2199d8f 100644
55789--- a/drivers/tty/hvc/hvc_console.c
55790+++ b/drivers/tty/hvc/hvc_console.c
55791@@ -343,7 +343,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
55792
55793 spin_lock_irqsave(&hp->port.lock, flags);
55794 /* Check and then increment for fast path open. */
55795- if (hp->port.count++ > 0) {
55796+ if (atomic_inc_return(&hp->port.count) > 1) {
55797 spin_unlock_irqrestore(&hp->port.lock, flags);
55798 hvc_kick();
55799 return 0;
55800@@ -398,7 +398,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
55801
55802 spin_lock_irqsave(&hp->port.lock, flags);
55803
55804- if (--hp->port.count == 0) {
55805+ if (atomic_dec_return(&hp->port.count) == 0) {
55806 spin_unlock_irqrestore(&hp->port.lock, flags);
55807 /* We are done with the tty pointer now. */
55808 tty_port_tty_set(&hp->port, NULL);
55809@@ -420,9 +420,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
55810 */
55811 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
55812 } else {
55813- if (hp->port.count < 0)
55814+ if (atomic_read(&hp->port.count) < 0)
55815 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
55816- hp->vtermno, hp->port.count);
55817+ hp->vtermno, atomic_read(&hp->port.count));
55818 spin_unlock_irqrestore(&hp->port.lock, flags);
55819 }
55820 }
55821@@ -452,12 +452,12 @@ static void hvc_hangup(struct tty_struct *tty)
55822 * open->hangup case this can be called after the final close so prevent
55823 * that from happening for now.
55824 */
55825- if (hp->port.count <= 0) {
55826+ if (atomic_read(&hp->port.count) <= 0) {
55827 spin_unlock_irqrestore(&hp->port.lock, flags);
55828 return;
55829 }
55830
55831- hp->port.count = 0;
55832+ atomic_set(&hp->port.count, 0);
55833 spin_unlock_irqrestore(&hp->port.lock, flags);
55834 tty_port_tty_set(&hp->port, NULL);
55835
55836@@ -505,7 +505,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
55837 return -EPIPE;
55838
55839 /* FIXME what's this (unprotected) check for? */
55840- if (hp->port.count <= 0)
55841+ if (atomic_read(&hp->port.count) <= 0)
55842 return -EIO;
55843
55844 spin_lock_irqsave(&hp->lock, flags);
55845diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
55846index f7ff97c..0c0ebbf 100644
55847--- a/drivers/tty/hvc/hvcs.c
55848+++ b/drivers/tty/hvc/hvcs.c
55849@@ -83,6 +83,7 @@
55850 #include <asm/hvcserver.h>
55851 #include <asm/uaccess.h>
55852 #include <asm/vio.h>
55853+#include <asm/local.h>
55854
55855 /*
55856 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
55857@@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
55858
55859 spin_lock_irqsave(&hvcsd->lock, flags);
55860
55861- if (hvcsd->port.count > 0) {
55862+ if (atomic_read(&hvcsd->port.count) > 0) {
55863 spin_unlock_irqrestore(&hvcsd->lock, flags);
55864 printk(KERN_INFO "HVCS: vterm state unchanged. "
55865 "The hvcs device node is still in use.\n");
55866@@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
55867 }
55868 }
55869
55870- hvcsd->port.count = 0;
55871+ atomic_set(&hvcsd->port.count, 0);
55872 hvcsd->port.tty = tty;
55873 tty->driver_data = hvcsd;
55874
55875@@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
55876 unsigned long flags;
55877
55878 spin_lock_irqsave(&hvcsd->lock, flags);
55879- hvcsd->port.count++;
55880+ atomic_inc(&hvcsd->port.count);
55881 hvcsd->todo_mask |= HVCS_SCHED_READ;
55882 spin_unlock_irqrestore(&hvcsd->lock, flags);
55883
55884@@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
55885 hvcsd = tty->driver_data;
55886
55887 spin_lock_irqsave(&hvcsd->lock, flags);
55888- if (--hvcsd->port.count == 0) {
55889+ if (atomic_dec_and_test(&hvcsd->port.count)) {
55890
55891 vio_disable_interrupts(hvcsd->vdev);
55892
55893@@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
55894
55895 free_irq(irq, hvcsd);
55896 return;
55897- } else if (hvcsd->port.count < 0) {
55898+ } else if (atomic_read(&hvcsd->port.count) < 0) {
55899 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
55900 " is missmanaged.\n",
55901- hvcsd->vdev->unit_address, hvcsd->port.count);
55902+ hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
55903 }
55904
55905 spin_unlock_irqrestore(&hvcsd->lock, flags);
55906@@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
55907
55908 spin_lock_irqsave(&hvcsd->lock, flags);
55909 /* Preserve this so that we know how many kref refs to put */
55910- temp_open_count = hvcsd->port.count;
55911+ temp_open_count = atomic_read(&hvcsd->port.count);
55912
55913 /*
55914 * Don't kref put inside the spinlock because the destruction
55915@@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
55916 tty->driver_data = NULL;
55917 hvcsd->port.tty = NULL;
55918
55919- hvcsd->port.count = 0;
55920+ atomic_set(&hvcsd->port.count, 0);
55921
55922 /* This will drop any buffered data on the floor which is OK in a hangup
55923 * scenario. */
55924@@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
55925 * the middle of a write operation? This is a crummy place to do this
55926 * but we want to keep it all in the spinlock.
55927 */
55928- if (hvcsd->port.count <= 0) {
55929+ if (atomic_read(&hvcsd->port.count) <= 0) {
55930 spin_unlock_irqrestore(&hvcsd->lock, flags);
55931 return -ENODEV;
55932 }
55933@@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
55934 {
55935 struct hvcs_struct *hvcsd = tty->driver_data;
55936
55937- if (!hvcsd || hvcsd->port.count <= 0)
55938+ if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
55939 return 0;
55940
55941 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
55942diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
55943index 4190199..06d5bfa 100644
55944--- a/drivers/tty/hvc/hvsi.c
55945+++ b/drivers/tty/hvc/hvsi.c
55946@@ -85,7 +85,7 @@ struct hvsi_struct {
55947 int n_outbuf;
55948 uint32_t vtermno;
55949 uint32_t virq;
55950- atomic_t seqno; /* HVSI packet sequence number */
55951+ atomic_unchecked_t seqno; /* HVSI packet sequence number */
55952 uint16_t mctrl;
55953 uint8_t state; /* HVSI protocol state */
55954 uint8_t flags;
55955@@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
55956
55957 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
55958 packet.hdr.len = sizeof(struct hvsi_query_response);
55959- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
55960+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
55961 packet.verb = VSV_SEND_VERSION_NUMBER;
55962 packet.u.version = HVSI_VERSION;
55963 packet.query_seqno = query_seqno+1;
55964@@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
55965
55966 packet.hdr.type = VS_QUERY_PACKET_HEADER;
55967 packet.hdr.len = sizeof(struct hvsi_query);
55968- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
55969+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
55970 packet.verb = verb;
55971
55972 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
55973@@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
55974 int wrote;
55975
55976 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
55977- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
55978+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
55979 packet.hdr.len = sizeof(struct hvsi_control);
55980 packet.verb = VSV_SET_MODEM_CTL;
55981 packet.mask = HVSI_TSDTR;
55982@@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
55983 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
55984
55985 packet.hdr.type = VS_DATA_PACKET_HEADER;
55986- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
55987+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
55988 packet.hdr.len = count + sizeof(struct hvsi_header);
55989 memcpy(&packet.data, buf, count);
55990
55991@@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
55992 struct hvsi_control packet __ALIGNED__;
55993
55994 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
55995- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
55996+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
55997 packet.hdr.len = 6;
55998 packet.verb = VSV_CLOSE_PROTOCOL;
55999
56000@@ -725,7 +725,7 @@ static int hvsi_open(struct tty_struct *tty, struct file *filp)
56001
56002 tty_port_tty_set(&hp->port, tty);
56003 spin_lock_irqsave(&hp->lock, flags);
56004- hp->port.count++;
56005+ atomic_inc(&hp->port.count);
56006 atomic_set(&hp->seqno, 0);
56007 h_vio_signal(hp->vtermno, VIO_IRQ_ENABLE);
56008 spin_unlock_irqrestore(&hp->lock, flags);
56009@@ -782,7 +782,7 @@ static void hvsi_close(struct tty_struct *tty, struct file *filp)
56010
56011 spin_lock_irqsave(&hp->lock, flags);
56012
56013- if (--hp->port.count == 0) {
56014+ if (atomic_dec_return(&hp->port.count) == 0) {
56015 tty_port_tty_set(&hp->port, NULL);
56016 hp->inbuf_end = hp->inbuf; /* discard remaining partial packets */
56017
56018@@ -815,9 +815,9 @@ static void hvsi_close(struct tty_struct *tty, struct file *filp)
56019
56020 spin_lock_irqsave(&hp->lock, flags);
56021 }
56022- } else if (hp->port.count < 0)
56023+ } else if (atomic_read(&hp->port.count) < 0)
56024 printk(KERN_ERR "hvsi_close %lu: oops, count is %d\n",
56025- hp - hvsi_ports, hp->port.count);
56026+ hp - hvsi_ports, atomic_read(&hp->port.count));
56027
56028 spin_unlock_irqrestore(&hp->lock, flags);
56029 }
56030@@ -832,7 +832,7 @@ static void hvsi_hangup(struct tty_struct *tty)
56031 tty_port_tty_set(&hp->port, NULL);
56032
56033 spin_lock_irqsave(&hp->lock, flags);
56034- hp->port.count = 0;
56035+ atomic_set(&hp->port.count, 0);
56036 hp->n_outbuf = 0;
56037 spin_unlock_irqrestore(&hp->lock, flags);
56038 }
56039diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
56040index a270f04..7c77b5d 100644
56041--- a/drivers/tty/hvc/hvsi_lib.c
56042+++ b/drivers/tty/hvc/hvsi_lib.c
56043@@ -8,7 +8,7 @@
56044
56045 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
56046 {
56047- packet->seqno = cpu_to_be16(atomic_inc_return(&pv->seqno));
56048+ packet->seqno = cpu_to_be16(atomic_inc_return_unchecked(&pv->seqno));
56049
56050 /* Assumes that always succeeds, works in practice */
56051 return pv->put_chars(pv->termno, (char *)packet, packet->len);
56052@@ -20,7 +20,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
56053
56054 /* Reset state */
56055 pv->established = 0;
56056- atomic_set(&pv->seqno, 0);
56057+ atomic_set_unchecked(&pv->seqno, 0);
56058
56059 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
56060
56061diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
56062index 345cebb..d5a1e9e 100644
56063--- a/drivers/tty/ipwireless/tty.c
56064+++ b/drivers/tty/ipwireless/tty.c
56065@@ -28,6 +28,7 @@
56066 #include <linux/tty_driver.h>
56067 #include <linux/tty_flip.h>
56068 #include <linux/uaccess.h>
56069+#include <asm/local.h>
56070
56071 #include "tty.h"
56072 #include "network.h"
56073@@ -93,10 +94,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
56074 return -ENODEV;
56075
56076 mutex_lock(&tty->ipw_tty_mutex);
56077- if (tty->port.count == 0)
56078+ if (atomic_read(&tty->port.count) == 0)
56079 tty->tx_bytes_queued = 0;
56080
56081- tty->port.count++;
56082+ atomic_inc(&tty->port.count);
56083
56084 tty->port.tty = linux_tty;
56085 linux_tty->driver_data = tty;
56086@@ -112,9 +113,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
56087
56088 static void do_ipw_close(struct ipw_tty *tty)
56089 {
56090- tty->port.count--;
56091-
56092- if (tty->port.count == 0) {
56093+ if (atomic_dec_return(&tty->port.count) == 0) {
56094 struct tty_struct *linux_tty = tty->port.tty;
56095
56096 if (linux_tty != NULL) {
56097@@ -135,7 +134,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
56098 return;
56099
56100 mutex_lock(&tty->ipw_tty_mutex);
56101- if (tty->port.count == 0) {
56102+ if (atomic_read(&tty->port.count) == 0) {
56103 mutex_unlock(&tty->ipw_tty_mutex);
56104 return;
56105 }
56106@@ -158,7 +157,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
56107
56108 mutex_lock(&tty->ipw_tty_mutex);
56109
56110- if (!tty->port.count) {
56111+ if (!atomic_read(&tty->port.count)) {
56112 mutex_unlock(&tty->ipw_tty_mutex);
56113 return;
56114 }
56115@@ -197,7 +196,7 @@ static int ipw_write(struct tty_struct *linux_tty,
56116 return -ENODEV;
56117
56118 mutex_lock(&tty->ipw_tty_mutex);
56119- if (!tty->port.count) {
56120+ if (!atomic_read(&tty->port.count)) {
56121 mutex_unlock(&tty->ipw_tty_mutex);
56122 return -EINVAL;
56123 }
56124@@ -237,7 +236,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
56125 if (!tty)
56126 return -ENODEV;
56127
56128- if (!tty->port.count)
56129+ if (!atomic_read(&tty->port.count))
56130 return -EINVAL;
56131
56132 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
56133@@ -279,7 +278,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
56134 if (!tty)
56135 return 0;
56136
56137- if (!tty->port.count)
56138+ if (!atomic_read(&tty->port.count))
56139 return 0;
56140
56141 return tty->tx_bytes_queued;
56142@@ -360,7 +359,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
56143 if (!tty)
56144 return -ENODEV;
56145
56146- if (!tty->port.count)
56147+ if (!atomic_read(&tty->port.count))
56148 return -EINVAL;
56149
56150 return get_control_lines(tty);
56151@@ -376,7 +375,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
56152 if (!tty)
56153 return -ENODEV;
56154
56155- if (!tty->port.count)
56156+ if (!atomic_read(&tty->port.count))
56157 return -EINVAL;
56158
56159 return set_control_lines(tty, set, clear);
56160@@ -390,7 +389,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
56161 if (!tty)
56162 return -ENODEV;
56163
56164- if (!tty->port.count)
56165+ if (!atomic_read(&tty->port.count))
56166 return -EINVAL;
56167
56168 /* FIXME: Exactly how is the tty object locked here .. */
56169@@ -546,7 +545,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
56170 * are gone */
56171 mutex_lock(&ttyj->ipw_tty_mutex);
56172 }
56173- while (ttyj->port.count)
56174+ while (atomic_read(&ttyj->port.count))
56175 do_ipw_close(ttyj);
56176 ipwireless_disassociate_network_ttys(network,
56177 ttyj->channel_idx);
56178diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
56179index 14c54e0..1efd4f2 100644
56180--- a/drivers/tty/moxa.c
56181+++ b/drivers/tty/moxa.c
56182@@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
56183 }
56184
56185 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
56186- ch->port.count++;
56187+ atomic_inc(&ch->port.count);
56188 tty->driver_data = ch;
56189 tty_port_tty_set(&ch->port, tty);
56190 mutex_lock(&ch->port.mutex);
56191diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
56192index 382d3fc..b16d625 100644
56193--- a/drivers/tty/n_gsm.c
56194+++ b/drivers/tty/n_gsm.c
56195@@ -1644,7 +1644,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
56196 spin_lock_init(&dlci->lock);
56197 mutex_init(&dlci->mutex);
56198 dlci->fifo = &dlci->_fifo;
56199- if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
56200+ if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
56201 kfree(dlci);
56202 return NULL;
56203 }
56204@@ -2957,7 +2957,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
56205 struct gsm_dlci *dlci = tty->driver_data;
56206 struct tty_port *port = &dlci->port;
56207
56208- port->count++;
56209+ atomic_inc(&port->count);
56210 tty_port_tty_set(port, tty);
56211
56212 dlci->modem_rx = 0;
56213diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
56214index afc1879..b605d4b 100644
56215--- a/drivers/tty/n_tty.c
56216+++ b/drivers/tty/n_tty.c
56217@@ -2574,6 +2574,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
56218 {
56219 *ops = tty_ldisc_N_TTY;
56220 ops->owner = NULL;
56221- ops->refcount = ops->flags = 0;
56222+ atomic_set(&ops->refcount, 0);
56223+ ops->flags = 0;
56224 }
56225 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
56226diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
56227index 4d5e840..a2340a6 100644
56228--- a/drivers/tty/pty.c
56229+++ b/drivers/tty/pty.c
56230@@ -849,8 +849,10 @@ static void __init unix98_pty_init(void)
56231 panic("Couldn't register Unix98 pts driver");
56232
56233 /* Now create the /dev/ptmx special device */
56234+ pax_open_kernel();
56235 tty_default_fops(&ptmx_fops);
56236- ptmx_fops.open = ptmx_open;
56237+ *(void **)&ptmx_fops.open = ptmx_open;
56238+ pax_close_kernel();
56239
56240 cdev_init(&ptmx_cdev, &ptmx_fops);
56241 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
56242diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
56243index c8dd8dc..dca6cfd 100644
56244--- a/drivers/tty/rocket.c
56245+++ b/drivers/tty/rocket.c
56246@@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
56247 tty->driver_data = info;
56248 tty_port_tty_set(port, tty);
56249
56250- if (port->count++ == 0) {
56251+ if (atomic_inc_return(&port->count) == 1) {
56252 atomic_inc(&rp_num_ports_open);
56253
56254 #ifdef ROCKET_DEBUG_OPEN
56255@@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
56256 #endif
56257 }
56258 #ifdef ROCKET_DEBUG_OPEN
56259- printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
56260+ printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
56261 #endif
56262
56263 /*
56264@@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
56265 spin_unlock_irqrestore(&info->port.lock, flags);
56266 return;
56267 }
56268- if (info->port.count)
56269+ if (atomic_read(&info->port.count))
56270 atomic_dec(&rp_num_ports_open);
56271 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
56272 spin_unlock_irqrestore(&info->port.lock, flags);
56273diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
56274index c35d96e..f05d689 100644
56275--- a/drivers/tty/serial/8250/8250_core.c
56276+++ b/drivers/tty/serial/8250/8250_core.c
56277@@ -3237,9 +3237,9 @@ static void univ8250_release_port(struct uart_port *port)
56278
56279 static void univ8250_rsa_support(struct uart_ops *ops)
56280 {
56281- ops->config_port = univ8250_config_port;
56282- ops->request_port = univ8250_request_port;
56283- ops->release_port = univ8250_release_port;
56284+ *(void **)&ops->config_port = univ8250_config_port;
56285+ *(void **)&ops->request_port = univ8250_request_port;
56286+ *(void **)&ops->release_port = univ8250_release_port;
56287 }
56288
56289 #else
56290@@ -3282,8 +3282,10 @@ static void __init serial8250_isa_init_ports(void)
56291 }
56292
56293 /* chain base port ops to support Remote Supervisor Adapter */
56294- univ8250_port_ops = *base_ops;
56295+ pax_open_kernel();
56296+ memcpy((void *)&univ8250_port_ops, base_ops, sizeof univ8250_port_ops);
56297 univ8250_rsa_support(&univ8250_port_ops);
56298+ pax_close_kernel();
56299
56300 if (share_irqs)
56301 irqflag = IRQF_SHARED;
56302diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c
56303index 536a33b..1b98f43 100644
56304--- a/drivers/tty/serial/ifx6x60.c
56305+++ b/drivers/tty/serial/ifx6x60.c
56306@@ -649,7 +649,7 @@ static void ifx_spi_complete(void *ctx)
56307 struct ifx_spi_device *ifx_dev = ctx;
56308 int length;
56309 int actual_length;
56310- unsigned char more;
56311+ unsigned char more = 0;
56312 unsigned char cts;
56313 int local_write_pending = 0;
56314 int queue_length;
56315diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
56316index e5c42fe..f091b02 100644
56317--- a/drivers/tty/serial/ioc4_serial.c
56318+++ b/drivers/tty/serial/ioc4_serial.c
56319@@ -437,7 +437,7 @@ struct ioc4_soft {
56320 } is_intr_info[MAX_IOC4_INTR_ENTS];
56321
56322 /* Number of entries active in the above array */
56323- atomic_t is_num_intrs;
56324+ atomic_unchecked_t is_num_intrs;
56325 } is_intr_type[IOC4_NUM_INTR_TYPES];
56326
56327 /* is_ir_lock must be held while
56328@@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
56329 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
56330 || (type == IOC4_OTHER_INTR_TYPE)));
56331
56332- i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
56333+ i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
56334 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
56335
56336 /* Save off the lower level interrupt handler */
56337@@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
56338
56339 soft = arg;
56340 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
56341- num_intrs = (int)atomic_read(
56342+ num_intrs = (int)atomic_read_unchecked(
56343 &soft->is_intr_type[intr_type].is_num_intrs);
56344
56345 this_mir = this_ir = pending_intrs(soft, intr_type);
56346diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
56347index 117df15..2f7dfcf 100644
56348--- a/drivers/tty/serial/kgdb_nmi.c
56349+++ b/drivers/tty/serial/kgdb_nmi.c
56350@@ -53,7 +53,9 @@ static int kgdb_nmi_console_setup(struct console *co, char *options)
56351 * I/O utilities that messages sent to the console will automatically
56352 * be displayed on the dbg_io.
56353 */
56354- dbg_io_ops->is_console = true;
56355+ pax_open_kernel();
56356+ *(int *)&dbg_io_ops->is_console = true;
56357+ pax_close_kernel();
56358
56359 return 0;
56360 }
56361diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
56362index a260cde..6b2b5ce 100644
56363--- a/drivers/tty/serial/kgdboc.c
56364+++ b/drivers/tty/serial/kgdboc.c
56365@@ -24,8 +24,9 @@
56366 #define MAX_CONFIG_LEN 40
56367
56368 static struct kgdb_io kgdboc_io_ops;
56369+static struct kgdb_io kgdboc_io_ops_console;
56370
56371-/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
56372+/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
56373 static int configured = -1;
56374
56375 static char config[MAX_CONFIG_LEN];
56376@@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
56377 kgdboc_unregister_kbd();
56378 if (configured == 1)
56379 kgdb_unregister_io_module(&kgdboc_io_ops);
56380+ else if (configured == 2)
56381+ kgdb_unregister_io_module(&kgdboc_io_ops_console);
56382 }
56383
56384 static int configure_kgdboc(void)
56385@@ -160,13 +163,13 @@ static int configure_kgdboc(void)
56386 int err;
56387 char *cptr = config;
56388 struct console *cons;
56389+ int is_console = 0;
56390
56391 err = kgdboc_option_setup(config);
56392 if (err || !strlen(config) || isspace(config[0]))
56393 goto noconfig;
56394
56395 err = -ENODEV;
56396- kgdboc_io_ops.is_console = 0;
56397 kgdb_tty_driver = NULL;
56398
56399 kgdboc_use_kms = 0;
56400@@ -187,7 +190,7 @@ static int configure_kgdboc(void)
56401 int idx;
56402 if (cons->device && cons->device(cons, &idx) == p &&
56403 idx == tty_line) {
56404- kgdboc_io_ops.is_console = 1;
56405+ is_console = 1;
56406 break;
56407 }
56408 cons = cons->next;
56409@@ -197,7 +200,13 @@ static int configure_kgdboc(void)
56410 kgdb_tty_line = tty_line;
56411
56412 do_register:
56413- err = kgdb_register_io_module(&kgdboc_io_ops);
56414+ if (is_console) {
56415+ err = kgdb_register_io_module(&kgdboc_io_ops_console);
56416+ configured = 2;
56417+ } else {
56418+ err = kgdb_register_io_module(&kgdboc_io_ops);
56419+ configured = 1;
56420+ }
56421 if (err)
56422 goto noconfig;
56423
56424@@ -205,8 +214,6 @@ do_register:
56425 if (err)
56426 goto nmi_con_failed;
56427
56428- configured = 1;
56429-
56430 return 0;
56431
56432 nmi_con_failed:
56433@@ -223,7 +230,7 @@ noconfig:
56434 static int __init init_kgdboc(void)
56435 {
56436 /* Already configured? */
56437- if (configured == 1)
56438+ if (configured >= 1)
56439 return 0;
56440
56441 return configure_kgdboc();
56442@@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
56443 if (config[len - 1] == '\n')
56444 config[len - 1] = '\0';
56445
56446- if (configured == 1)
56447+ if (configured >= 1)
56448 cleanup_kgdboc();
56449
56450 /* Go and configure with the new params. */
56451@@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
56452 .post_exception = kgdboc_post_exp_handler,
56453 };
56454
56455+static struct kgdb_io kgdboc_io_ops_console = {
56456+ .name = "kgdboc",
56457+ .read_char = kgdboc_get_char,
56458+ .write_char = kgdboc_put_char,
56459+ .pre_exception = kgdboc_pre_exp_handler,
56460+ .post_exception = kgdboc_post_exp_handler,
56461+ .is_console = 1
56462+};
56463+
56464 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
56465 /* This is only available if kgdboc is a built in for early debugging */
56466 static int __init kgdboc_early_init(char *opt)
56467diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
56468index b73889c..9f74f0a 100644
56469--- a/drivers/tty/serial/msm_serial.c
56470+++ b/drivers/tty/serial/msm_serial.c
56471@@ -1012,7 +1012,7 @@ static struct uart_driver msm_uart_driver = {
56472 .cons = MSM_CONSOLE,
56473 };
56474
56475-static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
56476+static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
56477
56478 static const struct of_device_id msm_uartdm_table[] = {
56479 { .compatible = "qcom,msm-uartdm-v1.1", .data = (void *)UARTDM_1P1 },
56480@@ -1036,7 +1036,7 @@ static int msm_serial_probe(struct platform_device *pdev)
56481 line = pdev->id;
56482
56483 if (line < 0)
56484- line = atomic_inc_return(&msm_uart_next_id) - 1;
56485+ line = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
56486
56487 if (unlikely(line < 0 || line >= UART_NR))
56488 return -ENXIO;
56489diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
56490index 5916311..1e32415 100644
56491--- a/drivers/tty/serial/samsung.c
56492+++ b/drivers/tty/serial/samsung.c
56493@@ -995,11 +995,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
56494 ourport->tx_in_progress = 0;
56495 }
56496
56497+static int s3c64xx_serial_startup(struct uart_port *port);
56498 static int s3c24xx_serial_startup(struct uart_port *port)
56499 {
56500 struct s3c24xx_uart_port *ourport = to_ourport(port);
56501 int ret;
56502
56503+ /* Startup sequence is different for s3c64xx and higher SoC's */
56504+ if (s3c24xx_serial_has_interrupt_mask(port))
56505+ return s3c64xx_serial_startup(port);
56506+
56507 dbg("s3c24xx_serial_startup: port=%p (%08llx,%p)\n",
56508 port, (unsigned long long)port->mapbase, port->membase);
56509
56510@@ -1706,10 +1711,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
56511 /* setup info for port */
56512 port->dev = &platdev->dev;
56513
56514- /* Startup sequence is different for s3c64xx and higher SoC's */
56515- if (s3c24xx_serial_has_interrupt_mask(port))
56516- s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
56517-
56518 port->uartclk = 1;
56519
56520 if (cfg->uart_flags & UPF_CONS_FLOW) {
56521diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
56522index f368520..c7a703a 100644
56523--- a/drivers/tty/serial/serial_core.c
56524+++ b/drivers/tty/serial/serial_core.c
56525@@ -1385,7 +1385,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
56526 state = drv->state + tty->index;
56527 port = &state->port;
56528 spin_lock_irq(&port->lock);
56529- --port->count;
56530+ atomic_dec(&port->count);
56531 spin_unlock_irq(&port->lock);
56532 return;
56533 }
56534@@ -1395,7 +1395,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
56535
56536 pr_debug("uart_close(%d) called\n", uport ? uport->line : -1);
56537
56538- if (!port->count || tty_port_close_start(port, tty, filp) == 0)
56539+ if (!atomic_read(&port->count) || tty_port_close_start(port, tty, filp) == 0)
56540 return;
56541
56542 /*
56543@@ -1520,7 +1520,7 @@ static void uart_hangup(struct tty_struct *tty)
56544 uart_flush_buffer(tty);
56545 uart_shutdown(tty, state);
56546 spin_lock_irqsave(&port->lock, flags);
56547- port->count = 0;
56548+ atomic_set(&port->count, 0);
56549 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
56550 spin_unlock_irqrestore(&port->lock, flags);
56551 tty_port_tty_set(port, NULL);
56552@@ -1607,7 +1607,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
56553 pr_debug("uart_open(%d) called\n", line);
56554
56555 spin_lock_irq(&port->lock);
56556- ++port->count;
56557+ atomic_inc(&port->count);
56558 spin_unlock_irq(&port->lock);
56559
56560 /*
56561diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
56562index b1c6bd3..5f038e2 100644
56563--- a/drivers/tty/serial/uartlite.c
56564+++ b/drivers/tty/serial/uartlite.c
56565@@ -341,13 +341,13 @@ static int ulite_request_port(struct uart_port *port)
56566 return -EBUSY;
56567 }
56568
56569- port->private_data = &uartlite_be;
56570+ port->private_data = (void *)&uartlite_be;
56571 ret = uart_in32(ULITE_CONTROL, port);
56572 uart_out32(ULITE_CONTROL_RST_TX, ULITE_CONTROL, port);
56573 ret = uart_in32(ULITE_STATUS, port);
56574 /* Endianess detection */
56575 if ((ret & ULITE_STATUS_TXEMPTY) != ULITE_STATUS_TXEMPTY)
56576- port->private_data = &uartlite_le;
56577+ port->private_data = (void *)&uartlite_le;
56578
56579 return 0;
56580 }
56581diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
56582index 2fac712..fcd5268 100644
56583--- a/drivers/tty/synclink.c
56584+++ b/drivers/tty/synclink.c
56585@@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
56586
56587 if (debug_level >= DEBUG_LEVEL_INFO)
56588 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
56589- __FILE__,__LINE__, info->device_name, info->port.count);
56590+ __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
56591
56592 if (tty_port_close_start(&info->port, tty, filp) == 0)
56593 goto cleanup;
56594@@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
56595 cleanup:
56596 if (debug_level >= DEBUG_LEVEL_INFO)
56597 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
56598- tty->driver->name, info->port.count);
56599+ tty->driver->name, atomic_read(&info->port.count));
56600
56601 } /* end of mgsl_close() */
56602
56603@@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
56604
56605 mgsl_flush_buffer(tty);
56606 shutdown(info);
56607-
56608- info->port.count = 0;
56609+
56610+ atomic_set(&info->port.count, 0);
56611 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
56612 info->port.tty = NULL;
56613
56614@@ -3296,10 +3296,10 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
56615
56616 if (debug_level >= DEBUG_LEVEL_INFO)
56617 printk("%s(%d):block_til_ready before block on %s count=%d\n",
56618- __FILE__,__LINE__, tty->driver->name, port->count );
56619+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56620
56621 spin_lock_irqsave(&info->irq_spinlock, flags);
56622- port->count--;
56623+ atomic_dec(&port->count);
56624 spin_unlock_irqrestore(&info->irq_spinlock, flags);
56625 port->blocked_open++;
56626
56627@@ -3327,7 +3327,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
56628
56629 if (debug_level >= DEBUG_LEVEL_INFO)
56630 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
56631- __FILE__,__LINE__, tty->driver->name, port->count );
56632+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56633
56634 tty_unlock(tty);
56635 schedule();
56636@@ -3339,12 +3339,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
56637
56638 /* FIXME: Racy on hangup during close wait */
56639 if (!tty_hung_up_p(filp))
56640- port->count++;
56641+ atomic_inc(&port->count);
56642 port->blocked_open--;
56643
56644 if (debug_level >= DEBUG_LEVEL_INFO)
56645 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
56646- __FILE__,__LINE__, tty->driver->name, port->count );
56647+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56648
56649 if (!retval)
56650 port->flags |= ASYNC_NORMAL_ACTIVE;
56651@@ -3396,7 +3396,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
56652
56653 if (debug_level >= DEBUG_LEVEL_INFO)
56654 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
56655- __FILE__,__LINE__,tty->driver->name, info->port.count);
56656+ __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
56657
56658 /* If port is closing, signal caller to try again */
56659 if (info->port.flags & ASYNC_CLOSING){
56660@@ -3415,10 +3415,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
56661 spin_unlock_irqrestore(&info->netlock, flags);
56662 goto cleanup;
56663 }
56664- info->port.count++;
56665+ atomic_inc(&info->port.count);
56666 spin_unlock_irqrestore(&info->netlock, flags);
56667
56668- if (info->port.count == 1) {
56669+ if (atomic_read(&info->port.count) == 1) {
56670 /* 1st open on this device, init hardware */
56671 retval = startup(info);
56672 if (retval < 0)
56673@@ -3442,8 +3442,8 @@ cleanup:
56674 if (retval) {
56675 if (tty->count == 1)
56676 info->port.tty = NULL; /* tty layer will release tty struct */
56677- if(info->port.count)
56678- info->port.count--;
56679+ if (atomic_read(&info->port.count))
56680+ atomic_dec(&info->port.count);
56681 }
56682
56683 return retval;
56684@@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
56685 unsigned short new_crctype;
56686
56687 /* return error if TTY interface open */
56688- if (info->port.count)
56689+ if (atomic_read(&info->port.count))
56690 return -EBUSY;
56691
56692 switch (encoding)
56693@@ -7758,7 +7758,7 @@ static int hdlcdev_open(struct net_device *dev)
56694
56695 /* arbitrate between network and tty opens */
56696 spin_lock_irqsave(&info->netlock, flags);
56697- if (info->port.count != 0 || info->netcount != 0) {
56698+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
56699 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
56700 spin_unlock_irqrestore(&info->netlock, flags);
56701 return -EBUSY;
56702@@ -7844,7 +7844,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
56703 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
56704
56705 /* return error if TTY interface open */
56706- if (info->port.count)
56707+ if (atomic_read(&info->port.count))
56708 return -EBUSY;
56709
56710 if (cmd != SIOCWANDEV)
56711diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
56712index 0ea8eee..b3f1b8f 100644
56713--- a/drivers/tty/synclink_gt.c
56714+++ b/drivers/tty/synclink_gt.c
56715@@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
56716 tty->driver_data = info;
56717 info->port.tty = tty;
56718
56719- DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
56720+ DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
56721
56722 /* If port is closing, signal caller to try again */
56723 if (info->port.flags & ASYNC_CLOSING){
56724@@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
56725 mutex_unlock(&info->port.mutex);
56726 goto cleanup;
56727 }
56728- info->port.count++;
56729+ atomic_inc(&info->port.count);
56730 spin_unlock_irqrestore(&info->netlock, flags);
56731
56732- if (info->port.count == 1) {
56733+ if (atomic_read(&info->port.count) == 1) {
56734 /* 1st open on this device, init hardware */
56735 retval = startup(info);
56736 if (retval < 0) {
56737@@ -715,8 +715,8 @@ cleanup:
56738 if (retval) {
56739 if (tty->count == 1)
56740 info->port.tty = NULL; /* tty layer will release tty struct */
56741- if(info->port.count)
56742- info->port.count--;
56743+ if(atomic_read(&info->port.count))
56744+ atomic_dec(&info->port.count);
56745 }
56746
56747 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
56748@@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
56749
56750 if (sanity_check(info, tty->name, "close"))
56751 return;
56752- DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
56753+ DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
56754
56755 if (tty_port_close_start(&info->port, tty, filp) == 0)
56756 goto cleanup;
56757@@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
56758 tty_port_close_end(&info->port, tty);
56759 info->port.tty = NULL;
56760 cleanup:
56761- DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
56762+ DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
56763 }
56764
56765 static void hangup(struct tty_struct *tty)
56766@@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
56767 shutdown(info);
56768
56769 spin_lock_irqsave(&info->port.lock, flags);
56770- info->port.count = 0;
56771+ atomic_set(&info->port.count, 0);
56772 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
56773 info->port.tty = NULL;
56774 spin_unlock_irqrestore(&info->port.lock, flags);
56775@@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
56776 unsigned short new_crctype;
56777
56778 /* return error if TTY interface open */
56779- if (info->port.count)
56780+ if (atomic_read(&info->port.count))
56781 return -EBUSY;
56782
56783 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
56784@@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
56785
56786 /* arbitrate between network and tty opens */
56787 spin_lock_irqsave(&info->netlock, flags);
56788- if (info->port.count != 0 || info->netcount != 0) {
56789+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
56790 DBGINFO(("%s hdlc_open busy\n", dev->name));
56791 spin_unlock_irqrestore(&info->netlock, flags);
56792 return -EBUSY;
56793@@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
56794 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
56795
56796 /* return error if TTY interface open */
56797- if (info->port.count)
56798+ if (atomic_read(&info->port.count))
56799 return -EBUSY;
56800
56801 if (cmd != SIOCWANDEV)
56802@@ -2417,7 +2417,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
56803 if (port == NULL)
56804 continue;
56805 spin_lock(&port->lock);
56806- if ((port->port.count || port->netcount) &&
56807+ if ((atomic_read(&port->port.count) || port->netcount) &&
56808 port->pending_bh && !port->bh_running &&
56809 !port->bh_requested) {
56810 DBGISR(("%s bh queued\n", port->device_name));
56811@@ -3303,7 +3303,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
56812 add_wait_queue(&port->open_wait, &wait);
56813
56814 spin_lock_irqsave(&info->lock, flags);
56815- port->count--;
56816+ atomic_dec(&port->count);
56817 spin_unlock_irqrestore(&info->lock, flags);
56818 port->blocked_open++;
56819
56820@@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
56821 remove_wait_queue(&port->open_wait, &wait);
56822
56823 if (!tty_hung_up_p(filp))
56824- port->count++;
56825+ atomic_inc(&port->count);
56826 port->blocked_open--;
56827
56828 if (!retval)
56829diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
56830index 08633a8..3d56e14 100644
56831--- a/drivers/tty/synclinkmp.c
56832+++ b/drivers/tty/synclinkmp.c
56833@@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
56834
56835 if (debug_level >= DEBUG_LEVEL_INFO)
56836 printk("%s(%d):%s open(), old ref count = %d\n",
56837- __FILE__,__LINE__,tty->driver->name, info->port.count);
56838+ __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
56839
56840 /* If port is closing, signal caller to try again */
56841 if (info->port.flags & ASYNC_CLOSING){
56842@@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
56843 spin_unlock_irqrestore(&info->netlock, flags);
56844 goto cleanup;
56845 }
56846- info->port.count++;
56847+ atomic_inc(&info->port.count);
56848 spin_unlock_irqrestore(&info->netlock, flags);
56849
56850- if (info->port.count == 1) {
56851+ if (atomic_read(&info->port.count) == 1) {
56852 /* 1st open on this device, init hardware */
56853 retval = startup(info);
56854 if (retval < 0)
56855@@ -796,8 +796,8 @@ cleanup:
56856 if (retval) {
56857 if (tty->count == 1)
56858 info->port.tty = NULL; /* tty layer will release tty struct */
56859- if(info->port.count)
56860- info->port.count--;
56861+ if(atomic_read(&info->port.count))
56862+ atomic_dec(&info->port.count);
56863 }
56864
56865 return retval;
56866@@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
56867
56868 if (debug_level >= DEBUG_LEVEL_INFO)
56869 printk("%s(%d):%s close() entry, count=%d\n",
56870- __FILE__,__LINE__, info->device_name, info->port.count);
56871+ __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
56872
56873 if (tty_port_close_start(&info->port, tty, filp) == 0)
56874 goto cleanup;
56875@@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
56876 cleanup:
56877 if (debug_level >= DEBUG_LEVEL_INFO)
56878 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
56879- tty->driver->name, info->port.count);
56880+ tty->driver->name, atomic_read(&info->port.count));
56881 }
56882
56883 /* Called by tty_hangup() when a hangup is signaled.
56884@@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
56885 shutdown(info);
56886
56887 spin_lock_irqsave(&info->port.lock, flags);
56888- info->port.count = 0;
56889+ atomic_set(&info->port.count, 0);
56890 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
56891 info->port.tty = NULL;
56892 spin_unlock_irqrestore(&info->port.lock, flags);
56893@@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
56894 unsigned short new_crctype;
56895
56896 /* return error if TTY interface open */
56897- if (info->port.count)
56898+ if (atomic_read(&info->port.count))
56899 return -EBUSY;
56900
56901 switch (encoding)
56902@@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
56903
56904 /* arbitrate between network and tty opens */
56905 spin_lock_irqsave(&info->netlock, flags);
56906- if (info->port.count != 0 || info->netcount != 0) {
56907+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
56908 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
56909 spin_unlock_irqrestore(&info->netlock, flags);
56910 return -EBUSY;
56911@@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
56912 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
56913
56914 /* return error if TTY interface open */
56915- if (info->port.count)
56916+ if (atomic_read(&info->port.count))
56917 return -EBUSY;
56918
56919 if (cmd != SIOCWANDEV)
56920@@ -2624,7 +2624,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
56921 * do not request bottom half processing if the
56922 * device is not open in a normal mode.
56923 */
56924- if ( port && (port->port.count || port->netcount) &&
56925+ if ( port && (atomic_read(&port->port.count) || port->netcount) &&
56926 port->pending_bh && !port->bh_running &&
56927 !port->bh_requested ) {
56928 if ( debug_level >= DEBUG_LEVEL_ISR )
56929@@ -3321,10 +3321,10 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
56930
56931 if (debug_level >= DEBUG_LEVEL_INFO)
56932 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
56933- __FILE__,__LINE__, tty->driver->name, port->count );
56934+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56935
56936 spin_lock_irqsave(&info->lock, flags);
56937- port->count--;
56938+ atomic_dec(&port->count);
56939 spin_unlock_irqrestore(&info->lock, flags);
56940 port->blocked_open++;
56941
56942@@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
56943
56944 if (debug_level >= DEBUG_LEVEL_INFO)
56945 printk("%s(%d):%s block_til_ready() count=%d\n",
56946- __FILE__,__LINE__, tty->driver->name, port->count );
56947+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56948
56949 tty_unlock(tty);
56950 schedule();
56951@@ -3362,12 +3362,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
56952 set_current_state(TASK_RUNNING);
56953 remove_wait_queue(&port->open_wait, &wait);
56954 if (!tty_hung_up_p(filp))
56955- port->count++;
56956+ atomic_inc(&port->count);
56957 port->blocked_open--;
56958
56959 if (debug_level >= DEBUG_LEVEL_INFO)
56960 printk("%s(%d):%s block_til_ready() after, count=%d\n",
56961- __FILE__,__LINE__, tty->driver->name, port->count );
56962+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56963
56964 if (!retval)
56965 port->flags |= ASYNC_NORMAL_ACTIVE;
56966diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
56967index b5b4278..bb9c7b0 100644
56968--- a/drivers/tty/sysrq.c
56969+++ b/drivers/tty/sysrq.c
56970@@ -1072,7 +1072,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
56971 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
56972 size_t count, loff_t *ppos)
56973 {
56974- if (count) {
56975+ if (count && capable(CAP_SYS_ADMIN)) {
56976 char c;
56977
56978 if (get_user(c, buf))
56979diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
56980index 4cf263d..fd011fa 100644
56981--- a/drivers/tty/tty_buffer.c
56982+++ b/drivers/tty/tty_buffer.c
56983@@ -242,7 +242,10 @@ void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld)
56984 atomic_inc(&buf->priority);
56985
56986 mutex_lock(&buf->lock);
56987- while ((next = buf->head->next) != NULL) {
56988+ /* paired w/ release in __tty_buffer_request_room; ensures there are
56989+ * no pending memory accesses to the freed buffer
56990+ */
56991+ while ((next = smp_load_acquire(&buf->head->next)) != NULL) {
56992 tty_buffer_free(port, buf->head);
56993 buf->head = next;
56994 }
56995@@ -290,13 +293,15 @@ static int __tty_buffer_request_room(struct tty_port *port, size_t size,
56996 if (n != NULL) {
56997 n->flags = flags;
56998 buf->tail = n;
56999- b->commit = b->used;
57000- /* paired w/ barrier in flush_to_ldisc(); ensures the
57001+ /* paired w/ acquire in flush_to_ldisc(); ensures
57002+ * flush_to_ldisc() sees buffer data.
57003+ */
57004+ smp_store_release(&b->commit, b->used);
57005+ /* paired w/ acquire in flush_to_ldisc(); ensures the
57006 * latest commit value can be read before the head is
57007 * advanced to the next buffer
57008 */
57009- smp_wmb();
57010- b->next = n;
57011+ smp_store_release(&b->next, n);
57012 } else if (change)
57013 size = 0;
57014 else
57015@@ -394,7 +399,10 @@ void tty_schedule_flip(struct tty_port *port)
57016 {
57017 struct tty_bufhead *buf = &port->buf;
57018
57019- buf->tail->commit = buf->tail->used;
57020+ /* paired w/ acquire in flush_to_ldisc(); ensures
57021+ * flush_to_ldisc() sees buffer data.
57022+ */
57023+ smp_store_release(&buf->tail->commit, buf->tail->used);
57024 schedule_work(&buf->work);
57025 }
57026 EXPORT_SYMBOL(tty_schedule_flip);
57027@@ -469,7 +477,7 @@ static void flush_to_ldisc(struct work_struct *work)
57028 struct tty_struct *tty;
57029 struct tty_ldisc *disc;
57030
57031- tty = port->itty;
57032+ tty = READ_ONCE(port->itty);
57033 if (tty == NULL)
57034 return;
57035
57036@@ -488,13 +496,15 @@ static void flush_to_ldisc(struct work_struct *work)
57037 if (atomic_read(&buf->priority))
57038 break;
57039
57040- next = head->next;
57041- /* paired w/ barrier in __tty_buffer_request_room();
57042+ /* paired w/ release in __tty_buffer_request_room();
57043 * ensures commit value read is not stale if the head
57044 * is advancing to the next buffer
57045 */
57046- smp_rmb();
57047- count = head->commit - head->read;
57048+ next = smp_load_acquire(&head->next);
57049+ /* paired w/ release in __tty_buffer_request_room() or in
57050+ * tty_buffer_flush(); ensures we see the committed buffer data
57051+ */
57052+ count = smp_load_acquire(&head->commit) - head->read;
57053 if (!count) {
57054 if (next == NULL) {
57055 check_other_closed(tty);
57056diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
57057index 774df35..62fa290 100644
57058--- a/drivers/tty/tty_io.c
57059+++ b/drivers/tty/tty_io.c
57060@@ -3524,7 +3524,7 @@ EXPORT_SYMBOL(tty_devnum);
57061
57062 void tty_default_fops(struct file_operations *fops)
57063 {
57064- *fops = tty_fops;
57065+ memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
57066 }
57067
57068 /*
57069diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
57070index c07fb5d..942acf7 100644
57071--- a/drivers/tty/tty_ldisc.c
57072+++ b/drivers/tty/tty_ldisc.c
57073@@ -70,7 +70,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
57074 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
57075 tty_ldiscs[disc] = new_ldisc;
57076 new_ldisc->num = disc;
57077- new_ldisc->refcount = 0;
57078+ atomic_set(&new_ldisc->refcount, 0);
57079 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
57080
57081 return ret;
57082@@ -98,7 +98,7 @@ int tty_unregister_ldisc(int disc)
57083 return -EINVAL;
57084
57085 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
57086- if (tty_ldiscs[disc]->refcount)
57087+ if (atomic_read(&tty_ldiscs[disc]->refcount))
57088 ret = -EBUSY;
57089 else
57090 tty_ldiscs[disc] = NULL;
57091@@ -119,7 +119,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
57092 if (ldops) {
57093 ret = ERR_PTR(-EAGAIN);
57094 if (try_module_get(ldops->owner)) {
57095- ldops->refcount++;
57096+ atomic_inc(&ldops->refcount);
57097 ret = ldops;
57098 }
57099 }
57100@@ -132,7 +132,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
57101 unsigned long flags;
57102
57103 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
57104- ldops->refcount--;
57105+ atomic_dec(&ldops->refcount);
57106 module_put(ldops->owner);
57107 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
57108 }
57109diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
57110index 40b31835..94d92ae 100644
57111--- a/drivers/tty/tty_port.c
57112+++ b/drivers/tty/tty_port.c
57113@@ -236,7 +236,7 @@ void tty_port_hangup(struct tty_port *port)
57114 unsigned long flags;
57115
57116 spin_lock_irqsave(&port->lock, flags);
57117- port->count = 0;
57118+ atomic_set(&port->count, 0);
57119 port->flags &= ~ASYNC_NORMAL_ACTIVE;
57120 tty = port->tty;
57121 if (tty)
57122@@ -398,7 +398,7 @@ int tty_port_block_til_ready(struct tty_port *port,
57123
57124 /* The port lock protects the port counts */
57125 spin_lock_irqsave(&port->lock, flags);
57126- port->count--;
57127+ atomic_dec(&port->count);
57128 port->blocked_open++;
57129 spin_unlock_irqrestore(&port->lock, flags);
57130
57131@@ -440,7 +440,7 @@ int tty_port_block_til_ready(struct tty_port *port,
57132 we must not mess that up further */
57133 spin_lock_irqsave(&port->lock, flags);
57134 if (!tty_hung_up_p(filp))
57135- port->count++;
57136+ atomic_inc(&port->count);
57137 port->blocked_open--;
57138 if (retval == 0)
57139 port->flags |= ASYNC_NORMAL_ACTIVE;
57140@@ -476,19 +476,19 @@ int tty_port_close_start(struct tty_port *port,
57141 return 0;
57142
57143 spin_lock_irqsave(&port->lock, flags);
57144- if (tty->count == 1 && port->count != 1) {
57145+ if (tty->count == 1 && atomic_read(&port->count) != 1) {
57146 printk(KERN_WARNING
57147 "tty_port_close_start: tty->count = 1 port count = %d.\n",
57148- port->count);
57149- port->count = 1;
57150+ atomic_read(&port->count));
57151+ atomic_set(&port->count, 1);
57152 }
57153- if (--port->count < 0) {
57154+ if (atomic_dec_return(&port->count) < 0) {
57155 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
57156- port->count);
57157- port->count = 0;
57158+ atomic_read(&port->count));
57159+ atomic_set(&port->count, 0);
57160 }
57161
57162- if (port->count) {
57163+ if (atomic_read(&port->count)) {
57164 spin_unlock_irqrestore(&port->lock, flags);
57165 return 0;
57166 }
57167@@ -590,7 +590,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
57168 struct file *filp)
57169 {
57170 spin_lock_irq(&port->lock);
57171- ++port->count;
57172+ atomic_inc(&port->count);
57173 spin_unlock_irq(&port->lock);
57174 tty_port_tty_set(port, tty);
57175
57176diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
57177index 6f0336f..5818bc1 100644
57178--- a/drivers/tty/vt/keyboard.c
57179+++ b/drivers/tty/vt/keyboard.c
57180@@ -642,6 +642,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
57181 kbd->kbdmode == VC_OFF) &&
57182 value != KVAL(K_SAK))
57183 return; /* SAK is allowed even in raw mode */
57184+
57185+#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
57186+ {
57187+ void *func = fn_handler[value];
57188+ if (func == fn_show_state || func == fn_show_ptregs ||
57189+ func == fn_show_mem)
57190+ return;
57191+ }
57192+#endif
57193+
57194 fn_handler[value](vc);
57195 }
57196
57197@@ -1880,9 +1890,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
57198 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
57199 return -EFAULT;
57200
57201- if (!capable(CAP_SYS_TTY_CONFIG))
57202- perm = 0;
57203-
57204 switch (cmd) {
57205 case KDGKBENT:
57206 /* Ensure another thread doesn't free it under us */
57207@@ -1897,6 +1904,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
57208 spin_unlock_irqrestore(&kbd_event_lock, flags);
57209 return put_user(val, &user_kbe->kb_value);
57210 case KDSKBENT:
57211+ if (!capable(CAP_SYS_TTY_CONFIG))
57212+ perm = 0;
57213+
57214 if (!perm)
57215 return -EPERM;
57216 if (!i && v == K_NOSUCHMAP) {
57217@@ -1987,9 +1997,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
57218 int i, j, k;
57219 int ret;
57220
57221- if (!capable(CAP_SYS_TTY_CONFIG))
57222- perm = 0;
57223-
57224 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
57225 if (!kbs) {
57226 ret = -ENOMEM;
57227@@ -2023,6 +2030,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
57228 kfree(kbs);
57229 return ((p && *p) ? -EOVERFLOW : 0);
57230 case KDSKBSENT:
57231+ if (!capable(CAP_SYS_TTY_CONFIG))
57232+ perm = 0;
57233+
57234 if (!perm) {
57235 ret = -EPERM;
57236 goto reterr;
57237diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
57238index 3257d42..b430b06 100644
57239--- a/drivers/uio/uio.c
57240+++ b/drivers/uio/uio.c
57241@@ -25,6 +25,7 @@
57242 #include <linux/kobject.h>
57243 #include <linux/cdev.h>
57244 #include <linux/uio_driver.h>
57245+#include <asm/local.h>
57246
57247 #define UIO_MAX_DEVICES (1U << MINORBITS)
57248
57249@@ -231,7 +232,7 @@ static ssize_t event_show(struct device *dev,
57250 struct device_attribute *attr, char *buf)
57251 {
57252 struct uio_device *idev = dev_get_drvdata(dev);
57253- return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
57254+ return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
57255 }
57256 static DEVICE_ATTR_RO(event);
57257
57258@@ -393,7 +394,7 @@ void uio_event_notify(struct uio_info *info)
57259 {
57260 struct uio_device *idev = info->uio_dev;
57261
57262- atomic_inc(&idev->event);
57263+ atomic_inc_unchecked(&idev->event);
57264 wake_up_interruptible(&idev->wait);
57265 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
57266 }
57267@@ -446,7 +447,7 @@ static int uio_open(struct inode *inode, struct file *filep)
57268 }
57269
57270 listener->dev = idev;
57271- listener->event_count = atomic_read(&idev->event);
57272+ listener->event_count = atomic_read_unchecked(&idev->event);
57273 filep->private_data = listener;
57274
57275 if (idev->info->open) {
57276@@ -497,7 +498,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
57277 return -EIO;
57278
57279 poll_wait(filep, &idev->wait, wait);
57280- if (listener->event_count != atomic_read(&idev->event))
57281+ if (listener->event_count != atomic_read_unchecked(&idev->event))
57282 return POLLIN | POLLRDNORM;
57283 return 0;
57284 }
57285@@ -522,7 +523,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
57286 do {
57287 set_current_state(TASK_INTERRUPTIBLE);
57288
57289- event_count = atomic_read(&idev->event);
57290+ event_count = atomic_read_unchecked(&idev->event);
57291 if (event_count != listener->event_count) {
57292 if (copy_to_user(buf, &event_count, count))
57293 retval = -EFAULT;
57294@@ -579,9 +580,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
57295 static int uio_find_mem_index(struct vm_area_struct *vma)
57296 {
57297 struct uio_device *idev = vma->vm_private_data;
57298+ unsigned long size;
57299
57300 if (vma->vm_pgoff < MAX_UIO_MAPS) {
57301- if (idev->info->mem[vma->vm_pgoff].size == 0)
57302+ size = idev->info->mem[vma->vm_pgoff].size;
57303+ if (size == 0)
57304+ return -1;
57305+ if (vma->vm_end - vma->vm_start > size)
57306 return -1;
57307 return (int)vma->vm_pgoff;
57308 }
57309@@ -813,7 +818,7 @@ int __uio_register_device(struct module *owner,
57310 idev->owner = owner;
57311 idev->info = info;
57312 init_waitqueue_head(&idev->wait);
57313- atomic_set(&idev->event, 0);
57314+ atomic_set_unchecked(&idev->event, 0);
57315
57316 ret = uio_get_minor(idev);
57317 if (ret)
57318diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
57319index 813d4d3..a71934f 100644
57320--- a/drivers/usb/atm/cxacru.c
57321+++ b/drivers/usb/atm/cxacru.c
57322@@ -472,7 +472,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
57323 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
57324 if (ret < 2)
57325 return -EINVAL;
57326- if (index < 0 || index > 0x7f)
57327+ if (index > 0x7f)
57328 return -EINVAL;
57329 pos += tmp;
57330
57331diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
57332index db322d9..f0f4bc1 100644
57333--- a/drivers/usb/atm/usbatm.c
57334+++ b/drivers/usb/atm/usbatm.c
57335@@ -331,7 +331,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57336 if (printk_ratelimit())
57337 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
57338 __func__, vpi, vci);
57339- atomic_inc(&vcc->stats->rx_err);
57340+ atomic_inc_unchecked(&vcc->stats->rx_err);
57341 return;
57342 }
57343
57344@@ -358,7 +358,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57345 if (length > ATM_MAX_AAL5_PDU) {
57346 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
57347 __func__, length, vcc);
57348- atomic_inc(&vcc->stats->rx_err);
57349+ atomic_inc_unchecked(&vcc->stats->rx_err);
57350 goto out;
57351 }
57352
57353@@ -367,14 +367,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57354 if (sarb->len < pdu_length) {
57355 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
57356 __func__, pdu_length, sarb->len, vcc);
57357- atomic_inc(&vcc->stats->rx_err);
57358+ atomic_inc_unchecked(&vcc->stats->rx_err);
57359 goto out;
57360 }
57361
57362 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
57363 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
57364 __func__, vcc);
57365- atomic_inc(&vcc->stats->rx_err);
57366+ atomic_inc_unchecked(&vcc->stats->rx_err);
57367 goto out;
57368 }
57369
57370@@ -387,7 +387,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57371 if (printk_ratelimit())
57372 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
57373 __func__, length);
57374- atomic_inc(&vcc->stats->rx_drop);
57375+ atomic_inc_unchecked(&vcc->stats->rx_drop);
57376 goto out;
57377 }
57378
57379@@ -415,7 +415,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57380
57381 vcc->push(vcc, skb);
57382
57383- atomic_inc(&vcc->stats->rx);
57384+ atomic_inc_unchecked(&vcc->stats->rx);
57385 out:
57386 skb_trim(sarb, 0);
57387 }
57388@@ -613,7 +613,7 @@ static void usbatm_tx_process(unsigned long data)
57389 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
57390
57391 usbatm_pop(vcc, skb);
57392- atomic_inc(&vcc->stats->tx);
57393+ atomic_inc_unchecked(&vcc->stats->tx);
57394
57395 skb = skb_dequeue(&instance->sndqueue);
57396 }
57397@@ -757,11 +757,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t *pos, char *page
57398 if (!left--)
57399 return sprintf(page,
57400 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
57401- atomic_read(&atm_dev->stats.aal5.tx),
57402- atomic_read(&atm_dev->stats.aal5.tx_err),
57403- atomic_read(&atm_dev->stats.aal5.rx),
57404- atomic_read(&atm_dev->stats.aal5.rx_err),
57405- atomic_read(&atm_dev->stats.aal5.rx_drop));
57406+ atomic_read_unchecked(&atm_dev->stats.aal5.tx),
57407+ atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
57408+ atomic_read_unchecked(&atm_dev->stats.aal5.rx),
57409+ atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
57410+ atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
57411
57412 if (!left--) {
57413 if (instance->disconnected)
57414diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
57415index dd9af38..75b53e3 100644
57416--- a/drivers/usb/class/cdc-acm.h
57417+++ b/drivers/usb/class/cdc-acm.h
57418@@ -95,7 +95,7 @@ struct acm {
57419 struct urb *read_urbs[ACM_NR];
57420 struct acm_rb read_buffers[ACM_NR];
57421 int rx_buflimit;
57422- int rx_endpoint;
57423+ unsigned int rx_endpoint;
57424 spinlock_t read_lock;
57425 int write_used; /* number of non-empty write buffers */
57426 int transmitting;
57427diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
57428index 2a3bbdf..91d72cf 100644
57429--- a/drivers/usb/core/devices.c
57430+++ b/drivers/usb/core/devices.c
57431@@ -126,7 +126,7 @@ static const char format_endpt[] =
57432 * time it gets called.
57433 */
57434 static struct device_connect_event {
57435- atomic_t count;
57436+ atomic_unchecked_t count;
57437 wait_queue_head_t wait;
57438 } device_event = {
57439 .count = ATOMIC_INIT(1),
57440@@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
57441
57442 void usbfs_conn_disc_event(void)
57443 {
57444- atomic_add(2, &device_event.count);
57445+ atomic_add_unchecked(2, &device_event.count);
57446 wake_up(&device_event.wait);
57447 }
57448
57449@@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
57450
57451 poll_wait(file, &device_event.wait, wait);
57452
57453- event_count = atomic_read(&device_event.count);
57454+ event_count = atomic_read_unchecked(&device_event.count);
57455 if (file->f_version != event_count) {
57456 file->f_version = event_count;
57457 return POLLIN | POLLRDNORM;
57458diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
57459index 986abde..2af59b11 100644
57460--- a/drivers/usb/core/devio.c
57461+++ b/drivers/usb/core/devio.c
57462@@ -187,7 +187,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
57463 struct usb_dev_state *ps = file->private_data;
57464 struct usb_device *dev = ps->dev;
57465 ssize_t ret = 0;
57466- unsigned len;
57467+ size_t len;
57468 loff_t pos;
57469 int i;
57470
57471@@ -229,22 +229,22 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
57472 for (i = 0; nbytes && i < dev->descriptor.bNumConfigurations; i++) {
57473 struct usb_config_descriptor *config =
57474 (struct usb_config_descriptor *)dev->rawdescriptors[i];
57475- unsigned int length = le16_to_cpu(config->wTotalLength);
57476+ size_t length = le16_to_cpu(config->wTotalLength);
57477
57478 if (*ppos < pos + length) {
57479
57480 /* The descriptor may claim to be longer than it
57481 * really is. Here is the actual allocated length. */
57482- unsigned alloclen =
57483+ size_t alloclen =
57484 le16_to_cpu(dev->config[i].desc.wTotalLength);
57485
57486- len = length - (*ppos - pos);
57487+ len = length + pos - *ppos;
57488 if (len > nbytes)
57489 len = nbytes;
57490
57491 /* Simply don't write (skip over) unallocated parts */
57492 if (alloclen > (*ppos - pos)) {
57493- alloclen -= (*ppos - pos);
57494+ alloclen = alloclen + pos - *ppos;
57495 if (copy_to_user(buf,
57496 dev->rawdescriptors[i] + (*ppos - pos),
57497 min(len, alloclen))) {
57498@@ -1499,7 +1499,7 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
57499 }
57500 }
57501 as->urb->dev = ps->dev;
57502- as->urb->pipe = (uurb->type << 30) |
57503+ as->urb->pipe = ((unsigned int)uurb->type << 30) |
57504 __create_pipe(ps->dev, uurb->endpoint & 0xf) |
57505 (uurb->endpoint & USB_DIR_IN);
57506
57507diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
57508index cbcd092..e783f87 100644
57509--- a/drivers/usb/core/hcd.c
57510+++ b/drivers/usb/core/hcd.c
57511@@ -1554,7 +1554,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
57512 */
57513 usb_get_urb(urb);
57514 atomic_inc(&urb->use_count);
57515- atomic_inc(&urb->dev->urbnum);
57516+ atomic_inc_unchecked(&urb->dev->urbnum);
57517 usbmon_urb_submit(&hcd->self, urb);
57518
57519 /* NOTE requirements on root-hub callers (usbfs and the hub
57520@@ -1581,7 +1581,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
57521 urb->hcpriv = NULL;
57522 INIT_LIST_HEAD(&urb->urb_list);
57523 atomic_dec(&urb->use_count);
57524- atomic_dec(&urb->dev->urbnum);
57525+ atomic_dec_unchecked(&urb->dev->urbnum);
57526 if (atomic_read(&urb->reject))
57527 wake_up(&usb_kill_urb_queue);
57528 usb_put_urb(urb);
57529diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
57530index 73dfa19..c22f1e43 100644
57531--- a/drivers/usb/core/hub.c
57532+++ b/drivers/usb/core/hub.c
57533@@ -26,6 +26,7 @@
57534 #include <linux/mutex.h>
57535 #include <linux/random.h>
57536 #include <linux/pm_qos.h>
57537+#include <linux/grsecurity.h>
57538
57539 #include <asm/uaccess.h>
57540 #include <asm/byteorder.h>
57541@@ -4655,6 +4656,10 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
57542 goto done;
57543 return;
57544 }
57545+
57546+ if (gr_handle_new_usb())
57547+ goto done;
57548+
57549 if (hub_is_superspeed(hub->hdev))
57550 unit_load = 150;
57551 else
57552diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
57553index d269738..7340cd7 100644
57554--- a/drivers/usb/core/sysfs.c
57555+++ b/drivers/usb/core/sysfs.c
57556@@ -244,7 +244,7 @@ static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
57557 struct usb_device *udev;
57558
57559 udev = to_usb_device(dev);
57560- return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
57561+ return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
57562 }
57563 static DEVICE_ATTR_RO(urbnum);
57564
57565diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
57566index 8d5b2f4..3896940 100644
57567--- a/drivers/usb/core/usb.c
57568+++ b/drivers/usb/core/usb.c
57569@@ -447,7 +447,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
57570 set_dev_node(&dev->dev, dev_to_node(bus->controller));
57571 dev->state = USB_STATE_ATTACHED;
57572 dev->lpm_disable_count = 1;
57573- atomic_set(&dev->urbnum, 0);
57574+ atomic_set_unchecked(&dev->urbnum, 0);
57575
57576 INIT_LIST_HEAD(&dev->ep0.urb_list);
57577 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
57578diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
57579index 8cfc319..4868255 100644
57580--- a/drivers/usb/early/ehci-dbgp.c
57581+++ b/drivers/usb/early/ehci-dbgp.c
57582@@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
57583
57584 #ifdef CONFIG_KGDB
57585 static struct kgdb_io kgdbdbgp_io_ops;
57586-#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
57587+static struct kgdb_io kgdbdbgp_io_ops_console;
57588+#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
57589 #else
57590 #define dbgp_kgdb_mode (0)
57591 #endif
57592@@ -1043,6 +1044,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
57593 .write_char = kgdbdbgp_write_char,
57594 };
57595
57596+static struct kgdb_io kgdbdbgp_io_ops_console = {
57597+ .name = "kgdbdbgp",
57598+ .read_char = kgdbdbgp_read_char,
57599+ .write_char = kgdbdbgp_write_char,
57600+ .is_console = 1
57601+};
57602+
57603 static int kgdbdbgp_wait_time;
57604
57605 static int __init kgdbdbgp_parse_config(char *str)
57606@@ -1058,8 +1066,10 @@ static int __init kgdbdbgp_parse_config(char *str)
57607 ptr++;
57608 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
57609 }
57610- kgdb_register_io_module(&kgdbdbgp_io_ops);
57611- kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
57612+ if (early_dbgp_console.index != -1)
57613+ kgdb_register_io_module(&kgdbdbgp_io_ops_console);
57614+ else
57615+ kgdb_register_io_module(&kgdbdbgp_io_ops);
57616
57617 return 0;
57618 }
57619diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/function/f_uac1.c
57620index 7856b33..8b7fe09 100644
57621--- a/drivers/usb/gadget/function/f_uac1.c
57622+++ b/drivers/usb/gadget/function/f_uac1.c
57623@@ -14,6 +14,7 @@
57624 #include <linux/module.h>
57625 #include <linux/device.h>
57626 #include <linux/atomic.h>
57627+#include <linux/module.h>
57628
57629 #include "u_uac1.h"
57630
57631diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
57632index 7ee05793..2e31e99 100644
57633--- a/drivers/usb/gadget/function/u_serial.c
57634+++ b/drivers/usb/gadget/function/u_serial.c
57635@@ -732,9 +732,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
57636 spin_lock_irq(&port->port_lock);
57637
57638 /* already open? Great. */
57639- if (port->port.count) {
57640+ if (atomic_read(&port->port.count)) {
57641 status = 0;
57642- port->port.count++;
57643+ atomic_inc(&port->port.count);
57644
57645 /* currently opening/closing? wait ... */
57646 } else if (port->openclose) {
57647@@ -793,7 +793,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
57648 tty->driver_data = port;
57649 port->port.tty = tty;
57650
57651- port->port.count = 1;
57652+ atomic_set(&port->port.count, 1);
57653 port->openclose = false;
57654
57655 /* if connected, start the I/O stream */
57656@@ -835,11 +835,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
57657
57658 spin_lock_irq(&port->port_lock);
57659
57660- if (port->port.count != 1) {
57661- if (port->port.count == 0)
57662+ if (atomic_read(&port->port.count) != 1) {
57663+ if (atomic_read(&port->port.count) == 0)
57664 WARN_ON(1);
57665 else
57666- --port->port.count;
57667+ atomic_dec(&port->port.count);
57668 goto exit;
57669 }
57670
57671@@ -849,7 +849,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
57672 * and sleep if necessary
57673 */
57674 port->openclose = true;
57675- port->port.count = 0;
57676+ atomic_set(&port->port.count, 0);
57677
57678 gser = port->port_usb;
57679 if (gser && gser->disconnect)
57680@@ -1065,7 +1065,7 @@ static int gs_closed(struct gs_port *port)
57681 int cond;
57682
57683 spin_lock_irq(&port->port_lock);
57684- cond = (port->port.count == 0) && !port->openclose;
57685+ cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
57686 spin_unlock_irq(&port->port_lock);
57687 return cond;
57688 }
57689@@ -1208,7 +1208,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
57690 /* if it's already open, start I/O ... and notify the serial
57691 * protocol about open/close status (connect/disconnect).
57692 */
57693- if (port->port.count) {
57694+ if (atomic_read(&port->port.count)) {
57695 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
57696 gs_start_io(port);
57697 if (gser->connect)
57698@@ -1255,7 +1255,7 @@ void gserial_disconnect(struct gserial *gser)
57699
57700 port->port_usb = NULL;
57701 gser->ioport = NULL;
57702- if (port->port.count > 0 || port->openclose) {
57703+ if (atomic_read(&port->port.count) > 0 || port->openclose) {
57704 wake_up_interruptible(&port->drain_wait);
57705 if (port->port.tty)
57706 tty_hangup(port->port.tty);
57707@@ -1271,7 +1271,7 @@ void gserial_disconnect(struct gserial *gser)
57708
57709 /* finally, free any unused/unusable I/O buffers */
57710 spin_lock_irqsave(&port->port_lock, flags);
57711- if (port->port.count == 0 && !port->openclose)
57712+ if (atomic_read(&port->port.count) == 0 && !port->openclose)
57713 gs_buf_free(&port->port_write_buf);
57714 gs_free_requests(gser->out, &port->read_pool, NULL);
57715 gs_free_requests(gser->out, &port->read_queue, NULL);
57716diff --git a/drivers/usb/gadget/function/u_uac1.c b/drivers/usb/gadget/function/u_uac1.c
57717index c78c841..48fd281 100644
57718--- a/drivers/usb/gadget/function/u_uac1.c
57719+++ b/drivers/usb/gadget/function/u_uac1.c
57720@@ -17,6 +17,7 @@
57721 #include <linux/ctype.h>
57722 #include <linux/random.h>
57723 #include <linux/syscalls.h>
57724+#include <linux/module.h>
57725
57726 #include "u_uac1.h"
57727
57728diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
57729index 181112c..036bcab 100644
57730--- a/drivers/usb/gadget/udc/dummy_hcd.c
57731+++ b/drivers/usb/gadget/udc/dummy_hcd.c
57732@@ -2384,7 +2384,7 @@ static int dummy_setup(struct usb_hcd *hcd)
57733 struct dummy *dum;
57734
57735 dum = *((void **)dev_get_platdata(hcd->self.controller));
57736- hcd->self.sg_tablesize = ~0;
57737+ hcd->self.sg_tablesize = SG_ALL;
57738 if (usb_hcd_is_primary_hcd(hcd)) {
57739 dum->hs_hcd = hcd_to_dummy_hcd(hcd);
57740 dum->hs_hcd->dum = dum;
57741diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
57742index c63d82c..a7e8665 100644
57743--- a/drivers/usb/host/ehci-hcd.c
57744+++ b/drivers/usb/host/ehci-hcd.c
57745@@ -564,7 +564,7 @@ static int ehci_init(struct usb_hcd *hcd)
57746
57747 /* Accept arbitrarily long scatter-gather lists */
57748 if (!(hcd->driver->flags & HCD_LOCAL_MEM))
57749- hcd->self.sg_tablesize = ~0;
57750+ hcd->self.sg_tablesize = SG_ALL;
57751 return 0;
57752 }
57753
57754diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
57755index 22abb68..50b7b84 100644
57756--- a/drivers/usb/host/ehci-hub.c
57757+++ b/drivers/usb/host/ehci-hub.c
57758@@ -773,7 +773,7 @@ static struct urb *request_single_step_set_feature_urb(
57759 urb->transfer_flags = URB_DIR_IN;
57760 usb_get_urb(urb);
57761 atomic_inc(&urb->use_count);
57762- atomic_inc(&urb->dev->urbnum);
57763+ atomic_inc_unchecked(&urb->dev->urbnum);
57764 urb->setup_dma = dma_map_single(
57765 hcd->self.controller,
57766 urb->setup_packet,
57767@@ -840,7 +840,7 @@ static int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
57768 urb->status = -EINPROGRESS;
57769 usb_get_urb(urb);
57770 atomic_inc(&urb->use_count);
57771- atomic_inc(&urb->dev->urbnum);
57772+ atomic_inc_unchecked(&urb->dev->urbnum);
57773 retval = submit_single_step_set_feature(hcd, urb, 0);
57774 if (!retval && !wait_for_completion_timeout(&done,
57775 msecs_to_jiffies(2000))) {
57776diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
57777index 54f5332..8b8335c 100644
57778--- a/drivers/usb/host/ehci-q.c
57779+++ b/drivers/usb/host/ehci-q.c
57780@@ -44,9 +44,9 @@
57781
57782 static int
57783 qtd_fill(struct ehci_hcd *ehci, struct ehci_qtd *qtd, dma_addr_t buf,
57784- size_t len, int token, int maxpacket)
57785+ size_t len, u32 token, int maxpacket)
57786 {
57787- int i, count;
57788+ u32 i, count;
57789 u64 addr = buf;
57790
57791 /* one buffer entry per 4K ... first might be short or unaligned */
57792diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
57793index 000ed80..2701154 100644
57794--- a/drivers/usb/host/fotg210-hcd.c
57795+++ b/drivers/usb/host/fotg210-hcd.c
57796@@ -5231,7 +5231,7 @@ static int hcd_fotg210_init(struct usb_hcd *hcd)
57797
57798 /* Accept arbitrarily long scatter-gather lists */
57799 if (!(hcd->driver->flags & HCD_LOCAL_MEM))
57800- hcd->self.sg_tablesize = ~0;
57801+ hcd->self.sg_tablesize = SG_ALL;
57802 return 0;
57803 }
57804
57805diff --git a/drivers/usb/host/fusbh200-hcd.c b/drivers/usb/host/fusbh200-hcd.c
57806index 1fd8718..c7ff47c 100644
57807--- a/drivers/usb/host/fusbh200-hcd.c
57808+++ b/drivers/usb/host/fusbh200-hcd.c
57809@@ -5156,7 +5156,7 @@ static int hcd_fusbh200_init(struct usb_hcd *hcd)
57810
57811 /* Accept arbitrarily long scatter-gather lists */
57812 if (!(hcd->driver->flags & HCD_LOCAL_MEM))
57813- hcd->self.sg_tablesize = ~0;
57814+ hcd->self.sg_tablesize = SG_ALL;
57815 return 0;
57816 }
57817
57818diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
57819index 1db0626..2e9f5ea 100644
57820--- a/drivers/usb/host/hwa-hc.c
57821+++ b/drivers/usb/host/hwa-hc.c
57822@@ -337,7 +337,10 @@ static int __hwahc_op_bwa_set(struct wusbhc *wusbhc, s8 stream_index,
57823 struct hwahc *hwahc = container_of(wusbhc, struct hwahc, wusbhc);
57824 struct wahc *wa = &hwahc->wa;
57825 struct device *dev = &wa->usb_iface->dev;
57826- u8 mas_le[UWB_NUM_MAS/8];
57827+ u8 *mas_le = kmalloc(UWB_NUM_MAS/8, GFP_KERNEL);
57828+
57829+ if (mas_le == NULL)
57830+ return -ENOMEM;
57831
57832 /* Set the stream index */
57833 result = usb_control_msg(wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0),
57834@@ -356,10 +359,12 @@ static int __hwahc_op_bwa_set(struct wusbhc *wusbhc, s8 stream_index,
57835 WUSB_REQ_SET_WUSB_MAS,
57836 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
57837 0, wa->usb_iface->cur_altsetting->desc.bInterfaceNumber,
57838- mas_le, 32, USB_CTRL_SET_TIMEOUT);
57839+ mas_le, UWB_NUM_MAS/8, USB_CTRL_SET_TIMEOUT);
57840 if (result < 0)
57841 dev_err(dev, "Cannot set WUSB MAS allocation: %d\n", result);
57842 out:
57843+ kfree(mas_le);
57844+
57845 return result;
57846 }
57847
57848@@ -812,7 +817,7 @@ static int hwahc_probe(struct usb_interface *usb_iface,
57849 goto error_alloc;
57850 }
57851 usb_hcd->wireless = 1;
57852- usb_hcd->self.sg_tablesize = ~0;
57853+ usb_hcd->self.sg_tablesize = SG_ALL;
57854 wusbhc = usb_hcd_to_wusbhc(usb_hcd);
57855 hwahc = container_of(wusbhc, struct hwahc, wusbhc);
57856 hwahc_init(hwahc);
57857diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
57858index 760cb57..fc7f8ad 100644
57859--- a/drivers/usb/host/ohci-hcd.c
57860+++ b/drivers/usb/host/ohci-hcd.c
57861@@ -444,7 +444,7 @@ static int ohci_init (struct ohci_hcd *ohci)
57862 struct usb_hcd *hcd = ohci_to_hcd(ohci);
57863
57864 /* Accept arbitrarily long scatter-gather lists */
57865- hcd->self.sg_tablesize = ~0;
57866+ hcd->self.sg_tablesize = SG_ALL;
57867
57868 if (distrust_firmware)
57869 ohci->flags |= OHCI_QUIRK_HUB_POWER;
57870diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h
57871index 672cea3..31a730db 100644
57872--- a/drivers/usb/host/r8a66597.h
57873+++ b/drivers/usb/host/r8a66597.h
57874@@ -125,7 +125,7 @@ struct r8a66597 {
57875 unsigned short interval_map;
57876 unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE];
57877 unsigned char dma_map;
57878- unsigned int max_root_hub;
57879+ unsigned char max_root_hub;
57880
57881 struct list_head child_device;
57882 unsigned long child_connect_map[4];
57883diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
57884index a7de8e8..e1ef134 100644
57885--- a/drivers/usb/host/uhci-hcd.c
57886+++ b/drivers/usb/host/uhci-hcd.c
57887@@ -570,7 +570,7 @@ static int uhci_start(struct usb_hcd *hcd)
57888 hcd->uses_new_polling = 1;
57889 /* Accept arbitrarily long scatter-gather lists */
57890 if (!(hcd->driver->flags & HCD_LOCAL_MEM))
57891- hcd->self.sg_tablesize = ~0;
57892+ hcd->self.sg_tablesize = SG_ALL;
57893
57894 spin_lock_init(&uhci->lock);
57895 setup_timer(&uhci->fsbr_timer, uhci_fsbr_timeout,
57896diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
57897index c79d336..8fe41af 100644
57898--- a/drivers/usb/host/xhci-pci.c
57899+++ b/drivers/usb/host/xhci-pci.c
57900@@ -30,7 +30,7 @@
57901
57902 #define PORT2_SSIC_CONFIG_REG2 0x883c
57903 #define PROG_DONE (1 << 30)
57904-#define SSIC_PORT_UNUSED (1 << 31)
57905+#define SSIC_PORT_UNUSED (1U << 31)
57906
57907 /* Device for a quirk */
57908 #define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73
57909diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
57910index d7b9f484..8208965 100644
57911--- a/drivers/usb/host/xhci.c
57912+++ b/drivers/usb/host/xhci.c
57913@@ -4837,7 +4837,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
57914 int retval;
57915
57916 /* Accept arbitrarily long scatter-gather lists */
57917- hcd->self.sg_tablesize = ~0;
57918+ hcd->self.sg_tablesize = SG_ALL;
57919
57920 /* support to build packet from discontinuous buffers */
57921 hcd->self.no_sg_constraint = 1;
57922diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
57923index a0a3827..d7ec10b 100644
57924--- a/drivers/usb/misc/appledisplay.c
57925+++ b/drivers/usb/misc/appledisplay.c
57926@@ -84,7 +84,7 @@ struct appledisplay {
57927 struct mutex sysfslock; /* concurrent read and write */
57928 };
57929
57930-static atomic_t count_displays = ATOMIC_INIT(0);
57931+static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
57932 static struct workqueue_struct *wq;
57933
57934 static void appledisplay_complete(struct urb *urb)
57935@@ -288,7 +288,7 @@ static int appledisplay_probe(struct usb_interface *iface,
57936
57937 /* Register backlight device */
57938 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
57939- atomic_inc_return(&count_displays) - 1);
57940+ atomic_inc_return_unchecked(&count_displays) - 1);
57941 memset(&props, 0, sizeof(struct backlight_properties));
57942 props.type = BACKLIGHT_RAW;
57943 props.max_brightness = 0xff;
57944diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
57945index 3806e70..55c508b 100644
57946--- a/drivers/usb/serial/console.c
57947+++ b/drivers/usb/serial/console.c
57948@@ -126,7 +126,7 @@ static int usb_console_setup(struct console *co, char *options)
57949
57950 info->port = port;
57951
57952- ++port->port.count;
57953+ atomic_inc(&port->port.count);
57954 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
57955 if (serial->type->set_termios) {
57956 /*
57957@@ -175,7 +175,7 @@ static int usb_console_setup(struct console *co, char *options)
57958 }
57959 /* Now that any required fake tty operations are completed restore
57960 * the tty port count */
57961- --port->port.count;
57962+ atomic_dec(&port->port.count);
57963 /* The console is special in terms of closing the device so
57964 * indicate this port is now acting as a system console. */
57965 port->port.console = 1;
57966@@ -188,7 +188,7 @@ static int usb_console_setup(struct console *co, char *options)
57967 put_tty:
57968 tty_kref_put(tty);
57969 reset_open_count:
57970- port->port.count = 0;
57971+ atomic_set(&port->port.count, 0);
57972 usb_autopm_put_interface(serial->interface);
57973 error_get_interface:
57974 usb_serial_put(serial);
57975@@ -199,7 +199,7 @@ static int usb_console_setup(struct console *co, char *options)
57976 static void usb_console_write(struct console *co,
57977 const char *buf, unsigned count)
57978 {
57979- static struct usbcons_info *info = &usbcons_info;
57980+ struct usbcons_info *info = &usbcons_info;
57981 struct usb_serial_port *port = info->port;
57982 struct usb_serial *serial;
57983 int retval = -ENODEV;
57984diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
57985index 540add2..2a2c7da 100644
57986--- a/drivers/usb/storage/transport.c
57987+++ b/drivers/usb/storage/transport.c
57988@@ -689,7 +689,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
57989 if (need_auto_sense) {
57990 int temp_result;
57991 struct scsi_eh_save ses;
57992- int sense_size = US_SENSE_SIZE;
57993+ unsigned int sense_size = US_SENSE_SIZE;
57994 struct scsi_sense_hdr sshdr;
57995 const u8 *scdd;
57996 u8 fm_ili;
57997diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
57998index 43576ed..583589d 100644
57999--- a/drivers/usb/storage/usb.c
58000+++ b/drivers/usb/storage/usb.c
58001@@ -912,7 +912,7 @@ static void usb_stor_scan_dwork(struct work_struct *work)
58002 clear_bit(US_FLIDX_SCAN_PENDING, &us->dflags);
58003 }
58004
58005-static unsigned int usb_stor_sg_tablesize(struct usb_interface *intf)
58006+static unsigned short usb_stor_sg_tablesize(struct usb_interface *intf)
58007 {
58008 struct usb_device *usb_dev = interface_to_usbdev(intf);
58009
58010diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
58011index da0ad32..50b5bbe 100644
58012--- a/drivers/usb/storage/usb.h
58013+++ b/drivers/usb/storage/usb.h
58014@@ -63,7 +63,7 @@ struct us_unusual_dev {
58015 __u8 useProtocol;
58016 __u8 useTransport;
58017 int (*initFunction)(struct us_data *);
58018-};
58019+} __do_const;
58020
58021
58022 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
58023diff --git a/drivers/usb/usbip/vhci.h b/drivers/usb/usbip/vhci.h
58024index a863a98..d272795 100644
58025--- a/drivers/usb/usbip/vhci.h
58026+++ b/drivers/usb/usbip/vhci.h
58027@@ -83,7 +83,7 @@ struct vhci_hcd {
58028 unsigned resuming:1;
58029 unsigned long re_timeout;
58030
58031- atomic_t seqnum;
58032+ atomic_unchecked_t seqnum;
58033
58034 /*
58035 * NOTE:
58036diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
58037index e9ef1ec..c3a0b04 100644
58038--- a/drivers/usb/usbip/vhci_hcd.c
58039+++ b/drivers/usb/usbip/vhci_hcd.c
58040@@ -440,7 +440,7 @@ static void vhci_tx_urb(struct urb *urb)
58041
58042 spin_lock(&vdev->priv_lock);
58043
58044- priv->seqnum = atomic_inc_return(&the_controller->seqnum);
58045+ priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
58046 if (priv->seqnum == 0xffff)
58047 dev_info(&urb->dev->dev, "seqnum max\n");
58048
58049@@ -685,7 +685,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
58050 return -ENOMEM;
58051 }
58052
58053- unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
58054+ unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
58055 if (unlink->seqnum == 0xffff)
58056 pr_info("seqnum max\n");
58057
58058@@ -889,7 +889,7 @@ static int vhci_start(struct usb_hcd *hcd)
58059 vdev->rhport = rhport;
58060 }
58061
58062- atomic_set(&vhci->seqnum, 0);
58063+ atomic_set_unchecked(&vhci->seqnum, 0);
58064 spin_lock_init(&vhci->lock);
58065
58066 hcd->power_budget = 0; /* no limit */
58067diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
58068index 00e4a54..d676f85 100644
58069--- a/drivers/usb/usbip/vhci_rx.c
58070+++ b/drivers/usb/usbip/vhci_rx.c
58071@@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
58072 if (!urb) {
58073 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
58074 pr_info("max seqnum %d\n",
58075- atomic_read(&the_controller->seqnum));
58076+ atomic_read_unchecked(&the_controller->seqnum));
58077 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
58078 return;
58079 }
58080diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
58081index 211f43f..6c22ae1 100644
58082--- a/drivers/usb/usbip/vhci_sysfs.c
58083+++ b/drivers/usb/usbip/vhci_sysfs.c
58084@@ -59,7 +59,7 @@ static ssize_t status_show(struct device *dev, struct device_attribute *attr,
58085 if (vdev->ud.status == VDEV_ST_USED) {
58086 out += sprintf(out, "%03u %08x ",
58087 vdev->speed, vdev->devid);
58088- out += sprintf(out, "%16p ", vdev->ud.tcp_socket);
58089+ out += sprintf(out, "%16pK ", vdev->ud.tcp_socket);
58090 out += sprintf(out, "%s", dev_name(&vdev->udev->dev));
58091
58092 } else {
58093diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
58094index edc7267..9f65ce2 100644
58095--- a/drivers/usb/wusbcore/wa-hc.h
58096+++ b/drivers/usb/wusbcore/wa-hc.h
58097@@ -240,7 +240,7 @@ struct wahc {
58098 spinlock_t xfer_list_lock;
58099 struct work_struct xfer_enqueue_work;
58100 struct work_struct xfer_error_work;
58101- atomic_t xfer_id_count;
58102+ atomic_unchecked_t xfer_id_count;
58103
58104 kernel_ulong_t quirks;
58105 };
58106@@ -305,7 +305,7 @@ static inline void wa_init(struct wahc *wa)
58107 INIT_WORK(&wa->xfer_enqueue_work, wa_urb_enqueue_run);
58108 INIT_WORK(&wa->xfer_error_work, wa_process_errored_transfers_run);
58109 wa->dto_in_use = 0;
58110- atomic_set(&wa->xfer_id_count, 1);
58111+ atomic_set_unchecked(&wa->xfer_id_count, 1);
58112 /* init the buf in URBs */
58113 for (index = 0; index < WA_MAX_BUF_IN_URBS; ++index)
58114 usb_init_urb(&(wa->buf_in_urbs[index]));
58115diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
58116index 69af4fd..da390d7 100644
58117--- a/drivers/usb/wusbcore/wa-xfer.c
58118+++ b/drivers/usb/wusbcore/wa-xfer.c
58119@@ -314,7 +314,7 @@ static void wa_xfer_completion(struct wa_xfer *xfer)
58120 */
58121 static void wa_xfer_id_init(struct wa_xfer *xfer)
58122 {
58123- xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
58124+ xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
58125 }
58126
58127 /* Return the xfer's ID. */
58128diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
58129index 563c510..1fcc957 100644
58130--- a/drivers/vfio/vfio.c
58131+++ b/drivers/vfio/vfio.c
58132@@ -517,7 +517,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
58133 return 0;
58134
58135 /* TODO Prevent device auto probing */
58136- WARN("Device %s added to live group %d!\n", dev_name(dev),
58137+ WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
58138 iommu_group_id(group->iommu_group));
58139
58140 return 0;
58141diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
58142index 3bb02c6..a01ff38 100644
58143--- a/drivers/vhost/vringh.c
58144+++ b/drivers/vhost/vringh.c
58145@@ -551,7 +551,7 @@ static inline void __vringh_notify_disable(struct vringh *vrh,
58146 static inline int getu16_user(const struct vringh *vrh, u16 *val, const __virtio16 *p)
58147 {
58148 __virtio16 v = 0;
58149- int rc = get_user(v, (__force __virtio16 __user *)p);
58150+ int rc = get_user(v, (__force_user __virtio16 *)p);
58151 *val = vringh16_to_cpu(vrh, v);
58152 return rc;
58153 }
58154@@ -559,12 +559,12 @@ static inline int getu16_user(const struct vringh *vrh, u16 *val, const __virtio
58155 static inline int putu16_user(const struct vringh *vrh, __virtio16 *p, u16 val)
58156 {
58157 __virtio16 v = cpu_to_vringh16(vrh, val);
58158- return put_user(v, (__force __virtio16 __user *)p);
58159+ return put_user(v, (__force_user __virtio16 *)p);
58160 }
58161
58162 static inline int copydesc_user(void *dst, const void *src, size_t len)
58163 {
58164- return copy_from_user(dst, (__force void __user *)src, len) ?
58165+ return copy_from_user(dst, (void __force_user *)src, len) ?
58166 -EFAULT : 0;
58167 }
58168
58169@@ -572,19 +572,19 @@ static inline int putused_user(struct vring_used_elem *dst,
58170 const struct vring_used_elem *src,
58171 unsigned int num)
58172 {
58173- return copy_to_user((__force void __user *)dst, src,
58174+ return copy_to_user((void __force_user *)dst, src,
58175 sizeof(*dst) * num) ? -EFAULT : 0;
58176 }
58177
58178 static inline int xfer_from_user(void *src, void *dst, size_t len)
58179 {
58180- return copy_from_user(dst, (__force void __user *)src, len) ?
58181+ return copy_from_user(dst, (void __force_user *)src, len) ?
58182 -EFAULT : 0;
58183 }
58184
58185 static inline int xfer_to_user(void *dst, void *src, size_t len)
58186 {
58187- return copy_to_user((__force void __user *)dst, src, len) ?
58188+ return copy_to_user((void __force_user *)dst, src, len) ?
58189 -EFAULT : 0;
58190 }
58191
58192@@ -621,9 +621,9 @@ int vringh_init_user(struct vringh *vrh, u64 features,
58193 vrh->last_used_idx = 0;
58194 vrh->vring.num = num;
58195 /* vring expects kernel addresses, but only used via accessors. */
58196- vrh->vring.desc = (__force struct vring_desc *)desc;
58197- vrh->vring.avail = (__force struct vring_avail *)avail;
58198- vrh->vring.used = (__force struct vring_used *)used;
58199+ vrh->vring.desc = (__force_kernel struct vring_desc *)desc;
58200+ vrh->vring.avail = (__force_kernel struct vring_avail *)avail;
58201+ vrh->vring.used = (__force_kernel struct vring_used *)used;
58202 return 0;
58203 }
58204 EXPORT_SYMBOL(vringh_init_user);
58205@@ -826,7 +826,7 @@ static inline int getu16_kern(const struct vringh *vrh,
58206
58207 static inline int putu16_kern(const struct vringh *vrh, __virtio16 *p, u16 val)
58208 {
58209- ACCESS_ONCE(*p) = cpu_to_vringh16(vrh, val);
58210+ ACCESS_ONCE_RW(*p) = cpu_to_vringh16(vrh, val);
58211 return 0;
58212 }
58213
58214diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
58215index 84a110a..96312c3 100644
58216--- a/drivers/video/backlight/kb3886_bl.c
58217+++ b/drivers/video/backlight/kb3886_bl.c
58218@@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
58219 static unsigned long kb3886bl_flags;
58220 #define KB3886BL_SUSPENDED 0x01
58221
58222-static struct dmi_system_id kb3886bl_device_table[] __initdata = {
58223+static const struct dmi_system_id kb3886bl_device_table[] __initconst = {
58224 {
58225 .ident = "Sahara Touch-iT",
58226 .matches = {
58227diff --git a/drivers/video/fbdev/arcfb.c b/drivers/video/fbdev/arcfb.c
58228index 1b0b233..6f34c2c 100644
58229--- a/drivers/video/fbdev/arcfb.c
58230+++ b/drivers/video/fbdev/arcfb.c
58231@@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
58232 return -ENOSPC;
58233
58234 err = 0;
58235- if ((count + p) > fbmemlength) {
58236+ if (count > (fbmemlength - p)) {
58237 count = fbmemlength - p;
58238 err = -ENOSPC;
58239 }
58240diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c
58241index c42ce2f..4c8bc59 100644
58242--- a/drivers/video/fbdev/aty/aty128fb.c
58243+++ b/drivers/video/fbdev/aty/aty128fb.c
58244@@ -145,7 +145,7 @@ enum {
58245 };
58246
58247 /* Must match above enum */
58248-static char * const r128_family[] = {
58249+static const char * const r128_family[] = {
58250 "AGP",
58251 "PCI",
58252 "PRO AGP",
58253diff --git a/drivers/video/fbdev/aty/atyfb_base.c b/drivers/video/fbdev/aty/atyfb_base.c
58254index 8789e48..698fe4c 100644
58255--- a/drivers/video/fbdev/aty/atyfb_base.c
58256+++ b/drivers/video/fbdev/aty/atyfb_base.c
58257@@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
58258 par->accel_flags = var->accel_flags; /* hack */
58259
58260 if (var->accel_flags) {
58261- info->fbops->fb_sync = atyfb_sync;
58262+ pax_open_kernel();
58263+ *(void **)&info->fbops->fb_sync = atyfb_sync;
58264+ pax_close_kernel();
58265 info->flags &= ~FBINFO_HWACCEL_DISABLED;
58266 } else {
58267- info->fbops->fb_sync = NULL;
58268+ pax_open_kernel();
58269+ *(void **)&info->fbops->fb_sync = NULL;
58270+ pax_close_kernel();
58271 info->flags |= FBINFO_HWACCEL_DISABLED;
58272 }
58273
58274diff --git a/drivers/video/fbdev/aty/mach64_cursor.c b/drivers/video/fbdev/aty/mach64_cursor.c
58275index 2fa0317..4983f2a 100644
58276--- a/drivers/video/fbdev/aty/mach64_cursor.c
58277+++ b/drivers/video/fbdev/aty/mach64_cursor.c
58278@@ -8,6 +8,7 @@
58279 #include "../core/fb_draw.h"
58280
58281 #include <asm/io.h>
58282+#include <asm/pgtable.h>
58283
58284 #ifdef __sparc__
58285 #include <asm/fbio.h>
58286@@ -218,7 +219,9 @@ int aty_init_cursor(struct fb_info *info)
58287 info->sprite.buf_align = 16; /* and 64 lines tall. */
58288 info->sprite.flags = FB_PIXMAP_IO;
58289
58290- info->fbops->fb_cursor = atyfb_cursor;
58291+ pax_open_kernel();
58292+ *(void **)&info->fbops->fb_cursor = atyfb_cursor;
58293+ pax_close_kernel();
58294
58295 return 0;
58296 }
58297diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
58298index 3fc63c2..eec5e49 100644
58299--- a/drivers/video/fbdev/core/fb_defio.c
58300+++ b/drivers/video/fbdev/core/fb_defio.c
58301@@ -207,7 +207,9 @@ void fb_deferred_io_init(struct fb_info *info)
58302
58303 BUG_ON(!fbdefio);
58304 mutex_init(&fbdefio->lock);
58305- info->fbops->fb_mmap = fb_deferred_io_mmap;
58306+ pax_open_kernel();
58307+ *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
58308+ pax_close_kernel();
58309 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
58310 INIT_LIST_HEAD(&fbdefio->pagelist);
58311 if (fbdefio->delay == 0) /* set a default of 1 s */
58312@@ -238,7 +240,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
58313 page->mapping = NULL;
58314 }
58315
58316- info->fbops->fb_mmap = NULL;
58317+ *(void **)&info->fbops->fb_mmap = NULL;
58318 mutex_destroy(&fbdefio->lock);
58319 }
58320 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
58321diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
58322index 0705d88..d9429bf 100644
58323--- a/drivers/video/fbdev/core/fbmem.c
58324+++ b/drivers/video/fbdev/core/fbmem.c
58325@@ -1301,7 +1301,7 @@ static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix,
58326 __u32 data;
58327 int err;
58328
58329- err = copy_to_user(&fix32->id, &fix->id, sizeof(fix32->id));
58330+ err = copy_to_user(fix32->id, &fix->id, sizeof(fix32->id));
58331
58332 data = (__u32) (unsigned long) fix->smem_start;
58333 err |= put_user(data, &fix32->smem_start);
58334diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c
58335index 807ee22..7814cd6 100644
58336--- a/drivers/video/fbdev/hyperv_fb.c
58337+++ b/drivers/video/fbdev/hyperv_fb.c
58338@@ -240,7 +240,7 @@ static uint screen_fb_size;
58339 static inline int synthvid_send(struct hv_device *hdev,
58340 struct synthvid_msg *msg)
58341 {
58342- static atomic64_t request_id = ATOMIC64_INIT(0);
58343+ static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
58344 int ret;
58345
58346 msg->pipe_hdr.type = PIPE_MSG_DATA;
58347@@ -248,7 +248,7 @@ static inline int synthvid_send(struct hv_device *hdev,
58348
58349 ret = vmbus_sendpacket(hdev->channel, msg,
58350 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
58351- atomic64_inc_return(&request_id),
58352+ atomic64_inc_return_unchecked(&request_id),
58353 VM_PKT_DATA_INBAND, 0);
58354
58355 if (ret)
58356diff --git a/drivers/video/fbdev/i810/i810_accel.c b/drivers/video/fbdev/i810/i810_accel.c
58357index 7672d2e..b56437f 100644
58358--- a/drivers/video/fbdev/i810/i810_accel.c
58359+++ b/drivers/video/fbdev/i810/i810_accel.c
58360@@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
58361 }
58362 }
58363 printk("ringbuffer lockup!!!\n");
58364+ printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
58365 i810_report_error(mmio);
58366 par->dev_flags |= LOCKUP;
58367 info->pixmap.scan_align = 1;
58368diff --git a/drivers/video/fbdev/matrox/matroxfb_DAC1064.c b/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
58369index a01147f..5d896f8 100644
58370--- a/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
58371+++ b/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
58372@@ -1088,14 +1088,20 @@ static void MGAG100_restore(struct matrox_fb_info *minfo)
58373
58374 #ifdef CONFIG_FB_MATROX_MYSTIQUE
58375 struct matrox_switch matrox_mystique = {
58376- MGA1064_preinit, MGA1064_reset, MGA1064_init, MGA1064_restore,
58377+ .preinit = MGA1064_preinit,
58378+ .reset = MGA1064_reset,
58379+ .init = MGA1064_init,
58380+ .restore = MGA1064_restore,
58381 };
58382 EXPORT_SYMBOL(matrox_mystique);
58383 #endif
58384
58385 #ifdef CONFIG_FB_MATROX_G
58386 struct matrox_switch matrox_G100 = {
58387- MGAG100_preinit, MGAG100_reset, MGAG100_init, MGAG100_restore,
58388+ .preinit = MGAG100_preinit,
58389+ .reset = MGAG100_reset,
58390+ .init = MGAG100_init,
58391+ .restore = MGAG100_restore,
58392 };
58393 EXPORT_SYMBOL(matrox_G100);
58394 #endif
58395diff --git a/drivers/video/fbdev/matrox/matroxfb_Ti3026.c b/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
58396index 195ad7c..09743fc 100644
58397--- a/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
58398+++ b/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
58399@@ -738,7 +738,10 @@ static int Ti3026_preinit(struct matrox_fb_info *minfo)
58400 }
58401
58402 struct matrox_switch matrox_millennium = {
58403- Ti3026_preinit, Ti3026_reset, Ti3026_init, Ti3026_restore
58404+ .preinit = Ti3026_preinit,
58405+ .reset = Ti3026_reset,
58406+ .init = Ti3026_init,
58407+ .restore = Ti3026_restore
58408 };
58409 EXPORT_SYMBOL(matrox_millennium);
58410 #endif
58411diff --git a/drivers/video/fbdev/matrox/matroxfb_base.c b/drivers/video/fbdev/matrox/matroxfb_base.c
58412index 11eb094..622ee31 100644
58413--- a/drivers/video/fbdev/matrox/matroxfb_base.c
58414+++ b/drivers/video/fbdev/matrox/matroxfb_base.c
58415@@ -2176,7 +2176,7 @@ static struct pci_driver matroxfb_driver = {
58416 #define RS1056x480 14 /* 132 x 60 text */
58417 #define RSNoxNo 15
58418 /* 10-FF */
58419-static struct { int xres, yres, left, right, upper, lower, hslen, vslen, vfreq; } timmings[] __initdata = {
58420+static struct { unsigned int xres, yres, left, right, upper, lower, hslen, vslen, vfreq; } timmings[] __initdata = {
58421 { 640, 400, 48, 16, 39, 8, 96, 2, 70 },
58422 { 640, 480, 48, 16, 33, 10, 96, 2, 60 },
58423 { 800, 600, 144, 24, 28, 8, 112, 6, 60 },
58424diff --git a/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c b/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
58425index fe92eed..106e085 100644
58426--- a/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
58427+++ b/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
58428@@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
58429 struct mb862xxfb_par *par = info->par;
58430
58431 if (info->var.bits_per_pixel == 32) {
58432- info->fbops->fb_fillrect = cfb_fillrect;
58433- info->fbops->fb_copyarea = cfb_copyarea;
58434- info->fbops->fb_imageblit = cfb_imageblit;
58435+ pax_open_kernel();
58436+ *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
58437+ *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
58438+ *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
58439+ pax_close_kernel();
58440 } else {
58441 outreg(disp, GC_L0EM, 3);
58442- info->fbops->fb_fillrect = mb86290fb_fillrect;
58443- info->fbops->fb_copyarea = mb86290fb_copyarea;
58444- info->fbops->fb_imageblit = mb86290fb_imageblit;
58445+ pax_open_kernel();
58446+ *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
58447+ *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
58448+ *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
58449+ pax_close_kernel();
58450 }
58451 outreg(draw, GDC_REG_DRAW_BASE, 0);
58452 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
58453diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c
58454index ce7dab7..a87baf8 100644
58455--- a/drivers/video/fbdev/nvidia/nvidia.c
58456+++ b/drivers/video/fbdev/nvidia/nvidia.c
58457@@ -660,19 +660,23 @@ static int nvidiafb_set_par(struct fb_info *info)
58458 info->fix.line_length = (info->var.xres_virtual *
58459 info->var.bits_per_pixel) >> 3;
58460 if (info->var.accel_flags) {
58461- info->fbops->fb_imageblit = nvidiafb_imageblit;
58462- info->fbops->fb_fillrect = nvidiafb_fillrect;
58463- info->fbops->fb_copyarea = nvidiafb_copyarea;
58464- info->fbops->fb_sync = nvidiafb_sync;
58465+ pax_open_kernel();
58466+ *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
58467+ *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
58468+ *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
58469+ *(void **)&info->fbops->fb_sync = nvidiafb_sync;
58470+ pax_close_kernel();
58471 info->pixmap.scan_align = 4;
58472 info->flags &= ~FBINFO_HWACCEL_DISABLED;
58473 info->flags |= FBINFO_READS_FAST;
58474 NVResetGraphics(info);
58475 } else {
58476- info->fbops->fb_imageblit = cfb_imageblit;
58477- info->fbops->fb_fillrect = cfb_fillrect;
58478- info->fbops->fb_copyarea = cfb_copyarea;
58479- info->fbops->fb_sync = NULL;
58480+ pax_open_kernel();
58481+ *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
58482+ *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
58483+ *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
58484+ *(void **)&info->fbops->fb_sync = NULL;
58485+ pax_close_kernel();
58486 info->pixmap.scan_align = 1;
58487 info->flags |= FBINFO_HWACCEL_DISABLED;
58488 info->flags &= ~FBINFO_READS_FAST;
58489@@ -1164,8 +1168,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
58490 info->pixmap.size = 8 * 1024;
58491 info->pixmap.flags = FB_PIXMAP_SYSTEM;
58492
58493- if (!hwcur)
58494- info->fbops->fb_cursor = NULL;
58495+ if (!hwcur) {
58496+ pax_open_kernel();
58497+ *(void **)&info->fbops->fb_cursor = NULL;
58498+ pax_close_kernel();
58499+ }
58500
58501 info->var.accel_flags = (!noaccel);
58502
58503diff --git a/drivers/video/fbdev/omap2/dss/display.c b/drivers/video/fbdev/omap2/dss/display.c
58504index ef5b902..47cf7f5 100644
58505--- a/drivers/video/fbdev/omap2/dss/display.c
58506+++ b/drivers/video/fbdev/omap2/dss/display.c
58507@@ -161,12 +161,14 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
58508 if (dssdev->name == NULL)
58509 dssdev->name = dssdev->alias;
58510
58511+ pax_open_kernel();
58512 if (drv && drv->get_resolution == NULL)
58513- drv->get_resolution = omapdss_default_get_resolution;
58514+ *(void **)&drv->get_resolution = omapdss_default_get_resolution;
58515 if (drv && drv->get_recommended_bpp == NULL)
58516- drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
58517+ *(void **)&drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
58518 if (drv && drv->get_timings == NULL)
58519- drv->get_timings = omapdss_default_get_timings;
58520+ *(void **)&drv->get_timings = omapdss_default_get_timings;
58521+ pax_close_kernel();
58522
58523 mutex_lock(&panel_list_mutex);
58524 list_add_tail(&dssdev->panel_list, &panel_list);
58525diff --git a/drivers/video/fbdev/s1d13xxxfb.c b/drivers/video/fbdev/s1d13xxxfb.c
58526index 83433cb..71e9b98 100644
58527--- a/drivers/video/fbdev/s1d13xxxfb.c
58528+++ b/drivers/video/fbdev/s1d13xxxfb.c
58529@@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
58530
58531 switch(prod_id) {
58532 case S1D13506_PROD_ID: /* activate acceleration */
58533- s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
58534- s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
58535+ pax_open_kernel();
58536+ *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
58537+ *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
58538+ pax_close_kernel();
58539 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
58540 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
58541 break;
58542diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
58543index 82c0a8c..42499a1 100644
58544--- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
58545+++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
58546@@ -439,9 +439,9 @@ static unsigned long lcdc_sys_read_data(void *handle)
58547 }
58548
58549 static struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = {
58550- lcdc_sys_write_index,
58551- lcdc_sys_write_data,
58552- lcdc_sys_read_data,
58553+ .write_index = lcdc_sys_write_index,
58554+ .write_data = lcdc_sys_write_data,
58555+ .read_data = lcdc_sys_read_data,
58556 };
58557
58558 static int sh_mobile_lcdc_sginit(struct fb_info *info,
58559diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
58560index 9279e5f..d5f5276 100644
58561--- a/drivers/video/fbdev/smscufx.c
58562+++ b/drivers/video/fbdev/smscufx.c
58563@@ -1174,7 +1174,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
58564 fb_deferred_io_cleanup(info);
58565 kfree(info->fbdefio);
58566 info->fbdefio = NULL;
58567- info->fbops->fb_mmap = ufx_ops_mmap;
58568+ pax_open_kernel();
58569+ *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
58570+ pax_close_kernel();
58571 }
58572
58573 pr_debug("released /dev/fb%d user=%d count=%d",
58574diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
58575index ff2b873..626a8d5 100644
58576--- a/drivers/video/fbdev/udlfb.c
58577+++ b/drivers/video/fbdev/udlfb.c
58578@@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
58579 dlfb_urb_completion(urb);
58580
58581 error:
58582- atomic_add(bytes_sent, &dev->bytes_sent);
58583- atomic_add(bytes_identical, &dev->bytes_identical);
58584- atomic_add(width*height*2, &dev->bytes_rendered);
58585+ atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
58586+ atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
58587+ atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
58588 end_cycles = get_cycles();
58589- atomic_add(((unsigned int) ((end_cycles - start_cycles)
58590+ atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
58591 >> 10)), /* Kcycles */
58592 &dev->cpu_kcycles_used);
58593
58594@@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
58595 dlfb_urb_completion(urb);
58596
58597 error:
58598- atomic_add(bytes_sent, &dev->bytes_sent);
58599- atomic_add(bytes_identical, &dev->bytes_identical);
58600- atomic_add(bytes_rendered, &dev->bytes_rendered);
58601+ atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
58602+ atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
58603+ atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
58604 end_cycles = get_cycles();
58605- atomic_add(((unsigned int) ((end_cycles - start_cycles)
58606+ atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
58607 >> 10)), /* Kcycles */
58608 &dev->cpu_kcycles_used);
58609 }
58610@@ -991,7 +991,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
58611 fb_deferred_io_cleanup(info);
58612 kfree(info->fbdefio);
58613 info->fbdefio = NULL;
58614- info->fbops->fb_mmap = dlfb_ops_mmap;
58615+ pax_open_kernel();
58616+ *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
58617+ pax_close_kernel();
58618 }
58619
58620 pr_warn("released /dev/fb%d user=%d count=%d\n",
58621@@ -1373,7 +1375,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
58622 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58623 struct dlfb_data *dev = fb_info->par;
58624 return snprintf(buf, PAGE_SIZE, "%u\n",
58625- atomic_read(&dev->bytes_rendered));
58626+ atomic_read_unchecked(&dev->bytes_rendered));
58627 }
58628
58629 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
58630@@ -1381,7 +1383,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
58631 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58632 struct dlfb_data *dev = fb_info->par;
58633 return snprintf(buf, PAGE_SIZE, "%u\n",
58634- atomic_read(&dev->bytes_identical));
58635+ atomic_read_unchecked(&dev->bytes_identical));
58636 }
58637
58638 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
58639@@ -1389,7 +1391,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
58640 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58641 struct dlfb_data *dev = fb_info->par;
58642 return snprintf(buf, PAGE_SIZE, "%u\n",
58643- atomic_read(&dev->bytes_sent));
58644+ atomic_read_unchecked(&dev->bytes_sent));
58645 }
58646
58647 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
58648@@ -1397,7 +1399,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
58649 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58650 struct dlfb_data *dev = fb_info->par;
58651 return snprintf(buf, PAGE_SIZE, "%u\n",
58652- atomic_read(&dev->cpu_kcycles_used));
58653+ atomic_read_unchecked(&dev->cpu_kcycles_used));
58654 }
58655
58656 static ssize_t edid_show(
58657@@ -1457,10 +1459,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
58658 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58659 struct dlfb_data *dev = fb_info->par;
58660
58661- atomic_set(&dev->bytes_rendered, 0);
58662- atomic_set(&dev->bytes_identical, 0);
58663- atomic_set(&dev->bytes_sent, 0);
58664- atomic_set(&dev->cpu_kcycles_used, 0);
58665+ atomic_set_unchecked(&dev->bytes_rendered, 0);
58666+ atomic_set_unchecked(&dev->bytes_identical, 0);
58667+ atomic_set_unchecked(&dev->bytes_sent, 0);
58668+ atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
58669
58670 return count;
58671 }
58672diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
58673index 178ae93..624b2eb 100644
58674--- a/drivers/video/fbdev/uvesafb.c
58675+++ b/drivers/video/fbdev/uvesafb.c
58676@@ -19,6 +19,7 @@
58677 #include <linux/io.h>
58678 #include <linux/mutex.h>
58679 #include <linux/slab.h>
58680+#include <linux/moduleloader.h>
58681 #include <video/edid.h>
58682 #include <video/uvesafb.h>
58683 #ifdef CONFIG_X86
58684@@ -565,10 +566,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
58685 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
58686 par->pmi_setpal = par->ypan = 0;
58687 } else {
58688+
58689+#ifdef CONFIG_PAX_KERNEXEC
58690+#ifdef CONFIG_MODULES
58691+ par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
58692+#endif
58693+ if (!par->pmi_code) {
58694+ par->pmi_setpal = par->ypan = 0;
58695+ return 0;
58696+ }
58697+#endif
58698+
58699 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
58700 + task->t.regs.edi);
58701+
58702+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58703+ pax_open_kernel();
58704+ memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
58705+ pax_close_kernel();
58706+
58707+ par->pmi_start = (void *)ktva_ktla((unsigned long)(par->pmi_code + par->pmi_base[1]));
58708+ par->pmi_pal = (void *)ktva_ktla((unsigned long)(par->pmi_code + par->pmi_base[2]));
58709+#else
58710 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
58711 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
58712+#endif
58713+
58714 printk(KERN_INFO "uvesafb: protected mode interface info at "
58715 "%04x:%04x\n",
58716 (u16)task->t.regs.es, (u16)task->t.regs.edi);
58717@@ -813,13 +836,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
58718 par->ypan = ypan;
58719
58720 if (par->pmi_setpal || par->ypan) {
58721+#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
58722 if (__supported_pte_mask & _PAGE_NX) {
58723 par->pmi_setpal = par->ypan = 0;
58724 printk(KERN_WARNING "uvesafb: NX protection is active, "
58725 "better not use the PMI.\n");
58726- } else {
58727+ } else
58728+#endif
58729 uvesafb_vbe_getpmi(task, par);
58730- }
58731 }
58732 #else
58733 /* The protected mode interface is not available on non-x86. */
58734@@ -1452,8 +1476,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
58735 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
58736
58737 /* Disable blanking if the user requested so. */
58738- if (!blank)
58739- info->fbops->fb_blank = NULL;
58740+ if (!blank) {
58741+ pax_open_kernel();
58742+ *(void **)&info->fbops->fb_blank = NULL;
58743+ pax_close_kernel();
58744+ }
58745
58746 /*
58747 * Find out how much IO memory is required for the mode with
58748@@ -1524,8 +1551,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
58749 info->flags = FBINFO_FLAG_DEFAULT |
58750 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
58751
58752- if (!par->ypan)
58753- info->fbops->fb_pan_display = NULL;
58754+ if (!par->ypan) {
58755+ pax_open_kernel();
58756+ *(void **)&info->fbops->fb_pan_display = NULL;
58757+ pax_close_kernel();
58758+ }
58759 }
58760
58761 static void uvesafb_init_mtrr(struct fb_info *info)
58762@@ -1786,6 +1816,11 @@ out_mode:
58763 out:
58764 kfree(par->vbe_modes);
58765
58766+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58767+ if (par->pmi_code)
58768+ module_memfree_exec(par->pmi_code);
58769+#endif
58770+
58771 framebuffer_release(info);
58772 return err;
58773 }
58774@@ -1810,6 +1845,11 @@ static int uvesafb_remove(struct platform_device *dev)
58775 kfree(par->vbe_state_orig);
58776 kfree(par->vbe_state_saved);
58777
58778+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58779+ if (par->pmi_code)
58780+ module_memfree_exec(par->pmi_code);
58781+#endif
58782+
58783 framebuffer_release(info);
58784 }
58785 return 0;
58786diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c
58787index 528fe91..6fd29fe 100644
58788--- a/drivers/video/fbdev/vesafb.c
58789+++ b/drivers/video/fbdev/vesafb.c
58790@@ -9,6 +9,7 @@
58791 */
58792
58793 #include <linux/module.h>
58794+#include <linux/moduleloader.h>
58795 #include <linux/kernel.h>
58796 #include <linux/errno.h>
58797 #include <linux/string.h>
58798@@ -56,8 +57,8 @@ static int vram_remap; /* Set amount of memory to be used */
58799 static int vram_total; /* Set total amount of memory */
58800 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
58801 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
58802-static void (*pmi_start)(void) __read_mostly;
58803-static void (*pmi_pal) (void) __read_mostly;
58804+static void (*pmi_start)(void) __read_only;
58805+static void (*pmi_pal) (void) __read_only;
58806 static int depth __read_mostly;
58807 static int vga_compat __read_mostly;
58808 /* --------------------------------------------------------------------- */
58809@@ -241,6 +242,7 @@ static int vesafb_probe(struct platform_device *dev)
58810 unsigned int size_remap;
58811 unsigned int size_total;
58812 char *option = NULL;
58813+ void *pmi_code = NULL;
58814
58815 /* ignore error return of fb_get_options */
58816 fb_get_options("vesafb", &option);
58817@@ -287,10 +289,6 @@ static int vesafb_probe(struct platform_device *dev)
58818 size_remap = size_total;
58819 vesafb_fix.smem_len = size_remap;
58820
58821-#ifndef __i386__
58822- screen_info.vesapm_seg = 0;
58823-#endif
58824-
58825 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
58826 printk(KERN_WARNING
58827 "vesafb: cannot reserve video memory at 0x%lx\n",
58828@@ -320,9 +318,21 @@ static int vesafb_probe(struct platform_device *dev)
58829 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
58830 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
58831
58832+#ifdef __i386__
58833+
58834+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58835+ pmi_code = module_alloc_exec(screen_info.vesapm_size);
58836+ if (!pmi_code)
58837+#elif !defined(CONFIG_PAX_KERNEXEC)
58838+ if (0)
58839+#endif
58840+
58841+#endif
58842+ screen_info.vesapm_seg = 0;
58843+
58844 if (screen_info.vesapm_seg) {
58845- printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
58846- screen_info.vesapm_seg,screen_info.vesapm_off);
58847+ printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
58848+ screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
58849 }
58850
58851 if (screen_info.vesapm_seg < 0xc000)
58852@@ -330,9 +340,25 @@ static int vesafb_probe(struct platform_device *dev)
58853
58854 if (ypan || pmi_setpal) {
58855 unsigned short *pmi_base;
58856+
58857 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
58858- pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
58859- pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
58860+
58861+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58862+ pax_open_kernel();
58863+ memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
58864+#else
58865+ pmi_code = pmi_base;
58866+#endif
58867+
58868+ pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
58869+ pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
58870+
58871+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58872+ pmi_start = (void *)ktva_ktla((unsigned long)pmi_start);
58873+ pmi_pal = (void *)ktva_ktla((unsigned long)pmi_pal);
58874+ pax_close_kernel();
58875+#endif
58876+
58877 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
58878 if (pmi_base[3]) {
58879 printk(KERN_INFO "vesafb: pmi: ports = ");
58880@@ -452,8 +478,11 @@ static int vesafb_probe(struct platform_device *dev)
58881 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
58882 (ypan ? FBINFO_HWACCEL_YPAN : 0);
58883
58884- if (!ypan)
58885- info->fbops->fb_pan_display = NULL;
58886+ if (!ypan) {
58887+ pax_open_kernel();
58888+ *(void **)&info->fbops->fb_pan_display = NULL;
58889+ pax_close_kernel();
58890+ }
58891
58892 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
58893 err = -ENOMEM;
58894@@ -467,6 +496,11 @@ static int vesafb_probe(struct platform_device *dev)
58895 fb_info(info, "%s frame buffer device\n", info->fix.id);
58896 return 0;
58897 err:
58898+
58899+#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58900+ module_memfree_exec(pmi_code);
58901+#endif
58902+
58903 arch_phys_wc_del(par->wc_cookie);
58904 if (info->screen_base)
58905 iounmap(info->screen_base);
58906diff --git a/drivers/video/fbdev/via/via_clock.h b/drivers/video/fbdev/via/via_clock.h
58907index 88714ae..16c2e11 100644
58908--- a/drivers/video/fbdev/via/via_clock.h
58909+++ b/drivers/video/fbdev/via/via_clock.h
58910@@ -56,7 +56,7 @@ struct via_clock {
58911
58912 void (*set_engine_pll_state)(u8 state);
58913 void (*set_engine_pll)(struct via_pll_config config);
58914-};
58915+} __no_const;
58916
58917
58918 static inline u32 get_pll_internal_frequency(u32 ref_freq,
58919diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
58920index 3c14e43..2630570 100644
58921--- a/drivers/video/logo/logo_linux_clut224.ppm
58922+++ b/drivers/video/logo/logo_linux_clut224.ppm
58923@@ -2,1603 +2,1123 @@ P3
58924 # Standard 224-color Linux logo
58925 80 80
58926 255
58927- 0 0 0 0 0 0 0 0 0 0 0 0
58928- 0 0 0 0 0 0 0 0 0 0 0 0
58929- 0 0 0 0 0 0 0 0 0 0 0 0
58930- 0 0 0 0 0 0 0 0 0 0 0 0
58931- 0 0 0 0 0 0 0 0 0 0 0 0
58932- 0 0 0 0 0 0 0 0 0 0 0 0
58933- 0 0 0 0 0 0 0 0 0 0 0 0
58934- 0 0 0 0 0 0 0 0 0 0 0 0
58935- 0 0 0 0 0 0 0 0 0 0 0 0
58936- 6 6 6 6 6 6 10 10 10 10 10 10
58937- 10 10 10 6 6 6 6 6 6 6 6 6
58938- 0 0 0 0 0 0 0 0 0 0 0 0
58939- 0 0 0 0 0 0 0 0 0 0 0 0
58940- 0 0 0 0 0 0 0 0 0 0 0 0
58941- 0 0 0 0 0 0 0 0 0 0 0 0
58942- 0 0 0 0 0 0 0 0 0 0 0 0
58943- 0 0 0 0 0 0 0 0 0 0 0 0
58944- 0 0 0 0 0 0 0 0 0 0 0 0
58945- 0 0 0 0 0 0 0 0 0 0 0 0
58946- 0 0 0 0 0 0 0 0 0 0 0 0
58947- 0 0 0 0 0 0 0 0 0 0 0 0
58948- 0 0 0 0 0 0 0 0 0 0 0 0
58949- 0 0 0 0 0 0 0 0 0 0 0 0
58950- 0 0 0 0 0 0 0 0 0 0 0 0
58951- 0 0 0 0 0 0 0 0 0 0 0 0
58952- 0 0 0 0 0 0 0 0 0 0 0 0
58953- 0 0 0 0 0 0 0 0 0 0 0 0
58954- 0 0 0 0 0 0 0 0 0 0 0 0
58955- 0 0 0 6 6 6 10 10 10 14 14 14
58956- 22 22 22 26 26 26 30 30 30 34 34 34
58957- 30 30 30 30 30 30 26 26 26 18 18 18
58958- 14 14 14 10 10 10 6 6 6 0 0 0
58959- 0 0 0 0 0 0 0 0 0 0 0 0
58960- 0 0 0 0 0 0 0 0 0 0 0 0
58961- 0 0 0 0 0 0 0 0 0 0 0 0
58962- 0 0 0 0 0 0 0 0 0 0 0 0
58963- 0 0 0 0 0 0 0 0 0 0 0 0
58964- 0 0 0 0 0 0 0 0 0 0 0 0
58965- 0 0 0 0 0 0 0 0 0 0 0 0
58966- 0 0 0 0 0 0 0 0 0 0 0 0
58967- 0 0 0 0 0 0 0 0 0 0 0 0
58968- 0 0 0 0 0 1 0 0 1 0 0 0
58969- 0 0 0 0 0 0 0 0 0 0 0 0
58970- 0 0 0 0 0 0 0 0 0 0 0 0
58971- 0 0 0 0 0 0 0 0 0 0 0 0
58972- 0 0 0 0 0 0 0 0 0 0 0 0
58973- 0 0 0 0 0 0 0 0 0 0 0 0
58974- 0 0 0 0 0 0 0 0 0 0 0 0
58975- 6 6 6 14 14 14 26 26 26 42 42 42
58976- 54 54 54 66 66 66 78 78 78 78 78 78
58977- 78 78 78 74 74 74 66 66 66 54 54 54
58978- 42 42 42 26 26 26 18 18 18 10 10 10
58979- 6 6 6 0 0 0 0 0 0 0 0 0
58980- 0 0 0 0 0 0 0 0 0 0 0 0
58981- 0 0 0 0 0 0 0 0 0 0 0 0
58982- 0 0 0 0 0 0 0 0 0 0 0 0
58983- 0 0 0 0 0 0 0 0 0 0 0 0
58984- 0 0 0 0 0 0 0 0 0 0 0 0
58985- 0 0 0 0 0 0 0 0 0 0 0 0
58986- 0 0 0 0 0 0 0 0 0 0 0 0
58987- 0 0 0 0 0 0 0 0 0 0 0 0
58988- 0 0 1 0 0 0 0 0 0 0 0 0
58989- 0 0 0 0 0 0 0 0 0 0 0 0
58990- 0 0 0 0 0 0 0 0 0 0 0 0
58991- 0 0 0 0 0 0 0 0 0 0 0 0
58992- 0 0 0 0 0 0 0 0 0 0 0 0
58993- 0 0 0 0 0 0 0 0 0 0 0 0
58994- 0 0 0 0 0 0 0 0 0 10 10 10
58995- 22 22 22 42 42 42 66 66 66 86 86 86
58996- 66 66 66 38 38 38 38 38 38 22 22 22
58997- 26 26 26 34 34 34 54 54 54 66 66 66
58998- 86 86 86 70 70 70 46 46 46 26 26 26
58999- 14 14 14 6 6 6 0 0 0 0 0 0
59000- 0 0 0 0 0 0 0 0 0 0 0 0
59001- 0 0 0 0 0 0 0 0 0 0 0 0
59002- 0 0 0 0 0 0 0 0 0 0 0 0
59003- 0 0 0 0 0 0 0 0 0 0 0 0
59004- 0 0 0 0 0 0 0 0 0 0 0 0
59005- 0 0 0 0 0 0 0 0 0 0 0 0
59006- 0 0 0 0 0 0 0 0 0 0 0 0
59007- 0 0 0 0 0 0 0 0 0 0 0 0
59008- 0 0 1 0 0 1 0 0 1 0 0 0
59009- 0 0 0 0 0 0 0 0 0 0 0 0
59010- 0 0 0 0 0 0 0 0 0 0 0 0
59011- 0 0 0 0 0 0 0 0 0 0 0 0
59012- 0 0 0 0 0 0 0 0 0 0 0 0
59013- 0 0 0 0 0 0 0 0 0 0 0 0
59014- 0 0 0 0 0 0 10 10 10 26 26 26
59015- 50 50 50 82 82 82 58 58 58 6 6 6
59016- 2 2 6 2 2 6 2 2 6 2 2 6
59017- 2 2 6 2 2 6 2 2 6 2 2 6
59018- 6 6 6 54 54 54 86 86 86 66 66 66
59019- 38 38 38 18 18 18 6 6 6 0 0 0
59020- 0 0 0 0 0 0 0 0 0 0 0 0
59021- 0 0 0 0 0 0 0 0 0 0 0 0
59022- 0 0 0 0 0 0 0 0 0 0 0 0
59023- 0 0 0 0 0 0 0 0 0 0 0 0
59024- 0 0 0 0 0 0 0 0 0 0 0 0
59025- 0 0 0 0 0 0 0 0 0 0 0 0
59026- 0 0 0 0 0 0 0 0 0 0 0 0
59027- 0 0 0 0 0 0 0 0 0 0 0 0
59028- 0 0 0 0 0 0 0 0 0 0 0 0
59029- 0 0 0 0 0 0 0 0 0 0 0 0
59030- 0 0 0 0 0 0 0 0 0 0 0 0
59031- 0 0 0 0 0 0 0 0 0 0 0 0
59032- 0 0 0 0 0 0 0 0 0 0 0 0
59033- 0 0 0 0 0 0 0 0 0 0 0 0
59034- 0 0 0 6 6 6 22 22 22 50 50 50
59035- 78 78 78 34 34 34 2 2 6 2 2 6
59036- 2 2 6 2 2 6 2 2 6 2 2 6
59037- 2 2 6 2 2 6 2 2 6 2 2 6
59038- 2 2 6 2 2 6 6 6 6 70 70 70
59039- 78 78 78 46 46 46 22 22 22 6 6 6
59040- 0 0 0 0 0 0 0 0 0 0 0 0
59041- 0 0 0 0 0 0 0 0 0 0 0 0
59042- 0 0 0 0 0 0 0 0 0 0 0 0
59043- 0 0 0 0 0 0 0 0 0 0 0 0
59044- 0 0 0 0 0 0 0 0 0 0 0 0
59045- 0 0 0 0 0 0 0 0 0 0 0 0
59046- 0 0 0 0 0 0 0 0 0 0 0 0
59047- 0 0 0 0 0 0 0 0 0 0 0 0
59048- 0 0 1 0 0 1 0 0 1 0 0 0
59049- 0 0 0 0 0 0 0 0 0 0 0 0
59050- 0 0 0 0 0 0 0 0 0 0 0 0
59051- 0 0 0 0 0 0 0 0 0 0 0 0
59052- 0 0 0 0 0 0 0 0 0 0 0 0
59053- 0 0 0 0 0 0 0 0 0 0 0 0
59054- 6 6 6 18 18 18 42 42 42 82 82 82
59055- 26 26 26 2 2 6 2 2 6 2 2 6
59056- 2 2 6 2 2 6 2 2 6 2 2 6
59057- 2 2 6 2 2 6 2 2 6 14 14 14
59058- 46 46 46 34 34 34 6 6 6 2 2 6
59059- 42 42 42 78 78 78 42 42 42 18 18 18
59060- 6 6 6 0 0 0 0 0 0 0 0 0
59061- 0 0 0 0 0 0 0 0 0 0 0 0
59062- 0 0 0 0 0 0 0 0 0 0 0 0
59063- 0 0 0 0 0 0 0 0 0 0 0 0
59064- 0 0 0 0 0 0 0 0 0 0 0 0
59065- 0 0 0 0 0 0 0 0 0 0 0 0
59066- 0 0 0 0 0 0 0 0 0 0 0 0
59067- 0 0 0 0 0 0 0 0 0 0 0 0
59068- 0 0 1 0 0 0 0 0 1 0 0 0
59069- 0 0 0 0 0 0 0 0 0 0 0 0
59070- 0 0 0 0 0 0 0 0 0 0 0 0
59071- 0 0 0 0 0 0 0 0 0 0 0 0
59072- 0 0 0 0 0 0 0 0 0 0 0 0
59073- 0 0 0 0 0 0 0 0 0 0 0 0
59074- 10 10 10 30 30 30 66 66 66 58 58 58
59075- 2 2 6 2 2 6 2 2 6 2 2 6
59076- 2 2 6 2 2 6 2 2 6 2 2 6
59077- 2 2 6 2 2 6 2 2 6 26 26 26
59078- 86 86 86 101 101 101 46 46 46 10 10 10
59079- 2 2 6 58 58 58 70 70 70 34 34 34
59080- 10 10 10 0 0 0 0 0 0 0 0 0
59081- 0 0 0 0 0 0 0 0 0 0 0 0
59082- 0 0 0 0 0 0 0 0 0 0 0 0
59083- 0 0 0 0 0 0 0 0 0 0 0 0
59084- 0 0 0 0 0 0 0 0 0 0 0 0
59085- 0 0 0 0 0 0 0 0 0 0 0 0
59086- 0 0 0 0 0 0 0 0 0 0 0 0
59087- 0 0 0 0 0 0 0 0 0 0 0 0
59088- 0 0 1 0 0 1 0 0 1 0 0 0
59089- 0 0 0 0 0 0 0 0 0 0 0 0
59090- 0 0 0 0 0 0 0 0 0 0 0 0
59091- 0 0 0 0 0 0 0 0 0 0 0 0
59092- 0 0 0 0 0 0 0 0 0 0 0 0
59093- 0 0 0 0 0 0 0 0 0 0 0 0
59094- 14 14 14 42 42 42 86 86 86 10 10 10
59095- 2 2 6 2 2 6 2 2 6 2 2 6
59096- 2 2 6 2 2 6 2 2 6 2 2 6
59097- 2 2 6 2 2 6 2 2 6 30 30 30
59098- 94 94 94 94 94 94 58 58 58 26 26 26
59099- 2 2 6 6 6 6 78 78 78 54 54 54
59100- 22 22 22 6 6 6 0 0 0 0 0 0
59101- 0 0 0 0 0 0 0 0 0 0 0 0
59102- 0 0 0 0 0 0 0 0 0 0 0 0
59103- 0 0 0 0 0 0 0 0 0 0 0 0
59104- 0 0 0 0 0 0 0 0 0 0 0 0
59105- 0 0 0 0 0 0 0 0 0 0 0 0
59106- 0 0 0 0 0 0 0 0 0 0 0 0
59107- 0 0 0 0 0 0 0 0 0 0 0 0
59108- 0 0 0 0 0 0 0 0 0 0 0 0
59109- 0 0 0 0 0 0 0 0 0 0 0 0
59110- 0 0 0 0 0 0 0 0 0 0 0 0
59111- 0 0 0 0 0 0 0 0 0 0 0 0
59112- 0 0 0 0 0 0 0 0 0 0 0 0
59113- 0 0 0 0 0 0 0 0 0 6 6 6
59114- 22 22 22 62 62 62 62 62 62 2 2 6
59115- 2 2 6 2 2 6 2 2 6 2 2 6
59116- 2 2 6 2 2 6 2 2 6 2 2 6
59117- 2 2 6 2 2 6 2 2 6 26 26 26
59118- 54 54 54 38 38 38 18 18 18 10 10 10
59119- 2 2 6 2 2 6 34 34 34 82 82 82
59120- 38 38 38 14 14 14 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- 0 0 0 0 0 0 0 0 0 0 0 0
59127- 0 0 0 0 0 0 0 0 0 0 0 0
59128- 0 0 0 0 0 1 0 0 1 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 6 6 6
59134- 30 30 30 78 78 78 30 30 30 2 2 6
59135- 2 2 6 2 2 6 2 2 6 2 2 6
59136- 2 2 6 2 2 6 2 2 6 2 2 6
59137- 2 2 6 2 2 6 2 2 6 10 10 10
59138- 10 10 10 2 2 6 2 2 6 2 2 6
59139- 2 2 6 2 2 6 2 2 6 78 78 78
59140- 50 50 50 18 18 18 6 6 6 0 0 0
59141- 0 0 0 0 0 0 0 0 0 0 0 0
59142- 0 0 0 0 0 0 0 0 0 0 0 0
59143- 0 0 0 0 0 0 0 0 0 0 0 0
59144- 0 0 0 0 0 0 0 0 0 0 0 0
59145- 0 0 0 0 0 0 0 0 0 0 0 0
59146- 0 0 0 0 0 0 0 0 0 0 0 0
59147- 0 0 0 0 0 0 0 0 0 0 0 0
59148- 0 0 1 0 0 0 0 0 0 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 10 10 10
59154- 38 38 38 86 86 86 14 14 14 2 2 6
59155- 2 2 6 2 2 6 2 2 6 2 2 6
59156- 2 2 6 2 2 6 2 2 6 2 2 6
59157- 2 2 6 2 2 6 2 2 6 2 2 6
59158- 2 2 6 2 2 6 2 2 6 2 2 6
59159- 2 2 6 2 2 6 2 2 6 54 54 54
59160- 66 66 66 26 26 26 6 6 6 0 0 0
59161- 0 0 0 0 0 0 0 0 0 0 0 0
59162- 0 0 0 0 0 0 0 0 0 0 0 0
59163- 0 0 0 0 0 0 0 0 0 0 0 0
59164- 0 0 0 0 0 0 0 0 0 0 0 0
59165- 0 0 0 0 0 0 0 0 0 0 0 0
59166- 0 0 0 0 0 0 0 0 0 0 0 0
59167- 0 0 0 0 0 0 0 0 0 0 0 0
59168- 0 0 0 0 0 1 0 0 1 0 0 0
59169- 0 0 0 0 0 0 0 0 0 0 0 0
59170- 0 0 0 0 0 0 0 0 0 0 0 0
59171- 0 0 0 0 0 0 0 0 0 0 0 0
59172- 0 0 0 0 0 0 0 0 0 0 0 0
59173- 0 0 0 0 0 0 0 0 0 14 14 14
59174- 42 42 42 82 82 82 2 2 6 2 2 6
59175- 2 2 6 6 6 6 10 10 10 2 2 6
59176- 2 2 6 2 2 6 2 2 6 2 2 6
59177- 2 2 6 2 2 6 2 2 6 6 6 6
59178- 14 14 14 10 10 10 2 2 6 2 2 6
59179- 2 2 6 2 2 6 2 2 6 18 18 18
59180- 82 82 82 34 34 34 10 10 10 0 0 0
59181- 0 0 0 0 0 0 0 0 0 0 0 0
59182- 0 0 0 0 0 0 0 0 0 0 0 0
59183- 0 0 0 0 0 0 0 0 0 0 0 0
59184- 0 0 0 0 0 0 0 0 0 0 0 0
59185- 0 0 0 0 0 0 0 0 0 0 0 0
59186- 0 0 0 0 0 0 0 0 0 0 0 0
59187- 0 0 0 0 0 0 0 0 0 0 0 0
59188- 0 0 1 0 0 0 0 0 0 0 0 0
59189- 0 0 0 0 0 0 0 0 0 0 0 0
59190- 0 0 0 0 0 0 0 0 0 0 0 0
59191- 0 0 0 0 0 0 0 0 0 0 0 0
59192- 0 0 0 0 0 0 0 0 0 0 0 0
59193- 0 0 0 0 0 0 0 0 0 14 14 14
59194- 46 46 46 86 86 86 2 2 6 2 2 6
59195- 6 6 6 6 6 6 22 22 22 34 34 34
59196- 6 6 6 2 2 6 2 2 6 2 2 6
59197- 2 2 6 2 2 6 18 18 18 34 34 34
59198- 10 10 10 50 50 50 22 22 22 2 2 6
59199- 2 2 6 2 2 6 2 2 6 10 10 10
59200- 86 86 86 42 42 42 14 14 14 0 0 0
59201- 0 0 0 0 0 0 0 0 0 0 0 0
59202- 0 0 0 0 0 0 0 0 0 0 0 0
59203- 0 0 0 0 0 0 0 0 0 0 0 0
59204- 0 0 0 0 0 0 0 0 0 0 0 0
59205- 0 0 0 0 0 0 0 0 0 0 0 0
59206- 0 0 0 0 0 0 0 0 0 0 0 0
59207- 0 0 0 0 0 0 0 0 0 0 0 0
59208- 0 0 1 0 0 1 0 0 1 0 0 0
59209- 0 0 0 0 0 0 0 0 0 0 0 0
59210- 0 0 0 0 0 0 0 0 0 0 0 0
59211- 0 0 0 0 0 0 0 0 0 0 0 0
59212- 0 0 0 0 0 0 0 0 0 0 0 0
59213- 0 0 0 0 0 0 0 0 0 14 14 14
59214- 46 46 46 86 86 86 2 2 6 2 2 6
59215- 38 38 38 116 116 116 94 94 94 22 22 22
59216- 22 22 22 2 2 6 2 2 6 2 2 6
59217- 14 14 14 86 86 86 138 138 138 162 162 162
59218-154 154 154 38 38 38 26 26 26 6 6 6
59219- 2 2 6 2 2 6 2 2 6 2 2 6
59220- 86 86 86 46 46 46 14 14 14 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 0 0 0 0 0 0 0 0 0
59225- 0 0 0 0 0 0 0 0 0 0 0 0
59226- 0 0 0 0 0 0 0 0 0 0 0 0
59227- 0 0 0 0 0 0 0 0 0 0 0 0
59228- 0 0 0 0 0 0 0 0 0 0 0 0
59229- 0 0 0 0 0 0 0 0 0 0 0 0
59230- 0 0 0 0 0 0 0 0 0 0 0 0
59231- 0 0 0 0 0 0 0 0 0 0 0 0
59232- 0 0 0 0 0 0 0 0 0 0 0 0
59233- 0 0 0 0 0 0 0 0 0 14 14 14
59234- 46 46 46 86 86 86 2 2 6 14 14 14
59235-134 134 134 198 198 198 195 195 195 116 116 116
59236- 10 10 10 2 2 6 2 2 6 6 6 6
59237-101 98 89 187 187 187 210 210 210 218 218 218
59238-214 214 214 134 134 134 14 14 14 6 6 6
59239- 2 2 6 2 2 6 2 2 6 2 2 6
59240- 86 86 86 50 50 50 18 18 18 6 6 6
59241- 0 0 0 0 0 0 0 0 0 0 0 0
59242- 0 0 0 0 0 0 0 0 0 0 0 0
59243- 0 0 0 0 0 0 0 0 0 0 0 0
59244- 0 0 0 0 0 0 0 0 0 0 0 0
59245- 0 0 0 0 0 0 0 0 0 0 0 0
59246- 0 0 0 0 0 0 0 0 0 0 0 0
59247- 0 0 0 0 0 0 0 0 1 0 0 0
59248- 0 0 1 0 0 1 0 0 1 0 0 0
59249- 0 0 0 0 0 0 0 0 0 0 0 0
59250- 0 0 0 0 0 0 0 0 0 0 0 0
59251- 0 0 0 0 0 0 0 0 0 0 0 0
59252- 0 0 0 0 0 0 0 0 0 0 0 0
59253- 0 0 0 0 0 0 0 0 0 14 14 14
59254- 46 46 46 86 86 86 2 2 6 54 54 54
59255-218 218 218 195 195 195 226 226 226 246 246 246
59256- 58 58 58 2 2 6 2 2 6 30 30 30
59257-210 210 210 253 253 253 174 174 174 123 123 123
59258-221 221 221 234 234 234 74 74 74 2 2 6
59259- 2 2 6 2 2 6 2 2 6 2 2 6
59260- 70 70 70 58 58 58 22 22 22 6 6 6
59261- 0 0 0 0 0 0 0 0 0 0 0 0
59262- 0 0 0 0 0 0 0 0 0 0 0 0
59263- 0 0 0 0 0 0 0 0 0 0 0 0
59264- 0 0 0 0 0 0 0 0 0 0 0 0
59265- 0 0 0 0 0 0 0 0 0 0 0 0
59266- 0 0 0 0 0 0 0 0 0 0 0 0
59267- 0 0 0 0 0 0 0 0 0 0 0 0
59268- 0 0 0 0 0 0 0 0 0 0 0 0
59269- 0 0 0 0 0 0 0 0 0 0 0 0
59270- 0 0 0 0 0 0 0 0 0 0 0 0
59271- 0 0 0 0 0 0 0 0 0 0 0 0
59272- 0 0 0 0 0 0 0 0 0 0 0 0
59273- 0 0 0 0 0 0 0 0 0 14 14 14
59274- 46 46 46 82 82 82 2 2 6 106 106 106
59275-170 170 170 26 26 26 86 86 86 226 226 226
59276-123 123 123 10 10 10 14 14 14 46 46 46
59277-231 231 231 190 190 190 6 6 6 70 70 70
59278- 90 90 90 238 238 238 158 158 158 2 2 6
59279- 2 2 6 2 2 6 2 2 6 2 2 6
59280- 70 70 70 58 58 58 22 22 22 6 6 6
59281- 0 0 0 0 0 0 0 0 0 0 0 0
59282- 0 0 0 0 0 0 0 0 0 0 0 0
59283- 0 0 0 0 0 0 0 0 0 0 0 0
59284- 0 0 0 0 0 0 0 0 0 0 0 0
59285- 0 0 0 0 0 0 0 0 0 0 0 0
59286- 0 0 0 0 0 0 0 0 0 0 0 0
59287- 0 0 0 0 0 0 0 0 1 0 0 0
59288- 0 0 1 0 0 1 0 0 1 0 0 0
59289- 0 0 0 0 0 0 0 0 0 0 0 0
59290- 0 0 0 0 0 0 0 0 0 0 0 0
59291- 0 0 0 0 0 0 0 0 0 0 0 0
59292- 0 0 0 0 0 0 0 0 0 0 0 0
59293- 0 0 0 0 0 0 0 0 0 14 14 14
59294- 42 42 42 86 86 86 6 6 6 116 116 116
59295-106 106 106 6 6 6 70 70 70 149 149 149
59296-128 128 128 18 18 18 38 38 38 54 54 54
59297-221 221 221 106 106 106 2 2 6 14 14 14
59298- 46 46 46 190 190 190 198 198 198 2 2 6
59299- 2 2 6 2 2 6 2 2 6 2 2 6
59300- 74 74 74 62 62 62 22 22 22 6 6 6
59301- 0 0 0 0 0 0 0 0 0 0 0 0
59302- 0 0 0 0 0 0 0 0 0 0 0 0
59303- 0 0 0 0 0 0 0 0 0 0 0 0
59304- 0 0 0 0 0 0 0 0 0 0 0 0
59305- 0 0 0 0 0 0 0 0 0 0 0 0
59306- 0 0 0 0 0 0 0 0 0 0 0 0
59307- 0 0 0 0 0 0 0 0 1 0 0 0
59308- 0 0 1 0 0 0 0 0 1 0 0 0
59309- 0 0 0 0 0 0 0 0 0 0 0 0
59310- 0 0 0 0 0 0 0 0 0 0 0 0
59311- 0 0 0 0 0 0 0 0 0 0 0 0
59312- 0 0 0 0 0 0 0 0 0 0 0 0
59313- 0 0 0 0 0 0 0 0 0 14 14 14
59314- 42 42 42 94 94 94 14 14 14 101 101 101
59315-128 128 128 2 2 6 18 18 18 116 116 116
59316-118 98 46 121 92 8 121 92 8 98 78 10
59317-162 162 162 106 106 106 2 2 6 2 2 6
59318- 2 2 6 195 195 195 195 195 195 6 6 6
59319- 2 2 6 2 2 6 2 2 6 2 2 6
59320- 74 74 74 62 62 62 22 22 22 6 6 6
59321- 0 0 0 0 0 0 0 0 0 0 0 0
59322- 0 0 0 0 0 0 0 0 0 0 0 0
59323- 0 0 0 0 0 0 0 0 0 0 0 0
59324- 0 0 0 0 0 0 0 0 0 0 0 0
59325- 0 0 0 0 0 0 0 0 0 0 0 0
59326- 0 0 0 0 0 0 0 0 0 0 0 0
59327- 0 0 0 0 0 0 0 0 1 0 0 1
59328- 0 0 1 0 0 0 0 0 1 0 0 0
59329- 0 0 0 0 0 0 0 0 0 0 0 0
59330- 0 0 0 0 0 0 0 0 0 0 0 0
59331- 0 0 0 0 0 0 0 0 0 0 0 0
59332- 0 0 0 0 0 0 0 0 0 0 0 0
59333- 0 0 0 0 0 0 0 0 0 10 10 10
59334- 38 38 38 90 90 90 14 14 14 58 58 58
59335-210 210 210 26 26 26 54 38 6 154 114 10
59336-226 170 11 236 186 11 225 175 15 184 144 12
59337-215 174 15 175 146 61 37 26 9 2 2 6
59338- 70 70 70 246 246 246 138 138 138 2 2 6
59339- 2 2 6 2 2 6 2 2 6 2 2 6
59340- 70 70 70 66 66 66 26 26 26 6 6 6
59341- 0 0 0 0 0 0 0 0 0 0 0 0
59342- 0 0 0 0 0 0 0 0 0 0 0 0
59343- 0 0 0 0 0 0 0 0 0 0 0 0
59344- 0 0 0 0 0 0 0 0 0 0 0 0
59345- 0 0 0 0 0 0 0 0 0 0 0 0
59346- 0 0 0 0 0 0 0 0 0 0 0 0
59347- 0 0 0 0 0 0 0 0 0 0 0 0
59348- 0 0 0 0 0 0 0 0 0 0 0 0
59349- 0 0 0 0 0 0 0 0 0 0 0 0
59350- 0 0 0 0 0 0 0 0 0 0 0 0
59351- 0 0 0 0 0 0 0 0 0 0 0 0
59352- 0 0 0 0 0 0 0 0 0 0 0 0
59353- 0 0 0 0 0 0 0 0 0 10 10 10
59354- 38 38 38 86 86 86 14 14 14 10 10 10
59355-195 195 195 188 164 115 192 133 9 225 175 15
59356-239 182 13 234 190 10 232 195 16 232 200 30
59357-245 207 45 241 208 19 232 195 16 184 144 12
59358-218 194 134 211 206 186 42 42 42 2 2 6
59359- 2 2 6 2 2 6 2 2 6 2 2 6
59360- 50 50 50 74 74 74 30 30 30 6 6 6
59361- 0 0 0 0 0 0 0 0 0 0 0 0
59362- 0 0 0 0 0 0 0 0 0 0 0 0
59363- 0 0 0 0 0 0 0 0 0 0 0 0
59364- 0 0 0 0 0 0 0 0 0 0 0 0
59365- 0 0 0 0 0 0 0 0 0 0 0 0
59366- 0 0 0 0 0 0 0 0 0 0 0 0
59367- 0 0 0 0 0 0 0 0 0 0 0 0
59368- 0 0 0 0 0 0 0 0 0 0 0 0
59369- 0 0 0 0 0 0 0 0 0 0 0 0
59370- 0 0 0 0 0 0 0 0 0 0 0 0
59371- 0 0 0 0 0 0 0 0 0 0 0 0
59372- 0 0 0 0 0 0 0 0 0 0 0 0
59373- 0 0 0 0 0 0 0 0 0 10 10 10
59374- 34 34 34 86 86 86 14 14 14 2 2 6
59375-121 87 25 192 133 9 219 162 10 239 182 13
59376-236 186 11 232 195 16 241 208 19 244 214 54
59377-246 218 60 246 218 38 246 215 20 241 208 19
59378-241 208 19 226 184 13 121 87 25 2 2 6
59379- 2 2 6 2 2 6 2 2 6 2 2 6
59380- 50 50 50 82 82 82 34 34 34 10 10 10
59381- 0 0 0 0 0 0 0 0 0 0 0 0
59382- 0 0 0 0 0 0 0 0 0 0 0 0
59383- 0 0 0 0 0 0 0 0 0 0 0 0
59384- 0 0 0 0 0 0 0 0 0 0 0 0
59385- 0 0 0 0 0 0 0 0 0 0 0 0
59386- 0 0 0 0 0 0 0 0 0 0 0 0
59387- 0 0 0 0 0 0 0 0 0 0 0 0
59388- 0 0 0 0 0 0 0 0 0 0 0 0
59389- 0 0 0 0 0 0 0 0 0 0 0 0
59390- 0 0 0 0 0 0 0 0 0 0 0 0
59391- 0 0 0 0 0 0 0 0 0 0 0 0
59392- 0 0 0 0 0 0 0 0 0 0 0 0
59393- 0 0 0 0 0 0 0 0 0 10 10 10
59394- 34 34 34 82 82 82 30 30 30 61 42 6
59395-180 123 7 206 145 10 230 174 11 239 182 13
59396-234 190 10 238 202 15 241 208 19 246 218 74
59397-246 218 38 246 215 20 246 215 20 246 215 20
59398-226 184 13 215 174 15 184 144 12 6 6 6
59399- 2 2 6 2 2 6 2 2 6 2 2 6
59400- 26 26 26 94 94 94 42 42 42 14 14 14
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 0 0 0
59404- 0 0 0 0 0 0 0 0 0 0 0 0
59405- 0 0 0 0 0 0 0 0 0 0 0 0
59406- 0 0 0 0 0 0 0 0 0 0 0 0
59407- 0 0 0 0 0 0 0 0 0 0 0 0
59408- 0 0 0 0 0 0 0 0 0 0 0 0
59409- 0 0 0 0 0 0 0 0 0 0 0 0
59410- 0 0 0 0 0 0 0 0 0 0 0 0
59411- 0 0 0 0 0 0 0 0 0 0 0 0
59412- 0 0 0 0 0 0 0 0 0 0 0 0
59413- 0 0 0 0 0 0 0 0 0 10 10 10
59414- 30 30 30 78 78 78 50 50 50 104 69 6
59415-192 133 9 216 158 10 236 178 12 236 186 11
59416-232 195 16 241 208 19 244 214 54 245 215 43
59417-246 215 20 246 215 20 241 208 19 198 155 10
59418-200 144 11 216 158 10 156 118 10 2 2 6
59419- 2 2 6 2 2 6 2 2 6 2 2 6
59420- 6 6 6 90 90 90 54 54 54 18 18 18
59421- 6 6 6 0 0 0 0 0 0 0 0 0
59422- 0 0 0 0 0 0 0 0 0 0 0 0
59423- 0 0 0 0 0 0 0 0 0 0 0 0
59424- 0 0 0 0 0 0 0 0 0 0 0 0
59425- 0 0 0 0 0 0 0 0 0 0 0 0
59426- 0 0 0 0 0 0 0 0 0 0 0 0
59427- 0 0 0 0 0 0 0 0 0 0 0 0
59428- 0 0 0 0 0 0 0 0 0 0 0 0
59429- 0 0 0 0 0 0 0 0 0 0 0 0
59430- 0 0 0 0 0 0 0 0 0 0 0 0
59431- 0 0 0 0 0 0 0 0 0 0 0 0
59432- 0 0 0 0 0 0 0 0 0 0 0 0
59433- 0 0 0 0 0 0 0 0 0 10 10 10
59434- 30 30 30 78 78 78 46 46 46 22 22 22
59435-137 92 6 210 162 10 239 182 13 238 190 10
59436-238 202 15 241 208 19 246 215 20 246 215 20
59437-241 208 19 203 166 17 185 133 11 210 150 10
59438-216 158 10 210 150 10 102 78 10 2 2 6
59439- 6 6 6 54 54 54 14 14 14 2 2 6
59440- 2 2 6 62 62 62 74 74 74 30 30 30
59441- 10 10 10 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 0 0 0
59444- 0 0 0 0 0 0 0 0 0 0 0 0
59445- 0 0 0 0 0 0 0 0 0 0 0 0
59446- 0 0 0 0 0 0 0 0 0 0 0 0
59447- 0 0 0 0 0 0 0 0 0 0 0 0
59448- 0 0 0 0 0 0 0 0 0 0 0 0
59449- 0 0 0 0 0 0 0 0 0 0 0 0
59450- 0 0 0 0 0 0 0 0 0 0 0 0
59451- 0 0 0 0 0 0 0 0 0 0 0 0
59452- 0 0 0 0 0 0 0 0 0 0 0 0
59453- 0 0 0 0 0 0 0 0 0 10 10 10
59454- 34 34 34 78 78 78 50 50 50 6 6 6
59455- 94 70 30 139 102 15 190 146 13 226 184 13
59456-232 200 30 232 195 16 215 174 15 190 146 13
59457-168 122 10 192 133 9 210 150 10 213 154 11
59458-202 150 34 182 157 106 101 98 89 2 2 6
59459- 2 2 6 78 78 78 116 116 116 58 58 58
59460- 2 2 6 22 22 22 90 90 90 46 46 46
59461- 18 18 18 6 6 6 0 0 0 0 0 0
59462- 0 0 0 0 0 0 0 0 0 0 0 0
59463- 0 0 0 0 0 0 0 0 0 0 0 0
59464- 0 0 0 0 0 0 0 0 0 0 0 0
59465- 0 0 0 0 0 0 0 0 0 0 0 0
59466- 0 0 0 0 0 0 0 0 0 0 0 0
59467- 0 0 0 0 0 0 0 0 0 0 0 0
59468- 0 0 0 0 0 0 0 0 0 0 0 0
59469- 0 0 0 0 0 0 0 0 0 0 0 0
59470- 0 0 0 0 0 0 0 0 0 0 0 0
59471- 0 0 0 0 0 0 0 0 0 0 0 0
59472- 0 0 0 0 0 0 0 0 0 0 0 0
59473- 0 0 0 0 0 0 0 0 0 10 10 10
59474- 38 38 38 86 86 86 50 50 50 6 6 6
59475-128 128 128 174 154 114 156 107 11 168 122 10
59476-198 155 10 184 144 12 197 138 11 200 144 11
59477-206 145 10 206 145 10 197 138 11 188 164 115
59478-195 195 195 198 198 198 174 174 174 14 14 14
59479- 2 2 6 22 22 22 116 116 116 116 116 116
59480- 22 22 22 2 2 6 74 74 74 70 70 70
59481- 30 30 30 10 10 10 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 0 0 0
59484- 0 0 0 0 0 0 0 0 0 0 0 0
59485- 0 0 0 0 0 0 0 0 0 0 0 0
59486- 0 0 0 0 0 0 0 0 0 0 0 0
59487- 0 0 0 0 0 0 0 0 0 0 0 0
59488- 0 0 0 0 0 0 0 0 0 0 0 0
59489- 0 0 0 0 0 0 0 0 0 0 0 0
59490- 0 0 0 0 0 0 0 0 0 0 0 0
59491- 0 0 0 0 0 0 0 0 0 0 0 0
59492- 0 0 0 0 0 0 0 0 0 0 0 0
59493- 0 0 0 0 0 0 6 6 6 18 18 18
59494- 50 50 50 101 101 101 26 26 26 10 10 10
59495-138 138 138 190 190 190 174 154 114 156 107 11
59496-197 138 11 200 144 11 197 138 11 192 133 9
59497-180 123 7 190 142 34 190 178 144 187 187 187
59498-202 202 202 221 221 221 214 214 214 66 66 66
59499- 2 2 6 2 2 6 50 50 50 62 62 62
59500- 6 6 6 2 2 6 10 10 10 90 90 90
59501- 50 50 50 18 18 18 6 6 6 0 0 0
59502- 0 0 0 0 0 0 0 0 0 0 0 0
59503- 0 0 0 0 0 0 0 0 0 0 0 0
59504- 0 0 0 0 0 0 0 0 0 0 0 0
59505- 0 0 0 0 0 0 0 0 0 0 0 0
59506- 0 0 0 0 0 0 0 0 0 0 0 0
59507- 0 0 0 0 0 0 0 0 0 0 0 0
59508- 0 0 0 0 0 0 0 0 0 0 0 0
59509- 0 0 0 0 0 0 0 0 0 0 0 0
59510- 0 0 0 0 0 0 0 0 0 0 0 0
59511- 0 0 0 0 0 0 0 0 0 0 0 0
59512- 0 0 0 0 0 0 0 0 0 0 0 0
59513- 0 0 0 0 0 0 10 10 10 34 34 34
59514- 74 74 74 74 74 74 2 2 6 6 6 6
59515-144 144 144 198 198 198 190 190 190 178 166 146
59516-154 121 60 156 107 11 156 107 11 168 124 44
59517-174 154 114 187 187 187 190 190 190 210 210 210
59518-246 246 246 253 253 253 253 253 253 182 182 182
59519- 6 6 6 2 2 6 2 2 6 2 2 6
59520- 2 2 6 2 2 6 2 2 6 62 62 62
59521- 74 74 74 34 34 34 14 14 14 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 0 0 0
59524- 0 0 0 0 0 0 0 0 0 0 0 0
59525- 0 0 0 0 0 0 0 0 0 0 0 0
59526- 0 0 0 0 0 0 0 0 0 0 0 0
59527- 0 0 0 0 0 0 0 0 0 0 0 0
59528- 0 0 0 0 0 0 0 0 0 0 0 0
59529- 0 0 0 0 0 0 0 0 0 0 0 0
59530- 0 0 0 0 0 0 0 0 0 0 0 0
59531- 0 0 0 0 0 0 0 0 0 0 0 0
59532- 0 0 0 0 0 0 0 0 0 0 0 0
59533- 0 0 0 10 10 10 22 22 22 54 54 54
59534- 94 94 94 18 18 18 2 2 6 46 46 46
59535-234 234 234 221 221 221 190 190 190 190 190 190
59536-190 190 190 187 187 187 187 187 187 190 190 190
59537-190 190 190 195 195 195 214 214 214 242 242 242
59538-253 253 253 253 253 253 253 253 253 253 253 253
59539- 82 82 82 2 2 6 2 2 6 2 2 6
59540- 2 2 6 2 2 6 2 2 6 14 14 14
59541- 86 86 86 54 54 54 22 22 22 6 6 6
59542- 0 0 0 0 0 0 0 0 0 0 0 0
59543- 0 0 0 0 0 0 0 0 0 0 0 0
59544- 0 0 0 0 0 0 0 0 0 0 0 0
59545- 0 0 0 0 0 0 0 0 0 0 0 0
59546- 0 0 0 0 0 0 0 0 0 0 0 0
59547- 0 0 0 0 0 0 0 0 0 0 0 0
59548- 0 0 0 0 0 0 0 0 0 0 0 0
59549- 0 0 0 0 0 0 0 0 0 0 0 0
59550- 0 0 0 0 0 0 0 0 0 0 0 0
59551- 0 0 0 0 0 0 0 0 0 0 0 0
59552- 0 0 0 0 0 0 0 0 0 0 0 0
59553- 6 6 6 18 18 18 46 46 46 90 90 90
59554- 46 46 46 18 18 18 6 6 6 182 182 182
59555-253 253 253 246 246 246 206 206 206 190 190 190
59556-190 190 190 190 190 190 190 190 190 190 190 190
59557-206 206 206 231 231 231 250 250 250 253 253 253
59558-253 253 253 253 253 253 253 253 253 253 253 253
59559-202 202 202 14 14 14 2 2 6 2 2 6
59560- 2 2 6 2 2 6 2 2 6 2 2 6
59561- 42 42 42 86 86 86 42 42 42 18 18 18
59562- 6 6 6 0 0 0 0 0 0 0 0 0
59563- 0 0 0 0 0 0 0 0 0 0 0 0
59564- 0 0 0 0 0 0 0 0 0 0 0 0
59565- 0 0 0 0 0 0 0 0 0 0 0 0
59566- 0 0 0 0 0 0 0 0 0 0 0 0
59567- 0 0 0 0 0 0 0 0 0 0 0 0
59568- 0 0 0 0 0 0 0 0 0 0 0 0
59569- 0 0 0 0 0 0 0 0 0 0 0 0
59570- 0 0 0 0 0 0 0 0 0 0 0 0
59571- 0 0 0 0 0 0 0 0 0 0 0 0
59572- 0 0 0 0 0 0 0 0 0 6 6 6
59573- 14 14 14 38 38 38 74 74 74 66 66 66
59574- 2 2 6 6 6 6 90 90 90 250 250 250
59575-253 253 253 253 253 253 238 238 238 198 198 198
59576-190 190 190 190 190 190 195 195 195 221 221 221
59577-246 246 246 253 253 253 253 253 253 253 253 253
59578-253 253 253 253 253 253 253 253 253 253 253 253
59579-253 253 253 82 82 82 2 2 6 2 2 6
59580- 2 2 6 2 2 6 2 2 6 2 2 6
59581- 2 2 6 78 78 78 70 70 70 34 34 34
59582- 14 14 14 6 6 6 0 0 0 0 0 0
59583- 0 0 0 0 0 0 0 0 0 0 0 0
59584- 0 0 0 0 0 0 0 0 0 0 0 0
59585- 0 0 0 0 0 0 0 0 0 0 0 0
59586- 0 0 0 0 0 0 0 0 0 0 0 0
59587- 0 0 0 0 0 0 0 0 0 0 0 0
59588- 0 0 0 0 0 0 0 0 0 0 0 0
59589- 0 0 0 0 0 0 0 0 0 0 0 0
59590- 0 0 0 0 0 0 0 0 0 0 0 0
59591- 0 0 0 0 0 0 0 0 0 0 0 0
59592- 0 0 0 0 0 0 0 0 0 14 14 14
59593- 34 34 34 66 66 66 78 78 78 6 6 6
59594- 2 2 6 18 18 18 218 218 218 253 253 253
59595-253 253 253 253 253 253 253 253 253 246 246 246
59596-226 226 226 231 231 231 246 246 246 253 253 253
59597-253 253 253 253 253 253 253 253 253 253 253 253
59598-253 253 253 253 253 253 253 253 253 253 253 253
59599-253 253 253 178 178 178 2 2 6 2 2 6
59600- 2 2 6 2 2 6 2 2 6 2 2 6
59601- 2 2 6 18 18 18 90 90 90 62 62 62
59602- 30 30 30 10 10 10 0 0 0 0 0 0
59603- 0 0 0 0 0 0 0 0 0 0 0 0
59604- 0 0 0 0 0 0 0 0 0 0 0 0
59605- 0 0 0 0 0 0 0 0 0 0 0 0
59606- 0 0 0 0 0 0 0 0 0 0 0 0
59607- 0 0 0 0 0 0 0 0 0 0 0 0
59608- 0 0 0 0 0 0 0 0 0 0 0 0
59609- 0 0 0 0 0 0 0 0 0 0 0 0
59610- 0 0 0 0 0 0 0 0 0 0 0 0
59611- 0 0 0 0 0 0 0 0 0 0 0 0
59612- 0 0 0 0 0 0 10 10 10 26 26 26
59613- 58 58 58 90 90 90 18 18 18 2 2 6
59614- 2 2 6 110 110 110 253 253 253 253 253 253
59615-253 253 253 253 253 253 253 253 253 253 253 253
59616-250 250 250 253 253 253 253 253 253 253 253 253
59617-253 253 253 253 253 253 253 253 253 253 253 253
59618-253 253 253 253 253 253 253 253 253 253 253 253
59619-253 253 253 231 231 231 18 18 18 2 2 6
59620- 2 2 6 2 2 6 2 2 6 2 2 6
59621- 2 2 6 2 2 6 18 18 18 94 94 94
59622- 54 54 54 26 26 26 10 10 10 0 0 0
59623- 0 0 0 0 0 0 0 0 0 0 0 0
59624- 0 0 0 0 0 0 0 0 0 0 0 0
59625- 0 0 0 0 0 0 0 0 0 0 0 0
59626- 0 0 0 0 0 0 0 0 0 0 0 0
59627- 0 0 0 0 0 0 0 0 0 0 0 0
59628- 0 0 0 0 0 0 0 0 0 0 0 0
59629- 0 0 0 0 0 0 0 0 0 0 0 0
59630- 0 0 0 0 0 0 0 0 0 0 0 0
59631- 0 0 0 0 0 0 0 0 0 0 0 0
59632- 0 0 0 6 6 6 22 22 22 50 50 50
59633- 90 90 90 26 26 26 2 2 6 2 2 6
59634- 14 14 14 195 195 195 250 250 250 253 253 253
59635-253 253 253 253 253 253 253 253 253 253 253 253
59636-253 253 253 253 253 253 253 253 253 253 253 253
59637-253 253 253 253 253 253 253 253 253 253 253 253
59638-253 253 253 253 253 253 253 253 253 253 253 253
59639-250 250 250 242 242 242 54 54 54 2 2 6
59640- 2 2 6 2 2 6 2 2 6 2 2 6
59641- 2 2 6 2 2 6 2 2 6 38 38 38
59642- 86 86 86 50 50 50 22 22 22 6 6 6
59643- 0 0 0 0 0 0 0 0 0 0 0 0
59644- 0 0 0 0 0 0 0 0 0 0 0 0
59645- 0 0 0 0 0 0 0 0 0 0 0 0
59646- 0 0 0 0 0 0 0 0 0 0 0 0
59647- 0 0 0 0 0 0 0 0 0 0 0 0
59648- 0 0 0 0 0 0 0 0 0 0 0 0
59649- 0 0 0 0 0 0 0 0 0 0 0 0
59650- 0 0 0 0 0 0 0 0 0 0 0 0
59651- 0 0 0 0 0 0 0 0 0 0 0 0
59652- 6 6 6 14 14 14 38 38 38 82 82 82
59653- 34 34 34 2 2 6 2 2 6 2 2 6
59654- 42 42 42 195 195 195 246 246 246 253 253 253
59655-253 253 253 253 253 253 253 253 253 250 250 250
59656-242 242 242 242 242 242 250 250 250 253 253 253
59657-253 253 253 253 253 253 253 253 253 253 253 253
59658-253 253 253 250 250 250 246 246 246 238 238 238
59659-226 226 226 231 231 231 101 101 101 6 6 6
59660- 2 2 6 2 2 6 2 2 6 2 2 6
59661- 2 2 6 2 2 6 2 2 6 2 2 6
59662- 38 38 38 82 82 82 42 42 42 14 14 14
59663- 6 6 6 0 0 0 0 0 0 0 0 0
59664- 0 0 0 0 0 0 0 0 0 0 0 0
59665- 0 0 0 0 0 0 0 0 0 0 0 0
59666- 0 0 0 0 0 0 0 0 0 0 0 0
59667- 0 0 0 0 0 0 0 0 0 0 0 0
59668- 0 0 0 0 0 0 0 0 0 0 0 0
59669- 0 0 0 0 0 0 0 0 0 0 0 0
59670- 0 0 0 0 0 0 0 0 0 0 0 0
59671- 0 0 0 0 0 0 0 0 0 0 0 0
59672- 10 10 10 26 26 26 62 62 62 66 66 66
59673- 2 2 6 2 2 6 2 2 6 6 6 6
59674- 70 70 70 170 170 170 206 206 206 234 234 234
59675-246 246 246 250 250 250 250 250 250 238 238 238
59676-226 226 226 231 231 231 238 238 238 250 250 250
59677-250 250 250 250 250 250 246 246 246 231 231 231
59678-214 214 214 206 206 206 202 202 202 202 202 202
59679-198 198 198 202 202 202 182 182 182 18 18 18
59680- 2 2 6 2 2 6 2 2 6 2 2 6
59681- 2 2 6 2 2 6 2 2 6 2 2 6
59682- 2 2 6 62 62 62 66 66 66 30 30 30
59683- 10 10 10 0 0 0 0 0 0 0 0 0
59684- 0 0 0 0 0 0 0 0 0 0 0 0
59685- 0 0 0 0 0 0 0 0 0 0 0 0
59686- 0 0 0 0 0 0 0 0 0 0 0 0
59687- 0 0 0 0 0 0 0 0 0 0 0 0
59688- 0 0 0 0 0 0 0 0 0 0 0 0
59689- 0 0 0 0 0 0 0 0 0 0 0 0
59690- 0 0 0 0 0 0 0 0 0 0 0 0
59691- 0 0 0 0 0 0 0 0 0 0 0 0
59692- 14 14 14 42 42 42 82 82 82 18 18 18
59693- 2 2 6 2 2 6 2 2 6 10 10 10
59694- 94 94 94 182 182 182 218 218 218 242 242 242
59695-250 250 250 253 253 253 253 253 253 250 250 250
59696-234 234 234 253 253 253 253 253 253 253 253 253
59697-253 253 253 253 253 253 253 253 253 246 246 246
59698-238 238 238 226 226 226 210 210 210 202 202 202
59699-195 195 195 195 195 195 210 210 210 158 158 158
59700- 6 6 6 14 14 14 50 50 50 14 14 14
59701- 2 2 6 2 2 6 2 2 6 2 2 6
59702- 2 2 6 6 6 6 86 86 86 46 46 46
59703- 18 18 18 6 6 6 0 0 0 0 0 0
59704- 0 0 0 0 0 0 0 0 0 0 0 0
59705- 0 0 0 0 0 0 0 0 0 0 0 0
59706- 0 0 0 0 0 0 0 0 0 0 0 0
59707- 0 0 0 0 0 0 0 0 0 0 0 0
59708- 0 0 0 0 0 0 0 0 0 0 0 0
59709- 0 0 0 0 0 0 0 0 0 0 0 0
59710- 0 0 0 0 0 0 0 0 0 0 0 0
59711- 0 0 0 0 0 0 0 0 0 6 6 6
59712- 22 22 22 54 54 54 70 70 70 2 2 6
59713- 2 2 6 10 10 10 2 2 6 22 22 22
59714-166 166 166 231 231 231 250 250 250 253 253 253
59715-253 253 253 253 253 253 253 253 253 250 250 250
59716-242 242 242 253 253 253 253 253 253 253 253 253
59717-253 253 253 253 253 253 253 253 253 253 253 253
59718-253 253 253 253 253 253 253 253 253 246 246 246
59719-231 231 231 206 206 206 198 198 198 226 226 226
59720- 94 94 94 2 2 6 6 6 6 38 38 38
59721- 30 30 30 2 2 6 2 2 6 2 2 6
59722- 2 2 6 2 2 6 62 62 62 66 66 66
59723- 26 26 26 10 10 10 0 0 0 0 0 0
59724- 0 0 0 0 0 0 0 0 0 0 0 0
59725- 0 0 0 0 0 0 0 0 0 0 0 0
59726- 0 0 0 0 0 0 0 0 0 0 0 0
59727- 0 0 0 0 0 0 0 0 0 0 0 0
59728- 0 0 0 0 0 0 0 0 0 0 0 0
59729- 0 0 0 0 0 0 0 0 0 0 0 0
59730- 0 0 0 0 0 0 0 0 0 0 0 0
59731- 0 0 0 0 0 0 0 0 0 10 10 10
59732- 30 30 30 74 74 74 50 50 50 2 2 6
59733- 26 26 26 26 26 26 2 2 6 106 106 106
59734-238 238 238 253 253 253 253 253 253 253 253 253
59735-253 253 253 253 253 253 253 253 253 253 253 253
59736-253 253 253 253 253 253 253 253 253 253 253 253
59737-253 253 253 253 253 253 253 253 253 253 253 253
59738-253 253 253 253 253 253 253 253 253 253 253 253
59739-253 253 253 246 246 246 218 218 218 202 202 202
59740-210 210 210 14 14 14 2 2 6 2 2 6
59741- 30 30 30 22 22 22 2 2 6 2 2 6
59742- 2 2 6 2 2 6 18 18 18 86 86 86
59743- 42 42 42 14 14 14 0 0 0 0 0 0
59744- 0 0 0 0 0 0 0 0 0 0 0 0
59745- 0 0 0 0 0 0 0 0 0 0 0 0
59746- 0 0 0 0 0 0 0 0 0 0 0 0
59747- 0 0 0 0 0 0 0 0 0 0 0 0
59748- 0 0 0 0 0 0 0 0 0 0 0 0
59749- 0 0 0 0 0 0 0 0 0 0 0 0
59750- 0 0 0 0 0 0 0 0 0 0 0 0
59751- 0 0 0 0 0 0 0 0 0 14 14 14
59752- 42 42 42 90 90 90 22 22 22 2 2 6
59753- 42 42 42 2 2 6 18 18 18 218 218 218
59754-253 253 253 253 253 253 253 253 253 253 253 253
59755-253 253 253 253 253 253 253 253 253 253 253 253
59756-253 253 253 253 253 253 253 253 253 253 253 253
59757-253 253 253 253 253 253 253 253 253 253 253 253
59758-253 253 253 253 253 253 253 253 253 253 253 253
59759-253 253 253 253 253 253 250 250 250 221 221 221
59760-218 218 218 101 101 101 2 2 6 14 14 14
59761- 18 18 18 38 38 38 10 10 10 2 2 6
59762- 2 2 6 2 2 6 2 2 6 78 78 78
59763- 58 58 58 22 22 22 6 6 6 0 0 0
59764- 0 0 0 0 0 0 0 0 0 0 0 0
59765- 0 0 0 0 0 0 0 0 0 0 0 0
59766- 0 0 0 0 0 0 0 0 0 0 0 0
59767- 0 0 0 0 0 0 0 0 0 0 0 0
59768- 0 0 0 0 0 0 0 0 0 0 0 0
59769- 0 0 0 0 0 0 0 0 0 0 0 0
59770- 0 0 0 0 0 0 0 0 0 0 0 0
59771- 0 0 0 0 0 0 6 6 6 18 18 18
59772- 54 54 54 82 82 82 2 2 6 26 26 26
59773- 22 22 22 2 2 6 123 123 123 253 253 253
59774-253 253 253 253 253 253 253 253 253 253 253 253
59775-253 253 253 253 253 253 253 253 253 253 253 253
59776-253 253 253 253 253 253 253 253 253 253 253 253
59777-253 253 253 253 253 253 253 253 253 253 253 253
59778-253 253 253 253 253 253 253 253 253 253 253 253
59779-253 253 253 253 253 253 253 253 253 250 250 250
59780-238 238 238 198 198 198 6 6 6 38 38 38
59781- 58 58 58 26 26 26 38 38 38 2 2 6
59782- 2 2 6 2 2 6 2 2 6 46 46 46
59783- 78 78 78 30 30 30 10 10 10 0 0 0
59784- 0 0 0 0 0 0 0 0 0 0 0 0
59785- 0 0 0 0 0 0 0 0 0 0 0 0
59786- 0 0 0 0 0 0 0 0 0 0 0 0
59787- 0 0 0 0 0 0 0 0 0 0 0 0
59788- 0 0 0 0 0 0 0 0 0 0 0 0
59789- 0 0 0 0 0 0 0 0 0 0 0 0
59790- 0 0 0 0 0 0 0 0 0 0 0 0
59791- 0 0 0 0 0 0 10 10 10 30 30 30
59792- 74 74 74 58 58 58 2 2 6 42 42 42
59793- 2 2 6 22 22 22 231 231 231 253 253 253
59794-253 253 253 253 253 253 253 253 253 253 253 253
59795-253 253 253 253 253 253 253 253 253 250 250 250
59796-253 253 253 253 253 253 253 253 253 253 253 253
59797-253 253 253 253 253 253 253 253 253 253 253 253
59798-253 253 253 253 253 253 253 253 253 253 253 253
59799-253 253 253 253 253 253 253 253 253 253 253 253
59800-253 253 253 246 246 246 46 46 46 38 38 38
59801- 42 42 42 14 14 14 38 38 38 14 14 14
59802- 2 2 6 2 2 6 2 2 6 6 6 6
59803- 86 86 86 46 46 46 14 14 14 0 0 0
59804- 0 0 0 0 0 0 0 0 0 0 0 0
59805- 0 0 0 0 0 0 0 0 0 0 0 0
59806- 0 0 0 0 0 0 0 0 0 0 0 0
59807- 0 0 0 0 0 0 0 0 0 0 0 0
59808- 0 0 0 0 0 0 0 0 0 0 0 0
59809- 0 0 0 0 0 0 0 0 0 0 0 0
59810- 0 0 0 0 0 0 0 0 0 0 0 0
59811- 0 0 0 6 6 6 14 14 14 42 42 42
59812- 90 90 90 18 18 18 18 18 18 26 26 26
59813- 2 2 6 116 116 116 253 253 253 253 253 253
59814-253 253 253 253 253 253 253 253 253 253 253 253
59815-253 253 253 253 253 253 250 250 250 238 238 238
59816-253 253 253 253 253 253 253 253 253 253 253 253
59817-253 253 253 253 253 253 253 253 253 253 253 253
59818-253 253 253 253 253 253 253 253 253 253 253 253
59819-253 253 253 253 253 253 253 253 253 253 253 253
59820-253 253 253 253 253 253 94 94 94 6 6 6
59821- 2 2 6 2 2 6 10 10 10 34 34 34
59822- 2 2 6 2 2 6 2 2 6 2 2 6
59823- 74 74 74 58 58 58 22 22 22 6 6 6
59824- 0 0 0 0 0 0 0 0 0 0 0 0
59825- 0 0 0 0 0 0 0 0 0 0 0 0
59826- 0 0 0 0 0 0 0 0 0 0 0 0
59827- 0 0 0 0 0 0 0 0 0 0 0 0
59828- 0 0 0 0 0 0 0 0 0 0 0 0
59829- 0 0 0 0 0 0 0 0 0 0 0 0
59830- 0 0 0 0 0 0 0 0 0 0 0 0
59831- 0 0 0 10 10 10 26 26 26 66 66 66
59832- 82 82 82 2 2 6 38 38 38 6 6 6
59833- 14 14 14 210 210 210 253 253 253 253 253 253
59834-253 253 253 253 253 253 253 253 253 253 253 253
59835-253 253 253 253 253 253 246 246 246 242 242 242
59836-253 253 253 253 253 253 253 253 253 253 253 253
59837-253 253 253 253 253 253 253 253 253 253 253 253
59838-253 253 253 253 253 253 253 253 253 253 253 253
59839-253 253 253 253 253 253 253 253 253 253 253 253
59840-253 253 253 253 253 253 144 144 144 2 2 6
59841- 2 2 6 2 2 6 2 2 6 46 46 46
59842- 2 2 6 2 2 6 2 2 6 2 2 6
59843- 42 42 42 74 74 74 30 30 30 10 10 10
59844- 0 0 0 0 0 0 0 0 0 0 0 0
59845- 0 0 0 0 0 0 0 0 0 0 0 0
59846- 0 0 0 0 0 0 0 0 0 0 0 0
59847- 0 0 0 0 0 0 0 0 0 0 0 0
59848- 0 0 0 0 0 0 0 0 0 0 0 0
59849- 0 0 0 0 0 0 0 0 0 0 0 0
59850- 0 0 0 0 0 0 0 0 0 0 0 0
59851- 6 6 6 14 14 14 42 42 42 90 90 90
59852- 26 26 26 6 6 6 42 42 42 2 2 6
59853- 74 74 74 250 250 250 253 253 253 253 253 253
59854-253 253 253 253 253 253 253 253 253 253 253 253
59855-253 253 253 253 253 253 242 242 242 242 242 242
59856-253 253 253 253 253 253 253 253 253 253 253 253
59857-253 253 253 253 253 253 253 253 253 253 253 253
59858-253 253 253 253 253 253 253 253 253 253 253 253
59859-253 253 253 253 253 253 253 253 253 253 253 253
59860-253 253 253 253 253 253 182 182 182 2 2 6
59861- 2 2 6 2 2 6 2 2 6 46 46 46
59862- 2 2 6 2 2 6 2 2 6 2 2 6
59863- 10 10 10 86 86 86 38 38 38 10 10 10
59864- 0 0 0 0 0 0 0 0 0 0 0 0
59865- 0 0 0 0 0 0 0 0 0 0 0 0
59866- 0 0 0 0 0 0 0 0 0 0 0 0
59867- 0 0 0 0 0 0 0 0 0 0 0 0
59868- 0 0 0 0 0 0 0 0 0 0 0 0
59869- 0 0 0 0 0 0 0 0 0 0 0 0
59870- 0 0 0 0 0 0 0 0 0 0 0 0
59871- 10 10 10 26 26 26 66 66 66 82 82 82
59872- 2 2 6 22 22 22 18 18 18 2 2 6
59873-149 149 149 253 253 253 253 253 253 253 253 253
59874-253 253 253 253 253 253 253 253 253 253 253 253
59875-253 253 253 253 253 253 234 234 234 242 242 242
59876-253 253 253 253 253 253 253 253 253 253 253 253
59877-253 253 253 253 253 253 253 253 253 253 253 253
59878-253 253 253 253 253 253 253 253 253 253 253 253
59879-253 253 253 253 253 253 253 253 253 253 253 253
59880-253 253 253 253 253 253 206 206 206 2 2 6
59881- 2 2 6 2 2 6 2 2 6 38 38 38
59882- 2 2 6 2 2 6 2 2 6 2 2 6
59883- 6 6 6 86 86 86 46 46 46 14 14 14
59884- 0 0 0 0 0 0 0 0 0 0 0 0
59885- 0 0 0 0 0 0 0 0 0 0 0 0
59886- 0 0 0 0 0 0 0 0 0 0 0 0
59887- 0 0 0 0 0 0 0 0 0 0 0 0
59888- 0 0 0 0 0 0 0 0 0 0 0 0
59889- 0 0 0 0 0 0 0 0 0 0 0 0
59890- 0 0 0 0 0 0 0 0 0 6 6 6
59891- 18 18 18 46 46 46 86 86 86 18 18 18
59892- 2 2 6 34 34 34 10 10 10 6 6 6
59893-210 210 210 253 253 253 253 253 253 253 253 253
59894-253 253 253 253 253 253 253 253 253 253 253 253
59895-253 253 253 253 253 253 234 234 234 242 242 242
59896-253 253 253 253 253 253 253 253 253 253 253 253
59897-253 253 253 253 253 253 253 253 253 253 253 253
59898-253 253 253 253 253 253 253 253 253 253 253 253
59899-253 253 253 253 253 253 253 253 253 253 253 253
59900-253 253 253 253 253 253 221 221 221 6 6 6
59901- 2 2 6 2 2 6 6 6 6 30 30 30
59902- 2 2 6 2 2 6 2 2 6 2 2 6
59903- 2 2 6 82 82 82 54 54 54 18 18 18
59904- 6 6 6 0 0 0 0 0 0 0 0 0
59905- 0 0 0 0 0 0 0 0 0 0 0 0
59906- 0 0 0 0 0 0 0 0 0 0 0 0
59907- 0 0 0 0 0 0 0 0 0 0 0 0
59908- 0 0 0 0 0 0 0 0 0 0 0 0
59909- 0 0 0 0 0 0 0 0 0 0 0 0
59910- 0 0 0 0 0 0 0 0 0 10 10 10
59911- 26 26 26 66 66 66 62 62 62 2 2 6
59912- 2 2 6 38 38 38 10 10 10 26 26 26
59913-238 238 238 253 253 253 253 253 253 253 253 253
59914-253 253 253 253 253 253 253 253 253 253 253 253
59915-253 253 253 253 253 253 231 231 231 238 238 238
59916-253 253 253 253 253 253 253 253 253 253 253 253
59917-253 253 253 253 253 253 253 253 253 253 253 253
59918-253 253 253 253 253 253 253 253 253 253 253 253
59919-253 253 253 253 253 253 253 253 253 253 253 253
59920-253 253 253 253 253 253 231 231 231 6 6 6
59921- 2 2 6 2 2 6 10 10 10 30 30 30
59922- 2 2 6 2 2 6 2 2 6 2 2 6
59923- 2 2 6 66 66 66 58 58 58 22 22 22
59924- 6 6 6 0 0 0 0 0 0 0 0 0
59925- 0 0 0 0 0 0 0 0 0 0 0 0
59926- 0 0 0 0 0 0 0 0 0 0 0 0
59927- 0 0 0 0 0 0 0 0 0 0 0 0
59928- 0 0 0 0 0 0 0 0 0 0 0 0
59929- 0 0 0 0 0 0 0 0 0 0 0 0
59930- 0 0 0 0 0 0 0 0 0 10 10 10
59931- 38 38 38 78 78 78 6 6 6 2 2 6
59932- 2 2 6 46 46 46 14 14 14 42 42 42
59933-246 246 246 253 253 253 253 253 253 253 253 253
59934-253 253 253 253 253 253 253 253 253 253 253 253
59935-253 253 253 253 253 253 231 231 231 242 242 242
59936-253 253 253 253 253 253 253 253 253 253 253 253
59937-253 253 253 253 253 253 253 253 253 253 253 253
59938-253 253 253 253 253 253 253 253 253 253 253 253
59939-253 253 253 253 253 253 253 253 253 253 253 253
59940-253 253 253 253 253 253 234 234 234 10 10 10
59941- 2 2 6 2 2 6 22 22 22 14 14 14
59942- 2 2 6 2 2 6 2 2 6 2 2 6
59943- 2 2 6 66 66 66 62 62 62 22 22 22
59944- 6 6 6 0 0 0 0 0 0 0 0 0
59945- 0 0 0 0 0 0 0 0 0 0 0 0
59946- 0 0 0 0 0 0 0 0 0 0 0 0
59947- 0 0 0 0 0 0 0 0 0 0 0 0
59948- 0 0 0 0 0 0 0 0 0 0 0 0
59949- 0 0 0 0 0 0 0 0 0 0 0 0
59950- 0 0 0 0 0 0 6 6 6 18 18 18
59951- 50 50 50 74 74 74 2 2 6 2 2 6
59952- 14 14 14 70 70 70 34 34 34 62 62 62
59953-250 250 250 253 253 253 253 253 253 253 253 253
59954-253 253 253 253 253 253 253 253 253 253 253 253
59955-253 253 253 253 253 253 231 231 231 246 246 246
59956-253 253 253 253 253 253 253 253 253 253 253 253
59957-253 253 253 253 253 253 253 253 253 253 253 253
59958-253 253 253 253 253 253 253 253 253 253 253 253
59959-253 253 253 253 253 253 253 253 253 253 253 253
59960-253 253 253 253 253 253 234 234 234 14 14 14
59961- 2 2 6 2 2 6 30 30 30 2 2 6
59962- 2 2 6 2 2 6 2 2 6 2 2 6
59963- 2 2 6 66 66 66 62 62 62 22 22 22
59964- 6 6 6 0 0 0 0 0 0 0 0 0
59965- 0 0 0 0 0 0 0 0 0 0 0 0
59966- 0 0 0 0 0 0 0 0 0 0 0 0
59967- 0 0 0 0 0 0 0 0 0 0 0 0
59968- 0 0 0 0 0 0 0 0 0 0 0 0
59969- 0 0 0 0 0 0 0 0 0 0 0 0
59970- 0 0 0 0 0 0 6 6 6 18 18 18
59971- 54 54 54 62 62 62 2 2 6 2 2 6
59972- 2 2 6 30 30 30 46 46 46 70 70 70
59973-250 250 250 253 253 253 253 253 253 253 253 253
59974-253 253 253 253 253 253 253 253 253 253 253 253
59975-253 253 253 253 253 253 231 231 231 246 246 246
59976-253 253 253 253 253 253 253 253 253 253 253 253
59977-253 253 253 253 253 253 253 253 253 253 253 253
59978-253 253 253 253 253 253 253 253 253 253 253 253
59979-253 253 253 253 253 253 253 253 253 253 253 253
59980-253 253 253 253 253 253 226 226 226 10 10 10
59981- 2 2 6 6 6 6 30 30 30 2 2 6
59982- 2 2 6 2 2 6 2 2 6 2 2 6
59983- 2 2 6 66 66 66 58 58 58 22 22 22
59984- 6 6 6 0 0 0 0 0 0 0 0 0
59985- 0 0 0 0 0 0 0 0 0 0 0 0
59986- 0 0 0 0 0 0 0 0 0 0 0 0
59987- 0 0 0 0 0 0 0 0 0 0 0 0
59988- 0 0 0 0 0 0 0 0 0 0 0 0
59989- 0 0 0 0 0 0 0 0 0 0 0 0
59990- 0 0 0 0 0 0 6 6 6 22 22 22
59991- 58 58 58 62 62 62 2 2 6 2 2 6
59992- 2 2 6 2 2 6 30 30 30 78 78 78
59993-250 250 250 253 253 253 253 253 253 253 253 253
59994-253 253 253 253 253 253 253 253 253 253 253 253
59995-253 253 253 253 253 253 231 231 231 246 246 246
59996-253 253 253 253 253 253 253 253 253 253 253 253
59997-253 253 253 253 253 253 253 253 253 253 253 253
59998-253 253 253 253 253 253 253 253 253 253 253 253
59999-253 253 253 253 253 253 253 253 253 253 253 253
60000-253 253 253 253 253 253 206 206 206 2 2 6
60001- 22 22 22 34 34 34 18 14 6 22 22 22
60002- 26 26 26 18 18 18 6 6 6 2 2 6
60003- 2 2 6 82 82 82 54 54 54 18 18 18
60004- 6 6 6 0 0 0 0 0 0 0 0 0
60005- 0 0 0 0 0 0 0 0 0 0 0 0
60006- 0 0 0 0 0 0 0 0 0 0 0 0
60007- 0 0 0 0 0 0 0 0 0 0 0 0
60008- 0 0 0 0 0 0 0 0 0 0 0 0
60009- 0 0 0 0 0 0 0 0 0 0 0 0
60010- 0 0 0 0 0 0 6 6 6 26 26 26
60011- 62 62 62 106 106 106 74 54 14 185 133 11
60012-210 162 10 121 92 8 6 6 6 62 62 62
60013-238 238 238 253 253 253 253 253 253 253 253 253
60014-253 253 253 253 253 253 253 253 253 253 253 253
60015-253 253 253 253 253 253 231 231 231 246 246 246
60016-253 253 253 253 253 253 253 253 253 253 253 253
60017-253 253 253 253 253 253 253 253 253 253 253 253
60018-253 253 253 253 253 253 253 253 253 253 253 253
60019-253 253 253 253 253 253 253 253 253 253 253 253
60020-253 253 253 253 253 253 158 158 158 18 18 18
60021- 14 14 14 2 2 6 2 2 6 2 2 6
60022- 6 6 6 18 18 18 66 66 66 38 38 38
60023- 6 6 6 94 94 94 50 50 50 18 18 18
60024- 6 6 6 0 0 0 0 0 0 0 0 0
60025- 0 0 0 0 0 0 0 0 0 0 0 0
60026- 0 0 0 0 0 0 0 0 0 0 0 0
60027- 0 0 0 0 0 0 0 0 0 0 0 0
60028- 0 0 0 0 0 0 0 0 0 0 0 0
60029- 0 0 0 0 0 0 0 0 0 6 6 6
60030- 10 10 10 10 10 10 18 18 18 38 38 38
60031- 78 78 78 142 134 106 216 158 10 242 186 14
60032-246 190 14 246 190 14 156 118 10 10 10 10
60033- 90 90 90 238 238 238 253 253 253 253 253 253
60034-253 253 253 253 253 253 253 253 253 253 253 253
60035-253 253 253 253 253 253 231 231 231 250 250 250
60036-253 253 253 253 253 253 253 253 253 253 253 253
60037-253 253 253 253 253 253 253 253 253 253 253 253
60038-253 253 253 253 253 253 253 253 253 253 253 253
60039-253 253 253 253 253 253 253 253 253 246 230 190
60040-238 204 91 238 204 91 181 142 44 37 26 9
60041- 2 2 6 2 2 6 2 2 6 2 2 6
60042- 2 2 6 2 2 6 38 38 38 46 46 46
60043- 26 26 26 106 106 106 54 54 54 18 18 18
60044- 6 6 6 0 0 0 0 0 0 0 0 0
60045- 0 0 0 0 0 0 0 0 0 0 0 0
60046- 0 0 0 0 0 0 0 0 0 0 0 0
60047- 0 0 0 0 0 0 0 0 0 0 0 0
60048- 0 0 0 0 0 0 0 0 0 0 0 0
60049- 0 0 0 6 6 6 14 14 14 22 22 22
60050- 30 30 30 38 38 38 50 50 50 70 70 70
60051-106 106 106 190 142 34 226 170 11 242 186 14
60052-246 190 14 246 190 14 246 190 14 154 114 10
60053- 6 6 6 74 74 74 226 226 226 253 253 253
60054-253 253 253 253 253 253 253 253 253 253 253 253
60055-253 253 253 253 253 253 231 231 231 250 250 250
60056-253 253 253 253 253 253 253 253 253 253 253 253
60057-253 253 253 253 253 253 253 253 253 253 253 253
60058-253 253 253 253 253 253 253 253 253 253 253 253
60059-253 253 253 253 253 253 253 253 253 228 184 62
60060-241 196 14 241 208 19 232 195 16 38 30 10
60061- 2 2 6 2 2 6 2 2 6 2 2 6
60062- 2 2 6 6 6 6 30 30 30 26 26 26
60063-203 166 17 154 142 90 66 66 66 26 26 26
60064- 6 6 6 0 0 0 0 0 0 0 0 0
60065- 0 0 0 0 0 0 0 0 0 0 0 0
60066- 0 0 0 0 0 0 0 0 0 0 0 0
60067- 0 0 0 0 0 0 0 0 0 0 0 0
60068- 0 0 0 0 0 0 0 0 0 0 0 0
60069- 6 6 6 18 18 18 38 38 38 58 58 58
60070- 78 78 78 86 86 86 101 101 101 123 123 123
60071-175 146 61 210 150 10 234 174 13 246 186 14
60072-246 190 14 246 190 14 246 190 14 238 190 10
60073-102 78 10 2 2 6 46 46 46 198 198 198
60074-253 253 253 253 253 253 253 253 253 253 253 253
60075-253 253 253 253 253 253 234 234 234 242 242 242
60076-253 253 253 253 253 253 253 253 253 253 253 253
60077-253 253 253 253 253 253 253 253 253 253 253 253
60078-253 253 253 253 253 253 253 253 253 253 253 253
60079-253 253 253 253 253 253 253 253 253 224 178 62
60080-242 186 14 241 196 14 210 166 10 22 18 6
60081- 2 2 6 2 2 6 2 2 6 2 2 6
60082- 2 2 6 2 2 6 6 6 6 121 92 8
60083-238 202 15 232 195 16 82 82 82 34 34 34
60084- 10 10 10 0 0 0 0 0 0 0 0 0
60085- 0 0 0 0 0 0 0 0 0 0 0 0
60086- 0 0 0 0 0 0 0 0 0 0 0 0
60087- 0 0 0 0 0 0 0 0 0 0 0 0
60088- 0 0 0 0 0 0 0 0 0 0 0 0
60089- 14 14 14 38 38 38 70 70 70 154 122 46
60090-190 142 34 200 144 11 197 138 11 197 138 11
60091-213 154 11 226 170 11 242 186 14 246 190 14
60092-246 190 14 246 190 14 246 190 14 246 190 14
60093-225 175 15 46 32 6 2 2 6 22 22 22
60094-158 158 158 250 250 250 253 253 253 253 253 253
60095-253 253 253 253 253 253 253 253 253 253 253 253
60096-253 253 253 253 253 253 253 253 253 253 253 253
60097-253 253 253 253 253 253 253 253 253 253 253 253
60098-253 253 253 253 253 253 253 253 253 253 253 253
60099-253 253 253 250 250 250 242 242 242 224 178 62
60100-239 182 13 236 186 11 213 154 11 46 32 6
60101- 2 2 6 2 2 6 2 2 6 2 2 6
60102- 2 2 6 2 2 6 61 42 6 225 175 15
60103-238 190 10 236 186 11 112 100 78 42 42 42
60104- 14 14 14 0 0 0 0 0 0 0 0 0
60105- 0 0 0 0 0 0 0 0 0 0 0 0
60106- 0 0 0 0 0 0 0 0 0 0 0 0
60107- 0 0 0 0 0 0 0 0 0 0 0 0
60108- 0 0 0 0 0 0 0 0 0 6 6 6
60109- 22 22 22 54 54 54 154 122 46 213 154 11
60110-226 170 11 230 174 11 226 170 11 226 170 11
60111-236 178 12 242 186 14 246 190 14 246 190 14
60112-246 190 14 246 190 14 246 190 14 246 190 14
60113-241 196 14 184 144 12 10 10 10 2 2 6
60114- 6 6 6 116 116 116 242 242 242 253 253 253
60115-253 253 253 253 253 253 253 253 253 253 253 253
60116-253 253 253 253 253 253 253 253 253 253 253 253
60117-253 253 253 253 253 253 253 253 253 253 253 253
60118-253 253 253 253 253 253 253 253 253 253 253 253
60119-253 253 253 231 231 231 198 198 198 214 170 54
60120-236 178 12 236 178 12 210 150 10 137 92 6
60121- 18 14 6 2 2 6 2 2 6 2 2 6
60122- 6 6 6 70 47 6 200 144 11 236 178 12
60123-239 182 13 239 182 13 124 112 88 58 58 58
60124- 22 22 22 6 6 6 0 0 0 0 0 0
60125- 0 0 0 0 0 0 0 0 0 0 0 0
60126- 0 0 0 0 0 0 0 0 0 0 0 0
60127- 0 0 0 0 0 0 0 0 0 0 0 0
60128- 0 0 0 0 0 0 0 0 0 10 10 10
60129- 30 30 30 70 70 70 180 133 36 226 170 11
60130-239 182 13 242 186 14 242 186 14 246 186 14
60131-246 190 14 246 190 14 246 190 14 246 190 14
60132-246 190 14 246 190 14 246 190 14 246 190 14
60133-246 190 14 232 195 16 98 70 6 2 2 6
60134- 2 2 6 2 2 6 66 66 66 221 221 221
60135-253 253 253 253 253 253 253 253 253 253 253 253
60136-253 253 253 253 253 253 253 253 253 253 253 253
60137-253 253 253 253 253 253 253 253 253 253 253 253
60138-253 253 253 253 253 253 253 253 253 253 253 253
60139-253 253 253 206 206 206 198 198 198 214 166 58
60140-230 174 11 230 174 11 216 158 10 192 133 9
60141-163 110 8 116 81 8 102 78 10 116 81 8
60142-167 114 7 197 138 11 226 170 11 239 182 13
60143-242 186 14 242 186 14 162 146 94 78 78 78
60144- 34 34 34 14 14 14 6 6 6 0 0 0
60145- 0 0 0 0 0 0 0 0 0 0 0 0
60146- 0 0 0 0 0 0 0 0 0 0 0 0
60147- 0 0 0 0 0 0 0 0 0 0 0 0
60148- 0 0 0 0 0 0 0 0 0 6 6 6
60149- 30 30 30 78 78 78 190 142 34 226 170 11
60150-239 182 13 246 190 14 246 190 14 246 190 14
60151-246 190 14 246 190 14 246 190 14 246 190 14
60152-246 190 14 246 190 14 246 190 14 246 190 14
60153-246 190 14 241 196 14 203 166 17 22 18 6
60154- 2 2 6 2 2 6 2 2 6 38 38 38
60155-218 218 218 253 253 253 253 253 253 253 253 253
60156-253 253 253 253 253 253 253 253 253 253 253 253
60157-253 253 253 253 253 253 253 253 253 253 253 253
60158-253 253 253 253 253 253 253 253 253 253 253 253
60159-250 250 250 206 206 206 198 198 198 202 162 69
60160-226 170 11 236 178 12 224 166 10 210 150 10
60161-200 144 11 197 138 11 192 133 9 197 138 11
60162-210 150 10 226 170 11 242 186 14 246 190 14
60163-246 190 14 246 186 14 225 175 15 124 112 88
60164- 62 62 62 30 30 30 14 14 14 6 6 6
60165- 0 0 0 0 0 0 0 0 0 0 0 0
60166- 0 0 0 0 0 0 0 0 0 0 0 0
60167- 0 0 0 0 0 0 0 0 0 0 0 0
60168- 0 0 0 0 0 0 0 0 0 10 10 10
60169- 30 30 30 78 78 78 174 135 50 224 166 10
60170-239 182 13 246 190 14 246 190 14 246 190 14
60171-246 190 14 246 190 14 246 190 14 246 190 14
60172-246 190 14 246 190 14 246 190 14 246 190 14
60173-246 190 14 246 190 14 241 196 14 139 102 15
60174- 2 2 6 2 2 6 2 2 6 2 2 6
60175- 78 78 78 250 250 250 253 253 253 253 253 253
60176-253 253 253 253 253 253 253 253 253 253 253 253
60177-253 253 253 253 253 253 253 253 253 253 253 253
60178-253 253 253 253 253 253 253 253 253 253 253 253
60179-250 250 250 214 214 214 198 198 198 190 150 46
60180-219 162 10 236 178 12 234 174 13 224 166 10
60181-216 158 10 213 154 11 213 154 11 216 158 10
60182-226 170 11 239 182 13 246 190 14 246 190 14
60183-246 190 14 246 190 14 242 186 14 206 162 42
60184-101 101 101 58 58 58 30 30 30 14 14 14
60185- 6 6 6 0 0 0 0 0 0 0 0 0
60186- 0 0 0 0 0 0 0 0 0 0 0 0
60187- 0 0 0 0 0 0 0 0 0 0 0 0
60188- 0 0 0 0 0 0 0 0 0 10 10 10
60189- 30 30 30 74 74 74 174 135 50 216 158 10
60190-236 178 12 246 190 14 246 190 14 246 190 14
60191-246 190 14 246 190 14 246 190 14 246 190 14
60192-246 190 14 246 190 14 246 190 14 246 190 14
60193-246 190 14 246 190 14 241 196 14 226 184 13
60194- 61 42 6 2 2 6 2 2 6 2 2 6
60195- 22 22 22 238 238 238 253 253 253 253 253 253
60196-253 253 253 253 253 253 253 253 253 253 253 253
60197-253 253 253 253 253 253 253 253 253 253 253 253
60198-253 253 253 253 253 253 253 253 253 253 253 253
60199-253 253 253 226 226 226 187 187 187 180 133 36
60200-216 158 10 236 178 12 239 182 13 236 178 12
60201-230 174 11 226 170 11 226 170 11 230 174 11
60202-236 178 12 242 186 14 246 190 14 246 190 14
60203-246 190 14 246 190 14 246 186 14 239 182 13
60204-206 162 42 106 106 106 66 66 66 34 34 34
60205- 14 14 14 6 6 6 0 0 0 0 0 0
60206- 0 0 0 0 0 0 0 0 0 0 0 0
60207- 0 0 0 0 0 0 0 0 0 0 0 0
60208- 0 0 0 0 0 0 0 0 0 6 6 6
60209- 26 26 26 70 70 70 163 133 67 213 154 11
60210-236 178 12 246 190 14 246 190 14 246 190 14
60211-246 190 14 246 190 14 246 190 14 246 190 14
60212-246 190 14 246 190 14 246 190 14 246 190 14
60213-246 190 14 246 190 14 246 190 14 241 196 14
60214-190 146 13 18 14 6 2 2 6 2 2 6
60215- 46 46 46 246 246 246 253 253 253 253 253 253
60216-253 253 253 253 253 253 253 253 253 253 253 253
60217-253 253 253 253 253 253 253 253 253 253 253 253
60218-253 253 253 253 253 253 253 253 253 253 253 253
60219-253 253 253 221 221 221 86 86 86 156 107 11
60220-216 158 10 236 178 12 242 186 14 246 186 14
60221-242 186 14 239 182 13 239 182 13 242 186 14
60222-242 186 14 246 186 14 246 190 14 246 190 14
60223-246 190 14 246 190 14 246 190 14 246 190 14
60224-242 186 14 225 175 15 142 122 72 66 66 66
60225- 30 30 30 10 10 10 0 0 0 0 0 0
60226- 0 0 0 0 0 0 0 0 0 0 0 0
60227- 0 0 0 0 0 0 0 0 0 0 0 0
60228- 0 0 0 0 0 0 0 0 0 6 6 6
60229- 26 26 26 70 70 70 163 133 67 210 150 10
60230-236 178 12 246 190 14 246 190 14 246 190 14
60231-246 190 14 246 190 14 246 190 14 246 190 14
60232-246 190 14 246 190 14 246 190 14 246 190 14
60233-246 190 14 246 190 14 246 190 14 246 190 14
60234-232 195 16 121 92 8 34 34 34 106 106 106
60235-221 221 221 253 253 253 253 253 253 253 253 253
60236-253 253 253 253 253 253 253 253 253 253 253 253
60237-253 253 253 253 253 253 253 253 253 253 253 253
60238-253 253 253 253 253 253 253 253 253 253 253 253
60239-242 242 242 82 82 82 18 14 6 163 110 8
60240-216 158 10 236 178 12 242 186 14 246 190 14
60241-246 190 14 246 190 14 246 190 14 246 190 14
60242-246 190 14 246 190 14 246 190 14 246 190 14
60243-246 190 14 246 190 14 246 190 14 246 190 14
60244-246 190 14 246 190 14 242 186 14 163 133 67
60245- 46 46 46 18 18 18 6 6 6 0 0 0
60246- 0 0 0 0 0 0 0 0 0 0 0 0
60247- 0 0 0 0 0 0 0 0 0 0 0 0
60248- 0 0 0 0 0 0 0 0 0 10 10 10
60249- 30 30 30 78 78 78 163 133 67 210 150 10
60250-236 178 12 246 186 14 246 190 14 246 190 14
60251-246 190 14 246 190 14 246 190 14 246 190 14
60252-246 190 14 246 190 14 246 190 14 246 190 14
60253-246 190 14 246 190 14 246 190 14 246 190 14
60254-241 196 14 215 174 15 190 178 144 253 253 253
60255-253 253 253 253 253 253 253 253 253 253 253 253
60256-253 253 253 253 253 253 253 253 253 253 253 253
60257-253 253 253 253 253 253 253 253 253 253 253 253
60258-253 253 253 253 253 253 253 253 253 218 218 218
60259- 58 58 58 2 2 6 22 18 6 167 114 7
60260-216 158 10 236 178 12 246 186 14 246 190 14
60261-246 190 14 246 190 14 246 190 14 246 190 14
60262-246 190 14 246 190 14 246 190 14 246 190 14
60263-246 190 14 246 190 14 246 190 14 246 190 14
60264-246 190 14 246 186 14 242 186 14 190 150 46
60265- 54 54 54 22 22 22 6 6 6 0 0 0
60266- 0 0 0 0 0 0 0 0 0 0 0 0
60267- 0 0 0 0 0 0 0 0 0 0 0 0
60268- 0 0 0 0 0 0 0 0 0 14 14 14
60269- 38 38 38 86 86 86 180 133 36 213 154 11
60270-236 178 12 246 186 14 246 190 14 246 190 14
60271-246 190 14 246 190 14 246 190 14 246 190 14
60272-246 190 14 246 190 14 246 190 14 246 190 14
60273-246 190 14 246 190 14 246 190 14 246 190 14
60274-246 190 14 232 195 16 190 146 13 214 214 214
60275-253 253 253 253 253 253 253 253 253 253 253 253
60276-253 253 253 253 253 253 253 253 253 253 253 253
60277-253 253 253 253 253 253 253 253 253 253 253 253
60278-253 253 253 250 250 250 170 170 170 26 26 26
60279- 2 2 6 2 2 6 37 26 9 163 110 8
60280-219 162 10 239 182 13 246 186 14 246 190 14
60281-246 190 14 246 190 14 246 190 14 246 190 14
60282-246 190 14 246 190 14 246 190 14 246 190 14
60283-246 190 14 246 190 14 246 190 14 246 190 14
60284-246 186 14 236 178 12 224 166 10 142 122 72
60285- 46 46 46 18 18 18 6 6 6 0 0 0
60286- 0 0 0 0 0 0 0 0 0 0 0 0
60287- 0 0 0 0 0 0 0 0 0 0 0 0
60288- 0 0 0 0 0 0 6 6 6 18 18 18
60289- 50 50 50 109 106 95 192 133 9 224 166 10
60290-242 186 14 246 190 14 246 190 14 246 190 14
60291-246 190 14 246 190 14 246 190 14 246 190 14
60292-246 190 14 246 190 14 246 190 14 246 190 14
60293-246 190 14 246 190 14 246 190 14 246 190 14
60294-242 186 14 226 184 13 210 162 10 142 110 46
60295-226 226 226 253 253 253 253 253 253 253 253 253
60296-253 253 253 253 253 253 253 253 253 253 253 253
60297-253 253 253 253 253 253 253 253 253 253 253 253
60298-198 198 198 66 66 66 2 2 6 2 2 6
60299- 2 2 6 2 2 6 50 34 6 156 107 11
60300-219 162 10 239 182 13 246 186 14 246 190 14
60301-246 190 14 246 190 14 246 190 14 246 190 14
60302-246 190 14 246 190 14 246 190 14 246 190 14
60303-246 190 14 246 190 14 246 190 14 242 186 14
60304-234 174 13 213 154 11 154 122 46 66 66 66
60305- 30 30 30 10 10 10 0 0 0 0 0 0
60306- 0 0 0 0 0 0 0 0 0 0 0 0
60307- 0 0 0 0 0 0 0 0 0 0 0 0
60308- 0 0 0 0 0 0 6 6 6 22 22 22
60309- 58 58 58 154 121 60 206 145 10 234 174 13
60310-242 186 14 246 186 14 246 190 14 246 190 14
60311-246 190 14 246 190 14 246 190 14 246 190 14
60312-246 190 14 246 190 14 246 190 14 246 190 14
60313-246 190 14 246 190 14 246 190 14 246 190 14
60314-246 186 14 236 178 12 210 162 10 163 110 8
60315- 61 42 6 138 138 138 218 218 218 250 250 250
60316-253 253 253 253 253 253 253 253 253 250 250 250
60317-242 242 242 210 210 210 144 144 144 66 66 66
60318- 6 6 6 2 2 6 2 2 6 2 2 6
60319- 2 2 6 2 2 6 61 42 6 163 110 8
60320-216 158 10 236 178 12 246 190 14 246 190 14
60321-246 190 14 246 190 14 246 190 14 246 190 14
60322-246 190 14 246 190 14 246 190 14 246 190 14
60323-246 190 14 239 182 13 230 174 11 216 158 10
60324-190 142 34 124 112 88 70 70 70 38 38 38
60325- 18 18 18 6 6 6 0 0 0 0 0 0
60326- 0 0 0 0 0 0 0 0 0 0 0 0
60327- 0 0 0 0 0 0 0 0 0 0 0 0
60328- 0 0 0 0 0 0 6 6 6 22 22 22
60329- 62 62 62 168 124 44 206 145 10 224 166 10
60330-236 178 12 239 182 13 242 186 14 242 186 14
60331-246 186 14 246 190 14 246 190 14 246 190 14
60332-246 190 14 246 190 14 246 190 14 246 190 14
60333-246 190 14 246 190 14 246 190 14 246 190 14
60334-246 190 14 236 178 12 216 158 10 175 118 6
60335- 80 54 7 2 2 6 6 6 6 30 30 30
60336- 54 54 54 62 62 62 50 50 50 38 38 38
60337- 14 14 14 2 2 6 2 2 6 2 2 6
60338- 2 2 6 2 2 6 2 2 6 2 2 6
60339- 2 2 6 6 6 6 80 54 7 167 114 7
60340-213 154 11 236 178 12 246 190 14 246 190 14
60341-246 190 14 246 190 14 246 190 14 246 190 14
60342-246 190 14 242 186 14 239 182 13 239 182 13
60343-230 174 11 210 150 10 174 135 50 124 112 88
60344- 82 82 82 54 54 54 34 34 34 18 18 18
60345- 6 6 6 0 0 0 0 0 0 0 0 0
60346- 0 0 0 0 0 0 0 0 0 0 0 0
60347- 0 0 0 0 0 0 0 0 0 0 0 0
60348- 0 0 0 0 0 0 6 6 6 18 18 18
60349- 50 50 50 158 118 36 192 133 9 200 144 11
60350-216 158 10 219 162 10 224 166 10 226 170 11
60351-230 174 11 236 178 12 239 182 13 239 182 13
60352-242 186 14 246 186 14 246 190 14 246 190 14
60353-246 190 14 246 190 14 246 190 14 246 190 14
60354-246 186 14 230 174 11 210 150 10 163 110 8
60355-104 69 6 10 10 10 2 2 6 2 2 6
60356- 2 2 6 2 2 6 2 2 6 2 2 6
60357- 2 2 6 2 2 6 2 2 6 2 2 6
60358- 2 2 6 2 2 6 2 2 6 2 2 6
60359- 2 2 6 6 6 6 91 60 6 167 114 7
60360-206 145 10 230 174 11 242 186 14 246 190 14
60361-246 190 14 246 190 14 246 186 14 242 186 14
60362-239 182 13 230 174 11 224 166 10 213 154 11
60363-180 133 36 124 112 88 86 86 86 58 58 58
60364- 38 38 38 22 22 22 10 10 10 6 6 6
60365- 0 0 0 0 0 0 0 0 0 0 0 0
60366- 0 0 0 0 0 0 0 0 0 0 0 0
60367- 0 0 0 0 0 0 0 0 0 0 0 0
60368- 0 0 0 0 0 0 0 0 0 14 14 14
60369- 34 34 34 70 70 70 138 110 50 158 118 36
60370-167 114 7 180 123 7 192 133 9 197 138 11
60371-200 144 11 206 145 10 213 154 11 219 162 10
60372-224 166 10 230 174 11 239 182 13 242 186 14
60373-246 186 14 246 186 14 246 186 14 246 186 14
60374-239 182 13 216 158 10 185 133 11 152 99 6
60375-104 69 6 18 14 6 2 2 6 2 2 6
60376- 2 2 6 2 2 6 2 2 6 2 2 6
60377- 2 2 6 2 2 6 2 2 6 2 2 6
60378- 2 2 6 2 2 6 2 2 6 2 2 6
60379- 2 2 6 6 6 6 80 54 7 152 99 6
60380-192 133 9 219 162 10 236 178 12 239 182 13
60381-246 186 14 242 186 14 239 182 13 236 178 12
60382-224 166 10 206 145 10 192 133 9 154 121 60
60383- 94 94 94 62 62 62 42 42 42 22 22 22
60384- 14 14 14 6 6 6 0 0 0 0 0 0
60385- 0 0 0 0 0 0 0 0 0 0 0 0
60386- 0 0 0 0 0 0 0 0 0 0 0 0
60387- 0 0 0 0 0 0 0 0 0 0 0 0
60388- 0 0 0 0 0 0 0 0 0 6 6 6
60389- 18 18 18 34 34 34 58 58 58 78 78 78
60390-101 98 89 124 112 88 142 110 46 156 107 11
60391-163 110 8 167 114 7 175 118 6 180 123 7
60392-185 133 11 197 138 11 210 150 10 219 162 10
60393-226 170 11 236 178 12 236 178 12 234 174 13
60394-219 162 10 197 138 11 163 110 8 130 83 6
60395- 91 60 6 10 10 10 2 2 6 2 2 6
60396- 18 18 18 38 38 38 38 38 38 38 38 38
60397- 38 38 38 38 38 38 38 38 38 38 38 38
60398- 38 38 38 38 38 38 26 26 26 2 2 6
60399- 2 2 6 6 6 6 70 47 6 137 92 6
60400-175 118 6 200 144 11 219 162 10 230 174 11
60401-234 174 13 230 174 11 219 162 10 210 150 10
60402-192 133 9 163 110 8 124 112 88 82 82 82
60403- 50 50 50 30 30 30 14 14 14 6 6 6
60404- 0 0 0 0 0 0 0 0 0 0 0 0
60405- 0 0 0 0 0 0 0 0 0 0 0 0
60406- 0 0 0 0 0 0 0 0 0 0 0 0
60407- 0 0 0 0 0 0 0 0 0 0 0 0
60408- 0 0 0 0 0 0 0 0 0 0 0 0
60409- 6 6 6 14 14 14 22 22 22 34 34 34
60410- 42 42 42 58 58 58 74 74 74 86 86 86
60411-101 98 89 122 102 70 130 98 46 121 87 25
60412-137 92 6 152 99 6 163 110 8 180 123 7
60413-185 133 11 197 138 11 206 145 10 200 144 11
60414-180 123 7 156 107 11 130 83 6 104 69 6
60415- 50 34 6 54 54 54 110 110 110 101 98 89
60416- 86 86 86 82 82 82 78 78 78 78 78 78
60417- 78 78 78 78 78 78 78 78 78 78 78 78
60418- 78 78 78 82 82 82 86 86 86 94 94 94
60419-106 106 106 101 101 101 86 66 34 124 80 6
60420-156 107 11 180 123 7 192 133 9 200 144 11
60421-206 145 10 200 144 11 192 133 9 175 118 6
60422-139 102 15 109 106 95 70 70 70 42 42 42
60423- 22 22 22 10 10 10 0 0 0 0 0 0
60424- 0 0 0 0 0 0 0 0 0 0 0 0
60425- 0 0 0 0 0 0 0 0 0 0 0 0
60426- 0 0 0 0 0 0 0 0 0 0 0 0
60427- 0 0 0 0 0 0 0 0 0 0 0 0
60428- 0 0 0 0 0 0 0 0 0 0 0 0
60429- 0 0 0 0 0 0 6 6 6 10 10 10
60430- 14 14 14 22 22 22 30 30 30 38 38 38
60431- 50 50 50 62 62 62 74 74 74 90 90 90
60432-101 98 89 112 100 78 121 87 25 124 80 6
60433-137 92 6 152 99 6 152 99 6 152 99 6
60434-138 86 6 124 80 6 98 70 6 86 66 30
60435-101 98 89 82 82 82 58 58 58 46 46 46
60436- 38 38 38 34 34 34 34 34 34 34 34 34
60437- 34 34 34 34 34 34 34 34 34 34 34 34
60438- 34 34 34 34 34 34 38 38 38 42 42 42
60439- 54 54 54 82 82 82 94 86 76 91 60 6
60440-134 86 6 156 107 11 167 114 7 175 118 6
60441-175 118 6 167 114 7 152 99 6 121 87 25
60442-101 98 89 62 62 62 34 34 34 18 18 18
60443- 6 6 6 0 0 0 0 0 0 0 0 0
60444- 0 0 0 0 0 0 0 0 0 0 0 0
60445- 0 0 0 0 0 0 0 0 0 0 0 0
60446- 0 0 0 0 0 0 0 0 0 0 0 0
60447- 0 0 0 0 0 0 0 0 0 0 0 0
60448- 0 0 0 0 0 0 0 0 0 0 0 0
60449- 0 0 0 0 0 0 0 0 0 0 0 0
60450- 0 0 0 6 6 6 6 6 6 10 10 10
60451- 18 18 18 22 22 22 30 30 30 42 42 42
60452- 50 50 50 66 66 66 86 86 86 101 98 89
60453-106 86 58 98 70 6 104 69 6 104 69 6
60454-104 69 6 91 60 6 82 62 34 90 90 90
60455- 62 62 62 38 38 38 22 22 22 14 14 14
60456- 10 10 10 10 10 10 10 10 10 10 10 10
60457- 10 10 10 10 10 10 6 6 6 10 10 10
60458- 10 10 10 10 10 10 10 10 10 14 14 14
60459- 22 22 22 42 42 42 70 70 70 89 81 66
60460- 80 54 7 104 69 6 124 80 6 137 92 6
60461-134 86 6 116 81 8 100 82 52 86 86 86
60462- 58 58 58 30 30 30 14 14 14 6 6 6
60463- 0 0 0 0 0 0 0 0 0 0 0 0
60464- 0 0 0 0 0 0 0 0 0 0 0 0
60465- 0 0 0 0 0 0 0 0 0 0 0 0
60466- 0 0 0 0 0 0 0 0 0 0 0 0
60467- 0 0 0 0 0 0 0 0 0 0 0 0
60468- 0 0 0 0 0 0 0 0 0 0 0 0
60469- 0 0 0 0 0 0 0 0 0 0 0 0
60470- 0 0 0 0 0 0 0 0 0 0 0 0
60471- 0 0 0 6 6 6 10 10 10 14 14 14
60472- 18 18 18 26 26 26 38 38 38 54 54 54
60473- 70 70 70 86 86 86 94 86 76 89 81 66
60474- 89 81 66 86 86 86 74 74 74 50 50 50
60475- 30 30 30 14 14 14 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 0 0 0 0 0 0
60479- 6 6 6 18 18 18 34 34 34 58 58 58
60480- 82 82 82 89 81 66 89 81 66 89 81 66
60481- 94 86 66 94 86 76 74 74 74 50 50 50
60482- 26 26 26 14 14 14 6 6 6 0 0 0
60483- 0 0 0 0 0 0 0 0 0 0 0 0
60484- 0 0 0 0 0 0 0 0 0 0 0 0
60485- 0 0 0 0 0 0 0 0 0 0 0 0
60486- 0 0 0 0 0 0 0 0 0 0 0 0
60487- 0 0 0 0 0 0 0 0 0 0 0 0
60488- 0 0 0 0 0 0 0 0 0 0 0 0
60489- 0 0 0 0 0 0 0 0 0 0 0 0
60490- 0 0 0 0 0 0 0 0 0 0 0 0
60491- 0 0 0 0 0 0 0 0 0 0 0 0
60492- 6 6 6 6 6 6 14 14 14 18 18 18
60493- 30 30 30 38 38 38 46 46 46 54 54 54
60494- 50 50 50 42 42 42 30 30 30 18 18 18
60495- 10 10 10 0 0 0 0 0 0 0 0 0
60496- 0 0 0 0 0 0 0 0 0 0 0 0
60497- 0 0 0 0 0 0 0 0 0 0 0 0
60498- 0 0 0 0 0 0 0 0 0 0 0 0
60499- 0 0 0 6 6 6 14 14 14 26 26 26
60500- 38 38 38 50 50 50 58 58 58 58 58 58
60501- 54 54 54 42 42 42 30 30 30 18 18 18
60502- 10 10 10 0 0 0 0 0 0 0 0 0
60503- 0 0 0 0 0 0 0 0 0 0 0 0
60504- 0 0 0 0 0 0 0 0 0 0 0 0
60505- 0 0 0 0 0 0 0 0 0 0 0 0
60506- 0 0 0 0 0 0 0 0 0 0 0 0
60507- 0 0 0 0 0 0 0 0 0 0 0 0
60508- 0 0 0 0 0 0 0 0 0 0 0 0
60509- 0 0 0 0 0 0 0 0 0 0 0 0
60510- 0 0 0 0 0 0 0 0 0 0 0 0
60511- 0 0 0 0 0 0 0 0 0 0 0 0
60512- 0 0 0 0 0 0 0 0 0 6 6 6
60513- 6 6 6 10 10 10 14 14 14 18 18 18
60514- 18 18 18 14 14 14 10 10 10 6 6 6
60515- 0 0 0 0 0 0 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 0 0 0 0 0 0
60519- 0 0 0 0 0 0 0 0 0 6 6 6
60520- 14 14 14 18 18 18 22 22 22 22 22 22
60521- 18 18 18 14 14 14 10 10 10 6 6 6
60522- 0 0 0 0 0 0 0 0 0 0 0 0
60523- 0 0 0 0 0 0 0 0 0 0 0 0
60524- 0 0 0 0 0 0 0 0 0 0 0 0
60525- 0 0 0 0 0 0 0 0 0 0 0 0
60526- 0 0 0 0 0 0 0 0 0 0 0 0
60527+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60528+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60529+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60530+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60531+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60532+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60533+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60534+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60535+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60536+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60537+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60538+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60539+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60540+4 4 4 4 4 4
60541+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60542+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60543+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60544+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60545+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60546+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60547+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60548+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60549+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60550+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60551+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60552+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60553+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60554+4 4 4 4 4 4
60555+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60556+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60557+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60558+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60559+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60560+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60561+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60562+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60563+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60564+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60565+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60566+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60567+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60568+4 4 4 4 4 4
60569+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60570+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60571+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60572+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60573+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60574+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60575+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60576+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60577+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60578+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60579+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60580+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60581+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60582+4 4 4 4 4 4
60583+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60584+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60585+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60586+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60587+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60588+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60589+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60590+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60591+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60592+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60593+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60594+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60595+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60596+4 4 4 4 4 4
60597+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60598+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60599+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60600+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60601+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60602+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60603+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60604+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60605+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60606+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60607+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60608+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60609+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60610+4 4 4 4 4 4
60611+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60612+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60613+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60614+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60615+4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
60616+0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
60617+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60618+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60619+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60620+4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
60621+0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
60622+4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
60623+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60624+4 4 4 4 4 4
60625+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60626+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60627+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60628+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60629+4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
60630+37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
60631+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60632+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60633+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60634+4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
60635+2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
60636+4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
60637+1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60638+4 4 4 4 4 4
60639+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60640+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60641+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60642+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60643+2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
60644+153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
60645+0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
60646+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60647+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60648+4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
60649+60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
60650+4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
60651+2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
60652+4 4 4 4 4 4
60653+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60654+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60655+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60656+4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
60657+4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
60658+165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
60659+1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
60660+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60661+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
60662+3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
60663+163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
60664+0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
60665+37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
60666+4 4 4 4 4 4
60667+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60668+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60669+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60670+4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
60671+37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
60672+156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
60673+125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
60674+5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
60675+4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
60676+0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
60677+174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
60678+0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
60679+64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
60680+4 4 4 4 4 4
60681+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60682+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60683+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
60684+5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
60685+156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
60686+156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
60687+174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
60688+1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
60689+4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
60690+13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
60691+174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
60692+22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
60693+90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
60694+4 4 4 4 4 4
60695+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60696+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60697+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
60698+0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
60699+174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
60700+156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
60701+163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
60702+4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
60703+5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
60704+131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
60705+190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
60706+90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
60707+31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
60708+4 4 4 4 4 4
60709+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60710+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60711+4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
60712+4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
60713+155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
60714+167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
60715+153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
60716+41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
60717+1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
60718+177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
60719+125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
60720+136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
60721+7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
60722+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 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
60726+125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
60727+156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
60728+137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
60729+156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
60730+167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
60731+0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
60732+166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
60733+6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
60734+90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
60735+1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
60736+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+1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
60740+167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
60741+157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
60742+26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
60743+158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
60744+165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
60745+60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
60746+137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
60747+52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
60748+13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
60749+4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
60750+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 3 3 3 0 0 0
60753+0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
60754+158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
60755+167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
60756+4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
60757+174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
60758+155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
60759+137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
60760+16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
60761+136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
60762+2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
60763+4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
60764+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 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
60767+37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
60768+157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
60769+153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
60770+4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
60771+125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
60772+156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
60773+174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
60774+4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
60775+136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
60776+1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
60777+2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
60778+0 0 0 4 4 4
60779+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
60780+4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
60781+158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
60782+153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
60783+37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
60784+4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
60785+4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
60786+154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
60787+174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
60788+32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
60789+28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
60790+50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
60791+0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
60792+2 0 0 0 0 0
60793+4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
60794+0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
60795+174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
60796+165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
60797+4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
60798+4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
60799+4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
60800+174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
60801+60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
60802+136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
60803+22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
60804+136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
60805+26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
60806+37 38 37 0 0 0
60807+4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
60808+13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
60809+153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
60810+177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
60811+4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
60812+5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
60813+6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
60814+166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
60815+4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
60816+146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
60817+71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
60818+90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
60819+125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
60820+85 115 134 4 0 0
60821+4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
60822+125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
60823+155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
60824+125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
60825+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
60826+0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
60827+5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
60828+37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
60829+4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
60830+90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
60831+2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
60832+13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
60833+166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
60834+60 73 81 4 0 0
60835+4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
60836+174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
60837+156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
60838+4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
60839+4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
60840+10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
60841+4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
60842+4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
60843+80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
60844+28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
60845+50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
60846+1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
60847+167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
60848+16 19 21 4 0 0
60849+4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
60850+158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
60851+167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
60852+4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
60853+4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
60854+80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
60855+4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
60856+3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
60857+146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
60858+68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
60859+136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
60860+24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
60861+163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
60862+4 0 0 4 3 3
60863+3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
60864+156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
60865+155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
60866+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
60867+2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
60868+136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
60869+0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
60870+0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
60871+136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
60872+28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
60873+22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
60874+137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
60875+60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
60876+3 2 2 4 4 4
60877+3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
60878+157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
60879+37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
60880+4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
60881+0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
60882+101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
60883+14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
60884+22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
60885+136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
60886+17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
60887+2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
60888+166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
60889+13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
60890+4 4 4 4 4 4
60891+1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
60892+163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
60893+4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
60894+4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
60895+40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
60896+101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
60897+101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
60898+136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
60899+136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
60900+136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
60901+3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
60902+174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
60903+4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
60904+4 4 4 4 4 4
60905+4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
60906+155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
60907+4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
60908+4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
60909+101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
60910+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
60911+136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
60912+136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
60913+136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
60914+90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
60915+85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
60916+167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
60917+6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
60918+5 5 5 5 5 5
60919+1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
60920+131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
60921+6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
60922+0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
60923+101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
60924+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
60925+101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
60926+136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
60927+101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
60928+7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
60929+174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
60930+24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
60931+4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
60932+5 5 5 4 4 4
60933+4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
60934+131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
60935+6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
60936+13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
60937+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
60938+101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
60939+101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
60940+136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
60941+136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
60942+2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
60943+174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
60944+4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
60945+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60946+4 4 4 4 4 4
60947+1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
60948+137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
60949+4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
60950+64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
60951+90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
60952+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
60953+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
60954+136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
60955+101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
60956+37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
60957+167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
60958+3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
60959+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60960+4 4 4 4 4 4
60961+4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
60962+153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
60963+4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
60964+90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
60965+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
60966+90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
60967+101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
60968+101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
60969+35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
60970+154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
60971+60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
60972+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60973+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60974+4 4 4 4 4 4
60975+1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
60976+153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
60977+4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
60978+64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
60979+64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
60980+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
60981+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
60982+136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
60983+13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
60984+174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
60985+6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
60986+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60987+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60988+4 4 4 4 4 4
60989+4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
60990+156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
60991+4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
60992+90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
60993+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
60994+90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
60995+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
60996+101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
60997+2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
60998+174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
60999+4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61000+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61001+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61002+4 4 4 4 4 4
61003+3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
61004+158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
61005+4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
61006+37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
61007+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
61008+90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
61009+101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
61010+90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
61011+5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
61012+167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
61013+6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
61014+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61015+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61016+4 4 4 4 4 4
61017+4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
61018+163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
61019+4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
61020+18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
61021+64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
61022+90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
61023+101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
61024+13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
61025+3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
61026+174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
61027+4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
61028+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61029+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61030+4 4 4 4 4 4
61031+1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
61032+167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
61033+4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
61034+18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
61035+26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
61036+90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
61037+101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
61038+7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
61039+4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
61040+174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
61041+4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61042+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61043+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61044+4 4 4 4 4 4
61045+4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
61046+174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
61047+5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
61048+18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
61049+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61050+90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
61051+101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
61052+2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
61053+3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
61054+153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
61055+4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61056+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61057+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61058+4 4 4 4 4 4
61059+1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
61060+174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
61061+5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
61062+18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
61063+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61064+26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
61065+35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
61066+2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
61067+3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
61068+131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
61069+4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61070+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61071+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61072+4 4 4 4 4 4
61073+3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
61074+174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
61075+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
61076+18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
61077+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61078+26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
61079+7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
61080+4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
61081+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
61082+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61083+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61084+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61085+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61086+4 4 4 4 4 4
61087+1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
61088+174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
61089+5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
61090+18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
61091+18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
61092+26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
61093+28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
61094+3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
61095+4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61096+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61097+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61098+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61099+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61100+4 4 4 4 4 4
61101+4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
61102+174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
61103+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
61104+10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
61105+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61106+18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
61107+90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
61108+3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
61109+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
61110+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61111+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61112+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61113+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61114+4 4 4 4 4 4
61115+1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
61116+177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
61117+5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
61118+10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
61119+26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
61120+6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
61121+10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
61122+2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
61123+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61124+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61125+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61126+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61127+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61128+4 4 4 4 4 4
61129+4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
61130+177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
61131+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
61132+10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
61133+26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
61134+7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
61135+3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
61136+21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
61137+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
61138+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61139+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61140+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61141+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61142+4 4 4 4 4 4
61143+3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
61144+190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
61145+5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
61146+10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
61147+24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
61148+18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
61149+28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
61150+26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
61151+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61152+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61153+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61154+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61155+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61156+4 4 4 4 4 4
61157+4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
61158+190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
61159+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
61160+10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
61161+0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
61162+26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
61163+37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
61164+90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
61165+4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
61166+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61167+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61168+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61169+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61170+4 4 4 4 4 4
61171+4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
61172+193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
61173+5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
61174+10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
61175+1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
61176+26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
61177+22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
61178+26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
61179+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61180+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61181+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61182+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61183+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61184+4 4 4 4 4 4
61185+4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
61186+190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
61187+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
61188+10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
61189+2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
61190+26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
61191+10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
61192+26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
61193+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
61194+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61195+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61196+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61197+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61198+4 4 4 4 4 4
61199+4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
61200+193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
61201+5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
61202+10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
61203+13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
61204+10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
61205+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61206+26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
61207+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61208+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61209+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61210+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61211+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61212+4 4 4 4 4 4
61213+4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
61214+190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
61215+5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
61216+28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
61217+10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
61218+28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
61219+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61220+26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
61221+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
61222+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61223+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61224+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61225+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61226+4 4 4 4 4 4
61227+4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
61228+193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
61229+5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
61230+4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
61231+10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
61232+10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
61233+18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
61234+22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
61235+4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
61236+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61237+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61238+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61239+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61240+4 4 4 4 4 4
61241+4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
61242+190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
61243+6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
61244+1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
61245+18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
61246+10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
61247+26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
61248+1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
61249+5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
61250+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61251+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61252+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61253+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61254+4 4 4 4 4 4
61255+4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
61256+193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
61257+2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
61258+4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
61259+10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
61260+10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
61261+26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
61262+2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
61263+3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
61264+131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61265+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61266+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61267+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61268+4 4 4 4 4 4
61269+4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
61270+193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
61271+0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
61272+4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
61273+13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
61274+10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
61275+28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
61276+4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
61277+0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
61278+125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61279+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61280+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61281+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61282+4 4 4 4 4 4
61283+4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
61284+193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
61285+120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
61286+4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
61287+4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
61288+10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
61289+4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
61290+4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
61291+24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
61292+125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
61293+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61294+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61295+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61296+4 4 4 4 4 4
61297+4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
61298+174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
61299+220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
61300+3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
61301+4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
61302+10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
61303+1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
61304+5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
61305+137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
61306+125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
61307+0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61308+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61309+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61310+4 4 4 4 4 4
61311+5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
61312+193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
61313+220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
61314+4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
61315+4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
61316+22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
61317+4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61318+1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
61319+166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
61320+125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
61321+4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
61322+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61323+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61324+4 4 4 4 4 4
61325+4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
61326+220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
61327+205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
61328+24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
61329+4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
61330+4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
61331+4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
61332+2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
61333+156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
61334+137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
61335+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61336+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61337+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61338+4 4 4 4 4 4
61339+5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
61340+125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
61341+205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
61342+193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
61343+5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
61344+1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
61345+5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
61346+60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
61347+153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
61348+125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
61349+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61350+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61351+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61352+4 4 4 4 4 4
61353+4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
61354+6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
61355+193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
61356+244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
61357+0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
61358+4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
61359+3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
61360+220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
61361+153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
61362+13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
61363+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61364+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61365+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61366+4 4 4 4 4 4
61367+5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
61368+6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
61369+244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
61370+220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
61371+3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
61372+4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
61373+0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
61374+177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
61375+158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
61376+4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
61377+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61378+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61379+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61380+4 4 4 4 4 4
61381+5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
61382+6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
61383+177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
61384+220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
61385+125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
61386+4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
61387+37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
61388+174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
61389+158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
61390+4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
61391+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61392+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61393+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61394+4 4 4 4 4 4
61395+4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
61396+4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
61397+26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
61398+205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
61399+244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
61400+0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
61401+177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
61402+174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
61403+60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
61404+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61405+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61406+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61407+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61408+4 4 4 4 4 4
61409+5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
61410+6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
61411+6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
61412+220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
61413+220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
61414+0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
61415+220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
61416+174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
61417+4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
61418+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61419+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61420+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61421+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61422+4 4 4 4 4 4
61423+4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
61424+6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
61425+4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
61426+220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
61427+205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
61428+60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
61429+177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
61430+190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
61431+4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61432+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61433+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61434+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61435+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61436+4 4 4 4 4 4
61437+4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
61438+4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
61439+6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
61440+125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
61441+205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
61442+193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
61443+190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
61444+153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
61445+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61446+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61447+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61448+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61449+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61450+4 4 4 4 4 4
61451+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
61452+6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
61453+4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
61454+4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
61455+205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
61456+220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
61457+174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
61458+6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
61459+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61460+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61461+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61462+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61463+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61464+4 4 4 4 4 4
61465+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
61466+5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
61467+6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
61468+4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
61469+220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
61470+190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
61471+193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
61472+4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
61473+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61474+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61475+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61476+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61477+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61478+4 4 4 4 4 4
61479+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61480+4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
61481+4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
61482+6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
61483+174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
61484+193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
61485+193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
61486+6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
61487+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61488+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61489+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61490+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61491+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61492+4 4 4 4 4 4
61493+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61494+4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
61495+5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
61496+5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
61497+6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
61498+193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
61499+60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
61500+5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
61501+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61502+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61503+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61504+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61505+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61506+4 4 4 4 4 4
61507+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61508+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61509+4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
61510+5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
61511+4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
61512+193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
61513+6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
61514+4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
61515+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61516+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61517+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61518+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61519+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61520+4 4 4 4 4 4
61521+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61522+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61523+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
61524+4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
61525+6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
61526+153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
61527+6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
61528+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61529+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61530+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61531+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61532+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61533+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61534+4 4 4 4 4 4
61535+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61536+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61537+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61538+4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
61539+6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
61540+24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
61541+6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
61542+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61543+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61544+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61545+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61546+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61547+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61548+4 4 4 4 4 4
61549+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61550+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61551+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61552+4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
61553+4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
61554+6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
61555+4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
61556+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61557+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61558+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61559+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61560+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61561+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61562+4 4 4 4 4 4
61563+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61564+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61565+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61566+4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
61567+5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
61568+6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
61569+6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
61570+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61571+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61572+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61573+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61574+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61575+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61576+4 4 4 4 4 4
61577+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61578+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61579+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61580+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
61581+4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
61582+4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
61583+6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61584+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61585+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61586+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61587+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61588+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61589+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61590+4 4 4 4 4 4
61591+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61592+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61593+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61594+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61595+4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
61596+6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
61597+4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
61598+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61599+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61600+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61601+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61602+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61603+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61604+4 4 4 4 4 4
61605+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61606+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61607+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61608+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61609+4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
61610+4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
61611+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61612+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61613+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61614+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61615+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61616+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61617+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61618+4 4 4 4 4 4
61619+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61620+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61621+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61622+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61623+4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
61624+5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
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 4 4 4 4 4 4 4 4 4 4 4 4
61627+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61628+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61629+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61630+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61631+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61632+4 4 4 4 4 4
61633+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61634+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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 5 5 5 4 3 3
61638+5 5 5 4 3 3 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
61641+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61642+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61643+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61644+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61645+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61646+4 4 4 4 4 4
61647diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
61648index 96093ae..b9eed29 100644
61649--- a/drivers/xen/events/events_base.c
61650+++ b/drivers/xen/events/events_base.c
61651@@ -1568,7 +1568,7 @@ void xen_irq_resume(void)
61652 restore_pirqs();
61653 }
61654
61655-static struct irq_chip xen_dynamic_chip __read_mostly = {
61656+static struct irq_chip xen_dynamic_chip = {
61657 .name = "xen-dyn",
61658
61659 .irq_disable = disable_dynirq,
61660@@ -1582,7 +1582,7 @@ static struct irq_chip xen_dynamic_chip __read_mostly = {
61661 .irq_retrigger = retrigger_dynirq,
61662 };
61663
61664-static struct irq_chip xen_pirq_chip __read_mostly = {
61665+static struct irq_chip xen_pirq_chip = {
61666 .name = "xen-pirq",
61667
61668 .irq_startup = startup_pirq,
61669@@ -1602,7 +1602,7 @@ static struct irq_chip xen_pirq_chip __read_mostly = {
61670 .irq_retrigger = retrigger_dynirq,
61671 };
61672
61673-static struct irq_chip xen_percpu_chip __read_mostly = {
61674+static struct irq_chip xen_percpu_chip = {
61675 .name = "xen-percpu",
61676
61677 .irq_disable = disable_dynirq,
61678diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
61679index 00f40f0..e3c0b15 100644
61680--- a/drivers/xen/evtchn.c
61681+++ b/drivers/xen/evtchn.c
61682@@ -201,8 +201,8 @@ static ssize_t evtchn_read(struct file *file, char __user *buf,
61683
61684 /* Byte lengths of two chunks. Chunk split (if any) is at ring wrap. */
61685 if (((c ^ p) & EVTCHN_RING_SIZE) != 0) {
61686- bytes1 = (EVTCHN_RING_SIZE - EVTCHN_RING_MASK(c)) *
61687- sizeof(evtchn_port_t);
61688+ bytes1 = EVTCHN_RING_SIZE - EVTCHN_RING_MASK(c);
61689+ bytes1 *= sizeof(evtchn_port_t);
61690 bytes2 = EVTCHN_RING_MASK(p) * sizeof(evtchn_port_t);
61691 } else {
61692 bytes1 = (p - c) * sizeof(evtchn_port_t);
61693diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
61694index fef20db..d28b1ab 100644
61695--- a/drivers/xen/xenfs/xenstored.c
61696+++ b/drivers/xen/xenfs/xenstored.c
61697@@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
61698 static int xsd_kva_open(struct inode *inode, struct file *file)
61699 {
61700 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
61701+#ifdef CONFIG_GRKERNSEC_HIDESYM
61702+ NULL);
61703+#else
61704 xen_store_interface);
61705+#endif
61706+
61707 if (!file->private_data)
61708 return -ENOMEM;
61709 return 0;
61710diff --git a/firmware/Makefile b/firmware/Makefile
61711index e297e1b..aeb0982 100644
61712--- a/firmware/Makefile
61713+++ b/firmware/Makefile
61714@@ -35,9 +35,11 @@ fw-shipped-$(CONFIG_BNX2X) += bnx2x/bnx2x-e1-6.2.9.0.fw \
61715 bnx2x/bnx2x-e1h-6.2.9.0.fw \
61716 bnx2x/bnx2x-e2-6.2.9.0.fw
61717 fw-shipped-$(CONFIG_BNX2) += bnx2/bnx2-mips-09-6.2.1a.fw \
61718+ bnx2/bnx2-mips-09-6.2.1b.fw \
61719 bnx2/bnx2-rv2p-09-6.0.17.fw \
61720 bnx2/bnx2-rv2p-09ax-6.0.17.fw \
61721 bnx2/bnx2-mips-06-6.2.1.fw \
61722+ bnx2/bnx2-mips-06-6.2.3.fw \
61723 bnx2/bnx2-rv2p-06-6.0.15.fw
61724 fw-shipped-$(CONFIG_CASSINI) += sun/cassini.bin
61725 fw-shipped-$(CONFIG_CHELSIO_T3) += cxgb3/t3b_psram-1.1.0.bin \
61726diff --git a/firmware/WHENCE b/firmware/WHENCE
61727index 0c4d96d..b17700f 100644
61728--- a/firmware/WHENCE
61729+++ b/firmware/WHENCE
61730@@ -653,21 +653,23 @@ Found in hex form in kernel source.
61731 Driver: BNX2 - Broadcom NetXtremeII
61732
61733 File: bnx2/bnx2-mips-06-6.2.1.fw
61734+File: bnx2/bnx2-mips-06-6.2.3.fw
61735 File: bnx2/bnx2-rv2p-06-6.0.15.fw
61736 File: bnx2/bnx2-mips-09-6.2.1a.fw
61737+File: bnx2/bnx2-mips-09-6.2.1b.fw
61738 File: bnx2/bnx2-rv2p-09-6.0.17.fw
61739 File: bnx2/bnx2-rv2p-09ax-6.0.17.fw
61740
61741 Licence:
61742-
61743- This file contains firmware data derived from proprietary unpublished
61744- source code, Copyright (c) 2004 - 2010 Broadcom Corporation.
61745-
61746- Permission is hereby granted for the distribution of this firmware data
61747- in hexadecimal or equivalent format, provided this copyright notice is
61748- accompanying it.
61749-
61750-Found in hex form in kernel source.
61751+
61752+ This file contains firmware data derived from proprietary unpublished
61753+ source code, Copyright (c) 2004 - 2010 Broadcom Corporation.
61754+
61755+ Permission is hereby granted for the distribution of this firmware data
61756+ in hexadecimal or equivalent format, provided this copyright notice is
61757+ accompanying it.
61758+
61759+Found in hex form in kernel source.
61760
61761 --------------------------------------------------------------------------
61762
61763diff --git a/firmware/bnx2/bnx2-mips-06-6.2.3.fw.ihex b/firmware/bnx2/bnx2-mips-06-6.2.3.fw.ihex
61764new file mode 100644
61765index 0000000..da72bf1
61766--- /dev/null
61767+++ b/firmware/bnx2/bnx2-mips-06-6.2.3.fw.ihex
61768@@ -0,0 +1,5804 @@
61769+:10000000080001180800000000004A68000000C84D
61770+:1000100000000000000000000000000008004A6826
61771+:100020000000001400004B30080000A00800000091
61772+:100030000000569400004B44080058200000008443
61773+:100040000000A1D808005694000001580000A25CEE
61774+:100050000800321008000000000072F00000A3B495
61775+:10006000000000000000000000000000080072F026
61776+:1000700000000024000116A40800049008000400F9
61777+:10008000000017D4000116C80000000000000000A6
61778+:100090000000000000000000000000000000000060
61779+:1000A000080000A80800000000003BFC00012E9C96
61780+:1000B0000000000000000000000000000000000040
61781+:1000C00000000000000000000A00004600000000E0
61782+:1000D000000000000000000D636F6D362E322E33DD
61783+:1000E0000000000006020302000000000000000300
61784+:1000F000000000C800000032000000030000000003
61785+:1001000000000000000000000000000000000000EF
61786+:1001100000000010000001360000EA600000000549
61787+:1001200000000000000000000000000000000008C7
61788+:1001300000000000000000000000000000000000BF
61789+:1001400000000000000000000000000000000000AF
61790+:10015000000000000000000000000000000000009F
61791+:10016000000000020000000000000000000000008D
61792+:10017000000000000000000000000000000000007F
61793+:10018000000000000000000000000010000000005F
61794+:10019000000000000000000000000000000000005F
61795+:1001A000000000000000000000000000000000004F
61796+:1001B000000000000000000000000000000000003F
61797+:1001C000000000000000000000000000000000002F
61798+:1001D000000000000000000000000000000000001F
61799+:1001E0000000000010000003000000000000000DEF
61800+:1001F0000000000D3C02080024424AA03C03080015
61801+:1002000024634B9CAC4000000043202B1480FFFD76
61802+:10021000244200043C1D080037BD7FFC03A0F021F0
61803+:100220003C100800261001183C1C0800279C4AA01E
61804+:100230000E000168000000000000000D27470100CB
61805+:1002400090E3000B2402001A94E5000814620028D1
61806+:10025000000020218CE200003C0308008C63004475
61807+:1002600094E60014000211C20002104030A4000203
61808+:10027000005A10212463000130A50004A446008028
61809+:100280003C010800AC23004410A000190004202BFE
61810+:100290008F4202B804410008240400013C02080017
61811+:1002A0008C420060244200013C010800AC22006046
61812+:1002B00003E00008008010218CE2002094E3001687
61813+:1002C00000002021AF4202808CE20004A743028498
61814+:1002D000AF4202883C021000AF4202B83C02080064
61815+:1002E0008C42005C244200013C010800AC22005C0E
61816+:1002F00003E00008008010212747010090E3000B75
61817+:100300002402000394E50008146200280000202164
61818+:100310008CE200003C0308008C63004494E6001467
61819+:10032000000211C20002104030A40002005A102145
61820+:100330002463000130A50004A44600803C010800AD
61821+:10034000AC23004410A000190004202B8F4202B8F7
61822+:1003500004410008240400013C0208008C420060B3
61823+:10036000244200013C010800AC22006003E00008C8
61824+:10037000008010218CE2002094E300160000202170
61825+:10038000AF4202808CE20004A7430284AF4202889D
61826+:100390003C021000AF4202B83C0208008C42005CF4
61827+:1003A000244200013C010800AC22005C03E000088C
61828+:1003B000008010218F4301002402010050620003DD
61829+:1003C000000311C20000000D000311C20002104022
61830+:1003D000005A1021A440008003E000080000102112
61831+:1003E0009362000003E00008AF80000003E0000813
61832+:1003F0000000102103E00008000010212402010089
61833+:1004000014820008000000003C0208008C4200FC3E
61834+:10041000244200013C010800AC2200FC0A0000DD7F
61835+:1004200030A200203C0208008C42008424420001DB
61836+:100430003C010800AC22008430A2002010400008DB
61837+:1004400030A300103C0208008C4201082442000145
61838+:100450003C010800AC22010803E000080000000095
61839+:1004600010600008000000003C0208008C420104FB
61840+:10047000244200013C010800AC22010403E0000812
61841+:10048000000000003C0208008C42010024420001F0
61842+:100490003C010800AC22010003E00008000000005D
61843+:1004A00027BDFFE8AFBF0010274401009483000878
61844+:1004B000306200041040001B306600028F4202B818
61845+:1004C00004410008240500013C0208008C42006041
61846+:1004D000244200013C010800AC2200600A0001290E
61847+:1004E0008FBF00108C82002094830016000028210A
61848+:1004F000AF4202808C820004A7430284AF4202888C
61849+:100500003C021000AF4202B83C0208008C42005C82
61850+:10051000244200013C010800AC22005C0A000129D1
61851+:100520008FBF001010C00006006028218F4401001A
61852+:100530000E0000CD000000000A0001282405000183
61853+:100540008F8200088F4301045043000700002821D8
61854+:100550008F4401000E0000CD000000008F42010416
61855+:10056000AF820008000028218FBF001000A01021DA
61856+:1005700003E0000827BD001827BDFFE8AFBF001447
61857+:10058000AFB00010974201083043700024022000F1
61858+:100590001062000B286220011440002F000010217F
61859+:1005A00024024000106200250000000024026000C8
61860+:1005B00010620026000010210A0001658FBF0014A0
61861+:1005C00027500100920200091040001A2403000184
61862+:1005D0003C0208008C420020104000160000182148
61863+:1005E0000E00049300000000960300083C0608007B
61864+:1005F00094C64B5E8E0400188F8200209605000C76
61865+:1006000000031C0000661825AC440000AC45000443
61866+:1006100024040001AC400008AC40000CAC400010C9
61867+:10062000AC400014AC4000180E0004B8AC43001CF1
61868+:10063000000018210A000164006010210E0003254B
61869+:10064000000000000A000164000010210E000EE905
61870+:1006500000000000000010218FBF00148FB00010B8
61871+:1006600003E0000827BD001827BDFFE0AFB2001867
61872+:100670003C036010AFBF001CAFB10014AFB000105E
61873+:100680008C6450002402FF7F3C1A800000822024EA
61874+:100690003484380C24020037AC6450003C1208004B
61875+:1006A00026524AD8AF42000824020C80AF420024F0
61876+:1006B0003C1B80083C06080024C60324024010218D
61877+:1006C0002404001D2484FFFFAC4600000481FFFDCC
61878+:1006D000244200043C020800244204B03C0108000B
61879+:1006E000AC224AE03C020800244202303C010800EF
61880+:1006F000AC224AE43C020800244201743C03080096
61881+:100700002463032C3C040800248403D83C0508001F
61882+:1007100024A538F03C010800AC224B403C02080004
61883+:10072000244202EC3C010800AC264B243C010800AA
61884+:10073000AC254B343C010800AC234B3C3C01080089
61885+:10074000AC244B443C010800AC224B483C0108005F
61886+:10075000AC234ADC3C010800AC204AE83C0108001C
61887+:10076000AC204AEC3C010800AC204AF03C010800F7
61888+:10077000AC204AF43C010800AC204AF83C010800D7
61889+:10078000AC204AFC3C010800AC204B003C010800B6
61890+:10079000AC244B043C010800AC204B083C01080091
61891+:1007A000AC204B0C3C010800AC204B103C01080075
61892+:1007B000AC204B143C010800AC204B183C01080055
61893+:1007C000AC264B1C3C010800AC264B203C01080029
61894+:1007D000AC254B303C010800AC234B380E000623FF
61895+:1007E000000000003C028000344200708C42000097
61896+:1007F000AF8200143C0308008C6300208F82000449
61897+:10080000104300043C0280000E00045BAF83000430
61898+:100810003C028000344600703C0308008C6300A05A
61899+:100820003C0208008C4200A4104300048F84001492
61900+:100830003C010800AC2300A4A743009E8CCA000022
61901+:100840003C0308008C6300BC3C0208008C4200B8EA
61902+:100850000144202300641821000040210064202B63
61903+:1008600000481021004410213C010800AC2300BCCA
61904+:100870003C010800AC2200B88F5100003222000772
61905+:100880001040FFDCAF8A00148CC600003C05080055
61906+:100890008CA500BC3C0408008C8400B800CA30233E
61907+:1008A00000A628210000102100A6302B0082202164
61908+:1008B00000862021322700013C010800AC2500BC45
61909+:1008C0003C010800AC2400B810E0001F32220002F6
61910+:1008D0008F420100AF4200208F420104AF4200A8C6
61911+:1008E0009342010B0E0000C6305000FF2E02001E86
61912+:1008F00054400004001010800E0000C90A000213CA
61913+:1009000000000000005210218C4200000040F80955
61914+:1009100000000000104000053C0240008F4301042D
61915+:100920003C026020AC4300143C024000AF4201385E
61916+:100930003C0208008C420034244200013C010800C3
61917+:10094000AC220034322200021040000E3222000499
61918+:100950008F4201400E0000C6AF4200200E000295FB
61919+:10096000000000003C024000AF4201783C02080059
61920+:100970008C420038244200013C010800AC220038BF
61921+:10098000322200041040FF983C0280008F42018018
61922+:100990000E0000C6AF4200208F43018024020F00EA
61923+:1009A00014620005000000008F420188A742009CED
61924+:1009B0000A0002483C0240009362000024030050F9
61925+:1009C000304200FF144300083C0240000E00027B4E
61926+:1009D00000000000544000043C0240000E000D7571
61927+:1009E000000000003C024000AF4201B83C02080099
61928+:1009F0008C42003C244200013C010800AC22003C37
61929+:100A00000A0001C83C0280003C0290003442000110
61930+:100A100000822025AF4400208F4200200440FFFECA
61931+:100A20000000000003E00008000000003C0280001D
61932+:100A3000344200010082202503E00008AF4400207A
61933+:100A400027BDFFE0AFB10014AFB0001000808821D7
61934+:100A5000AFBF00180E00025030B000FF9362007D5F
61935+:100A60000220202102028025A370007D8F70007477
61936+:100A70003C0280000E000259020280241600000988
61937+:100A80008FBF00188F4201F80440FFFE24020002CD
61938+:100A9000AF5101C0A34201C43C021000AF4201F8B3
61939+:100AA0008FBF00188FB100148FB0001003E0000852
61940+:100AB00027BD002027BDFFE8AFBF0010974201848B
61941+:100AC0008F440188304202001040000500002821B8
61942+:100AD0000E000FAA000000000A00028D240500018C
61943+:100AE0003C02FF0004800005008218243C02040040
61944+:100AF000506200019362003E240500018FBF001088
61945+:100B000000A0102103E0000827BD0018A360002208
61946+:100B10008F4401400A00025E2405000127BDFFE862
61947+:100B2000AFBF0014AFB0001093620000304400FF6C
61948+:100B300038830020388200300003182B0002102B6D
61949+:100B40000062182410600003240200501482008008
61950+:100B50008FBF001493620005304200011040007CFA
61951+:100B60008FBF0014934201482443FFFF2C6200050D
61952+:100B7000104000788FB00010000310803C03080084
61953+:100B800024634A68004310218C42000000400008A2
61954+:100B9000000000000E0002508F4401408F70000CD6
61955+:100BA0008F4201441602000224020001AF62000CD1
61956+:100BB0000E0002598F4401408F420144145000043A
61957+:100BC0008FBF00148FB000100A000F2027BD00183F
61958+:100BD0008F62000C0A0003040000000097620010FE
61959+:100BE0008F4301443042FFFF1462001A00000000EE
61960+:100BF00024020001A76200108F4202380443001053
61961+:100C00008F4201403C02003F3446F0003C0560004A
61962+:100C10003C04FFC08CA22BBC0044182400461024C6
61963+:100C20000002130200031D82106200390000000060
61964+:100C30008F4202380440FFF7000000008F4201405D
61965+:100C4000AF4202003C021000AF4202380A00032209
61966+:100C50008FBF0014976200100A0003040000000018
61967+:100C60000E0002508F440140976200128F430144EE
61968+:100C70003050FFFF1603000224020001A762001299
61969+:100C80000E0002598F4401408F42014416020004B5
61970+:100C90008FBF00148FB000100A00029127BD00180A
61971+:100CA000976200120A00030400000000976200141B
61972+:100CB0008F4301443042FFFF14620006240200010A
61973+:100CC0008FBF00148FB00010A76200140A00124AF0
61974+:100CD00027BD0018976200141440001D8FBF001438
61975+:100CE0000A00031C00000000976200168F430144B5
61976+:100CF0003042FFFF1462000B240200018FBF00147A
61977+:100D00008FB00010A76200160A000B1227BD001852
61978+:100D10009742007824420004A76200100A000322D0
61979+:100D20008FBF001497620016240300013042FFFFBA
61980+:100D3000144300078FBF00143C0208008C4200706F
61981+:100D4000244200013C010800AC2200708FBF001457
61982+:100D50008FB0001003E0000827BD001827BDFFE892
61983+:100D6000AFBF0014AFB000108F50010093620000BD
61984+:100D700093430109304400FF2402001F106200A5C4
61985+:100D80002862002010400018240200382862000A5F
61986+:100D90001040000C2402000B286200081040002CB8
61987+:100DA00000000000046000E52862000214400028F2
61988+:100DB00024020006106200268FBF00140A00041FE0
61989+:100DC0008FB000101062005E2862000B144000DC3F
61990+:100DD0008FBF00142402000E106200738FB0001049
61991+:100DE0000A00041F00000000106200C028620039E1
61992+:100DF0001040000A2402008024020036106200CA5B
61993+:100E000028620037104000B424020035106200C18F
61994+:100E10008FBF00140A00041F8FB000101062002B57
61995+:100E20002862008110400006240200C82402003914
61996+:100E3000106200B48FBF00140A00041F8FB00010AE
61997+:100E4000106200998FBF00140A00041F8FB00010B9
61998+:100E50003C0208008C420020104000B98FBF0014F3
61999+:100E60000E000493000000008F4201008F830020D9
62000+:100E70009745010C97460108AC6200008F420104BF
62001+:100E80003C04080094844B5E00052C00AC62000416
62002+:100E90008F4201180006340000C43025AC620008FF
62003+:100EA0008F42011C24040001AC62000C9342010A31
62004+:100EB00000A22825AC650010AC600014AC600018DE
62005+:100EC000AC66001C0A0003F58FBF00143C0208004A
62006+:100ED0008C4200201040009A8FBF00140E00049333
62007+:100EE00000000000974401083C03080094634B5E37
62008+:100EF0009745010C000422029746010E8F820020C4
62009+:100F0000000426000083202500052C003C030080FF
62010+:100F100000A6282500832025AC400000AC4000043A
62011+:100F2000AC400008AC40000CAC450010AC400014D4
62012+:100F3000AC400018AC44001C0A0003F42404000177
62013+:100F40009742010C14400015000000009362000558
62014+:100F50003042001014400011000000000E0002504A
62015+:100F6000020020219362000502002021344200107B
62016+:100F70000E000259A36200059362000024030020C2
62017+:100F8000304200FF1043006D020020218FBF00148B
62018+:100F90008FB000100A000FC027BD00180000000D20
62019+:100FA0000A00041E8FBF00143C0208008C4200207F
62020+:100FB000104000638FBF00140E0004930000000077
62021+:100FC0008F4201048F8300209744010C3C050800E8
62022+:100FD00094A54B5EAC6200009762002C00042400D4
62023+:100FE0003042FFFF008220253C02400E00A228254F
62024+:100FF000AC640004AC600008AC60000CAC60001095
62025+:10100000AC600014AC600018AC65001C0A0003F46E
62026+:10101000240400010E00025002002021A7600008F5
62027+:101020000E00025902002021020020210E00025E63
62028+:10103000240500013C0208008C42002010400040C2
62029+:101040008FBF00140E000493000000009742010CB3
62030+:101050008F8300203C05080094A54B5E000214001D
62031+:10106000AC700000AC620004AC6000088F64004CFF
62032+:101070003C02401F00A22825AC64000C8F62005087
62033+:1010800024040001AC6200108F620054AC620014B2
62034+:10109000AC600018AC65001C8FBF00148FB000104E
62035+:1010A0000A0004B827BD0018240200205082002541
62036+:1010B0008FB000100E000F0A020020211040002007
62037+:1010C0008FBF0014020020218FB0001000002821E3
62038+:1010D0000A00025E27BD0018020020218FBF001405
62039+:1010E0008FB000100A00058027BD00189745010C3D
62040+:1010F000020020218FBF00148FB000100A0005A04D
62041+:1011000027BD0018020020218FB000100A0005C57D
62042+:1011100027BD00189345010D020020218FB000105B
62043+:101120000A00060F27BD0018020020218FBF0014FF
62044+:101130008FB000100A0005EB27BD00188FBF001408
62045+:101140008FB0001003E0000827BD00188F4202781E
62046+:101150000440FFFE2402000234840080AF440240B9
62047+:10116000A34202443C02100003E00008AF420278B0
62048+:101170003C04080094844B6A3C0208008C424B7487
62049+:101180003083FFFF000318C000431021AF42003C32
62050+:101190003C0208008C424B70AF4200383C020050C9
62051+:1011A00034420008AF4200300000000000000000A0
62052+:1011B000000000008F420000304200201040FFFD80
62053+:1011C000000000008F4204003C010800AC224B608C
62054+:1011D0008F4204043C010800AC224B643C02002016
62055+:1011E000AF420030000000003C02080094424B680F
62056+:1011F0003C03080094634B6C3C05080094A54B6EBF
62057+:1012000024840001004310213083FFFF3C010800CB
62058+:10121000A4224B683C010800A4244B6A1465000317
62059+:10122000000000003C010800A4204B6A03E0000815
62060+:10123000000000003C05000A27BDFFE80345282107
62061+:101240003C04080024844B50AFBF00100E00051D65
62062+:101250002406000A3C02080094424B523C0308005A
62063+:1012600094634B6E3042000F244200030043180485
62064+:1012700024027FFF0043102B10400002AF83001CAC
62065+:101280000000000D0E00042A000000003C020800CF
62066+:1012900094424B5A8FBF001027BD001803E000088E
62067+:1012A000A74200A23C02000A034210219443000618
62068+:1012B0003C02080094424B5A3C010800A4234B56C0
62069+:1012C000004310238F83001C00021400000214034B
62070+:1012D0000043102B03E000083842000127BDFFE85F
62071+:1012E000AFBF00103C02000A0342102194420006E6
62072+:1012F0003C010800A4224B560E00047700000000B9
62073+:101300005440FFF93C02000A8FBF001003E00008C0
62074+:1013100027BD001827BDFFE8AFBF00100E000477FF
62075+:101320000000000010400003000000000E000485D3
62076+:10133000000000003C0208008C424B608FBF001090
62077+:1013400027430400AF4200383C0208008C424B6443
62078+:1013500027BD0018AF830020AF42003C3C020005CF
62079+:10136000AF42003003E00008AF8000188F82001801
62080+:101370003C0300060002114000431025AF4200303C
62081+:101380000000000000000000000000008F4200008C
62082+:10139000304200101040FFFD27420400AF820020C1
62083+:1013A00003E00008AF8000183C0608008CC64B64C0
62084+:1013B0008F8500188F8300203C02080094424B5A0E
62085+:1013C00027BDFFE024A50001246300202442000182
62086+:1013D00024C70020AFB10014AFB00010AFBF001899
62087+:1013E000AF850018AF8300203C010800A4224B5AAF
62088+:1013F000309000FF3C010800AC274B6404C100089A
62089+:101400000000882104E00006000000003C02080003
62090+:101410008C424B60244200013C010800AC224B602E
62091+:101420003C02080094424B5A3C03080094634B680A
62092+:101430000010202B004310262C42000100441025F0
62093+:10144000144000048F830018240200101462000F5F
62094+:10145000000000000E0004A9241100013C03080054
62095+:1014600094634B5A3C02080094424B681462000398
62096+:10147000000000000E00042A000000001600000317
62097+:10148000000000000E000493000000003C03080070
62098+:1014900094634B5E3C02080094424B5C2463000161
62099+:1014A0003064FFFF3C010800A4234B5E148200035C
62100+:1014B000000000003C010800A4204B5E1200000662
62101+:1014C000000000003C02080094424B5AA74200A2D0
62102+:1014D0000A00050B022010210E0004770000000016
62103+:1014E00010400004022010210E00048500000000BE
62104+:1014F000022010218FBF00188FB100148FB0001090
62105+:1015000003E0000827BD00203084FFFF30A5FFFF67
62106+:101510000000182110800007000000003082000148
62107+:101520001040000200042042006518210A00051343
62108+:101530000005284003E000080060102110C00006EC
62109+:1015400024C6FFFF8CA2000024A50004AC8200008A
62110+:101550000A00051D2484000403E0000800000000C8
62111+:1015600010A0000824A3FFFFAC86000000000000CC
62112+:10157000000000002402FFFF2463FFFF1462FFFA53
62113+:101580002484000403E0000800000000240200019D
62114+:10159000AF62000CA7620010A7620012A7620014DD
62115+:1015A00003E00008A76200163082007F034210218A
62116+:1015B0003C08000E004818213C0208008C42002024
62117+:1015C00027BDFFD82407FF80AFB3001CAFB20018BF
62118+:1015D000AFB10014AFB00010AFBF00200080802179
62119+:1015E00030B100FF0087202430D200FF1040002FD0
62120+:1015F00000009821AF44002C9062000024030050AA
62121+:10160000304200FF1443000E000000003C020800BE
62122+:101610008C4200E00202102100471024AF42002C4F
62123+:101620003C0208008C4200E0020210213042007FA0
62124+:101630000342102100481021944200D43053FFFF90
62125+:101640000E000493000000003C02080094424B5E30
62126+:101650008F8300200011340000C2302500122C00BE
62127+:101660003C02400000C2302534A50001AC700000EF
62128+:101670008FBF0020AC6000048FB20018AC7300086C
62129+:101680008FB10014AC60000C8FB3001CAC6500106F
62130+:101690008FB00010AC60001424040001AC6000188E
62131+:1016A00027BD00280A0004B8AC66001C8FBF0020CC
62132+:1016B0008FB3001C8FB200188FB100148FB00010D0
62133+:1016C00003E0000827BD00289343010F2402001007
62134+:1016D0001062000E2865001110A0000724020012FD
62135+:1016E000240200082405003A1062000600003021A0
62136+:1016F00003E0000800000000240500351462FFFC30
62137+:10170000000030210A000538000000008F420074FC
62138+:1017100024420FA003E00008AF62000C27BDFFE8E1
62139+:10172000AFBF00100E00025E240500018FBF001045
62140+:1017300024020001A762001227BD00182402000144
62141+:1017400003E00008A360002227BDFFE0AFB1001452
62142+:10175000AFB00010AFBF001830B1FFFF0E00025055
62143+:10176000008080219362003F24030004304200FF88
62144+:101770001443000C02002021122000082402000A59
62145+:101780000E00053100000000936200052403FFFEF7
62146+:1017900000431024A362000524020012A362003F4C
62147+:1017A000020020210E000259A360008116200003D0
62148+:1017B000020020210E0005950000000002002021FB
62149+:1017C000322600FF8FBF00188FB100148FB00010B9
62150+:1017D000240500380A00053827BD002027BDFFE09A
62151+:1017E000AFBF001CAFB20018AFB10014AFB0001013
62152+:1017F0000E000250008080210E0005310000000024
62153+:101800009362003F24120018305100FF123200038F
62154+:101810000200202124020012A362003F936200050F
62155+:101820002403FFFE004310240E000259A3620005AA
62156+:10183000020020212405002016320007000030217C
62157+:101840008FBF001C8FB200188FB100148FB0001032
62158+:101850000A00025E27BD00208FBF001C8FB2001857
62159+:101860008FB100148FB00010240500390A0005382C
62160+:1018700027BD002027BDFFE8AFB00010AFBF0014A8
62161+:101880009742010C2405003600808021144000108E
62162+:10189000304600FF0E00025000000000240200123B
62163+:1018A000A362003F93620005344200100E00053130
62164+:1018B000A36200050E00025902002021020020212F
62165+:1018C0000E00025E240500200A000604000000004D
62166+:1018D0000E000538000000000E000250020020211A
62167+:1018E000936200232403FF9F020020210043102461
62168+:1018F0008FBF00148FB00010A36200230A000259AA
62169+:1019000027BD001827BDFFE0AFBF0018AFB100141E
62170+:10191000AFB0001030B100FF0E00025000808021F7
62171+:10192000240200120E000531A362003F0E0002598E
62172+:101930000200202102002021022030218FBF001848
62173+:101940008FB100148FB00010240500350A0005384F
62174+:1019500027BD0020A380002C03E00008A380002DF9
62175+:101960008F4202780440FFFE8F820034AF42024073
62176+:1019700024020002A34202443C02100003E00008DB
62177+:10198000AF4202783C0360008C6254003042000891
62178+:101990001440FFFD000000008C625408AF82000C70
62179+:1019A00024020052AC605408AC645430AC6254342D
62180+:1019B0002402000803E00008AC6254003C0260000E
62181+:1019C0008C42540030420008104000053C03600087
62182+:1019D0008C625400304200081440FFFD00000000FB
62183+:1019E0008F83000C3C02600003E00008AC43540805
62184+:1019F00090A3000024020005008040213063003FD6
62185+:101A000000004821146200050000502190A2001C33
62186+:101A100094A3001E304900FF306AFFFFAD00000CA8
62187+:101A2000AD000010AD000024950200148D05001CCF
62188+:101A30008D0400183042FFFF0049102300021100FE
62189+:101A4000000237C3004038210086202300A2102B5B
62190+:101A50000082202300A72823AD05001CAD04001838
62191+:101A6000A5090014A5090020A50A001603E0000836
62192+:101A7000A50A00228F4201F80440FFFE2402000262
62193+:101A8000AF4401C0A34201C43C02100003E00008BF
62194+:101A9000AF4201F83C0208008C4200B427BDFFE8C9
62195+:101AA000AFBF001424420001AFB000103C01080099
62196+:101AB000AC2200B48F4300243C02001F30AA00FF78
62197+:101AC0003442FF8030D800FF006280240080F8217B
62198+:101AD00030EF00FF1158003B01405821240CFF80DB
62199+:101AE0003C19000A3163007F000310C00003194055
62200+:101AF000006218213C0208008C4200DC25680001CD
62201+:101B0000310D007F03E21021004310213043007F9C
62202+:101B100003431821004C102400794821AF420024CF
62203+:101B20008D220024016C1824006C7026AD22000C5C
62204+:101B30008D220024310800FFAD22001095220014F0
62205+:101B4000952300208D27001C3042FFFF3063FFFFEC
62206+:101B50008D2600180043102300021100000227C345
62207+:101B60000040282100C4302300E2102B00C23023A3
62208+:101B700000E53823AD27001CAD2600189522002073
62209+:101B8000A522001495220022154B000AA52200165A
62210+:101B90008D2300248D220008254600013145008058
62211+:101BA0001462000430C4007F108F000238AA008045
62212+:101BB00000C0502151AF000131C800FF1518FFC906
62213+:101BC000010058218F8400343082007F03421821A5
62214+:101BD0003C02000A006218212402FF8000822024B7
62215+:101BE000AF440024A06A0079A06A00838C62005090
62216+:101BF0008F840034AC6200708C6500743C027FFFFF
62217+:101C00003442FFFF00A228240E00066BAC6500746E
62218+:101C1000AF5000248FBF00148FB0001003E0000805
62219+:101C200027BD001827BDFFC0AFBE0038AFB70034D6
62220+:101C3000AFB5002CAFB20020AFB1001CAFB00018A0
62221+:101C4000AFBF003CAFB60030AFB40028AFB3002444
62222+:101C50008F4500248F4600288F43002C3C02001F34
62223+:101C60003442FF800062182400C230240080A82182
62224+:101C7000AFA3001400A2F0240E00062FAFA60010A0
62225+:101C80003C0208008C4200E02410FF8003608821A1
62226+:101C900002A2102100501024AF4200243C02080090
62227+:101CA0008C4200E002A210213042007F0342182142
62228+:101CB0003C02000A00629021924200D293630084A9
62229+:101CC000305700FF306300FF24020001106200342F
62230+:101CD000036020212402000214620036000000008C
62231+:101CE0000E001216024028219223008392220083C4
62232+:101CF0003063007F3042007F000210C000031940B3
62233+:101D0000006218213C0208008C4200DC02A2102173
62234+:101D10000043382100F01024AF42002892250078BB
62235+:101D20009224008330E2007F034218213C02000C21
62236+:101D300014850007006280212402FFFFA24200F107
62237+:101D40002402FFFFA64200F20A0007272402FFFF39
62238+:101D500096020020A24200F196020022A64200F262
62239+:101D60008E020024AE4200F492220083A24200F0D0
62240+:101D70008E4200C8AE4200FC8E4200C4AE4200F863
62241+:101D80008E220050AE4201008E4200CCAE420104D1
62242+:101D9000922200853042003F0A0007823442004010
62243+:101DA0000E00123902402821922200850A00078283
62244+:101DB0003042003F936200852403FFDF3042003F42
62245+:101DC000A36200859362008500431024A36200850E
62246+:101DD0009363008393620078307400FF304200FF09
62247+:101DE00010540036240AFF803C0C000C3283007F24
62248+:101DF000000310C000031940006218213C020800D3
62249+:101E00008C4200DC268800013109007F02A21021EB
62250+:101E10000043382130E2007F0342182100EA1024F9
62251+:101E2000AF420028006C80218E020024028A182410
62252+:101E3000006A5826AE02000C8E020024310800FF12
62253+:101E4000AE02001096020014960300208E07001CBC
62254+:101E50003042FFFF3063FFFF8E060018004310235F
62255+:101E600000021100000227C30040282100C43023D3
62256+:101E700000E2102B00C2302300E53823AE07001C1F
62257+:101E8000AE06001896020020A60200149602002258
62258+:101E9000A602001692220079304200FF105400077B
62259+:101EA0000000000051370001316800FF92220078E5
62260+:101EB000304200FF1448FFCD0100A0219222008390
62261+:101EC000A22200798E2200500A0007E2AE220070A2
62262+:101ED000A22200858E22004C2405FF80AE42010C18
62263+:101EE0009222008534420020A2220085924200D135
62264+:101EF0003C0308008C6300DC305400FF3C02080007
62265+:101F00008C4200E400143140001420C002A31821C8
62266+:101F100000C4202102A210210064382100461021B3
62267+:101F20000045182400E52824AF450028AF43002CC5
62268+:101F30003042007F924400D030E3007F03422821EA
62269+:101F4000034318213C02000C006280213C02000E79
62270+:101F5000309600FF00A298211296002A000000008F
62271+:101F60008E02000C02002021026028211040002572
62272+:101F7000261000280E00064A000000009262000DA4
62273+:101F800026830001307400FF3042007FA262000D02
62274+:101F90002404FF801697FFF0267300203C020800FF
62275+:101FA0008C4200DC0000A02102A210210044102479
62276+:101FB000AF4200283C0208008C4200E43C030800C9
62277+:101FC0008C6300DC02A2102100441024AF42002CDC
62278+:101FD0003C0208008C4200E402A318213063007F19
62279+:101FE00002A210213042007F034220210343182126
62280+:101FF0003C02000C006280213C02000E0A0007A493
62281+:10200000008298218E4200D8AE2200508E4200D825
62282+:10201000AE22007092250083924600D19223008365
62283+:10202000924400D12402FF8000A228243063007F64
62284+:10203000308400FF00A628250064182A10600002E2
62285+:1020400030A500FF38A50080A2250083A2250079D5
62286+:102050000E00063D000000009222007E02A020211A
62287+:10206000A222007A8E2300743C027FFF3442FFFFDD
62288+:10207000006218240E00066BAE2300748FA20010BD
62289+:10208000AF5E00248FBF003CAF4200288FBE0038F7
62290+:102090008FA200148FB700348FB600308FB5002C9C
62291+:1020A0008FB400288FB300248FB200208FB1001CA2
62292+:1020B0008FB0001827BD004003E00008AF42002C9D
62293+:1020C00090A2000024420001A0A200003C030800EE
62294+:1020D0008C6300F4304200FF1443000F0080302175
62295+:1020E000A0A000003C0208008C4200E48F84003471
62296+:1020F000008220213082007F034218213C02000C24
62297+:10210000006218212402FF8000822024ACC300005A
62298+:1021100003E00008AF4400288C8200002442002025
62299+:1021200003E00008AC82000094C200003C080800F4
62300+:10213000950800CA30E7FFFF008048210102102106
62301+:10214000A4C2000094C200003042FFFF00E2102B46
62302+:1021500054400001A4C7000094A200003C03080002
62303+:102160008C6300CC24420001A4A2000094A20000D1
62304+:102170003042FFFF544300078F8600280107102BD1
62305+:10218000A4A000005440000101003821A4C70000B1
62306+:102190008F8600288CC4001CAF44003C94A2000031
62307+:1021A0008F43003C3042FFFF000210C00062182144
62308+:1021B000AF43003C8F42003C008220231880000483
62309+:1021C000000000008CC200180A00084324420001ED
62310+:1021D0008CC20018AF4200383C020050344200105C
62311+:1021E000AF420030000000000000000000000000CE
62312+:1021F0008F420000304200201040FFFD0000000030
62313+:102200008F420404AD2200048F420400AD2200007E
62314+:102210003C020020AF42003003E000080000000054
62315+:1022200027BDFFE0AFB20018AFB10014AFB000108F
62316+:10223000AFBF001C94C2000000C080213C12080007
62317+:10224000965200C624420001A60200009603000038
62318+:1022500094E2000000E03021144300058FB100300B
62319+:102260000E000818024038210A000875000000001E
62320+:102270008C8300048C820004244200400461000727
62321+:10228000AC8200048C8200040440000400000000C2
62322+:102290008C82000024420001AC8200009602000003
62323+:1022A0003042FFFF50520001A600000096220000BD
62324+:1022B00024420001A62200008F82002896230000FD
62325+:1022C00094420016144300048FBF001C2402000136
62326+:1022D000A62200008FBF001C8FB200188FB100141F
62327+:1022E0008FB0001003E0000827BD00208F89002870
62328+:1022F00027BDFFE0AFBF00188D220028274804004B
62329+:1023000030E700FFAF4200388D22002CAF8800304C
62330+:10231000AF42003C3C020005AF420030000000002C
62331+:1023200000000000000000000000000000000000AD
62332+:10233000000000008C82000C8C82000CAD020000BA
62333+:102340008C820010AD0200048C820018AD020008DF
62334+:102350008C82001CAD02000C8CA20014AD02001097
62335+:102360008C820020AD02001490820005304200FFF4
62336+:1023700000021200AD0200188CA20018AD02001C71
62337+:102380008CA2000CAD0200208CA20010AD02002433
62338+:102390008CA2001CAD0200288CA20020AD02002CF3
62339+:1023A000AD060030AD000034978300263402FFFFF5
62340+:1023B00014620002006020213404FFFF10E00011CD
62341+:1023C000AD04003895230036952400362402000120
62342+:1023D0003063FFFF000318C20069182190650040B8
62343+:1023E000308400070082100400451025A0620040E0
62344+:1023F0008F820028944200563042FFFF0A0008DC1A
62345+:10240000AD02003C952300369524003624020001DD
62346+:102410003063FFFF000318C2006918219065004077
62347+:1024200030840007008210040002102700451024A9
62348+:10243000A0620040AD00003C000000000000000071
62349+:10244000000000003C02000634420040AF42003071
62350+:102450000000000000000000000000008F420000AB
62351+:10246000304200101040FFFD8F860028AF880030FA
62352+:1024700024C2005624C7003C24C4002824C50032CE
62353+:1024800024C600360E000856AFA200108FBF0018F9
62354+:1024900003E0000827BD00208F8300243C060800CD
62355+:1024A0008CC600E88F82003430633FFF0003198040
62356+:1024B00000461021004310212403FF803046007F96
62357+:1024C00000431024AF420028034618213C02000CB0
62358+:1024D0000062302190C2000D30A500FF00003821BD
62359+:1024E00034420010A0C2000D8F8900288F8A00247A
62360+:1024F00095230036000A13823048000324020001AD
62361+:10250000A4C3000E1102000B2902000210400005B6
62362+:10251000240200021100000C240300010A0009201B
62363+:102520000000182111020006000000000A00092026
62364+:10253000000018218CC2002C0A000920244300014D
62365+:102540008CC20014244300018CC200180043102BDD
62366+:1025500050400009240700012402002714A20003B0
62367+:10256000000000000A00092C240700019522003E0B
62368+:1025700024420001A522003E000A138230430003DA
62369+:102580002C62000210400009008028211460000421
62370+:102590000000000094C200360A00093C3046FFFFEC
62371+:1025A0008CC600380A00093C008028210000302138
62372+:1025B0003C04080024844B780A00088900000000CD
62373+:1025C000274901008D22000C9523000601202021BF
62374+:1025D000000216023046003F3063FFFF240200274E
62375+:1025E00000C0282128C7002810C2000EAF83002495
62376+:1025F00010E00008240200312402002110C200096A
62377+:102600002402002510C200079382002D0A00095BF6
62378+:102610000000000010C200059382002D0A00095B33
62379+:10262000000000000A0008F4000000000A0006266E
62380+:102630000000000095230006912400058D25000C64
62381+:102640008D2600108D2700188D28001C8D29002054
62382+:10265000244200013C010800A4234B7E3C010800F9
62383+:10266000A0244B7D3C010800AC254B843C010800B4
62384+:10267000AC264B883C010800AC274B903C0108007D
62385+:10268000AC284B943C010800AC294B9803E00008AF
62386+:10269000A382002D8F87002827BDFFC0AFB3003471
62387+:1026A000AFB20030AFB1002CAFB00028AFBF0038E0
62388+:1026B0003C0208008C4200D094E3003030B0FFFFB1
62389+:1026C000005010073045FFFF3063FFFF00C0982126
62390+:1026D000A7A200103C110800963100C614A3000602
62391+:1026E0003092FFFF8CE2002424420030AF42003CD5
62392+:1026F0000A0009948CE2002094E200323042FFFF8D
62393+:1027000054A2000827A400188CE2002C24420030B8
62394+:10271000AF42003C8CE20028AF4200380A0009A218
62395+:102720008F84002827A5001027A60020022038212A
62396+:102730000E000818A7A000208FA200182442003025
62397+:10274000AF4200388FA2001CAF42003C8F840028AB
62398+:102750003C020005AF42003094820034274304005D
62399+:102760003042FFFF0202102B14400007AF830030FD
62400+:1027700094820054948300340202102100431023F9
62401+:102780000A0009B63043FFFF94830054948200345A
62402+:102790000223182100501023006218233063FFFF2A
62403+:1027A000948200163042FFFF144300030000000033
62404+:1027B0000A0009C424030001948200163042FFFF7E
62405+:1027C0000043102B104000058F82003094820016C9
62406+:1027D000006210233043FFFF8F820030AC530000B3
62407+:1027E000AC400004AC520008AC43000C3C020006B4
62408+:1027F00034420010AF420030000000000000000032
62409+:10280000000000008F420000304200101040FFFD29
62410+:10281000001018C2006418219065004032040007BF
62411+:10282000240200018FBF00388FB300348FB2003014
62412+:102830008FB1002C8FB000280082100400451025B5
62413+:1028400027BD004003E00008A062004027BDFFA8AC
62414+:10285000AFB60050AFB5004CAFB40048AFB30044C2
62415+:10286000AFB1003CAFBF0054AFB20040AFB00038D2
62416+:102870008C9000003C0208008C4200E88F860034F7
62417+:10288000960300022413FF8000C2302130633FFF13
62418+:102890000003198000C3382100F3102490B2000017
62419+:1028A000AF42002C9203000230E2007F034230214D
62420+:1028B0003C02000E00C28821306300C024020040A8
62421+:1028C0000080A82100A0B021146200260000A021F1
62422+:1028D0008E3400388E2200181440000224020001B9
62423+:1028E000AE2200189202000D304200201440001564
62424+:1028F0008F8200343C0308008C6300DC001238C077
62425+:10290000001231400043102100C730210046382119
62426+:1029100030E300073C02008030E6007800C230253A
62427+:102920000343182100F31024AF4208002463090078
62428+:10293000AF4608108E2200188C6300080043102157
62429+:10294000AE2200188E22002C8E2300182442000193
62430+:102950000062182B1060003D000000000A000A7899
62431+:1029600000000000920300022402FFC00043102474
62432+:10297000304200FF1440000524020001AE2200187E
62433+:10298000962200360A000A613054FFFF8E2200149E
62434+:1029900024420001AE22001892020000000216003C
62435+:1029A0000002160304410029000000009602000204
62436+:1029B00027A4001000802821A7A20016960200027A
62437+:1029C00024070001000030213042FFFFAF820024C5
62438+:1029D0000E000889AFA0001C960300023C0408000A
62439+:1029E0008C8400E88F82003430633FFF000319803D
62440+:1029F00000441021004310213043007F3C05000CAF
62441+:102A00000053102403431821AF4200280065182109
62442+:102A10009062000D001221403042007FA062000D44
62443+:102A20003C0308008C6300E48F82003400431021D3
62444+:102A30000044382130E2007F03421021004510217C
62445+:102A400000F31824AF430028AEA200009222000D2C
62446+:102A5000304200101040001302A020218F83002874
62447+:102A60008EA40000028030219462003E2442FFFFC9
62448+:102A7000A462003E948400029625000E3084FFFF7D
62449+:102A80000E00097330A5FFFF8F82002894430034A5
62450+:102A90009622000E1443000302A02021240200010C
62451+:102AA000A382002C02C028210E0007FE00000000B7
62452+:102AB0008FBF00548FB600508FB5004C8FB40048C4
62453+:102AC0008FB300448FB200408FB1003C8FB000380C
62454+:102AD00003E0000827BD00588F82002827BDFFD0E3
62455+:102AE000AFB40028AFB20020AFBF002CAFB30024BA
62456+:102AF000AFB1001CAFB00018904400D0904300D19B
62457+:102B00000000A021309200FFA3A30010306300FF5B
62458+:102B10008C5100D88C5300DC1072002B2402000171
62459+:102B20003C0308008C6300E493A400108F820034FF
62460+:102B30002406FF800004214000431021004410219E
62461+:102B40003043007F00461024AF4200280343182181
62462+:102B50003C02000C006218218C62000427A40014BF
62463+:102B600027A50010022280210270102304400015C6
62464+:102B7000AFA300149062000D00C21024304200FF89
62465+:102B800014400007020088219062000D344200408A
62466+:102B90000E0007FEA062000D0A000ABD93A20010FD
62467+:102BA0000E0009E1241400018F830028AC7000D8C6
62468+:102BB00093A20010A06200D193A200101452FFD87B
62469+:102BC0000000000024020001168200048FBF002CC8
62470+:102BD0000E000626000000008FBF002C8FB40028D6
62471+:102BE0008FB300248FB200208FB1001C8FB000186B
62472+:102BF00003E0000827BD003027BDFFD8AFB3001C9D
62473+:102C0000AFB20018AFB10014AFB00010AFBF0020DA
62474+:102C10000080982100E0802130B1FFFF0E00049376
62475+:102C200030D200FF000000000000000000000000A3
62476+:102C30008F820020AC510000AC520004AC5300085D
62477+:102C4000AC40000CAC400010AC400014AC4000188C
62478+:102C50003C03080094634B5E02038025AC50001CCB
62479+:102C6000000000000000000000000000240400013B
62480+:102C70008FBF00208FB3001C8FB200188FB10014DB
62481+:102C80008FB000100A0004B827BD002827BDFFE858
62482+:102C9000AFB00010AFBF001430A5FFFF30C600FF7B
62483+:102CA0000080802124020C80AF420024000000003C
62484+:102CB0000000000000000000000000000000000014
62485+:102CC0000E000ACC000000003C040800248400E050
62486+:102CD0008C8200002403FF808FBF001402021021A9
62487+:102CE00000431024AF4200248C8200003C03000A01
62488+:102CF000020280213210007F035010218FB000109B
62489+:102D00000043102127BD001803E00008AF8200280F
62490+:102D100027BDFFE8AFBF00108F4401403C0308000F
62491+:102D20008C6300E02402FF80AF840034008318210C
62492+:102D300000621024AF4200243C02000803424021FC
62493+:102D4000950500023063007F3C02000A034318210E
62494+:102D50000062182130A5FFFF3402FFFF0000302180
62495+:102D60003C07602010A20006AF8300282402FFFF6A
62496+:102D7000A5020002946500D40E000AF130A5FFFF01
62497+:102D80008FBF001024020C8027BD001803E000084C
62498+:102D9000AF4200243C020008034240219502000299
62499+:102DA0003C0A0800954A00C63046FFFF14C00007E1
62500+:102DB0003402FFFF8F8200288F8400343C0760209C
62501+:102DC000944500D40A000B5A30A5FFFF10C200241E
62502+:102DD0008F87002894E2005494E400163045FFFFEA
62503+:102DE00000A6102300A6182B3089FFFF10600004F6
62504+:102DF0003044FFFF00C51023012210233044FFFFA1
62505+:102E0000008A102B1040000C012A1023240200011C
62506+:102E1000A50200162402FFFFA502000294E500D4DB
62507+:102E20008F8400340000302130A5FFFF3C07602074
62508+:102E30000A000AF1000000000044102A10400008B7
62509+:102E4000000000009502001630420001104000040E
62510+:102E5000000000009742007E24420014A5020016E4
62511+:102E600003E00008000000008F84002827BDFFE079
62512+:102E7000AFBF0018948200349483003E1060001AA3
62513+:102E80003048FFFF9383002C2402000114620027C6
62514+:102E90008FBF00188F820028000818C23108000771
62515+:102EA000006218212447003A244900542444002099
62516+:102EB000244500302446003490620040304200FF38
62517+:102EC0000102100730420001104000168FBF0018A9
62518+:102ED0000E000856AFA900108F82002894420034DB
62519+:102EE0000A000B733048FFFF94830036948200344D
62520+:102EF0001043000E8FBF001894820036A482003465
62521+:102F000094820056A48200548C82002CAC8200244F
62522+:102F100094820032A48200309482003CA482003A61
62523+:102F20008FBF00180A000B3327BD002003E0000804
62524+:102F300027BD002027BDFFE8AFBF00108F4A01006A
62525+:102F40003C0508008CA500E03C02080090424B8440
62526+:102F50003C0C0800958C4B7E01452821304B003FEE
62527+:102F600030A2007F03424021396900323C02000A4E
62528+:102F70003963003F2C630001010240212D2900012B
62529+:102F80002402FF8000A2282401234825AF8A0034B0
62530+:102F900000801821AF450024000030210080282146
62531+:102FA00024070001AF8800283C04080024844B78E3
62532+:102FB000AF8C002415200007A380002D24020020E0
62533+:102FC0005562000F006020213402FFFF5582000C83
62534+:102FD000006020212402002015620005000000008E
62535+:102FE0008C6300142402FFFF106200070000000041
62536+:102FF0000E000889000000000A000BD0000000004D
62537+:103000000E0008F4016028210E000B68000000008B
62538+:103010008FBF001024020C8027BD001803E00008B9
62539+:10302000AF4200243C0208008C4200E027BDFFA014
62540+:10303000AFB1003C008210212411FF80AFBE0058C8
62541+:10304000AFB70054AFB20040AFB00038AFBF005CC4
62542+:10305000AFB60050AFB5004CAFB40048AFB30044BA
62543+:10306000005110248F4800248F4900288F470028E2
62544+:10307000AF4200243C0208008C4200E00080902116
62545+:1030800024060006008210213042007F03421821EE
62546+:103090003C02000A006280213C02001F3442FF8093
62547+:1030A00000E2382427A40010260500F00122F024B5
62548+:1030B0000102B8240E00051DAFA700308FA2001832
62549+:1030C000AE0200C48FA2001CAE0200C88FA2002472
62550+:1030D000AE0200CC93A40010920300D12402FF8022
62551+:1030E0000082102400431025304900FF3083007F08
62552+:1030F0003122007F0062102A10400004000310C03B
62553+:1031000001311026304900FF000310C000031940B0
62554+:10311000006218213C0208008C4200DC920400D2BC
62555+:10312000024210210043102100511024AF42002818
62556+:1031300093A300103063007F000310C00003194008
62557+:10314000006218213C0208008C4200DC024210217F
62558+:10315000004310213042007F034218213C02000C42
62559+:10316000006240218FA300142402FFFF1062003090
62560+:10317000309500FF93A2001195030014304400FF26
62561+:103180003063FFFF0064182B1060000D000000008A
62562+:10319000950400148D07001C8D0600183084FFFF75
62563+:1031A00000442023000421000000102100E4382105
62564+:1031B00000E4202B00C230210A000C4A00C4302158
62565+:1031C000950400148D07001C8D0600183084FFFF45
62566+:1031D000008220230004210000001021008018211B
62567+:1031E00000C2302300E4202B00C4302300E3382346
62568+:1031F000AD07001CAD06001893A20011A502001433
62569+:1032000097A20012A50200168FA20014AD020010B2
62570+:103210008FA20014AD02000C93A20011A5020020A1
62571+:1032200097A20012A50200228FA20014AD02002472
62572+:103230002406FF80024610243256007FAF4200244D
62573+:10324000035618213C02000A006280218E02004CC5
62574+:103250008FA200203124007F000428C0AE0200505D
62575+:103260008FA200200004214000852821AE020070BA
62576+:1032700093A2001001208821A202008393A20010D3
62577+:10328000A2020079920200853042003FA20200852E
62578+:103290003C0208008C4200DC024210210045102153
62579+:1032A00000461024AF42002C3C0208008C4200E48F
62580+:1032B0003C0308008C6300DC024210210044102112
62581+:1032C00000461024AF4200283C0208008C4200E473
62582+:1032D00002431821006518210242102100441021E8
62583+:1032E0003042007F3063007F93A50010034220210D
62584+:1032F000034318213C02000E006240213C02000CF6
62585+:1033000010B1008C008248213233007F1660001912
62586+:103310002404FF803C0208008C4200DC02421021A1
62587+:1033200000441024AF42002C3C0208008C4200E410
62588+:103330003C0308008C6300DC02421021004410248E
62589+:10334000AF4200283C0208008C4200E402431821EE
62590+:103350003063007F024210213042007F034220216F
62591+:10336000034318213C02000E006240213C02000C85
62592+:10337000008248219124000D2414FF8000001021B8
62593+:1033800000942025A124000D950400029505001449
62594+:103390008D07001C3084FFFF30A5FFFF8D0600184D
62595+:1033A000008520230004210000E4382100C23021E0
62596+:1033B00000E4202B00C43021AD07001CAD0600182E
62597+:1033C00095020002A5020014A50000168D02000857
62598+:1033D000AD0200108D020008AD02000C9502000243
62599+:1033E000A5020020A50000228D020008AD020024E5
62600+:1033F0009122000D30420040104000422622000180
62601+:103400003C0208008C4200E0A3B300283C10000AF4
62602+:103410000242102100541024AF4200243C02080054
62603+:103420008C4200E0A380002C27A4002C0242102133
62604+:103430003042007F03421821007018218C6200D8AE
62605+:103440008D26000427A50028AFA9002C00461021D6
62606+:10345000AC6200D80E0009E1AF83002893A30028D6
62607+:103460008F8200280E000626A04300D10E000B68B4
62608+:103470000000000002541024AF4200243C02080067
62609+:103480008C4200DC00132940001320C000A420213E
62610+:10349000024210210044102100541024AF42002C9D
62611+:1034A0003C0208008C4200E43C0308008C6300DC12
62612+:1034B00003563021024210210045102100541024EF
62613+:1034C000AF4200283C0208008C4200E4024318216D
62614+:1034D0000064182102421021004510213042007F73
62615+:1034E0003063007F03422021034318213C02000E79
62616+:1034F000006240213C02000C00D080210082482163
62617+:10350000262200013043007F14750005304400FF7F
62618+:103510002403FF800223102400431026304400FFC0
62619+:1035200093A2001000808821250800281444FF760B
62620+:103530002529002093A400108FA300142402FFFF6C
62621+:103540001062000A308900FF2482000124830001F8
62622+:103550003042007F14550005306900FF2403FF80CE
62623+:103560000083102400431026304900FF92020078A7
62624+:10357000305300FF11330032012088213C02080043
62625+:103580008C4200DC3225007F000520C00005294068
62626+:1035900000A42021024210212406FF8000441021B3
62627+:1035A00000461024AF42002C3C0308008C6300DC72
62628+:1035B0003C0208008C4200E4024318210242102120
62629+:1035C0000045102100641821004610243063007F5C
62630+:1035D000AF420028034318213C02000E0062402144
62631+:1035E0003C0208008C4200E48D06000C0100202102
62632+:1035F00002421021004510213042007F0342182171
62633+:103600003C02000C0062482110C0000D012028215E
62634+:103610000E00064A000000002402FF800222182447
62635+:1036200026240001006228263082007F1455000203
62636+:10363000308300FF30A300FF1473FFD000608821A7
62637+:103640008E0300743C027FFF3442FFFF00621824A7
62638+:10365000AE0300740E00066B02402021AF57002419
62639+:103660008FA20030AF5E00288FBF005C8FBE005875
62640+:103670008FB700548FB600508FB5004C8FB4004800
62641+:103680008FB300448FB200408FB1003C8FB0003840
62642+:1036900027BD006003E00008AF42002C27BDFFD823
62643+:1036A000AFB1001CAFBF0020AFB000182751018898
62644+:1036B000922200032408FF803C03000A3047007F69
62645+:1036C000A3A700108F4601803C0208008C4200E056
62646+:1036D000AF86003400C2282100A81024AF42002485
62647+:1036E0009224000030A2007F0342102100431021E9
62648+:1036F000AF8200283084007F24020002148200255B
62649+:10370000000719403C0208008C4200E400C210216E
62650+:103710000043282130A2007F0342182100A8102472
62651+:10372000AF4200283C02000C006218219062000D9C
62652+:10373000AFA3001400481025A062000D8FA3001451
62653+:103740009062000D304200405040006A8FBF002060
62654+:103750008F860028A380002C27A400148CC200D8D8
62655+:103760008C63000427A50010004310210E0009E11E
62656+:10377000ACC200D893A300108F8200280E0006264A
62657+:10378000A04300D10E000B68000000000A000E0BE1
62658+:103790008FBF00200E00062F00C020210E00063D26
62659+:1037A000000000003C020008034280219223000137
62660+:1037B0009202007B1443004F8FBF00209222000032
62661+:1037C0003044007F24020004108200172882000584
62662+:1037D00010400006240200052402000310820007A6
62663+:1037E0008FB1001C0A000E0C0000000010820012B5
62664+:1037F0008FBF00200A000E0C8FB1001C92050083C1
62665+:10380000920600788E0700748F84003430A500FF84
62666+:1038100000073E0230C600FF0E00067330E7007F4F
62667+:103820000A000E0B8FBF00200E000BD78F840034D0
62668+:103830000A000E0B8FBF002024020C80AF42002430
62669+:103840009202003E30420040104000200000000084
62670+:103850009202003E00021600000216030441000618
62671+:10386000000000008F8400340E0005A024050093A2
62672+:103870000A000E0B8FBF00209202003F24030018A5
62673+:10388000304200FF1443000C8F84003424050039BB
62674+:103890000E000538000030210E0002508F840034E5
62675+:1038A00024020012A202003F0E0002598F8400344D
62676+:1038B0000A000E0B8FBF0020240500360E000538CD
62677+:1038C000000030210A000E0B8FBF00200E000250B6
62678+:1038D0008F8400349202000534420020A2020005C9
62679+:1038E0000E0002598F8400340E000FC08F84003404
62680+:1038F0008FBF00208FB1001C8FB0001824020C80F5
62681+:1039000027BD002803E00008AF42002427BDFFE8E0
62682+:10391000AFB00010AFBF001427430100946200084D
62683+:103920000002140000021403044100020000802180
62684+:103930002410000194620008304200801040001AF8
62685+:10394000020010219462000830422000104000164E
62686+:10395000020010218C6300183C021C2D344219ED2A
62687+:10396000240600061062000F3C0760213C0208009C
62688+:103970008C4200D4104000078F8200288F830028DB
62689+:10398000906200623042000F34420040A062006248
62690+:103990008F8200288F840034944500D40E000AF1F1
62691+:1039A00030A5FFFF020010218FBF00148FB0001060
62692+:1039B00003E0000827BD001827BDFFE0AFB10014E9
62693+:1039C000AFB00010A380002CAFBF00188F450100DE
62694+:1039D0003C0308008C6300E02402FF80AF850034C4
62695+:1039E00000A318213064007F0344202100621824C2
62696+:1039F0003C02000A00822021AF430024275001002E
62697+:103A00008E0200148C8300DCAF8400280043102356
62698+:103A100018400004000088218E0200140E000A8461
62699+:103A2000AC8200DC9202000B24030002304200FF53
62700+:103A30001443002F0000000096020008304300FFEE
62701+:103A40002402008214620005240200840E00093E54
62702+:103A5000000000000A000E97000000001462000938
62703+:103A6000240200818F8200288F8400343C0760216B
62704+:103A7000944500D49206000530A5FFFF0A000E868B
62705+:103A800030C600FF14620027000000009202000A06
62706+:103A9000304300FF306200201040000430620040DC
62707+:103AA0008F8400340A000E82240600401040000477
62708+:103AB000000316008F8400340A000E8224060041A1
62709+:103AC00000021603044100178F84003424060042CC
62710+:103AD0008F8200283C076019944500D430A5FFFF71
62711+:103AE0000E000AF1000000000A000E97000000001E
62712+:103AF0009202000B24030016304200FF1043000620
62713+:103B0000000000009202000B24030017304200FF67
62714+:103B100014430004000000000E000E11000000001D
62715+:103B2000004088210E000B68000000009202000A8D
62716+:103B3000304200081040000624020C808F850028C7
62717+:103B40003C0400080E0011EE0344202124020C80E6
62718+:103B5000AF4200248FBF0018022010218FB0001048
62719+:103B60008FB1001403E0000827BD002027BDFFE847
62720+:103B7000AFBF0014AFB000108F5000243C0308000A
62721+:103B80008C6300E08F4501002402FF8000A3182110
62722+:103B90003064007F03442021006218243C02000AA4
62723+:103BA00000822021AF850034AF4300249082006260
62724+:103BB000AF8400283042000F34420050A0820062DF
62725+:103BC0003C02001F3442FF800E00062602028024C1
62726+:103BD000AF5000248FBF00148FB0001003E0000826
62727+:103BE00027BD00183C0208008C4200201040001D38
62728+:103BF0002745010090A300093C0200080342202150
62729+:103C000024020018546200033C0200080A000ED887
62730+:103C10002402000803422021240200161462000539
62731+:103C20002402001724020012A082003F0A000EE2C4
62732+:103C300094A700085462000694A700089362000548
62733+:103C40002403FFFE00431024A362000594A700088C
62734+:103C500090A6001B8CA4000094A500060A000ACCC4
62735+:103C600000073C0003E000080000000027440100BA
62736+:103C700094820008304500FF38A3008238A20084F7
62737+:103C80002C6300012C420001006218251060000620
62738+:103C9000240200839382002D1040000D00000000DC
62739+:103CA0000A000B9B0000000014A2000524A2FF8064
62740+:103CB0008F4301043C02602003E00008AC43001481
62741+:103CC000304200FF2C420002104000032402002278
62742+:103CD0000A000E3C0000000014A2000300000000D7
62743+:103CE0000A000EA9000000000A000EC70000000034
62744+:103CF0009363007E9362007A144300090000202140
62745+:103D00009362000024030050304200FF144300047B
62746+:103D1000240400019362007E24420001A362007E1D
62747+:103D200003E00008008010218F4201F80440FFFEEC
62748+:103D300024020002AF4401C0A34201C43C021000AF
62749+:103D400003E00008AF4201F827BDFFE8AFBF001055
62750+:103D50009362003F2403000A304200FF14430046F0
62751+:103D6000000000008F6300548F62004C1062007DE1
62752+:103D7000036030219362000024030050304200FFB2
62753+:103D80001443002F000000008F4401403C02080053
62754+:103D90008C4200E02403FF800082102100431024A5
62755+:103DA000AF4200243C0208008C4200E08F650054C2
62756+:103DB0003C03000A008220213084007F034410214C
62757+:103DC00000431021AC4501089762003C8F63004C12
62758+:103DD0003042FFFF0002104000621821AF63005C18
62759+:103DE0008F6300548F64004C9762003C006418237A
62760+:103DF0003042FFFF00031843000210400043102A26
62761+:103E000010400006000000008F6200548F63004CD9
62762+:103E1000004310230A000F58000210439762003C31
62763+:103E20003042FFFF00021040ACC2006424020001D7
62764+:103E3000A0C0007CA0C2008424020C80AF420024F9
62765+:103E40000E000F0A8F440140104000478FBF001042
62766+:103E50008F4301408F4201F80440FFFE240200021C
62767+:103E6000AF4301C0A34201C43C021000AF4201F8BD
62768+:103E70000A000FA88FBF00109362003F24030010B8
62769+:103E8000304200FF14430004000000008F44014052
62770+:103E90000A000F94000028219362003F24030016BB
62771+:103EA000304200FF1443000424020014A362003FC8
62772+:103EB0000A000FA2000000008F62004C8F630050C8
62773+:103EC00000431023044100288FBF0010936200813B
62774+:103ED00024420001A3620081936200812C4200040D
62775+:103EE00014400010000000009362003F240300040F
62776+:103EF000304200FF14430006000000008F440140E0
62777+:103F00008FBF0010240500930A0005A027BD0018EC
62778+:103F10008F440140240500938FBF00100A00060F54
62779+:103F200027BD00188F4401400E0002500000000021
62780+:103F30008F6200542442FFFFAF6200548F62005032
62781+:103F40002442FFFFAF6200500E0002598F4401402F
62782+:103F50008F4401408FBF0010240500040A00025E58
62783+:103F600027BD00188FBF001003E0000827BD001810
62784+:103F70008F4201889363007E00021402304400FFE8
62785+:103F8000306300FF1464000D0000000093620080A5
62786+:103F9000304200FF1044000900000000A3640080CC
62787+:103FA0009362000024030050304200FF14430004D9
62788+:103FB000000000000A0006D78F440180A36400803F
62789+:103FC00003E000080000000027BDFFE8AFB00010CC
62790+:103FD000AFBF00149362000524030030304200306C
62791+:103FE00014430089008080213C0208008C4200209C
62792+:103FF00010400080020020210E0004930000000009
62793+:104000008F850020ACB000009362003E9363003FB8
62794+:10401000304200FF00021200306300FF0043102511
62795+:10402000ACA2000493620082000216000002160394
62796+:1040300004410005000000003C0308008C630048B8
62797+:104040000A000FE6000000009362003E304200408C
62798+:10405000144000030000182193620081304300FFE8
62799+:104060009362008200031E00304200FF0002140031
62800+:1040700000621825ACA300088F620040ACA2000CBF
62801+:104080008F620048ACA200108F62004CACA20014FA
62802+:104090008F6200508F63004C0043102304410003E3
62803+:1040A000000000000A000FFA8F62004C8F6200507F
62804+:1040B000ACA200183C02080094424B5E3C03C00BCB
62805+:1040C00000002021004310250E0004B8ACA2001C03
62806+:1040D0008F6200548F840020AC8200008F620058F1
62807+:1040E000AC8200048F62005CAC8200088F620060CA
62808+:1040F0008F43007400431021AC82000C8F62006477
62809+:10410000AC820010976300689762006A00031C008D
62810+:104110003042FFFF00621825AC83001493620082D6
62811+:1041200024030080304200FF14430003000000001D
62812+:104130000A00102EAC8000188F63000C24020001CE
62813+:104140001062000E2402FFFF9362003E30420040E6
62814+:104150001440000A2402FFFF8F63000C8F4200749A
62815+:10416000006218233C020800006210241440000280
62816+:10417000000028210060282100051043AC820018AF
62817+:104180003C02080094424B5E3C03C00C000020211E
62818+:10419000004310258F8300200E0004B8AC62001C81
62819+:1041A0008F6200188F8300203C05080094A54B5EA9
62820+:1041B00024040001AC620000AC6000048F66006C57
62821+:1041C0003C02400D00A22825AC6600088F6200DC8E
62822+:1041D000AC62000CAC600010936200050002160097
62823+:1041E000AC620014AC6000180E0004B8AC65001C92
62824+:1041F000020020218FBF00148FB00010A3600005C3
62825+:104200000A00042127BD00188FBF00148FB00010D2
62826+:1042100003E0000827BD00189742007C30C600FF6D
62827+:10422000A08600843047FFFF2402000514C2000B63
62828+:1042300024E3465090A201122C42000710400007D0
62829+:1042400024E30A0090A30112240200140062100467
62830+:1042500000E210210A0010663047FFFF3067FFFFC1
62831+:1042600003E00008A4870014AC87004C8CA201086E
62832+:104270000080402100A0482100E2102330C600FF4A
62833+:104280001840000393AA001324E2FFFCACA201082B
62834+:1042900030C2000110400008000000008D020050F4
62835+:1042A00000E2102304410013240600058D0200548F
62836+:1042B00010E20010000000008D02005414E2001A09
62837+:1042C000000000003C0208008C4200D83042002070
62838+:1042D0001040000A2402000191030078910200833B
62839+:1042E000144300062402000101002021012028219E
62840+:1042F000240600040A00105400000000A1000084FD
62841+:1043000011400009A50200148F4301008F4201F8FB
62842+:104310000440FFFE24020002AF4301C0A34201C4D7
62843+:104320003C021000AF4201F803E00008000000006A
62844+:1043300027BDFFE88FA90028AFBF001000804021F3
62845+:1043400000E918231860007330C600FFA080007CCD
62846+:10435000A08000818CA2010800E210230440004DDF
62847+:10436000000000008C8200509483003C8C84006428
62848+:10437000004748233063FFFF012318210083202BCF
62849+:1043800010800004000000008D0200640A0010B7D5
62850+:1043900000E210219502003C3042FFFF0122102173
62851+:1043A00000E21021AD02005C9502003C8D03005C30
62852+:1043B0003042FFFF0002104000E210210043102BAA
62853+:1043C00010400003000000000A0010C68D02005CCF
62854+:1043D0009502003C3042FFFF0002104000E2102135
62855+:1043E000AD02005CA1000084AD07004C8CA2010866
62856+:1043F00000E210231840000224E2FFFCACA20108F6
62857+:1044000030C200011040000A000000008D02005080
62858+:1044100000E2102304410004010020218D02005419
62859+:1044200014E20003000000000A0010E82406000562
62860+:104430008D02005414E200478FBF00103C020800B8
62861+:104440008C4200D8304200201040000A24020001B3
62862+:1044500091030078910200831443000624020001B6
62863+:1044600001002021240600048FBF00100A00105410
62864+:1044700027BD0018A1000084A50200148F4301008D
62865+:104480008F4201F80440FFFE240200020A00110DD1
62866+:10449000000000008C82005C004910230043102BB8
62867+:1044A00054400001AC87005C9502003C3042FFFFA5
62868+:1044B0000062102B14400007240200029502003C09
62869+:1044C0008D03005C3042FFFF00621821AD03005CE9
62870+:1044D00024020002AD07004CA10200840E000F0A66
62871+:1044E0008F4401001040001B8FBF00108F4301005C
62872+:1044F0008F4201F80440FFFE24020002AF4301C0D6
62873+:10450000A34201C43C021000AF4201F80A0011238B
62874+:104510008FBF001030C200101040000E8FBF00107F
62875+:104520008C83005C9482003C006918233042FFFFBA
62876+:10453000006218213C023FFF3444FFFF0083102B30
62877+:10454000544000010080182101231021AD02005CBD
62878+:104550008FBF001003E0000827BD001827BDFFE84B
62879+:104560008FAA0028AFBF00100080402100EA482336
62880+:104570001920002130C600FF8C83005C8C8200640F
62881+:10458000006A18230043102B5040001000691821C6
62882+:1045900094A2011001221021A4A2011094A20110E2
62883+:1045A0003042FFFF0043102B1440000A3C023FFF43
62884+:1045B00094A2011000431023A4A201109482003C95
62885+:1045C0003042FFFF0A00114200621821A4A001102E
62886+:1045D0003C023FFF3444FFFF0083102B5440000196
62887+:1045E0000080182100671021AD02005CA100007C52
62888+:1045F0000A00118AA100008130C200101040003C66
62889+:10460000000000008C820050004A1023184000383F
62890+:10461000000000009082007C24420001A082007C07
62891+:104620009082007C3C0308008C630024304200FF31
62892+:104630000043102B1440005C8FBF00108CA20108B7
62893+:1046400000E2102318400058000000008C83005442
62894+:104650009482003C006A18233042FFFF0003184395
62895+:10466000000210400043102A104000050000000026
62896+:104670008C820054004A10230A001171000210437A
62897+:104680009482003C3042FFFF00021040AD02006403
62898+:104690009502003C8D0400649503003C3042FFFF0E
62899+:1046A00000021040008220213063FFFF00831821A8
62900+:1046B00001431021AD02005C8D020054ACA2010840
62901+:1046C00024020002A10200840E000F0A8F440100A0
62902+:1046D000104000358FBF00108F4301008F4201F85A
62903+:1046E0000440FFFE240200020A0011B30000000093
62904+:1046F000AD07004C8CA2010800E210231840000214
62905+:1047000024E2FFFCACA2010830C200011040000A04
62906+:10471000000000008D02005000E21023044100045C
62907+:10472000010020218D02005414E20003000000006B
62908+:104730000A0011AA240600058D02005414E2001A92
62909+:104740008FBF00103C0208008C4200D8304200208D
62910+:104750001040000A240200019103007891020083B6
62911+:104760001443000624020001010020212406000455
62912+:104770008FBF00100A00105427BD0018A10000844C
62913+:10478000A50200148F4301008F4201F80440FFFE90
62914+:1047900024020002AF4301C0A34201C43C02100046
62915+:1047A000AF4201F88FBF001003E0000827BD0018DA
62916+:1047B0008FAA00108C8200500080402130C600FF7C
62917+:1047C000004A102300A048211840000700E01821EB
62918+:1047D00024020001A0800084A0A00112A482001481
62919+:1047E0000A001125AFAA0010A0800081AD07004C7F
62920+:1047F0008CA2010800E210231840000224E2FFFC12
62921+:10480000ACA2010830C20001104000080000000006
62922+:104810008D0200500062102304410013240600059D
62923+:104820008D02005410620010000000008D02005440
62924+:1048300014620011000000003C0208008C4200D805
62925+:10484000304200201040000A240200019103007849
62926+:10485000910200831443000624020001010020217C
62927+:1048600001202821240600040A0010540000000042
62928+:10487000A1000084A502001403E00008000000006D
62929+:1048800027BDFFE0AFBF0018274201009046000A95
62930+:104890008C4800148C8B004C9082008430C900FF3F
62931+:1048A00001681823304A00FF1C60001A2D460006DC
62932+:1048B000240200010142100410C00016304300031E
62933+:1048C000012030210100382114600007304C000C19
62934+:1048D00015800009304200301440000B8FBF0018D3
62935+:1048E0000A001214000000000E001125AFAB0010EA
62936+:1048F0000A0012148FBF00180E00109AAFAB001000
62937+:104900000A0012148FBF0018AFAB00100E0011BACE
62938+:10491000AFAA00148FBF001803E0000827BD0020D5
62939+:1049200024020003A08200848C82005403E000086B
62940+:10493000ACA201083C0200080342182190620081E9
62941+:10494000240600433C07601924420001A062008154
62942+:10495000906300813C0208008C4200C0306300FF7D
62943+:10496000146200102403FF803C0208008C4200E027
62944+:104970000082102100431024AF4200243C020800B2
62945+:104980008C4200E03C03000A008210213042007F8C
62946+:104990000342102100431021944500D40A000AF17B
62947+:1049A00030A5FFFF03E000080000000027BDFFE086
62948+:1049B000AFBF0018AFB10014AFB000108F4201803C
62949+:1049C0000080802100A088210E00121B00402021C1
62950+:1049D000A20000848E0200548FBF00188FB0001018
62951+:1049E000AE2201088FB1001403E0000827BD0020AB
62952+:1049F00027BDFFE03C020008AFB00010AFBF0018B9
62953+:104A0000AFB10014034280218F5101409203008412
62954+:104A10008E0400508E02004C14820040306600FF6D
62955+:104A20003C0208008C4200E02403FF800222102197
62956+:104A300000431024AF4200243C0208008C4200E0F6
62957+:104A40009744007C92050081022210213042007FB1
62958+:104A5000034218213C02000A0062182114A0000B36
62959+:104A60003084FFFF2402000554C20014248205DCB8
62960+:104A70009062011224420001A062011224020C8003
62961+:104A8000AF4200240A00127324020005A060011244
62962+:104A90002402000514C20009248205DC9202008170
62963+:104AA0002C4200075040000524820A009203008136
62964+:104AB0002402001400621004008210213044FFFF21
62965+:104AC000A60400140E00121B022020219602003CB6
62966+:104AD0008E03004C022020213042FFFF00021040D4
62967+:104AE000006218210E000250AE03005C9202007DAD
62968+:104AF00002202021344200400E000259A202007D13
62969+:104B00008F4201F80440FFFE24020002AF5101C0B1
62970+:104B1000A34201C43C021000AF4201F88FBF00184D
62971+:104B20008FB100148FB0001003E0000827BD0020F3
62972+:104B300008000ACC08000B1408000B9808000BE4CE
62973+:104B400008000C200A0000280000000000000000FF
62974+:104B50000000000D6370362E322E3300000000007E
62975+:104B60000602030400000000000000000000000036
62976+:104B70000000000000000000000000000000000035
62977+:104B80000000000000000000000000000000002005
62978+:104B90000000000000000000000000000000000015
62979+:104BA0000000000000000000000000000000000005
62980+:104BB00000000000000000000000000000000001F4
62981+:104BC0000000002B000000000000000400030D4066
62982+:104BD00000000000000000000000000000000000D5
62983+:104BE00000000000000000001000000300000000B2
62984+:104BF0000000000D0000000D3C020800244258A4F3
62985+:104C00003C03080024635F70AC4000000043202B8D
62986+:104C10001480FFFD244200043C1D080037BD7FFCCA
62987+:104C200003A0F0213C100800261000A03C1C080046
62988+:104C3000279C58A40E0001AC000000000000000DED
62989+:104C400027BDFFE83C096018AFBF00108D2C500055
62990+:104C5000240DFF7F24080031018D5824356A380C5B
62991+:104C600024070C003C1A8000AD2A50003C04800A46
62992+:104C7000AF4800083C1B8008AF4700240E00091510
62993+:104C8000AF8400100E0008D8000000000E000825B8
62994+:104C9000000000000E001252000000003C046016EC
62995+:104CA0008C8500003C06FFFF3C02535300A61824ED
62996+:104CB0001062004734867C0094C201F2A780002C69
62997+:104CC00010400003A78000CC38581E1EA798002C67
62998+:104CD00094C201F810400004978300CC38591E1E7E
62999+:104CE000A79900CC978300CC2C7F006753E000018C
63000+:104CF000240300669784002C2C82040114400002D7
63001+:104D000000602821240404003C0760008CE904387A
63002+:104D10002403103C3128FFFF1103001F30B9FFFFAF
63003+:104D200057200010A38000CE24020050A38200CEA2
63004+:104D3000939F00CE53E0000FA78500CCA78000CC46
63005+:104D4000978500CC8FBF0010A780002CA78000346F
63006+:104D5000A78000E63C010800AC25008003E00008C5
63007+:104D600027BD0018939F00CE57E0FFF5A78000CC29
63008+:104D7000A78500CC978500CC8FBF0010A784002C9E
63009+:104D8000A7800034A78000E63C010800AC25008025
63010+:104D900003E0000827BD0018A38000CE8CCB003CA8
63011+:104DA000316A00011140000E0000000030A7FFFF33
63012+:104DB00010E0FFDE240200508CCC00C831860001D8
63013+:104DC00014C0FFDC939F00CE0A00007A2402005139
63014+:104DD0008C8F00043C0E60000A00005D01EE302163
63015+:104DE0008CEF0808240D5708000F740211CD000441
63016+:104DF00030B8FFFF240500660A00007B240404008D
63017+:104E00001700FFCC939F00CE0A00007A24020050C6
63018+:104E10008F8600103089FFFF000939408CC30010D5
63019+:104E20003C08005000E82025AF4300388CC5001432
63020+:104E300027420400AF82001CAF45003CAF44003065
63021+:104E40000000000000000000000000000000000062
63022+:104E50000000000000000000000000000000000052
63023+:104E60008F4B0000316A00201140FFFD0000000060
63024+:104E700003E00008000000008F840010948A001AEC
63025+:104E80008C8700243149FFFF000940C000E8302131
63026+:104E9000AF46003C8C8500248F43003C00A31023C8
63027+:104EA00018400029000000008C8B002025620001C2
63028+:104EB0003C0D005035AC0008AF420038AF4C00301C
63029+:104EC00000000000000000000000000000000000E2
63030+:104ED00000000000000000000000000000000000D2
63031+:104EE0008F4F000031EE002011C0FFFD00000000D8
63032+:104EF0008F4A04003C080020AC8A00108F4904044B
63033+:104F0000AC890014AF4800300000000094860018FF
63034+:104F10009487001C00C71821A48300189485001AE8
63035+:104F200024A20001A482001A9498001A9499001EE9
63036+:104F3000133800030000000003E000080000000038
63037+:104F400003E00008A480001A8C8200200A0000DC24
63038+:104F50003C0D00500A0000CD000000003C0308009A
63039+:104F60008C6300208F82001827BDFFE810620008C4
63040+:104F7000AFBF00100E000104AF8300183C0308000F
63041+:104F80008C63002024040001106400048F89001049
63042+:104F90008FBF001003E0000827BD00188FBF00106E
63043+:104FA0003C076012A520000A9528000A34E500108D
63044+:104FB00027BD00183106FFFF03E00008ACA60090F3
63045+:104FC0003C0208008C42002027BDFFC8AFBF003460
63046+:104FD000AFBE0030AFB7002CAFB60028AFB500248D
63047+:104FE000AFB40020AFB3001CAFB20018AFB10014D3
63048+:104FF00010400050AFB000108F840010948600065F
63049+:105000009483000A00C3282330B6FFFF12C0004A71
63050+:105010008FBF003494890018948A000A012A402323
63051+:105020003102FFFF02C2382B14E0000202C020212F
63052+:10503000004020212C8C0005158000020080A0215A
63053+:10504000241400040E0000B3028020218F8700107A
63054+:1050500002809821AF80001494ED000A028088211C
63055+:105060001280004E31B2FFFF3C1770003C1540002B
63056+:105070003C1E60008F8F001C8DEE000001D71824AD
63057+:10508000507500500220202102A3802B160000350D
63058+:105090003C182000507800470220202124100001F5
63059+:1050A0008F83001414600039029158230230F823D2
63060+:1050B0000250C82133F1FFFF1620FFEE3332FFFF0D
63061+:1050C0008F8700103C110020AF510030000000001D
63062+:1050D00094E6000A3C1E601237D5001002662821B3
63063+:1050E000A4E5000A94E2000A94F2000A94F400187D
63064+:1050F0003057FFFF1292003BAEB700908CED0014CA
63065+:105100008CE400100013714001AE4021000E5FC31B
63066+:10511000010E502B008B4821012A1821ACE8001405
63067+:10512000ACE3001002D3382330F6FFFF16C0FFB9FE
63068+:105130008F8400108FBF00348FBE00308FB7002CDB
63069+:105140008FB600288FB500248FB400208FB3001CC9
63070+:105150008FB200188FB100148FB0001003E0000868
63071+:1051600027BD0038107E001B000000001477FFCC24
63072+:10517000241000010E00159B000000008F83001416
63073+:105180001060FFCB0230F823029158238F87001064
63074+:10519000017020210A0001973093FFFF8F830014D4
63075+:1051A0001460FFCB3C110020AF5100300A000163B6
63076+:1051B000000000000E00077D024028210A00015770
63077+:1051C000004080210E00033A024028210A000157C6
63078+:1051D000004080210E001463022020210A000157A4
63079+:1051E000004080210E0000CD000000000A0001797F
63080+:1051F00002D3382327BDFFE8AFB00010AFBF0014C3
63081+:105200000E00003F000000003C028000345000709F
63082+:105210000A0001BA8E0600008F4F000039EE00012F
63083+:1052200031C20001104000248F8600A88E070000C4
63084+:105230003C0C08008D8C003C3C0908008D2900388E
63085+:1052400000E66823018D28210000502100AD302B9D
63086+:10525000012A4021010620213C010800AC25003C28
63087+:10526000AF8700A83C010800AC2400380E000106FE
63088+:10527000000000003C0308008C6300701060FFE633
63089+:10528000006020213C0508008CA500683C06080051
63090+:105290008CC6006C0E00152A000000003C010800BE
63091+:1052A000AC2000708F4F000039EE000131C20001C8
63092+:1052B0001440FFDE8F8600A88E0A00008F8B00A8A6
63093+:1052C0003C0508008CA5003C3C0408008C84003898
63094+:1052D000014B482300A938210082182100E9402B06
63095+:1052E000006810213C010800AC27003C3C0108008C
63096+:1052F000AC2200388F5F01002419FF0024180C0035
63097+:1053000003F9202410980012AF840000AF4400205D
63098+:10531000936D0000240C002031A600FF10CC001279
63099+:10532000240E005010CE00043C194000AF59013843
63100+:105330000A0001B3000000000E0011C800000000C8
63101+:105340003C194000AF5901380A0001B300000000C9
63102+:105350000E00011F000000003C194000AF59013849
63103+:105360000A0001B3000000008F58010000802821CE
63104+:10537000330F00FF01E020210E0002F1AF8F000487
63105+:105380003C194000AF5901380A0001B30000000089
63106+:1053900000A4102B2403000110400009000030215C
63107+:1053A0000005284000A4102B04A0000300031840AF
63108+:1053B0005440FFFC000528405060000A0004182BF0
63109+:1053C0000085382B54E000040003184200C3302548
63110+:1053D00000852023000318421460FFF900052842CD
63111+:1053E0000004182B03E0000800C310218F4201B80D
63112+:1053F0000440FFFE00000000AF4401803C031000A9
63113+:1054000024040040AF450184A3440188A3460189D8
63114+:10541000A747018A03E00008AF4301B83084FFFFCB
63115+:105420000080382130A5FFFF000020210A00022A59
63116+:10543000240600803087FFFF8CA40000240600387B
63117+:105440000A00022A000028218F8300388F8600304E
63118+:105450001066000B008040213C07080024E75A1822
63119+:10546000000328C000A710218C4400002463000121
63120+:10547000108800053063000F5466FFFA000328C04F
63121+:1054800003E00008000010213C07080024E75A1C34
63122+:1054900000A7302103E000088CC200003C0390000C
63123+:1054A0003462000100822025AF4400208F45002097
63124+:1054B00004A0FFFE0000000003E000080000000060
63125+:1054C0003C038000346200010082202503E00008D4
63126+:1054D000AF44002027BDFFE0AFB100143091FFFFC3
63127+:1054E000AFB00010AFBF00181220001300A0802141
63128+:1054F0008CA2000024040002240601401040000F8A
63129+:10550000004028210E000C5C00000000000010216B
63130+:10551000AE000000022038218FBF00188FB10014A8
63131+:105520008FB0001000402021000028210000302111
63132+:105530000A00022A27BD00208CA200000220382188
63133+:105540008FBF00188FB100148FB0001000402021D1
63134+:1055500000002821000030210A00022A27BD002077
63135+:1055600000A010213087FFFF8CA500048C440000B0
63136+:105570000A00022A2406000627BDFFE0AFB0001093
63137+:10558000AFBF0018AFB100149363003E00808021CC
63138+:105590000080282130620040000020211040000FD0
63139+:1055A0008E1100000E000851022020219367000098
63140+:1055B0002404005030E500FF50A400128E0F0000BC
63141+:1055C000022020218FBF00188FB100148FB000106F
63142+:1055D000A762013C0A00091127BD00200E000287C6
63143+:1055E000000000000E0008510220202193670000F7
63144+:1055F0002404005030E500FF14A4FFF20220202113
63145+:105600008E0F00003C1008008E1000503C0D000C66
63146+:10561000240BFF8001F05021314E007F01DA602120
63147+:10562000018D4021014B4824AF4900280220202150
63148+:105630008FBF00188FB100148FB00010A50200D6E4
63149+:1056400027BD00200A000911AF8800D027BDFFE068
63150+:10565000AFBF0018AFB10014AFB0001093660001E7
63151+:10566000008080210E00025630D1000493640005B2
63152+:10567000001029C2A765000034830040A363000521
63153+:105680000E00025F020020210E00091302002021FB
63154+:1056900024020001AF62000C02002821A762001062
63155+:1056A00024040002A762001224060140A76200142D
63156+:1056B0000E000C5CA76200161620000F8FBF0018AA
63157+:1056C000978C00343C0B08008D6B00782588FFFF19
63158+:1056D0003109FFFF256A0001012A382B10E000067E
63159+:1056E000A78800343C0F6006240E001635ED00102C
63160+:1056F000ADAE00508FBF00188FB100148FB00010F6
63161+:1057000003E0000827BD002027BDFFE0AFB1001473
63162+:10571000AFBF0018AFB0001000A088211080000AB1
63163+:105720003C03600024020080108200120000000090
63164+:105730000000000D8FBF00188FB100148FB0001053
63165+:1057400003E0000827BD00208C682BF80500FFFE51
63166+:1057500000000000AC712BC08FBF00188FB1001487
63167+:105760008FB000103C09100027BD002003E00008A6
63168+:10577000AC692BF80E00025600A0202193650005AD
63169+:10578000022020210E00025F30B000FF2403003E03
63170+:105790001603FFE7000000008F4401780480FFFE3D
63171+:1057A000240700073C061000AF51014002202021D1
63172+:1057B000A34701448FBF00188FB100148FB00010B1
63173+:1057C000AF4601780A0002C227BD002027BDFFE8CE
63174+:1057D000AFBF0014AFB000108F50002000000000D9
63175+:1057E0000E000913AF440020AF5000208FBF0014FB
63176+:1057F0008FB0001003E0000827BD00183084FFFFC1
63177+:10580000008038212406003500A020210A00022A49
63178+:10581000000028213084FFFF008038212406003654
63179+:1058200000A020210A00022A0000282127BDFFD065
63180+:10583000AFB3001C3093FFFFAFB50024AFB2001828
63181+:10584000AFBF0028AFB40020AFB10014AFB000105C
63182+:1058500030B5FFFF12600027000090218F90001CE0
63183+:105860008E0300003C0680002402004000033E023C
63184+:1058700000032C0230E4007F006688241482001D9F
63185+:1058800030A500FF8F8300282C68000A510000100B
63186+:105890008F910014000358803C0C0800258C56940E
63187+:1058A000016C50218D49000001200008000000001B
63188+:1058B00002B210213045FFFF0E000236240400849E
63189+:1058C000162000028F90001CAF8000288F910014DA
63190+:1058D000260C002026430001018080213072FFFF4A
63191+:1058E00016200004AF8C001C0253502B1540FFDC27
63192+:1058F00000000000024010218FBF00288FB5002457
63193+:105900008FB400208FB3001C8FB200188FB1001429
63194+:105910008FB0001003E0000827BD0030240E0034D3
63195+:1059200014AE00F9000000009203000E241F168040
63196+:105930003C07000CA36300219202000D0347C8211D
63197+:105940003C066000A3620020961100123C0A7FFF13
63198+:10595000354CFFFFA771003C960B00102403000597
63199+:105960003168FFFFAF6800848E05001CAF5F002820
63200+:105970008F3800008CC4444803057826008F3021FE
63201+:10598000AF66004C8F69004C24CE00013C057F00BF
63202+:10599000AF6900508F740050AF740054AF66007050
63203+:1059A000AF6E00588F6D005824140050AF6D005C2E
63204+:1059B000A3600023AF6C0064A36300378E02001461
63205+:1059C000AF6200488F710048AF7100248E0B001841
63206+:1059D000AF6B006C9208000CA3680036937F003E0A
63207+:1059E00037F90020A379003E8F78007403058024E6
63208+:1059F000360F4000AF6F007493640000308900FFE1
63209+:105A0000513402452404FF803C04080024845A9841
63210+:105A10000E00028D000000003C1008008E105A9805
63211+:105A20000E00025602002021240600042407000173
63212+:105A3000A366007D020020210E00025FA36700051F
63213+:105A40008F5F017807E0FFFE240B0002AF5001409A
63214+:105A5000A34B01448F90001C3C081000AF48017814
63215+:105A60000A000362AF8000282CAD003751A0FF98D8
63216+:105A70008F9100140005A0803C180800271856BC20
63217+:105A8000029878218DEE000001C00008000000009F
63218+:105A90002418000614B80011000000003C0808009B
63219+:105AA0008D085A9824040005AF4800208E1F001866
63220+:105AB000AF7F00188F79004CAF79001C8F650050C4
63221+:105AC000122000C0AF6500700A000362AF84002896
63222+:105AD0002406000710A60083240300063C050800E6
63223+:105AE00024A55A980E000264240400818F90001CA3
63224+:105AF0000011102B0A000362AF8200282407000463
63225+:105B000014A7FFF6240500503C1808008F185A9877
63226+:105B1000AF5800208E0F0008AF6F00408E090008BC
63227+:105B2000AF6900448E14000CAF7400488E0E001054
63228+:105B3000AF6E004C8E0D0010AF6D00848E0A001405
63229+:105B4000AF6A00508E0C0018AF6C00548E04001C1D
63230+:105B5000AF64005893630000306B00FF116501D8FB
63231+:105B6000000000008F7400488F6900400289702394
63232+:105B700005C000042404008C1620FFDE240200036C
63233+:105B8000240400823C05080024A55A980E000287D0
63234+:105B9000000000008F90001C000010210A0003622A
63235+:105BA000AF820028240F000514AFFFCC240520008D
63236+:105BB0003C0708008CE75A98AF4700208E06000487
63237+:105BC000AF66005C9208000824100008A36800215A
63238+:105BD0008F9F001C93F90009A37900208F86001C79
63239+:105BE00090D8000A330400FF10900011000000005C
63240+:105BF0002885000914A0006924020002240A00205C
63241+:105C0000108A000B34058000288D002115A00008A3
63242+:105C100024054000240E0040108E00053C050001C4
63243+:105C200024140080109400023C050002240540006A
63244+:105C30008F7800743C19FF00031980240205782531
63245+:105C4000AF6F007490C4000BA36400818F84001CAC
63246+:105C50009489000C11200192000000009490000C27
63247+:105C60002406FFBF24050004A770003C908F000E9F
63248+:105C7000A36F003E8F84001C9089000FA369003F32
63249+:105C80008F8B001C8D6E00108F54007401D468231C
63250+:105C9000AF6D00608D6A0014AF6A0064956C0018E7
63251+:105CA000A76C00689563001AA763006A8D62001CE8
63252+:105CB000AF62006C9167000EA367003E9368003EE0
63253+:105CC0000106F8241220014BA37F003E8F90001C98
63254+:105CD0000A000362AF8500282407002214A7FF7F73
63255+:105CE000240300073C0B08008D6B5A981220000C0F
63256+:105CF000AF4B00200A000362AF830028240C00335E
63257+:105D000010AC0014240A00283C05080024A55A9869
63258+:105D10000E00023C240400810A0003EB8F90001C5B
63259+:105D20003C04080024845A980E00028D00000000F4
63260+:105D30009363000024110050306200FF10510135C0
63261+:105D4000000000008F90001C000018210A00036270
63262+:105D5000AF8300283C0D08008DAD5A9824040081C3
63263+:105D6000AF4D00203C05080024A55A980E00023CC7
63264+:105D7000A36A00348F90001C240200090A00036209
63265+:105D8000AF82002802B288213225FFFF0E000236C2
63266+:105D9000240400840A0003628F90001C1082FFA478
63267+:105DA00024050400288B000311600170240C0004FA
63268+:105DB000240300015483FF9E240540000A00043B95
63269+:105DC000240501003C04080024845A988F62004C8A
63270+:105DD0000E00028D8F6300508F90001C0000202168
63271+:105DE0000A000362AF8400288E1000042404008A95
63272+:105DF000AF50002093790005333800021700015F8F
63273+:105E0000020028219368002302002821311F00206E
63274+:105E100017E0015A2404008D9367003F2406001206
63275+:105E200030E200FF10460155240400810E000256A6
63276+:105E30000200202193630023240500040200202196
63277+:105E4000346B0042A36B00230E00025FA365007D4C
63278+:105E50008F4401780480FFFE240A0002AF50014005
63279+:105E6000A34A01448F90001C3C0C1000AF4C0178F9
63280+:105E70000A0003EC0011102B8E1000042404008A89
63281+:105E8000AF500020936E000531CD000215A0001622
63282+:105E900002002821936F003F2414000402002821EF
63283+:105EA00031E900FF11340010240400810E00025675
63284+:105EB000020020219362002324080012241FFFFE09
63285+:105EC00034460020A3660023A368003F93790005B1
63286+:105ED00002002021033FC0240E00025FA3780005CA
63287+:105EE00002002821000020210E00033400000000E1
63288+:105EF0000A0003EB8F90001C8E1000043C03000886
63289+:105F00000343A021AF500020928B000024050050D5
63290+:105F1000316400FF10850161240700880200202100
63291+:105F2000000028210E00022A2406000E928D000097
63292+:105F3000240EFF800200282101AE8025A2900000DF
63293+:105F4000240400040E000C5C240600300A0003EB5D
63294+:105F50008F90001C8E0800043C14080026945A9868
63295+:105F60003C010800AC285A98AF480020921F00035B
63296+:105F700033F9000413200002240200122402000658
63297+:105F8000A362003F920B001B2404FFC03165003F59
63298+:105F900000A43825A367003E9206000330C200012A
63299+:105FA00014400132000000008E020008AE8200089A
63300+:105FB0003C0208008C425AA010400131000249C244
63301+:105FC000A76900088E14000C240C0001240300149F
63302+:105FD000AF74002C8E0E0010AF6E0030960D0016C0
63303+:105FE000A76D0038960A0014A76A003AAF6C000C3F
63304+:105FF000A76C0010A76C0012A76C0014A76C001609
63305+:1060000012200136A3630034920F000331F0000226
63306+:106010002E1100018F90001C262200080A00036246
63307+:10602000AF8200288E0400043C0E0008034E30218D
63308+:10603000AF4400208E05000890CD0000240C0050D5
63309+:1060400031AA00FF114C00862407008824060009AD
63310+:106050000E00022A000000000A0003EB8F90001CD3
63311+:106060008E04001C0E00024100000000104000F4ED
63312+:10607000004050218F89001C240700890140202105
63313+:106080008D25001C240600010E00022A00000000DD
63314+:106090000A0003EB8F90001C960D00023C140800D0
63315+:1060A00026945A9831AA0004514000B83C10600070
63316+:1060B0008E0E001C3C010800AC2E5A98AF4E0020FA
63317+:1060C000920700102408001430E200FF144800D6A4
63318+:1060D00000000000960B00023163000114600165AE
63319+:1060E000000000008E020004AE8200083C1408008C
63320+:1060F0008E945AA01280015B000000008F7400741F
63321+:106100003C0380002404000102835825AF6B007417
63322+:10611000A3600005AF64000C3C0708008CE75AA0A0
63323+:106120008F86001CA7640010000711C2A76400122C
63324+:10613000A7640014A7640016A76200088CC80008B2
63325+:1061400024040002AF68002C8CC5000CAF65003041
63326+:1061500090DF0010A37F00348F99001C9330001152
63327+:10616000A37000358F98001C930F0012A36F0036A8
63328+:106170008F89001C912E0013A36E00378F90001C96
63329+:10618000960D0014A76D0038960A0016A76A003A0B
63330+:106190008E0C0018AF6C00245620FDCCAF84002874
63331+:1061A0003C05080024A55A980E0002640000202136
63332+:1061B0008F90001C0A0004A7000020218E1000040C
63333+:1061C00024070081AF500020936900233134001070
63334+:1061D000128000170000000002002021000028218A
63335+:1061E0002406001F0E00022A000000000A0003EB34
63336+:1061F0008F90001C3C05080024A55A980E000287C9
63337+:10620000240400828F90001C000028210A000362F1
63338+:10621000AF8500283C0408008C845A980E0014E8CE
63339+:10622000000000008F90001C0A000482000018216A
63340+:106230000E00025602002021937800230200202144
63341+:10624000370F00100E00025FA36F002300003821FB
63342+:1062500002002021000028210A0005A82406001FB2
63343+:10626000920F000C31E90001112000030000000032
63344+:106270009618000EA4D8002C921F000C33F90002CF
63345+:1062800013200005000038218E0200149608001229
63346+:10629000ACC2001CA4C8001A0A0005432406000969
63347+:1062A0003C05080024A55A980E0002872404008BA0
63348+:1062B0008F90001C0011282B0A000362AF85002874
63349+:1062C000AF6000843C0A08008D4A5A983C0D0800D3
63350+:1062D0008DAD0050240CFF803C02000C014D1821B4
63351+:1062E000006C2024AF4400288E070014306B007F20
63352+:1062F000017A282100A2C821AF2700D88E060014F9
63353+:10630000AF9900D0AF2600DC8E080010251FFFFEDD
63354+:106310000A000408AF3F01083C0508008CA55A9804
63355+:106320003C1908008F39005024CCFFFE00B9C02171
63356+:1063300003047824AF4F00283C1408008E945A9828
63357+:106340003C0908008D2900500289702131CD007F61
63358+:1063500001BA502101478021AE0600D8AF9000D08D
63359+:10636000AE0000DC0A0003B1AE0C0108548CFE3014
63360+:10637000240540000A00043B240510000E00032EF3
63361+:10638000000000000A0003EB8F90001C8E0F442CCD
63362+:106390003C186C62370979703C010800AC205A98AF
63363+:1063A00015E9000824050140979F00349786002CCA
63364+:1063B0000280282103E6C82B132000112404009238
63365+:1063C000240501400E000C7A240400023C01080060
63366+:1063D000AC225A98AF4200203C0508008CA55A9880
63367+:1063E00010A00005240400830E00084500000000F2
63368+:1063F00010400009240400833C05080024A55A9895
63369+:106400000E000264000000008F90001C0011202B81
63370+:106410000A000362AF8400280E0008490000000053
63371+:106420000A00055F8F90001C0E00084D0000000060
63372+:106430003C05080024A55A980A00062F2404008B66
63373+:10644000240400040E000C7A240500301440002AB5
63374+:10645000004050218F89001C240700830140202127
63375+:106460008D25001C0A000551240600018E04000839
63376+:106470000E000241000000000A00051BAE82000869
63377+:106480003C05080024A55A980E00023C240400870D
63378+:106490008F90001C0A0005360011102B8F830038E6
63379+:1064A0008F8600301066FE9D000038213C070800F2
63380+:1064B00024E75A1C000320C0008728218CAC000070
63381+:1064C00011900061246A00013143000F5466FFFA05
63382+:1064D000000320C00A0004F6000038213C05080033
63383+:1064E00024A55A980E000287240400828F90001C75
63384+:1064F0000A000536000010213C0B0008034B202148
63385+:106500002403005024070001AF420020A0830000B4
63386+:10651000A08700018F82001C90480004A08800180A
63387+:106520008F85001C90A60005A08600198F9F001C77
63388+:1065300093F90006A099001A8F90001C921800078A
63389+:10654000A098001B8F94001C928F0008A08F001C45
63390+:106550008F89001C912E0009A08E001D8F8D001CBC
63391+:1065600091AC000AA08C001E8F8B001C3C0C080014
63392+:10657000258C5A1C9163000B3C0B0800256B5A18A4
63393+:10658000A083001F8F87001C90E8000CA0880020CB
63394+:106590008F82001C9045000D24024646A0850021F4
63395+:1065A0008F86001C90DF000EA09F00228F99001C98
63396+:1065B0009330000FA09000238F98001C93140010BC
63397+:1065C000A09400248F8F001C91E90011A089002560
63398+:1065D0008F89001C8F8E00308F900038952D00140D
63399+:1065E000000E18C025C80001A48D002895270016AC
63400+:1065F000006C3021006BC821A487002A9525001863
63401+:106600003108000FA485002CA482002E8D3F001CB1
63402+:10661000ACCA0000AF88003011100006AF3F000088
63403+:10662000000038218D25001C014020210A00055161
63404+:1066300024060001250C00013184000F00003821E0
63405+:106640000A0006B8AF8400383C07080024E75A184F
63406+:106650000087302100003821ACA000000A0004F6B9
63407+:10666000ACC000003C05080024A55A980A00062F7B
63408+:10667000240400878E0400040E0002410000000084
63409+:106680000A00056AAE8200083084FFFF30C600FFB2
63410+:106690008F4201B80440FFFE00064400010430258B
63411+:1066A0003C07200000C720253C031000AF400180BC
63412+:1066B000AF450184AF44018803E00008AF4301B84F
63413+:1066C00027BDFFE8AFB00010AFBF00143C0760006B
63414+:1066D000240600021080000600A080210010102B6C
63415+:1066E0008FBF00148FB0001003E0000827BD001812
63416+:1066F0003C09600EAD2000348CE5201C8F82001C0C
63417+:106700002408FFFC00A81824ACE3201C0E0006D1CE
63418+:106710008C45000C0010102B8FBF00148FB00010A0
63419+:1067200003E0000827BD00183C02600E344701005A
63420+:1067300024090018274A040000000000000000009F
63421+:10674000000000003C06005034C30200AF44003893
63422+:10675000AF45003CAF430030014018218F4B000093
63423+:10676000316800201100FFFD2406007F2408FFFF90
63424+:106770008C6C000024C6FFFF24630004ACEC000016
63425+:1067800014C8FFFB24E70004000000000000000024
63426+:10679000000000003C0F0020AF4F00300000000060
63427+:1067A00024AD020001A5702B2529FFFF008E2021BA
63428+:1067B0001520FFE101A0282103E0000800000000EF
63429+:1067C00027BDFFE0AFB10014AFBF0018AFB000109D
63430+:1067D0003C05600E8CA20034008088211440000625
63431+:1067E0003C0460008C87201C2408FFFC00E8302457
63432+:1067F00034C30001AC83201C8F8B001C24090001D2
63433+:10680000ACA90034956900028D6500148D70000CF0
63434+:106810002D2400818D6700048D660008108000071C
63435+:106820008D6A00102D2C00041580000E30CE00075C
63436+:10683000312D000311A0000B000000002404008B88
63437+:10684000020028210E0006D1240600030011102B9F
63438+:106850008FBF00188FB100148FB0001003E0000844
63439+:1068600027BD002015C0FFF62404008B3C03002048
63440+:10687000AF4300300000000024020001AF8200148A
63441+:106880000000000000000000000000003C1F01505C
63442+:10689000013FC825253800033C0F600EAF47003884
63443+:1068A00000181882AF46003C35E8003CAF59003074
63444+:1068B000274704008F4400003086002010C0FFFDF1
63445+:1068C00000000000106000082466FFFF2403FFFFA3
63446+:1068D0008CEB000024C6FFFF24E70004AD0B000092
63447+:1068E00014C3FFFB250800043C08600EAD09003806
63448+:1068F0000000000000000000000000003C07002035
63449+:10690000AF470030000000000E0006F901402021D2
63450+:1069100002002821000020210E0006D124060003D9
63451+:106920000011102B8FBF00188FB100148FB0001012
63452+:1069300003E0000827BD002027BDFFE0AFB200182C
63453+:106940003092FFFFAFB10014AFBF001CAFB000101A
63454+:106950001640000D000088210A0007AA022010211D
63455+:1069600024050001508500278CE5000C0000000D77
63456+:10697000262300013071FFFF24E200200232382B71
63457+:1069800010E00019AF82001C8F8200141440001622
63458+:106990008F87001C3C0670003C0320008CE5000043
63459+:1069A00000A62024148300108F84003C00054402BC
63460+:1069B0003C09800000A980241480FFE9310600FF13
63461+:1069C0002CCA00095140FFEB262300010006688015
63462+:1069D0003C0E080025CE579801AE60218D8B00003B
63463+:1069E0000160000800000000022010218FBF001C81
63464+:1069F0008FB200188FB100148FB0001003E00008B0
63465+:106A000027BD00200E0006D1240400841600FFD804
63466+:106A10008F87001C0A00078BAF80003C90EF0002BC
63467+:106A200000002021240600090E0006D1000F2E00D0
63468+:106A30008F87001C0010102B0A00078BAF82003CD0
63469+:106A4000020028210E0006DF240400018F87001CAD
63470+:106A50000A00078BAF82003C020028210E0006DFEF
63471+:106A6000000020210A0007C38F87001C0E00071FAB
63472+:106A7000020020210A0007C38F87001C30B0FFFFEF
63473+:106A8000001019C08F5801B80700FFFE3C1F2004FA
63474+:106A90003C191000AF430180AF400184AF5F018813
63475+:106AA000AF5901B80A00078C262300013082FFFF8E
63476+:106AB00014400003000018210004240224030010E5
63477+:106AC000308500FF14A000053087000F2466000801
63478+:106AD0000004220230C300FF3087000F14E00005DD
63479+:106AE000308900032468000400042102310300FF00
63480+:106AF0003089000315200005388B0001246A00024C
63481+:106B000000042082314300FF388B00013164000112
63482+:106B100010800002246C0001318300FF03E00008B4
63483+:106B200000601021308BFFFF000B394230E600FF80
63484+:106B30003C09080025295998000640800109602178
63485+:106B40008D8700003164001F240A0001008A1804A8
63486+:106B500030A500FF00E3202514A000020003102749
63487+:106B600000E22024240F000100CF700401096821F5
63488+:106B7000000E282714800005ADA400008F86000CAD
63489+:106B800000A6102403E00008AF82000C8F88000CE0
63490+:106B900001C8102503E00008AF82000C3C06001F6E
63491+:106BA0003C0360003084FFFF34C5FF8024020020D6
63492+:106BB000AC602008AC60200CAC602010AC652014E8
63493+:106BC000AC642018AC62200000000000000000004F
63494+:106BD00003E000080000000027BDFFE82402FFFFDB
63495+:106BE000AFBF0010AF82000C000020213C0608005F
63496+:106BF00024C659982405FFFF248900010004408021
63497+:106C00003124FFFF010618212C87002014E0FFFA31
63498+:106C1000AC6500000E0008160000202124020001CF
63499+:106C20003C04600024050020AC822018AC852000C4
63500+:106C3000000000000000000000000000244A0001E5
63501+:106C40003142FFFF2C46040014C0FFF78FBF001035
63502+:106C500003E0000827BD00188F8300082C620400A1
63503+:106C600003E00008384200018F830008246200011D
63504+:106C700003E00008AF8200088F8300082462FFFF52
63505+:106C800003E00008AF82000827BDFFE0AFB10014A9
63506+:106C9000AFBF0018AFB000108F6B00303C06600033
63507+:106CA00000808821ACCB20088F6A002C3C02800039
63508+:106CB00024030008ACCA200C9769003A9768003892
63509+:106CC00000092C003107FFFF00A72025ACC42010CD
63510+:106CD000ACC22014ACC32000000000000000000083
63511+:106CE000000000003C0360008C6D200031AC000807
63512+:106CF0001580FFF9000000008C6E201405C00020F4
63513+:106D0000000000000E0007DA8F84000C00024080B3
63514+:106D10003C09080025295998010938218CE4000014
63515+:106D20000E0007DA00028140020220213090FFFFAE
63516+:106D3000020020210E0007F8000028213C0C8000F2
63517+:106D4000022C58253210FFFF3C116000240A00205D
63518+:106D5000AE2B2014AE302018AE2A20000000000018
63519+:106D60000000000000000000020010218FBF00188A
63520+:106D70008FB100148FB0001003E0000827BD002081
63521+:106D80008C6620143C02001F3443FF803C1FFFE848
63522+:106D900000C3C02437F9080003198021001079C20C
63523+:106DA0003C0C8000022C582531F0FFFF3C116000A4
63524+:106DB000240A0020AE2B2014AE302018AE2A20006A
63525+:106DC0000000000000000000000000000200102190
63526+:106DD0008FBF00188FB100148FB0001003E00008BF
63527+:106DE00027BD002027BDFFE8AFB000103402FFFF31
63528+:106DF0003090FFFFAFBF00141202000602002021F6
63529+:106E00000E00081600000000020020210E0007F806
63530+:106E1000240500018F8400088FBF00148FB000107C
63531+:106E20002483FFFF27BD001803E00008AF8300089C
63532+:106E3000000439C230E6003F00043B42000718401E
63533+:106E4000240210002CC4002024C8FFE0AF42002C14
63534+:106E5000246300011480000330A900FF00071840DC
63535+:106E6000310600FF0003608024080001019A5821C8
63536+:106E70003C0A000E00C82804016A382111200005D0
63537+:106E8000000530278CE900000125302503E00008CB
63538+:106E9000ACE600008CEE000001C6682403E00008A8
63539+:106EA000ACED000027BDFFE8AFBF0014AFB000108D
63540+:106EB0003C0460008C8508083403F00030A2F00028
63541+:106EC00050430006240200018C8708083404E000C7
63542+:106ED00030E6F00010C4001E24020002AF82004021
63543+:106EE0003C1060003C0A0200AE0A0814240910009D
63544+:106EF0003C08000E8E03440003482021AF49002CBB
63545+:106F0000240501200E000CC0000030218F830040BA
63546+:106F1000106000043C021691240B0001106B000E5F
63547+:106F20003C023D2C344F0090AE0F44088FBF00143C
63548+:106F30008FB000103C0C6000240E10003C0D0200CD
63549+:106F400027BD0018AD8E442003E00008AD8D081069
63550+:106F50000A0008E7AF8000403C0218DA344F009086
63551+:106F6000AE0F44088FBF00148FB000103C0C6000BF
63552+:106F7000240E10003C0D020027BD0018AD8E4420E9
63553+:106F800003E00008AD8D08100A0008BB24050001CD
63554+:106F90000A0008BB000028213C08080025085DA461
63555+:106FA0002404FFFF010018212402001E2442FFFFD9
63556+:106FB000AC6400000441FFFD246300043C070800AA
63557+:106FC00024E75E208CE5FFFC2404001C240600015D
63558+:106FD000308A001F0146480424840001000910275C
63559+:106FE0002C8300201460FFFA00A22824ACE5FFFCEB
63560+:106FF0003C05666634A4616E3C06080024C65EE06B
63561+:10700000AF840058AF88009C2404FFFF00C0182103
63562+:107010002402001F2442FFFFAC6400000441FFFD76
63563+:10702000246300043C0766663C05080024A55EA0B6
63564+:10703000AF86004834E6616EAF8600982404FFFFF7
63565+:1070400000A018212402000F2442FFFFAC640000BE
63566+:107050000441FFFD246300043C0B66663C06080007
63567+:1070600024C65E203568616EAF8500A4AF880070CD
63568+:107070002404FFFF00C018212402001F2442FFFF48
63569+:10708000AC6400000441FFFD246300043C0D66660F
63570+:107090003C0A0800254A5F6035AC616EAF860090FF
63571+:1070A000AF8C005C2404FFFF014018212402000380
63572+:1070B0002442FFFFAC6400000441FFFD2463000490
63573+:1070C0003C09080025295F708D27FFFC2404000679
63574+:1070D000240500013099001F0325C0042484000109
63575+:1070E000001878272C8E002015C0FFFA00EF3824F6
63576+:1070F000AD27FFFC3C09666624030400240403DC7E
63577+:1071000024050200240600663522616E3C08080052
63578+:1071100025085AA4AF820074AF830044AF83006C8B
63579+:10712000AF830050AF830084AF8A008CAF840064CB
63580+:10713000AF85004CAF860054AF840078AF85006007
63581+:10714000AF86008001001821240200022442FFFFC4
63582+:10715000AC6000000441FFFD24630004240400032C
63583+:107160002403000C3C0A0800254A5AB0AF8A006884
63584+:107170000A00098E2405FFFF000418802484000102
63585+:10718000006858212C8700C014E0FFFBAD650000AB
63586+:107190003C0E666635CD616E240C17A024081800DD
63587+:1071A000AF8D0088AF8C009403E00008AF88007CAE
63588+:1071B0002484007F000421C200004021000030210F
63589+:1071C00000003821000028210A0009A5AF8400A092
63590+:1071D0001060000624E7000100C4302124A500014E
63591+:1071E0002CC20BF51440FFFA2CA300663C090800E2
63592+:1071F00025295F6001201821240200032442FFFF9B
63593+:10720000AC6000000441FFFD2463000410E0001A9C
63594+:1072100024E3FFFF0003294210A0000A0000202100
63595+:107220002406FFFF3C03080024635F602484000100
63596+:107230000085502BAC660000250800011540FFFBBF
63597+:107240002463000430E2001F10400008000868803A
63598+:10725000240C0001004C38040008588001692821E2
63599+:1072600024E6FFFF03E00008ACA6000001A94021CE
63600+:107270002409FFFFAD09000003E000080000000042
63601+:10728000AF4400283C04000C034420210005288260
63602+:107290000A000CC000003021000421803C03600083
63603+:1072A000AC6410080000000000052980AC65100CDB
63604+:1072B0000000000003E000088C62100C27BDFFE80E
63605+:1072C0000080282124040038AFBF00140E0009D527
63606+:1072D000AFB0001024040E00AF4400283C10000C96
63607+:1072E00003502021240500100E000CC000003021A6
63608+:1072F00003501021AC400000AC40000424040038CE
63609+:107300008FBF00148FB0001024053FFF27BD001869
63610+:107310000A0009D58C430000000421803C03600072
63611+:10732000AC641008000000008C62100C03E0000840
63612+:107330000002118227BDFFC8AFB400208F940068FF
63613+:10734000AFBE0030AFB7002CAFB600280000B821A8
63614+:107350000080B021241E00C0AFBF0034AFB50024B0
63615+:10736000AFB3001CAFB20018AFB10014AFB0001043
63616+:107370000A000A12AFA5003C504000018F9400683B
63617+:1073800027DEFFFF13C00028269400048E92000021
63618+:107390003C03080024635DA01240FFF70283102B1A
63619+:1073A0003C04080024845AA4028410230002A8C0CC
63620+:1073B000000098210A000A212411000100118840D0
63621+:1073C000122000260000000002B380210251282470
63622+:1073D0000200202110A0FFF9267300010E0009DE33
63623+:1073E000000000000016684032EC000101AC2021D2
63624+:1073F0000E0009D5020028218F89009426F700018C
63625+:107400008FA6003C3AEB0001316A00012528FFFFFE
63626+:107410000011382702CAB021AF88009416E6FFE7B2
63627+:1074200002479024AE92000002E010218FBF00348A
63628+:107430008FBE00308FB7002C8FB600288FB5002488
63629+:107440008FB400208FB3001C8FB200188FB10014CE
63630+:107450008FB0001003E0000827BD00383C0E080084
63631+:1074600025CE5DA0028E102B0A000A0DAE92000000
63632+:1074700027BDFFD8AFB10014AFB00010AFBF0020E0
63633+:10748000AFB3001CAFB2001800A0882110A0001FED
63634+:10749000000480403C13080026735AA40A000A5ACC
63635+:1074A0002412000112200019261000010E0009F517
63636+:1074B00002002021000231422444FFA0000618806F
63637+:1074C0003045001F2C8217A1007318212631FFFFC1
63638+:1074D0001040FFF400B230048C690000020020214B
63639+:1074E00024053FFF012640241500FFEE0126382524
63640+:1074F0000E0009D5AC6700008F8A009426100001A9
63641+:10750000254700011620FFE9AF8700948FBF0020B8
63642+:107510008FB3001C8FB200188FB100148FB0001011
63643+:1075200003E0000827BD00288F85009C00805821BB
63644+:107530000000402100004821240A001F3C0C0800E4
63645+:10754000258C5E1C3C0D080025AD5DA48CA60000BA
63646+:1075500050C000140000402100AD1023000238C0CC
63647+:10756000240300010A000A930000202115000003F3
63648+:1075700000E410212448202400004821252900018E
63649+:10758000512B00132506DFDC106000062484000167
63650+:1075900000C3702415C0FFF5000318400A000A91CB
63651+:1075A0000000402110AC002624A300040060282124
63652+:1075B000254AFFFF1540FFE5AF85009C512B0004D5
63653+:1075C0002506DFDC0000402103E000080100102157
63654+:1075D0000006614230C5001F000C50803C070800C7
63655+:1075E00024E75DA424040001014730211120000F8D
63656+:1075F00000A420043C05080024A55E20148000059A
63657+:107600002529FFFF24C6000410C50011000000005A
63658+:10761000240400018CCF00000004C0270004204097
63659+:1076200001F868241520FFF5ACCD00008F99007893
63660+:1076300001001021032B482303E00008AF890078E4
63661+:107640003C05080024A55DA40A000A9B0000402117
63662+:107650003C06080024C65DA40A000AB42404000104
63663+:10766000308800FF240200021102000A24030003F4
63664+:107670001103005C8F8900A4240400041104005F3E
63665+:1076800024050005110500670000182103E000082B
63666+:10769000006010218F8900483C0C0800258C5EE0BA
63667+:1076A0003C04080024845F60240300201060000F65
63668+:1076B00000005821240D0002240E00033C0F080096
63669+:1076C00025EF5EE08D27000014E0000B30F9FFFF8E
63670+:1076D000252900040124C02B53000001018048210A
63671+:1076E0002463FFFF5460FFF88D270000016018211C
63672+:1076F00003E0000800601021132000323C0500FF69
63673+:1077000030E200FF004030211040004200005021D4
63674+:1077100024050001000020210005C84000A6C02467
63675+:1077200017000003332500FF14A0FFFB2484000191
63676+:10773000012CC023001828C000AA6021008C502111
63677+:107740003144001F240C0001008C18040003102792
63678+:1077500000E23024110D0041AD260000110E004C56
63679+:10776000000A1840110D00368F87006C510E00562C
63680+:107770008F8C0060240D0004110D005A8F8E008440
63681+:10778000240E0005150EFFDA01601821240B1430B9
63682+:1077900011400006000018218F8400A0246300011E
63683+:1077A000006A402B1500FFFD016458218F8A00807C
63684+:1077B000AF89008C016018212549FFFF0A000AEB00
63685+:1077C000AF89008000E52024000736021080FFD03A
63686+:1077D000240A001800075402314600FF0A000AF389
63687+:1077E000240A00103C0C0800258C5EA03C04080014
63688+:1077F00024845EE00A000ADA240300103C0C08002E
63689+:10780000258C5E203C04080024845EA00A000AD96E
63690+:107810008F89009000071A02306600FF0A000AF301
63691+:10782000240A00088F89008C3C0C0800258C5F60BE
63692+:107830003C04080024845F700A000ADA2403000470
63693+:10784000000A4080250B003024E6FFFF016018216C
63694+:10785000AF8900480A000AEBAF86006C000AC982B3
63695+:10786000001978803C07080024E75EA001E720218A
63696+:10787000000A18428C8F00003079001F032C380456
63697+:107880000007C02701F860240A000B08AC8C000038
63698+:10789000000331420006288000AF28213062001F1B
63699+:1078A0008CB8000024630001004CC804000321428E
63700+:1078B000001938270004108003073024004F2021CE
63701+:1078C0000A000B4CACA60000000A68C025AB0032D1
63702+:1078D000258AFFFF01601821AF8900A40A000AEB86
63703+:1078E000AF8A0060254B1030AF89009001601821ED
63704+:1078F00025C9FFFF0A000AEBAF8900843086000724
63705+:107900002CC2000610400014000000000006408059
63706+:107910003C030800246357BC010338218CE40000B9
63707+:1079200000800008000000002409000310A9000ED8
63708+:1079300000000000240A000510AA000B000000004F
63709+:10794000240B000110AB0008000000008F8C00A089
63710+:1079500010AC00050000000003E00008000010214A
63711+:107960000A000A7900A020210A000AC700C02021CD
63712+:1079700027BDFFE8308400FF240300021083000BC2
63713+:10798000AFBF0010240600031086003A240800044C
63714+:1079900010880068240E0005108E007F2CAF143074
63715+:1079A0008FBF001003E0000827BD00182CA2003094
63716+:1079B0001440FFFC8FBF001024A5FFD0000531C28A
63717+:1079C000000668803C07080024E75EE001A730213C
63718+:1079D0008CC900000005288230AC001F240B000178
63719+:1079E000018B50048F840048012A4025ACC8000058
63720+:1079F0008C83000050600001AF8600488F98006CB7
63721+:107A000030AE000124A6FFFF270F000115C00002C1
63722+:107A1000AF8F006C24A600010006414200082080C0
63723+:107A2000008718218C79000030C2001F2406000155
63724+:107A30000046F804033F382410E0FFDA8FBF00103F
63725+:107A40000005C182001870803C0F080025EF5EA081
63726+:107A500001CF48218D2B00000005684231A5001F91
63727+:107A600000A66004016C502527BD001803E0000843
63728+:107A7000AD2A00002CA7003014E0FFCA8FBF001011
63729+:107A800030B900071723FFC724A8FFCE00086A02F9
63730+:107A9000000D60803C0B0800256B5EA0018B30213F
63731+:107AA0008CC40000000828C230AA001F240800016E
63732+:107AB000014848048F8200A400891825ACC3000047
63733+:107AC0008C5F000053E00001AF8600A40005704009
63734+:107AD000000E7942000F28803C04080024845EE0F8
63735+:107AE00000A418218C6B000025DF000131CD001FA0
63736+:107AF000001F514201A86004016C4825000A108053
63737+:107B0000AC690000004428218CA600008F9800601A
63738+:107B100033F9001F8FBF00100328380400C77825F1
63739+:107B2000270E000127BD0018ACAF000003E00008DD
63740+:107B3000AF8E006024A5EFD02CB804001300FF998D
63741+:107B40008FBF001000053142000658803C0A080033
63742+:107B5000254A5E20016A30218CC4000030A3001F3A
63743+:107B600024090001006910048F9900900082F82513
63744+:107B7000ACDF00008F27000050E00001AF860090CE
63745+:107B80008F8D00848FBF001027BD001825AC000129
63746+:107B900003E00008AF8C008415E0FF828FBF001067
63747+:107BA0008F8600A0000610400046F821001F21002B
63748+:107BB00003E4C8210019384024F8143000B8402BE1
63749+:107BC0001100FF788FBF001024A4EBD00E00021329
63750+:107BD00000C0282100027942000F70803C0D08008F
63751+:107BE00025AD5F6001CD20218C8B0000304C001F43
63752+:107BF00024060001018618048F89008C016350253A
63753+:107C0000AC8A00008D25000050A00001AF84008CDC
63754+:107C10008F9800808FBF001027BD00182708000133
63755+:107C200003E00008AF88008030A5000724030003AC
63756+:107C300010A3001028A2000414400008240700022A
63757+:107C40002403000410A300152408000510A8000F49
63758+:107C50008F8500A003E000080000000014A7FFFDCE
63759+:107C60000080282114C3FFFB240400020A000B8BB0
63760+:107C700000000000240900050080282110C9FFFB36
63761+:107C80002404000303E000080000000014C5FFF115
63762+:107C9000008028210A000B8B24040005240A00011F
63763+:107CA0000080282110CAFFF12404000403E000082A
63764+:107CB0000000000027BDFFE0AFB00010000581C24A
63765+:107CC0002603FFD024C5003F2C6223D024C6007FAA
63766+:107CD000AFB20018AFB10014AFBF001C309100FF6D
63767+:107CE000000691C2000529820200202110400008F0
63768+:107CF0002403FFFF0E000A4B0000000002002021B9
63769+:107D0000022028210E000C390240302100001821E9
63770+:107D10008FBF001C8FB200188FB100148FB00010FD
63771+:107D20000060102103E0000827BD002027BDFFD818
63772+:107D300024A2007FAFB3001CAFB20018000299C2AA
63773+:107D4000309200FF24A3003F02402021026028213E
63774+:107D5000AFB10014AFB00010AFBF00200E000B6E2B
63775+:107D60000003898200408021004020210220282138
63776+:107D700014400009000018218FBF00208FB3001CA1
63777+:107D80008FB200188FB100148FB000100060102166
63778+:107D900003E0000827BD00280E0009FC00000000D9
63779+:107DA00000402821020020211051FFF3001019C0CB
63780+:107DB0000E000A4B00000000020020210240282192
63781+:107DC0000E000C39026030218FBF00208FB3001CE1
63782+:107DD0008FB200188FB100148FB00010000018216E
63783+:107DE0000060102103E0000827BD00283084FFFF59
63784+:107DF00030A5FFFF1080000700001821308200012D
63785+:107E00001040000200042042006518211480FFFB8E
63786+:107E10000005284003E000080060102110C00007A2
63787+:107E2000000000008CA2000024C6FFFF24A500046F
63788+:107E3000AC82000014C0FFFB2484000403E00008AF
63789+:107E40000000000010A0000824A3FFFFAC86000083
63790+:107E500000000000000000002402FFFF2463FFFF79
63791+:107E60001462FFFA2484000403E00008000000000C
63792+:107E700030A5FFFF8F4201B80440FFFE3C076015AC
63793+:107E800000A730253C031000AF440180AF400184BF
63794+:107E9000AF46018803E00008AF4301B88F8500D0EA
63795+:107EA0002C864000008018218CA700840087102BAE
63796+:107EB00014400010000000008CA800842D06400033
63797+:107EC00050C0000F240340008CAA0084008A482B75
63798+:107ED000512000018CA3008400035A42000B208033
63799+:107EE0003C05080024A558200085182103E000085F
63800+:107EF0008C62000014C0FFF4000000002403400066
63801+:107F000000035A42000B20803C05080024A558209D
63802+:107F10000085182103E000088C6200008F8300D0E8
63803+:107F2000906600D024C50001A06500D08F8500D0E8
63804+:107F3000906400D090A200D210440017000000000E
63805+:107F4000936C00788F8B00BC318A00FFA16A000C13
63806+:107F500025490001938700C4312200FF3048007F8B
63807+:107F60001107000B00026827A36200788F4E01788A
63808+:107F700005C0FFFE8F9900B0241800023C0F1000CE
63809+:107F8000AF590140A358014403E00008AF4F017806
63810+:107F90000A000D0931A20080A0A000D00A000CFF49
63811+:107FA000000000008F8700D027BDFFC8AFBF0030A2
63812+:107FB000AFB7002CAFB60028AFB50024AFB4002097
63813+:107FC000AFB3001CAFB20018AFB10014AFB00010D7
63814+:107FD00094E300E094E200E2104300D72405FFFFA1
63815+:107FE0003C047FFF3497FFFF2415FF800A000DF04B
63816+:107FF0003C16000E108A00D18FBF00308F9100B068
63817+:108000003C1808008F18005C001230C0001291402C
63818+:108010000311702101D57824AF4F002C94EC00E2BD
63819+:1080200031CD007F01BA5821318A7FFF0176482186
63820+:10803000000A804002091021945300003C08080007
63821+:108040008D0800580246C02132733FFF001319808B
63822+:10805000010320210224282130BF007F03FAC82118
63823+:1080600000B5A024AF54002C0336A0218E87001049
63824+:108070008E8F003003785821256D008800EF702323
63825+:10808000240C0002AE8E0010AF8D00ACA16C0088F5
63826+:10809000976A003C8E8400308F9100AC0E000CD6A5
63827+:1080A0003150FFFF00024B80020940253C02420094
63828+:1080B00001022025AE2400048E8300048F8D00ACC5
63829+:1080C0008E860000240E0008ADA3001CADA600188B
63830+:1080D000ADA0000CADA00010929F000A33F900FF84
63831+:1080E000A5B90014968500083C1F000CA5A5001634
63832+:1080F0009298000A331100FFA5B100209690000865
63833+:1081000024180005A5B00022ADA00024928F000B1A
63834+:108110002410C00031E700FFA5A70002A1AE0001B6
63835+:108120008E8C00308F8B00AC8F8400B0AD6C00085B
63836+:108130003C0A08008D4A005401444821013540247E
63837+:10814000AF4800283C0208008C4200540044302113
63838+:1081500030C3007F007AC821033F282102458821CF
63839+:10816000AF9100BCAF8500C0A23800008F8A00BC70
63840+:108170002403FFBF2418FFDF954F000201F03824CD
63841+:1081800000F37025A54E0002914D000231AC003F76
63842+:10819000358B0040A14B00028F8600BC8F8900D038
63843+:1081A000ACC000048D28007C3C098000ACC80008ED
63844+:1081B00090C4000D3082007FA0C2000D8F8500BCEE
63845+:1081C00090BF000D03E3C824A0B9000D8F9100BC3F
63846+:1081D0009233000D02789024A232000D8E9000346C
63847+:1081E0008F8B00BCAD7000108E87002C8E8F0030FE
63848+:1081F00000EF7023AD6E0014916D001831AC007F5C
63849+:10820000A16C00188F9F00BC8E8A00308FE8001888
63850+:10821000015720240109302400C41025AFE20018C2
63851+:108220009283000AA3E3001C969900088F8500BC86
63852+:108230008F9800D0A4B9001E8E9000308E8400303C
63853+:108240000E0002138F0500848F8500D0000291403C
63854+:108250000002990090AF00BC0253882100403021F9
63855+:1082600031E7000210E0000302118021000290803B
63856+:108270000212802190B900BC3327000410E00002F4
63857+:108280000006F880021F80218E9800308F8B00BC82
63858+:1082900024068000330F0003000F702331CD00034C
63859+:1082A000020D6021AD6C000494A400E294AA00E2E7
63860+:1082B00094B000E231497FFF2522000130537FFF57
63861+:1082C0000206182400734025A4A800E294A400E24A
63862+:1082D0003C1408008E94006030917FFF123400221D
63863+:1082E000000000000E000CF6000000008F8700D098
63864+:1082F0000000282194F300E094F000E21213000F34
63865+:108300008FBF003090E900D090E800D1313200FFFB
63866+:10831000310400FF0244302B14C0FF36264A00010E
63867+:1083200090EE00D2264B000131CD00FF008D602180
63868+:10833000158BFF338F9100B08FBF00308FB7002CAB
63869+:108340008FB600288FB500248FB400208FB3001C97
63870+:108350008FB200188FB100148FB0001000A0102150
63871+:1083600003E0000827BD003894A300E20066402423
63872+:10837000A4A800E290A400E290B900E2309100FFCE
63873+:108380000011A1C20014F827001F39C03332007F4A
63874+:10839000024730250A000DE8A0A600E23084FFFF66
63875+:1083A00030A5FFFFAF440018AF45001C03E00008F4
63876+:1083B0008F42001427BDFFB8AFB000208F9000D0CF
63877+:1083C0003084FFFFAFA40010AFBF0044AFBE004039
63878+:1083D000AFB7003CAFB60038AFB50034AFB4003033
63879+:1083E000AFB3002CAFB20028AFB10024A7A0001893
63880+:1083F000920600D1920500D030C400FF30A300FFE8
63881+:108400000064102B10400122AFA00014920900D08C
63882+:108410008FB50010312800FF0088382324F4FFFFB7
63883+:108420000014882B0015982B02339024524001260B
63884+:108430008FB40014961E0012961F00108FB7001004
63885+:1084400003DFC823001714000019C400000224032E
63886+:108450000018140302E2B02A52C00001004020219B
63887+:108460000284282B10A0000200801821028018210D
63888+:1084700000033C0000071C033064FFFF2C8600094A
63889+:1084800014C000020060B821241700088E0A0008FA
63890+:10849000001769808E09000C31ABFFFF3C0C001007
63891+:1084A000016C402527520400AF4A0038AF9200B853
63892+:1084B000AF49003CAF480030000000000000000061
63893+:1084C00000000000000000000000000000000000AC
63894+:1084D00000000000000000008F4F000031EE00207F
63895+:1084E00011C0FFFD0017982A027110240A000E83A4
63896+:1084F0000000B02155E001019258000131130080C5
63897+:10850000126001CF012020219655001232A5FFFFF5
63898+:108510000E000CCBA7B500188F9000D00291A023BD
63899+:1085200026CD00018F9100B8000DB4000016B403F1
63900+:108530002638004002D7582A0014882B2405000151
63901+:108540000300902101711024AF9800B8AFA500146A
63902+:10855000104001BC8F8900B03C0C08008D8C005489
63903+:10856000240BFF80921E00D001895021014B28244A
63904+:10857000921900D0AF4500288E4700103C08080033
63905+:108580008D0800583C1808008F18005430E33FFF56
63906+:108590000003218001043021012658212402FF809C
63907+:1085A0000162F824920C00D0AF5F002C92480000CA
63908+:1085B00033D100FF333500FF0309982100117140CA
63909+:1085C000001578C0326D007F01CF382101BA282113
63910+:1085D000318300FF3164007F3C0A000C00AA88212F
63911+:1085E0000367F02100033140009A10213108003F59
63912+:1085F0003C1F000E00D1C021005F982127D90088C0
63913+:108600002D150008AF9100C0AF9900ACAF9800BC29
63914+:10861000AF9300B412A0018A00008821240E00014B
63915+:10862000010E4004310D005D11A0FFB2310F0002B8
63916+:108630008E4A00283C0300803C04FFEFAE6A000035
63917+:108640008E450024A260000A3488FFFFAE65000456
63918+:108650009247002C3C1FFF9F37FEFFFFA267000CD4
63919+:108660008E62000C3C180040A267000B00433025CE
63920+:1086700000C8C824033E88240238A825AE75000C23
63921+:108680008E490004AE6000183C0F00FFAE69001474
63922+:108690008E4D002C35EEFFFF8F8B00B001AE6024B5
63923+:1086A000AE6C00108E470008A660000896450012C8
63924+:1086B000AE6700208E42000C30B03FFF00105180AA
63925+:1086C000AE6200248E5E0014014B182130A400011C
63926+:1086D000AE7E00288E590018000331C2000443808A
63927+:1086E000AE79002C8E51001C00C8F821A67F001C1A
63928+:1086F000AE710030965800028E550020A678001EFC
63929+:10870000AE75003492490033313000045600000544
63930+:10871000925000008F8C00D08D8B007CAE6B0030AF
63931+:10872000925000008F8F00BCA1F00000924E0033E9
63932+:1087300031CD000251A00007925E00018F8900BC7C
63933+:108740002418FF80913100000311A825A1350000F5
63934+:10875000925E00018F9900BC2409FFBF240BFFDF4C
63935+:10876000A33E00018F9500BC92B8000D3311007F2D
63936+:10877000A2B1000D8F8E00BC91D0000D02097824AB
63937+:10878000A1CF000D8F8800BC8E6D0014910A000DE2
63938+:108790002DAC0001000C2940014B382400E51825C0
63939+:1087A000A103000D964200128F8800BC8F8700D075
63940+:1087B000A50200028E45000490FF00BC30A4000317
63941+:1087C0000004302330DE000300BE102133F9000224
63942+:1087D00017200002244400342444003090E200BCFE
63943+:1087E00000A2302430DF000417E0000224830004DC
63944+:1087F000008018218F8F00AC24090002AD03000413
63945+:10880000A1E90000924E003F8F8D00ACA1AE0001A7
63946+:108810008F9500AC924C003F8E440004A6AC000241
63947+:10882000976B003C0E000CD63170FFFF00025380A6
63948+:10883000020A38253C05420000E51825AEA30004D5
63949+:108840008F8600AC8E480038ACC800188E440034C7
63950+:10885000ACC4001CACC0000CACC00010A4C0001420
63951+:10886000A4C00016A4C00020A4C00022ACC00024F4
63952+:108870008E6400145080000124040001ACC4000880
63953+:108880000E000CF6241100010A000E768F9000D025
63954+:10889000920F00D2920E00D08FB5001031EB00FF86
63955+:1088A00031CD00FF008D6023016C50212554FFFF66
63956+:1088B0000014882B0015982B023390241640FEDDFF
63957+:1088C000000000008FB400148FBF00448FBE004032
63958+:1088D0003A8200018FB7003C8FB600388FB5003464
63959+:1088E0008FB400308FB3002C8FB200288FB10024DA
63960+:1088F0008FB0002003E0000827BD0048331100209E
63961+:10890000122000EF24150001921E00BC241F00015C
63962+:108910000000A82133D900011320000DAFBF001CB7
63963+:108920008E4400148E0800840088102B144000022E
63964+:10893000008030218E0600848E03006400C3A82BC3
63965+:1089400016A0000200C020218E0400640080A8212F
63966+:108950008E4700148E05006400E5302B14C0000221
63967+:1089600000E020218E0400640095F02313C0000471
63968+:108970008FAC001C240A0002AFAA001C8FAC001CA4
63969+:10898000028C582B156000A8000018218E4F00386B
63970+:108990008E6D000C3C0E0080AE6F00008E4A0034DD
63971+:1089A0003C10FF9F01AE5825AE6A00049246003F7E
63972+:1089B000360CFFFF016C38243C0500203C03FFEF20
63973+:1089C000A266000B00E510253468FFFF8F8700B812
63974+:1089D0000048F8243C04000803E4C825AE79000CE4
63975+:1089E0008CF80014AE60001802BE7821AE78001436
63976+:1089F0008CF10018AE71001C8CE90008AE690024EF
63977+:108A00008CEE000CAE6F002CAE600028AE6E002025
63978+:108A1000A6600038A660003A8CED001401B58023F2
63979+:108A2000021E902312400011AE72001090EA003D29
63980+:108A30008E6500048E640000000A310000A6C82183
63981+:108A4000000010210326402B0082F82103E8C021FA
63982+:108A5000AE790004AE78000090F1003DA271000AEA
63983+:108A60008F8900B895320006A67200088F9800AC76
63984+:108A70002419000202A02021A31900009769003CDC
63985+:108A80008F9200AC0E000CD63131FFFF00027B80CC
63986+:108A90008F8500B8022F68253C0E420001AE80256C
63987+:108AA000AE5000048F8400AC8CAC0038AC8C001845
63988+:108AB0008CAB0034AC8B001CAC80000CAC80001084
63989+:108AC000A4800014A4800016A4800020A4800022AA
63990+:108AD000AC80002490A7003FA487000212A00135BB
63991+:108AE0002403000153C0000290A2003D90A2003E6A
63992+:108AF00024480001A08800018F9F00ACAFF500085A
63993+:108B00008F8300D024070034906600BC30C500027B
63994+:108B100050A00001240700308F9200B88F8A00BC5B
63995+:108B2000906D00BC924B00002412C00032A50003DF
63996+:108B3000A14B00008F8600B88F8800BC240200047F
63997+:108B400090C400010045182330790003A1040001FE
63998+:108B50008F8A00BC8F9F00B800F53821955800021D
63999+:108B600097E9001200F9382103128824312F3FFFC2
64000+:108B7000022F7025A54E00029150000231A800047A
64001+:108B8000320C003F358B0040A14B000212A00002C6
64002+:108B90008F8500BC00E838218F8E00D0ACA7000480
64003+:108BA000240BFFBF8DCD007C2EA400012403FFDF2A
64004+:108BB000ACAD000890B0000D00044140320C007FC5
64005+:108BC000A0AC000D8F8600BC90CA000D014B102494
64006+:108BD000A0C2000D8F8700BC90E5000D00A3F82413
64007+:108BE00003E8C825A0F9000D8F9100B88F8D00BC57
64008+:108BF0008E380020ADB800108E290024ADA90014D5
64009+:108C00008E2F0028ADAF00188E2E002C0E000CF613
64010+:108C1000ADAE001C8FB0001C240C0002120C00EE44
64011+:108C20008F9000D08FA3001C006088211460000288
64012+:108C30000060A8210000A02156A0FE390291A023C7
64013+:108C40000014882B8FA90010960700103C1E0020EE
64014+:108C50000136402302C750213112FFFFA60A00103F
64015+:108C6000AFB20010AF5E0030000000009617001099
64016+:108C7000961300121277008F000000008E05000C82
64017+:108C80008E0B00080016698000AD7021000DC7C36F
64018+:108C900001CDA82B0178782101F56021AE0E000CE2
64019+:108CA000AE0C00088FB300100013B82B02378024DD
64020+:108CB0001200FF048F9000D00A000E3C000000005C
64021+:108CC0008E4D0038A6600008240B0003AE6D000036
64022+:108CD0008E500034A260000A8F9800B8AE70000475
64023+:108CE0003C0500809311003FA26B000C8E6F000CBE
64024+:108CF0003C0EFF9FA271000B01E5102535CCFFFF54
64025+:108D00003C03FFEF8F9200B8004C30243464FFFF27
64026+:108D100000C4F824AE7F000C8E590014964800124F
64027+:108D20008F8A00B0AE7900108E490014AE60001832
64028+:108D3000AE600020AE690014AE6000248E470018BB
64029+:108D400031093FFF0009F180AE6700288E4D000811
64030+:108D500003CA802131180001AE6D00308E4F000C27
64031+:108D60008F8C00AC001089C200185B80022B282178
64032+:108D7000240E0002A665001CA6600036AE6F002C13
64033+:108D8000A18E00009763003C8F8A00AC3C04420037
64034+:108D90003062FFFF00443025AD4600048F9F00B8CD
64035+:108DA000240700012411C0008FF30038240600348A
64036+:108DB000AD5300188FF90034AD59001CAD40000CC4
64037+:108DC000AD400010A5400014A5400016A5400020AD
64038+:108DD000A5400022AD400024A5550002A147000196
64039+:108DE0008F9E00AC8F8800B88F9200BCAFD5000872
64040+:108DF000910D0000A24D00008F9000B88F8B00BC39
64041+:108E000092180001A17800018F8400BC94850002B3
64042+:108E100000B1782401E97025A48E0002908C000234
64043+:108E20003183003FA08300028F8300D08F8400BC79
64044+:108E3000906200BC305300025260000124060030F2
64045+:108E4000AC8600048C6F007C2403FFBF02A0882145
64046+:108E5000AC8F0008908E000D31CC007FA08C000DEF
64047+:108E60008F8600BC90C2000D00432024A0C4000DDA
64048+:108E70008F8900BC913F000D37F90020A139000D0A
64049+:108E80008F8800B88F9300BC8D070020AE6700105C
64050+:108E90008D0A0024AE6A00148D1E0028AE7E0018D4
64051+:108EA0008D12002C0E000CF6AE72001C0A00103D54
64052+:108EB0008F9000D0960E00148E03000431CCFFFF7B
64053+:108EC000000C10C000622021AF44003C8E1F000443
64054+:108ED0008F46003C03E6C8231B20003C0000000036
64055+:108EE0008E0F000025E200013C05001034B500089B
64056+:108EF000AF420038AF550030000000000000000015
64057+:108F00000000000000000000000000000000000061
64058+:108F100000000000000000008F580000330B00200C
64059+:108F20001160FFFD000000008F5304003C0D002085
64060+:108F3000AE1300088F570404AE17000CAF4D00307D
64061+:108F4000000000003C0608008CC600442416000106
64062+:108F500010D600BD00000000961F00123C0508005E
64063+:108F60008CA5004000BFC821A61900129609001464
64064+:108F700025270001A6070014960A00143144FFFFBC
64065+:108F80005486FF498FB30010A60000140E000E1681
64066+:108F900030A5FFFF3C0408008C84002496030012D7
64067+:108FA0000044102300623023A60600120A00105964
64068+:108FB0008FB30010A08300018F8200AC2404000155
64069+:108FC000AC4400080A000FF08F8300D08E0200002E
64070+:108FD0000A0010EA3C0500108F8200C08FA7001C19
64071+:108FE000921800D0920B00D0920E00D0331100FFE7
64072+:108FF000316900FF00117940000928C001E56021B6
64073+:1090000031C300FF036C50210003314000C2C8216E
64074+:10901000255F0088AF9F00ACAF9900BCA1470088D6
64075+:109020009768003C03C020218F9100AC0E000CD645
64076+:109030003110FFFF00026B80020DC0253C0442008E
64077+:109040008F8D00B803045825AE2B00048DA900387D
64078+:109050008F8B00AC0000882100118100AD690018E1
64079+:109060008DAF00343C087FFF3504FFFFAD6F001C5F
64080+:1090700091AC003E8D65001C8D660018000C190037
64081+:10908000000C770200A33821020E102500E3F82B14
64082+:1090900000C2C821033F5021AD67001CAD6A001813
64083+:1090A000AD60000CAD60001091B8003E24050005D5
64084+:1090B00003C45024A578001495A9000403C02021FE
64085+:1090C000A569001691AF003EA56F002095B1000480
64086+:1090D000A5710022AD60002491AE003FA56E000294
64087+:1090E00091B0003E91AC003D01901023244300015B
64088+:1090F000A16300018F8600AC8F9F00BCACDE00082E
64089+:10910000A3E500008F9000BC8F9900B82405FFBF35
64090+:1091100096070002973800120247782433093FFF70
64091+:1091200001E98825A6110002921200022418FFDF2F
64092+:10913000324E003F35CD0040A20D00028F8600BCAC
64093+:109140008F8C00D02412FFFFACC000048D8B007CFC
64094+:109150003C0C8000ACCB000890C2000D3043007F77
64095+:10916000A0C3000D8F8700BC90FF000D03E5C8244D
64096+:10917000A0F9000D8F9100BC9229000D01387824D0
64097+:10918000A22F000D8F9000BCAE120010AE1500147F
64098+:10919000920E00182415FF8002AE6825A20D00185B
64099+:1091A0008F8500BC8F8300B88CAB0018016C102435
64100+:1091B000004A3025ACA600189068003EA0A8001C0C
64101+:1091C0008F9F00B88F8700BC8F9800D097F900045C
64102+:1091D000A4F9001E0E0002138F0500848F8600D0B4
64103+:1091E000000279400002490090D200BC01E98821C8
64104+:1091F000004028213255000212A0000303D1202193
64105+:109200000002A8800095202190CD00BC31B200045E
64106+:109210001240000333DF0003000540800088202156
64107+:10922000240600048F9E00BC00DFC8233327000300
64108+:1092300000875021AFCA00040E000CF6A665003866
64109+:109240000A0010388F9000D0961E00123C080800CB
64110+:109250008D080024011E9021A61200120A00105948
64111+:109260008FB3001027BDFFE03C1808008F18005096
64112+:10927000AFB00010AFBF0018AFB10014AF8400B0A2
64113+:1092800093710074030478212410FF8031EE007F75
64114+:109290003225007F01F0582401DA68213C0C000AD5
64115+:1092A000A38500C401AC2821AF4B002494A9001071
64116+:1092B0009768000690A600620080382124020030E2
64117+:1092C0000109202330C300F0AF8500D010620019DF
64118+:1092D0003090FFFF90AE0062240DFFF0240A005092
64119+:1092E00001AE6024318B00FF116A002F00000000E6
64120+:1092F00016000007241F0C00AF5F00248FB100147C
64121+:109300008FBF00188FB0001003E0000827BD0020B9
64122+:109310000E000E1C02002021241F0C00AF5F002451
64123+:109320008FB100148FBF00188FB0001003E0000849
64124+:1093300027BD002094A200E094A400E290BF011396
64125+:10934000008218263079FFFF33E700C014E00009DF
64126+:109350002F31000116000038000000005620FFE603
64127+:10936000241F0C000E000D18000000000A0011ED73
64128+:10937000241F0C001620FFDE000000000E000D1858
64129+:10938000000000001440FFDC241F0C001600002227
64130+:109390008F8300D0906901133122003FA062011336
64131+:1093A0000A0011ED241F0C0094AF00D48F8600D466
64132+:1093B00000E02821240400050E000C5C31F0FFFFC2
64133+:1093C0001440000524030003979100E600001821D3
64134+:1093D0002625FFFFA78500E68F5801B80700FFFE8E
64135+:1093E0003C196013AF400180241F0C00AF50018472
64136+:1093F000007938253C101000AF4701888FB1001468
64137+:10940000AF5001B8AF5F00248FB000108FBF0018BD
64138+:1094100003E0000827BD00200E000E1C02002021E2
64139+:109420005040FFB5241F0C008F8300D090690113BA
64140+:109430000A0012163122003F0E000E1C02002021ED
64141+:109440001440FFAD241F0C00122000078F8300D0B2
64142+:10945000906801133106003F34C20040A06201133E
64143+:109460000A0011ED241F0C000E000D180000000072
64144+:109470005040FFA1241F0C008F8300D0906801137F
64145+:109480003106003F0A00124634C20040AF9B00C8BC
64146+:1094900003E00008AF8000EC3089FFFF0009404284
64147+:1094A0002D020041000921801440000200095040B3
64148+:1094B00024080040000830C0000811400046582130
64149+:1094C000256701A800E2C821272F007F2418FF800C
64150+:1094D00001F818240064302100CA702125CC00FF57
64151+:1094E000240DFF00018D202425650088240A0088B2
64152+:1094F0003C010800AC2A004C3C010800AC2500509F
64153+:10950000AF8400D43C010800AC2900603C01080095
64154+:10951000AC2800643C010800AC2700543C01080062
64155+:10952000AC2300583C010800AC26005C03E00008B6
64156+:1095300000000000308300FF30C6FFFF30E400FF72
64157+:109540008F4201B80440FFFE00034C00012438257F
64158+:109550003C08600000E820253C031000AF45018076
64159+:10956000AF460184AF44018803E00008AF4301B86F
64160+:109570008F86001C3C096012352700108CCB00043C
64161+:109580003C0C600E35850010316A00062D48000144
64162+:10959000ACE800C48CC40004ACA431808CC20008C8
64163+:1095A00094C30002ACA2318403E00008A78300E466
64164+:1095B0003C0308008C6300508F8400E88F86001CF9
64165+:1095C0002402FF800064C0210302C824AF59002890
64166+:1095D0008CCD00043305007F00BA78213C0E000CCE
64167+:1095E00001EE2821ACAD00588CC80008AF8500D032
64168+:1095F0003C076012ACA8005C8CCC001034E8001072
64169+:10960000ACAC000C8CCB000CACAB000894AA0014E2
64170+:109610003C0208008C42004425490001A4A9001422
64171+:1096200094A400143083FFFF106200178F8400D0D1
64172+:109630003C0A08008D4A0040A4AA00128CCE0018F3
64173+:10964000AC8E00248CCD0014AC8D00208CC700188B
64174+:10965000AC87002C8CCC001424060001AC8C0028B4
64175+:109660008D0B00BC5166001A8D0200B48D0200B84B
64176+:10967000A482003A948F003AA48F003C948800D4CE
64177+:1096800003E000083102FFFF3C0908008D29002497
64178+:10969000A4A000148F8400D0A4A900128CCE0018BE
64179+:1096A000AC8E00248CCD0014AC8D00208CC700182B
64180+:1096B000AC87002C8CCC001424060001AC8C002854
64181+:1096C0008D0B00BC5566FFEA8D0200B88D0200B418
64182+:1096D000A482003A948F003AA48F003C948800D46E
64183+:1096E00003E000083102FFFF8F86001C3C0C0800DD
64184+:1096F0008D8C0050240BFF808CCD00083C03000CA7
64185+:10970000000D51C0018A4021010B4824AF8A00E8B6
64186+:10971000AF49002890C700073105007F00BA10212B
64187+:109720000043282130E4000410800039AF8500D0C8
64188+:1097300090CF000731EE000811C000380000000093
64189+:109740008CD9000C8CC400140324C02B13000030EF
64190+:10975000000000008CC2000CACA200648CCD00188C
64191+:109760002402FFF8ACAD00688CCC0010ACAC0080DB
64192+:109770008CCB000CACAB00848CCA001CACAA007C67
64193+:1097800090A900BC01224024A0A800BC90C30007FF
64194+:109790003067000810E000048F8500D090AF00BC57
64195+:1097A00035EE0001A0AE00BC90D9000733380001AF
64196+:1097B000130000088F8300D08F8700D0240400346A
64197+:1097C00090E800BC35030002A0E300BC8F8300D00A
64198+:1097D000AC6400C090C900073126000210C000052B
64199+:1097E00000000000906A00BC35420004A06200BC8A
64200+:1097F0008F8300D09065011330AD003FA06D011341
64201+:109800008F8C00D0958B00D403E000083162FFFFFD
64202+:109810008CC200140A001305000000000A001306A1
64203+:10982000ACA0006427BDFFD8AFB000108F90001C23
64204+:10983000AFBF0024AFB40020AFB20018AFB1001426
64205+:10984000AFB3001C9613000E3C07600A3C14600680
64206+:109850003264FFFF369300100E00125534F40410EA
64207+:109860008F8400D43C11600E0E00099B363100102D
64208+:10987000920E00153C0708008CE700603C12601255
64209+:1098800031CD000FA38D00F08E0E00048E0D000868
64210+:1098900096080012961F00109619001A9618001EBE
64211+:1098A000960F001C310CFFFF33EBFFFF332AFFFF45
64212+:1098B0003309FFFF31E6FFFF3C010800AC2B0040FD
64213+:1098C0003C010800AC2C00243C010800AC2A0044F8
64214+:1098D000AE293178AE26317C92020015960300162F
64215+:1098E00036520010304400FF3065FFFF3C06080090
64216+:1098F0008CC60064AE243188AE4500B492080014D2
64217+:1099000096190018241F0001011FC004332FFFFF08
64218+:109910003C0508008CA50058AE5800B8AE4F00BCFE
64219+:10992000920C0014AF8E00D8AF8D00DC318B00FF9D
64220+:10993000AE4B00C0920A0015AE670048AE66004C00
64221+:10994000314900FFAE4900C8AE65007C3C03080009
64222+:109950008C6300503C0408008C84004C3C080800D8
64223+:109960008D0800543C0208008C42005C8FBF00242C
64224+:10997000AE6300808FB00010AE8300748FB3001C04
64225+:10998000AE22319CAE4200DCAE2731A0AE2631A41F
64226+:10999000AE24318CAE233190AE283194AE2531986F
64227+:1099A000AE870050AE860054AE8500708FB10014B3
64228+:1099B000AE4700E0AE4600E4AE4400CCAE4300D07B
64229+:1099C000AE4800D4AE4500D88FB400208FB2001846
64230+:1099D00003E0000827BD002827BDFFE0AFB1001459
64231+:1099E000AFBF0018241100010E000845AFB00010F1
64232+:1099F00010510005978400E6978300CC0083102B5C
64233+:109A0000144000088F8500D4240700028FBF00187F
64234+:109A10008FB100148FB0001000E0102103E00008A7
64235+:109A200027BD00200E000C7A24040005AF8200E858
64236+:109A30001040FFF6240700020E0008498F90001C1A
64237+:109A4000979F00E68F9900E88F8D00C827EF0001EF
64238+:109A5000240E0050AF590020A78F00E6A1AE0000F1
64239+:109A60003C0C08008D8C00648F8600C8240A80009E
64240+:109A7000000C5E00ACCB0074A4C0000694C9000AC0
64241+:109A8000241FFF803C0D000C012AC024A4D8000A2A
64242+:109A900090C8000A24182000011F1825A0C3000A3E
64243+:109AA0008F8700C8A0E000788F8500C800003821AB
64244+:109AB000A0A000833C0208008C4200508F8400E884
64245+:109AC0000044782101FFC824AF590028960B0002FA
64246+:109AD00031EE007F01DA6021018D3021A4CB00D46A
64247+:109AE000960A0002AF8600D03C0E000425492401EE
64248+:109AF000A4C900E68E080004ACC800048E03000868
64249+:109B0000ACC30000A4C00010A4C00014A0C000D0CA
64250+:109B10008F8500D02403FFBFA0A000D13C04080023
64251+:109B20008C8400648F8200D0A04400D28E1F000C71
64252+:109B30008F8A00D0978F00E4AD5F001C8E19001053
64253+:109B400024100030AD590018A5400030A551005434
64254+:109B5000A5510056A54F0016AD4E0068AD580080C7
64255+:109B6000AD580084914D006231AC000F358B001070
64256+:109B7000A14B00628F8600D090C900633128007F1E
64257+:109B8000A0C800638F8400D02406FFFF9085006387
64258+:109B900000A31024A08200638F9100D000E0102168
64259+:109BA000923F00BC37F90001A23900BC8F8A00D077
64260+:109BB000938F00F0AD580064AD5000C0914E00D3BB
64261+:109BC000000F690031CC000F018D5825A14B00D347
64262+:109BD0008F8500D08F8900DCACA900E88F8800D881
64263+:109BE0008FBF00188FB100148FB0001027BD002068
64264+:109BF000ACA800ECA4A600D6A4A000E0A4A000E2BB
64265+:109C000003E000080000000027BDFFE0AFB0001037
64266+:109C10008F90001CAFB10014AFBF00188E19000464
64267+:109C20003C1808008F180050240FFF80001989C0CD
64268+:109C30000238702131CD007F01CF602401BA50215C
64269+:109C40003C0B000CAF4C0028014B4021950900D47F
64270+:109C5000950400D68E0700043131FFFFAF8800D095
64271+:109C60000E000913000721C08E0600048F8300C870
64272+:109C7000000629C0AF4500209064003E30820040BD
64273+:109C8000144000068F8400D0341FFFFF948300D659
64274+:109C90003062FFFF145F000400000000948400D6CF
64275+:109CA0000E0008A83084FFFF8E050004022030213A
64276+:109CB0008FBF00188FB100148FB000102404002251
64277+:109CC00000003821000529C00A00127C27BD0020B1
64278+:109CD00027BDFFE0AFB100143091FFFFAFB000101F
64279+:109CE000AFBF00181220001D000080218F86001CCD
64280+:109CF0008CC500002403000600053F020005140285
64281+:109D000030E4000714830015304500FF2CA800063E
64282+:109D10001100004D000558803C0C0800258C57D4DC
64283+:109D2000016C50218D490000012000080000000056
64284+:109D30008F8E00EC240D000111CD005900000000B1
64285+:109D4000260B00013170FFFF24CA00200211202BD6
64286+:109D5000014030211480FFE6AF8A001C0200102170
64287+:109D60008FBF00188FB100148FB0001003E00008FF
64288+:109D700027BD0020938700CE14E00038240400148F
64289+:109D80000E001338000000008F86001C2402000122
64290+:109D90000A00147FAF8200EC8F8900EC24080002D7
64291+:109DA0001128003B2404001300002821000030216A
64292+:109DB000240700010E00127C000000000A00147F3E
64293+:109DC0008F86001C8F8700EC2405000214E5FFF647
64294+:109DD000240400120E0012E9000000008F8500E844
64295+:109DE00000403021240400120E00127C00003821B3
64296+:109DF0000A00147F8F86001C8F8300EC241F000351
64297+:109E0000147FFFD0260B00010E00129B0000000003
64298+:109E10008F8500E800403021240200022404001055
64299+:109E200000003821AF8200EC0E00127C0000000020
64300+:109E30000A00147F8F86001C8F8F00EC240600021E
64301+:109E400011E6000B0000000024040010000028218F
64302+:109E5000000030210A00149C240700010000282182
64303+:109E60000E00127C000030210A00147F8F86001C37
64304+:109E70000E0013A500000000144000128F99001C72
64305+:109E80008F86001C240200030A00147FAF8200ECBE
64306+:109E90000E001431000000000A00147F8F86001CA1
64307+:109EA0000E00128B000000002402000224040014A3
64308+:109EB0000000282100003021000038210A0014B9D8
64309+:109EC000AF8200EC004038212404001097380002D3
64310+:109ED000000028210E00127C3306FFFF0A00147FC9
64311+:109EE0008F86001C8F8400C83C077FFF34E6FFFF8D
64312+:109EF0008C8500742402000100A61824AC83007431
64313+:109F000003E00008A082000510A000362CA200800B
64314+:109F1000274A04003C0B000524090080104000077C
64315+:109F20002408008030A6000F00C540212D030081C9
64316+:109F30001460000200A0482124080080AF4B0030CC
64317+:109F400000000000000000000000000011000009F7
64318+:109F500000003821014030218C8D000024E70004EE
64319+:109F600000E8602BACCD0000248400041580FFFACB
64320+:109F700024C60004000000000000000000000000F3
64321+:109F80003C0E0006010E3825AF47003000000000EF
64322+:109F900000000000000000008F4F000031E80010BA
64323+:109FA0001100FFFD000000008F42003C8F43003C89
64324+:109FB0000049C8210323C02B130000040000000047
64325+:109FC0008F4C003825860001AF4600388F47003C93
64326+:109FD00000A9282300E96821AF4D003C14A0FFCE62
64327+:109FE0002CA2008003E000080000000027BDFFD085
64328+:109FF0003C020002AFB100143C11000CAF45003828
64329+:10A00000AFB3001CAF46003C00809821AF42003047
64330+:10A0100024050088AF44002803512021AFBF002849
64331+:10A02000AFB50024AFB40020AFB200180E0014F199
64332+:10A03000AFB000103C1F08008FFF004C3C18080018
64333+:10A040008F1800642410FF8003F3A82132B9007F29
64334+:10A0500002B078240018A0C0033A70210018914083
64335+:10A0600001D12021AF4F00280E0014F10254282105
64336+:10A070003C0D08008DAD00502405012001B358218E
64337+:10A08000316C007F01705024019A48210131202158
64338+:10A090000E0014F1AF4A00283C0808008D08005457
64339+:10A0A0003C0508008CA500640113382130E6007FD0
64340+:10A0B00000F0182400DA202100912021AF4300286D
64341+:10A0C0000E0014F1000529403C0208008C420058A3
64342+:10A0D0003C1008008E1000601200001C0053882104
64343+:10A0E0002415FF800A0015743C14000C3226007FF2
64344+:10A0F0000235182400DA202102402821AF4300282D
64345+:10A10000009420210E0014F12610FFC01200000F51
64346+:10A11000023288212E05004110A0FFF42412100005
64347+:10A120003226007F001091800235182400DA2021A9
64348+:10A1300002402821AF430028009420210E0014F192
64349+:10A14000000080211600FFF3023288213C0B08003A
64350+:10A150008D6B005C240AFF802405000201734021FE
64351+:10A16000010A4824AF4900283C0408009484006296
64352+:10A170003110007F021A88213C07000C0E000CAA47
64353+:10A180000227982100402821026020218FBF00284B
64354+:10A190008FB500248FB400208FB3001C8FB200183D
64355+:10A1A0008FB100148FB000100A0014F127BD0030E9
64356+:10A1B0008F83001C8C62000410400003000000002C
64357+:10A1C00003E00008000000008C6400108C650008AB
64358+:10A1D0000A00152A8C66000C000000000000001B1D
64359+:10A1E0000000000F0000000A000000080000000648
64360+:10A1F000000000050000000500000004000000044D
64361+:10A200000000000300000003000000030000000342
64362+:10A210000000000300000002000000020000000235
64363+:10A220000000000200000002000000020000000226
64364+:10A230000000000200000002000000020000000216
64365+:10A240000000000200000002000000020000000206
64366+:10A2500000000001000000010000000108000F24C0
64367+:10A2600008000D6C08000FB80800106008000F4CC3
64368+:10A2700008000F8C0800119408000D88080011B820
64369+:10A2800008000DD8080015540800151C08000D889A
64370+:10A2900008000D8808000D880800124008001240D0
64371+:10A2A00008000D8808000D88080014E008000D88DB
64372+:10A2B00008000D8808000D8808000D88080013B4F8
64373+:10A2C00008000D8808000D8808000D8808000D881A
64374+:10A2D00008000D8808000D8808000D8808000D880A
64375+:10A2E00008000D8808000D8808000D8808000D88FA
64376+:10A2F00008000D8808000D8808000FAC08000D88C4
64377+:10A3000008000D880800167808000D8808000D88E0
64378+:10A3100008000D8808000D8808000D8808000D88C9
64379+:10A3200008000D8808000D8808000D8808000D88B9
64380+:10A3300008000D8808000D8808000D8808000D88A9
64381+:10A3400008000D8808000D8808000D88080014100A
64382+:10A3500008000D8808000D8808001334080012A4B6
64383+:10A3600008001E2C08001EFC08001F1408001F28EF
64384+:10A3700008001F3808001E2C08001E2C08001E2C88
64385+:10A3800008001ED808002E1408002E1C08002DE41A
64386+:10A3900008002DF008002DFC08002E08080052F4DB
64387+:10A3A000080052B40800528008005254080052308D
64388+:10A3B000080051EC0A000C840000000000000000BE
64389+:10A3C0000000000D727870362E322E33000000002F
64390+:10A3D000060203030000000000000001000000006E
64391+:10A3E000000000000000000000000000000000006D
64392+:10A3F000000000000000000000000000000000005D
64393+:10A40000000000000000000000000000000000004C
64394+:10A41000000000000000000000000000000000003C
64395+:10A42000000000000000000000000000000000002C
64396+:10A43000000000000000000000000000000000001C
64397+:10A44000000000000000000000000000000000000C
64398+:10A4500000000000000000000000000000000000FC
64399+:10A4600000000000000000000000000000000000EC
64400+:10A4700000000000000000000000000000000000DC
64401+:10A4800000000000000000000000000000000000CC
64402+:10A4900000000000000000000000000000000000BC
64403+:10A4A00000000000000000000000000000000000AC
64404+:10A4B000000000000000000000000000000000009C
64405+:10A4C000000000000000000000000000000000008C
64406+:10A4D000000000000000000000000000000000007C
64407+:10A4E000000000000000000000000000000000006C
64408+:10A4F000000000000000000000000000000000005C
64409+:10A50000000000000000000000000000000000004B
64410+:10A51000000000000000000000000000000000003B
64411+:10A52000000000000000000000000000000000002B
64412+:10A53000000000000000000000000000000000001B
64413+:10A54000000000000000000000000000000000000B
64414+:10A5500000000000000000000000000000000000FB
64415+:10A5600000000000000000000000000000000000EB
64416+:10A5700000000000000000000000000000000000DB
64417+:10A5800000000000000000000000000000000000CB
64418+:10A5900000000000000000000000000000000000BB
64419+:10A5A00000000000000000000000000000000000AB
64420+:10A5B000000000000000000000000000000000009B
64421+:10A5C000000000000000000000000000000000008B
64422+:10A5D000000000000000000000000000000000007B
64423+:10A5E000000000000000000000000000000000006B
64424+:10A5F000000000000000000000000000000000005B
64425+:10A60000000000000000000000000000000000004A
64426+:10A61000000000000000000000000000000000003A
64427+:10A62000000000000000000000000000000000002A
64428+:10A63000000000000000000000000000000000001A
64429+:10A64000000000000000000000000000000000000A
64430+:10A6500000000000000000000000000000000000FA
64431+:10A6600000000000000000000000000000000000EA
64432+:10A6700000000000000000000000000000000000DA
64433+:10A6800000000000000000000000000000000000CA
64434+:10A6900000000000000000000000000000000000BA
64435+:10A6A00000000000000000000000000000000000AA
64436+:10A6B000000000000000000000000000000000009A
64437+:10A6C000000000000000000000000000000000008A
64438+:10A6D000000000000000000000000000000000007A
64439+:10A6E000000000000000000000000000000000006A
64440+:10A6F000000000000000000000000000000000005A
64441+:10A700000000000000000000000000000000000049
64442+:10A710000000000000000000000000000000000039
64443+:10A720000000000000000000000000000000000029
64444+:10A730000000000000000000000000000000000019
64445+:10A740000000000000000000000000000000000009
64446+:10A7500000000000000000000000000000000000F9
64447+:10A7600000000000000000000000000000000000E9
64448+:10A7700000000000000000000000000000000000D9
64449+:10A7800000000000000000000000000000000000C9
64450+:10A7900000000000000000000000000000000000B9
64451+:10A7A00000000000000000000000000000000000A9
64452+:10A7B0000000000000000000000000000000000099
64453+:10A7C0000000000000000000000000000000000089
64454+:10A7D0000000000000000000000000000000000079
64455+:10A7E0000000000000000000000000000000000069
64456+:10A7F0000000000000000000000000000000000059
64457+:10A800000000000000000000000000000000000048
64458+:10A810000000000000000000000000000000000038
64459+:10A820000000000000000000000000000000000028
64460+:10A830000000000000000000000000000000000018
64461+:10A840000000000000000000000000000000000008
64462+:10A8500000000000000000000000000000000000F8
64463+:10A8600000000000000000000000000000000000E8
64464+:10A8700000000000000000000000000000000000D8
64465+:10A8800000000000000000000000000000000000C8
64466+:10A8900000000000000000000000000000000000B8
64467+:10A8A00000000000000000000000000000000000A8
64468+:10A8B0000000000000000000000000000000000098
64469+:10A8C0000000000000000000000000000000000088
64470+:10A8D0000000000000000000000000000000000078
64471+:10A8E0000000000000000000000000000000000068
64472+:10A8F0000000000000000000000000000000000058
64473+:10A900000000000000000000000000000000000047
64474+:10A910000000000000000000000000000000000037
64475+:10A920000000000000000000000000000000000027
64476+:10A930000000000000000000000000000000000017
64477+:10A940000000000000000000000000000000000007
64478+:10A9500000000000000000000000000000000000F7
64479+:10A9600000000000000000000000000000000000E7
64480+:10A9700000000000000000000000000000000000D7
64481+:10A9800000000000000000000000000000000000C7
64482+:10A9900000000000000000000000000000000000B7
64483+:10A9A00000000000000000000000000000000000A7
64484+:10A9B0000000000000000000000000000000000097
64485+:10A9C0000000000000000000000000000000000087
64486+:10A9D0000000000000000000000000000000000077
64487+:10A9E0000000000000000000000000000000000067
64488+:10A9F0000000000000000000000000000000000057
64489+:10AA00000000000000000000000000000000000046
64490+:10AA10000000000000000000000000000000000036
64491+:10AA20000000000000000000000000000000000026
64492+:10AA30000000000000000000000000000000000016
64493+:10AA40000000000000000000000000000000000006
64494+:10AA500000000000000000000000000000000000F6
64495+:10AA600000000000000000000000000000000000E6
64496+:10AA700000000000000000000000000000000000D6
64497+:10AA800000000000000000000000000000000000C6
64498+:10AA900000000000000000000000000000000000B6
64499+:10AAA00000000000000000000000000000000000A6
64500+:10AAB0000000000000000000000000000000000096
64501+:10AAC0000000000000000000000000000000000086
64502+:10AAD0000000000000000000000000000000000076
64503+:10AAE0000000000000000000000000000000000066
64504+:10AAF0000000000000000000000000000000000056
64505+:10AB00000000000000000000000000000000000045
64506+:10AB10000000000000000000000000000000000035
64507+:10AB20000000000000000000000000000000000025
64508+:10AB30000000000000000000000000000000000015
64509+:10AB40000000000000000000000000000000000005
64510+:10AB500000000000000000000000000000000000F5
64511+:10AB600000000000000000000000000000000000E5
64512+:10AB700000000000000000000000000000000000D5
64513+:10AB800000000000000000000000000000000000C5
64514+:10AB900000000000000000000000000000000000B5
64515+:10ABA00000000000000000000000000000000000A5
64516+:10ABB0000000000000000000000000000000000095
64517+:10ABC0000000000000000000000000000000000085
64518+:10ABD0000000000000000000000000000000000075
64519+:10ABE0000000000000000000000000000000000065
64520+:10ABF0000000000000000000000000000000000055
64521+:10AC00000000000000000000000000000000000044
64522+:10AC10000000000000000000000000000000000034
64523+:10AC20000000000000000000000000000000000024
64524+:10AC30000000000000000000000000000000000014
64525+:10AC40000000000000000000000000000000000004
64526+:10AC500000000000000000000000000000000000F4
64527+:10AC600000000000000000000000000000000000E4
64528+:10AC700000000000000000000000000000000000D4
64529+:10AC800000000000000000000000000000000000C4
64530+:10AC900000000000000000000000000000000000B4
64531+:10ACA00000000000000000000000000000000000A4
64532+:10ACB0000000000000000000000000000000000094
64533+:10ACC0000000000000000000000000000000000084
64534+:10ACD0000000000000000000000000000000000074
64535+:10ACE0000000000000000000000000000000000064
64536+:10ACF0000000000000000000000000000000000054
64537+:10AD00000000000000000000000000000000000043
64538+:10AD10000000000000000000000000000000000033
64539+:10AD20000000000000000000000000000000000023
64540+:10AD30000000000000000000000000000000000013
64541+:10AD40000000000000000000000000000000000003
64542+:10AD500000000000000000000000000000000000F3
64543+:10AD600000000000000000000000000000000000E3
64544+:10AD700000000000000000000000000000000000D3
64545+:10AD800000000000000000000000000000000000C3
64546+:10AD900000000000000000000000000000000000B3
64547+:10ADA00000000000000000000000000000000000A3
64548+:10ADB0000000000000000000000000000000000093
64549+:10ADC0000000000000000000000000000000000083
64550+:10ADD0000000000000000000000000000000000073
64551+:10ADE0000000000000000000000000000000000063
64552+:10ADF0000000000000000000000000000000000053
64553+:10AE00000000000000000000000000000000000042
64554+:10AE10000000000000000000000000000000000032
64555+:10AE20000000000000000000000000000000000022
64556+:10AE30000000000000000000000000000000000012
64557+:10AE40000000000000000000000000000000000002
64558+:10AE500000000000000000000000000000000000F2
64559+:10AE600000000000000000000000000000000000E2
64560+:10AE700000000000000000000000000000000000D2
64561+:10AE800000000000000000000000000000000000C2
64562+:10AE900000000000000000000000000000000000B2
64563+:10AEA00000000000000000000000000000000000A2
64564+:10AEB0000000000000000000000000000000000092
64565+:10AEC0000000000000000000000000000000000082
64566+:10AED0000000000000000000000000000000000072
64567+:10AEE0000000000000000000000000000000000062
64568+:10AEF0000000000000000000000000000000000052
64569+:10AF00000000000000000000000000000000000041
64570+:10AF10000000000000000000000000000000000031
64571+:10AF20000000000000000000000000000000000021
64572+:10AF30000000000000000000000000000000000011
64573+:10AF40000000000000000000000000000000000001
64574+:10AF500000000000000000000000000000000000F1
64575+:10AF600000000000000000000000000000000000E1
64576+:10AF700000000000000000000000000000000000D1
64577+:10AF800000000000000000000000000000000000C1
64578+:10AF900000000000000000000000000000000000B1
64579+:10AFA00000000000000000000000000000000000A1
64580+:10AFB0000000000000000000000000000000000091
64581+:10AFC0000000000000000000000000000000000081
64582+:10AFD0000000000000000000000000000000000071
64583+:10AFE0000000000000000000000000000000000061
64584+:10AFF0000000000000000000000000000000000051
64585+:10B000000000000000000000000000000000000040
64586+:10B010000000000000000000000000000000000030
64587+:10B020000000000000000000000000000000000020
64588+:10B030000000000000000000000000000000000010
64589+:10B040000000000000000000000000000000000000
64590+:10B0500000000000000000000000000000000000F0
64591+:10B0600000000000000000000000000000000000E0
64592+:10B0700000000000000000000000000000000000D0
64593+:10B0800000000000000000000000000000000000C0
64594+:10B0900000000000000000000000000000000000B0
64595+:10B0A00000000000000000000000000000000000A0
64596+:10B0B0000000000000000000000000000000000090
64597+:10B0C0000000000000000000000000000000000080
64598+:10B0D0000000000000000000000000000000000070
64599+:10B0E0000000000000000000000000000000000060
64600+:10B0F0000000000000000000000000000000000050
64601+:10B10000000000000000000000000000000000003F
64602+:10B11000000000000000000000000000000000002F
64603+:10B12000000000000000000000000000000000001F
64604+:10B13000000000000000000000000000000000000F
64605+:10B1400000000000000000000000000000000000FF
64606+:10B1500000000000000000000000000000000000EF
64607+:10B1600000000000000000000000000000000000DF
64608+:10B1700000000000000000000000000000000000CF
64609+:10B1800000000000000000000000000000000000BF
64610+:10B1900000000000000000000000000000000000AF
64611+:10B1A000000000000000000000000000000000009F
64612+:10B1B000000000000000000000000000000000008F
64613+:10B1C000000000000000000000000000000000007F
64614+:10B1D000000000000000000000000000000000006F
64615+:10B1E000000000000000000000000000000000005F
64616+:10B1F000000000000000000000000000000000004F
64617+:10B20000000000000000000000000000000000003E
64618+:10B21000000000000000000000000000000000002E
64619+:10B22000000000000000000000000000000000001E
64620+:10B23000000000000000000000000000000000000E
64621+:10B2400000000000000000000000000000000000FE
64622+:10B2500000000000000000000000000000000000EE
64623+:10B2600000000000000000000000000000000000DE
64624+:10B2700000000000000000000000000000000000CE
64625+:10B2800000000000000000000000000000000000BE
64626+:10B2900000000000000000000000000000000000AE
64627+:10B2A000000000000000000000000000000000009E
64628+:10B2B000000000000000000000000000000000008E
64629+:10B2C000000000000000000000000000000000007E
64630+:10B2D000000000000000000000000000000000006E
64631+:10B2E000000000000000000000000000000000005E
64632+:10B2F000000000000000000000000000000000004E
64633+:10B30000000000000000000000000000000000003D
64634+:10B31000000000000000000000000000000000002D
64635+:10B32000000000000000000000000000000000001D
64636+:10B33000000000000000000000000000000000000D
64637+:10B3400000000000000000000000000000000000FD
64638+:10B3500000000000000000000000000000000000ED
64639+:10B3600000000000000000000000000000000000DD
64640+:10B3700000000000000000000000000000000000CD
64641+:10B3800000000000000000000000000000000000BD
64642+:10B3900000000000000000000000000000000000AD
64643+:10B3A000000000000000000000000000000000009D
64644+:10B3B000000000000000000000000000000000008D
64645+:10B3C000000000000000000000000000000000007D
64646+:10B3D000000000000000000000000000000000006D
64647+:10B3E000000000000000000000000000000000005D
64648+:10B3F000000000000000000000000000000000004D
64649+:10B40000000000000000000000000000000000003C
64650+:10B41000000000000000000000000000000000002C
64651+:10B42000000000000000000000000000000000001C
64652+:10B43000000000000000000000000000000000000C
64653+:10B4400000000000000000000000000000000000FC
64654+:10B4500000000000000000000000000000000000EC
64655+:10B4600000000000000000000000000000000000DC
64656+:10B4700000000000000000000000000000000000CC
64657+:10B4800000000000000000000000000000000000BC
64658+:10B4900000000000000000000000000000000000AC
64659+:10B4A000000000000000000000000000000000009C
64660+:10B4B000000000000000000000000000000000008C
64661+:10B4C000000000000000000000000000000000007C
64662+:10B4D000000000000000000000000000000000006C
64663+:10B4E000000000000000000000000000000000005C
64664+:10B4F000000000000000000000000000000000004C
64665+:10B50000000000000000000000000000000000003B
64666+:10B51000000000000000000000000000000000002B
64667+:10B52000000000000000000000000000000000001B
64668+:10B53000000000000000000000000000000000000B
64669+:10B5400000000000000000000000000000000000FB
64670+:10B5500000000000000000000000000000000000EB
64671+:10B5600000000000000000000000000000000000DB
64672+:10B5700000000000000000000000000000000000CB
64673+:10B5800000000000000000000000000000000000BB
64674+:10B5900000000000000000000000000000000000AB
64675+:10B5A000000000000000000000000000000000009B
64676+:10B5B000000000000000000000000000000000008B
64677+:10B5C000000000000000000000000000000000007B
64678+:10B5D000000000000000000000000000000000006B
64679+:10B5E000000000000000000000000000000000005B
64680+:10B5F000000000000000000000000000000000004B
64681+:10B60000000000000000000000000000000000003A
64682+:10B61000000000000000000000000000000000002A
64683+:10B62000000000000000000000000000000000001A
64684+:10B63000000000000000000000000000000000000A
64685+:10B6400000000000000000000000000000000000FA
64686+:10B6500000000000000000000000000000000000EA
64687+:10B6600000000000000000000000000000000000DA
64688+:10B6700000000000000000000000000000000000CA
64689+:10B6800000000000000000000000000000000000BA
64690+:10B6900000000000000000000000000000000000AA
64691+:10B6A000000000000000000000000000000000009A
64692+:10B6B000000000000000000000000000000000008A
64693+:10B6C000000000000000000000000000000000007A
64694+:10B6D000000000000000000000000000000000006A
64695+:10B6E000000000000000000000000000000000005A
64696+:10B6F000000000000000000000000000000000004A
64697+:10B700000000000000000000000000000000000039
64698+:10B710000000000000000000000000000000000029
64699+:10B720000000000000000000000000000000000019
64700+:10B730000000000000000000000000000000000009
64701+:10B7400000000000000000000000000000000000F9
64702+:10B7500000000000000000000000000000000000E9
64703+:10B7600000000000000000000000000000000000D9
64704+:10B7700000000000000000000000000000000000C9
64705+:10B7800000000000000000000000000000000000B9
64706+:10B7900000000000000000000000000000000000A9
64707+:10B7A0000000000000000000000000000000000099
64708+:10B7B0000000000000000000000000000000000089
64709+:10B7C0000000000000000000000000000000000079
64710+:10B7D0000000000000000000000000000000000069
64711+:10B7E0000000000000000000000000000000000059
64712+:10B7F0000000000000000000000000000000000049
64713+:10B800000000000000000000000000000000000038
64714+:10B810000000000000000000000000000000000028
64715+:10B820000000000000000000000000000000000018
64716+:10B830000000000000000000000000000000000008
64717+:10B8400000000000000000000000000000000000F8
64718+:10B8500000000000000000000000000000000000E8
64719+:10B8600000000000000000000000000000000000D8
64720+:10B8700000000000000000000000000000000000C8
64721+:10B8800000000000000000000000000000000000B8
64722+:10B8900000000000000000000000000000000000A8
64723+:10B8A0000000000000000000000000000000000098
64724+:10B8B0000000000000000000000000000000000088
64725+:10B8C0000000000000000000000000000000000078
64726+:10B8D0000000000000000000000000000000000068
64727+:10B8E0000000000000000000000000000000000058
64728+:10B8F0000000000000000000000000000000000048
64729+:10B900000000000000000000000000000000000037
64730+:10B910000000000000000000000000000000000027
64731+:10B920000000000000000000000000000000000017
64732+:10B930000000000000000000000000000000000007
64733+:10B9400000000000000000000000000000000000F7
64734+:10B9500000000000000000000000000000000000E7
64735+:10B9600000000000000000000000000000000000D7
64736+:10B9700000000000000000000000000000000000C7
64737+:10B9800000000000000000000000000000000000B7
64738+:10B9900000000000000000000000000000000000A7
64739+:10B9A0000000000000000000000000000000000097
64740+:10B9B0000000000000000000000000000000000087
64741+:10B9C0000000000000000000000000000000000077
64742+:10B9D0000000000000000000000000000000000067
64743+:10B9E0000000000000000000000000000000000057
64744+:10B9F0000000000000000000000000000000000047
64745+:10BA00000000000000000000000000000000000036
64746+:10BA10000000000000000000000000000000000026
64747+:10BA20000000000000000000000000000000000016
64748+:10BA30000000000000000000000000000000000006
64749+:10BA400000000000000000000000000000000000F6
64750+:10BA500000000000000000000000000000000000E6
64751+:10BA600000000000000000000000000000000000D6
64752+:10BA700000000000000000000000000000000000C6
64753+:10BA800000000000000000000000000000000000B6
64754+:10BA900000000000000000000000000000000000A6
64755+:10BAA0000000000000000000000000000000000096
64756+:10BAB0000000000000000000000000000000000086
64757+:10BAC0000000000000000000000000000000000076
64758+:10BAD0000000000000000000000000000000000066
64759+:10BAE0000000000000000000000000000000000056
64760+:10BAF0000000000000000000000000000000000046
64761+:10BB00000000000000000000000000000000000035
64762+:10BB10000000000000000000000000000000000025
64763+:10BB20000000000000000000000000000000000015
64764+:10BB30000000000000000000000000000000000005
64765+:10BB400000000000000000000000000000000000F5
64766+:10BB500000000000000000000000000000000000E5
64767+:10BB600000000000000000000000000000000000D5
64768+:10BB700000000000000000000000000000000000C5
64769+:10BB800000000000000000000000000000000000B5
64770+:10BB900000000000000000000000000000000000A5
64771+:10BBA0000000000000000000000000000000000095
64772+:10BBB0000000000000000000000000000000000085
64773+:10BBC0000000000000000000000000000000000075
64774+:10BBD0000000000000000000000000000000000065
64775+:10BBE0000000000000000000000000000000000055
64776+:10BBF0000000000000000000000000000000000045
64777+:10BC00000000000000000000000000000000000034
64778+:10BC10000000000000000000000000000000000024
64779+:10BC20000000000000000000000000000000000014
64780+:10BC30000000000000000000000000000000000004
64781+:10BC400000000000000000000000000000000000F4
64782+:10BC500000000000000000000000000000000000E4
64783+:10BC600000000000000000000000000000000000D4
64784+:10BC700000000000000000000000000000000000C4
64785+:10BC800000000000000000000000000000000000B4
64786+:10BC900000000000000000000000000000000000A4
64787+:10BCA0000000000000000000000000000000000094
64788+:10BCB0000000000000000000000000000000000084
64789+:10BCC0000000000000000000000000000000000074
64790+:10BCD0000000000000000000000000000000000064
64791+:10BCE0000000000000000000000000000000000054
64792+:10BCF0000000000000000000000000000000000044
64793+:10BD00000000000000000000000000000000000033
64794+:10BD10000000000000000000000000000000000023
64795+:10BD20000000000000000000000000000000000013
64796+:10BD30000000000000000000000000000000000003
64797+:10BD400000000000000000000000000000000000F3
64798+:10BD500000000000000000000000000000000000E3
64799+:10BD600000000000000000000000000000000000D3
64800+:10BD700000000000000000000000000000000000C3
64801+:10BD800000000000000000000000000000000000B3
64802+:10BD900000000000000000000000000000000000A3
64803+:10BDA0000000000000000000000000000000000093
64804+:10BDB0000000000000000000000000000000000083
64805+:10BDC0000000000000000000000000000000000073
64806+:10BDD0000000000000000000000000000000000063
64807+:10BDE0000000000000000000000000000000000053
64808+:10BDF0000000000000000000000000000000000043
64809+:10BE00000000000000000000000000000000000032
64810+:10BE10000000000000000000000000000000000022
64811+:10BE20000000000000000000000000000000000012
64812+:10BE30000000000000000000000000000000000002
64813+:10BE400000000000000000000000000000000000F2
64814+:10BE500000000000000000000000000000000000E2
64815+:10BE600000000000000000000000000000000000D2
64816+:10BE700000000000000000000000000000000000C2
64817+:10BE800000000000000000000000000000000000B2
64818+:10BE900000000000000000000000000000000000A2
64819+:10BEA0000000000000000000000000000000000092
64820+:10BEB0000000000000000000000000000000000082
64821+:10BEC0000000000000000000000000000000000072
64822+:10BED0000000000000000000000000000000000062
64823+:10BEE0000000000000000000000000000000000052
64824+:10BEF0000000000000000000000000000000000042
64825+:10BF00000000000000000000000000000000000031
64826+:10BF10000000000000000000000000000000000021
64827+:10BF20000000000000000000000000000000000011
64828+:10BF30000000000000000000000000000000000001
64829+:10BF400000000000000000000000000000000000F1
64830+:10BF500000000000000000000000000000000000E1
64831+:10BF600000000000000000000000000000000000D1
64832+:10BF700000000000000000000000000000000000C1
64833+:10BF800000000000000000000000000000000000B1
64834+:10BF900000000000000000000000000000000000A1
64835+:10BFA0000000000000000000000000000000000091
64836+:10BFB0000000000000000000000000000000000081
64837+:10BFC0000000000000000000000000000000000071
64838+:10BFD0000000000000000000000000000000000061
64839+:10BFE0000000000000000000000000000000000051
64840+:10BFF0000000000000000000000000000000000041
64841+:10C000000000000000000000000000000000000030
64842+:10C010000000000000000000000000000000000020
64843+:10C020000000000000000000000000000000000010
64844+:10C030000000000000000000000000000000000000
64845+:10C0400000000000000000000000000000000000F0
64846+:10C0500000000000000000000000000000000000E0
64847+:10C0600000000000000000000000000000000000D0
64848+:10C0700000000000000000000000000000000000C0
64849+:10C0800000000000000000000000000000000000B0
64850+:10C0900000000000000000000000000000000000A0
64851+:10C0A0000000000000000000000000000000000090
64852+:10C0B0000000000000000000000000000000000080
64853+:10C0C0000000000000000000000000000000000070
64854+:10C0D0000000000000000000000000000000000060
64855+:10C0E0000000000000000000000000000000000050
64856+:10C0F0000000000000000000000000000000000040
64857+:10C10000000000000000000000000000000000002F
64858+:10C11000000000000000000000000000000000001F
64859+:10C12000000000000000000000000000000000000F
64860+:10C1300000000000000000000000000000000000FF
64861+:10C1400000000000000000000000000000000000EF
64862+:10C1500000000000000000000000000000000000DF
64863+:10C1600000000000000000000000000000000000CF
64864+:10C1700000000000000000000000000000000000BF
64865+:10C1800000000000000000000000000000000000AF
64866+:10C19000000000000000000000000000000000009F
64867+:10C1A000000000000000000000000000000000008F
64868+:10C1B000000000000000000000000000000000007F
64869+:10C1C000000000000000000000000000000000006F
64870+:10C1D000000000000000000000000000000000005F
64871+:10C1E000000000000000000000000000000000004F
64872+:10C1F000000000000000000000000000000000003F
64873+:10C20000000000000000000000000000000000002E
64874+:10C21000000000000000000000000000000000001E
64875+:10C22000000000000000000000000000000000000E
64876+:10C2300000000000000000000000000000000000FE
64877+:10C2400000000000000000000000000000000000EE
64878+:10C2500000000000000000000000000000000000DE
64879+:10C2600000000000000000000000000000000000CE
64880+:10C2700000000000000000000000000000000000BE
64881+:10C2800000000000000000000000000000000000AE
64882+:10C29000000000000000000000000000000000009E
64883+:10C2A000000000000000000000000000000000008E
64884+:10C2B000000000000000000000000000000000007E
64885+:10C2C000000000000000000000000000000000006E
64886+:10C2D000000000000000000000000000000000005E
64887+:10C2E000000000000000000000000000000000004E
64888+:10C2F000000000000000000000000000000000003E
64889+:10C30000000000000000000000000000000000002D
64890+:10C31000000000000000000000000000000000001D
64891+:10C32000000000000000000000000000000000000D
64892+:10C3300000000000000000000000000000000000FD
64893+:10C3400000000000000000000000000000000000ED
64894+:10C3500000000000000000000000000000000000DD
64895+:10C3600000000000000000000000000000000000CD
64896+:10C3700000000000000000000000000000000000BD
64897+:10C3800000000000000000000000000000000000AD
64898+:10C39000000000000000000000000000000000009D
64899+:10C3A000000000000000000000000000000000008D
64900+:10C3B000000000000000000000000000000000007D
64901+:10C3C000000000000000000000000000000000006D
64902+:10C3D000000000000000000000000000000000005D
64903+:10C3E000000000000000000000000000000000004D
64904+:10C3F000000000000000000000000000000000003D
64905+:10C40000000000000000000000000000000000002C
64906+:10C41000000000000000000000000000000000001C
64907+:10C42000000000000000000000000000000000000C
64908+:10C4300000000000000000000000000000000000FC
64909+:10C4400000000000000000000000000000000000EC
64910+:10C4500000000000000000000000000000000000DC
64911+:10C4600000000000000000000000000000000000CC
64912+:10C4700000000000000000000000000000000000BC
64913+:10C4800000000000000000000000000000000000AC
64914+:10C49000000000000000000000000000000000009C
64915+:10C4A000000000000000000000000000000000008C
64916+:10C4B000000000000000000000000000000000007C
64917+:10C4C000000000000000000000000000000000006C
64918+:10C4D000000000000000000000000000000000005C
64919+:10C4E000000000000000000000000000000000004C
64920+:10C4F000000000000000000000000000000000003C
64921+:10C50000000000000000000000000000000000002B
64922+:10C51000000000000000000000000000000000001B
64923+:10C52000000000000000000000000000000000000B
64924+:10C5300000000000000000000000000000000000FB
64925+:10C5400000000000000000000000000000000000EB
64926+:10C5500000000000000000000000000000000000DB
64927+:10C5600000000000000000000000000000000000CB
64928+:10C5700000000000000000000000000000000000BB
64929+:10C5800000000000000000000000000000000000AB
64930+:10C59000000000000000000000000000000000009B
64931+:10C5A000000000000000000000000000000000008B
64932+:10C5B000000000000000000000000000000000007B
64933+:10C5C000000000000000000000000000000000006B
64934+:10C5D000000000000000000000000000000000005B
64935+:10C5E000000000000000000000000000000000004B
64936+:10C5F000000000000000000000000000000000003B
64937+:10C60000000000000000000000000000000000002A
64938+:10C61000000000000000000000000000000000001A
64939+:10C62000000000000000000000000000000000000A
64940+:10C6300000000000000000000000000000000000FA
64941+:10C6400000000000000000000000000000000000EA
64942+:10C6500000000000000000000000000000000000DA
64943+:10C6600000000000000000000000000000000000CA
64944+:10C6700000000000000000000000000000000000BA
64945+:10C6800000000000000000000000000000000000AA
64946+:10C69000000000000000000000000000000000009A
64947+:10C6A000000000000000000000000000000000008A
64948+:10C6B000000000000000000000000000000000007A
64949+:10C6C000000000000000000000000000000000006A
64950+:10C6D000000000000000000000000000000000005A
64951+:10C6E000000000000000000000000000000000004A
64952+:10C6F000000000000000000000000000000000003A
64953+:10C700000000000000000000000000000000000029
64954+:10C710000000000000000000000000000000000019
64955+:10C720000000000000000000000000000000000009
64956+:10C7300000000000000000000000000000000000F9
64957+:10C7400000000000000000000000000000000000E9
64958+:10C7500000000000000000000000000000000000D9
64959+:10C7600000000000000000000000000000000000C9
64960+:10C7700000000000000000000000000000000000B9
64961+:10C7800000000000000000000000000000000000A9
64962+:10C790000000000000000000000000000000000099
64963+:10C7A0000000000000000000000000000000000089
64964+:10C7B0000000000000000000000000000000000079
64965+:10C7C0000000000000000000000000000000000069
64966+:10C7D0000000000000000000000000000000000059
64967+:10C7E0000000000000000000000000000000000049
64968+:10C7F0000000000000000000000000000000000039
64969+:10C800000000000000000000000000000000000028
64970+:10C810000000000000000000000000000000000018
64971+:10C820000000000000000000000000000000000008
64972+:10C8300000000000000000000000000000000000F8
64973+:10C8400000000000000000000000000000000000E8
64974+:10C8500000000000000000000000000000000000D8
64975+:10C8600000000000000000000000000000000000C8
64976+:10C8700000000000000000000000000000000000B8
64977+:10C8800000000000000000000000000000000000A8
64978+:10C890000000000000000000000000000000000098
64979+:10C8A0000000000000000000000000000000000088
64980+:10C8B0000000000000000000000000000000000078
64981+:10C8C0000000000000000000000000000000000068
64982+:10C8D0000000000000000000000000000000000058
64983+:10C8E0000000000000000000000000000000000048
64984+:10C8F0000000000000000000000000000000000038
64985+:10C900000000000000000000000000000000000027
64986+:10C910000000000000000000000000000000000017
64987+:10C920000000000000000000000000000000000007
64988+:10C9300000000000000000000000000000000000F7
64989+:10C9400000000000000000000000000000000000E7
64990+:10C9500000000000000000000000000000000000D7
64991+:10C9600000000000000000000000000000000000C7
64992+:10C9700000000000000000000000000000000000B7
64993+:10C9800000000000000000000000000000000000A7
64994+:10C990000000000000000000000000000000000097
64995+:10C9A0000000000000000000000000000000000087
64996+:10C9B0000000000000000000000000000000000077
64997+:10C9C0000000000000000000000000000000000067
64998+:10C9D0000000000000000000000000000000000057
64999+:10C9E0000000000000000000000000000000000047
65000+:10C9F0000000000000000000000000000000000037
65001+:10CA00000000000000000000000000000000000026
65002+:10CA10000000000000000000000000000000000016
65003+:10CA20000000000000000000000000000000000006
65004+:10CA300000000000000000000000000000000000F6
65005+:10CA400000000000000000000000000000000000E6
65006+:10CA500000000000000000000000000000000000D6
65007+:10CA600000000000000000000000000000000000C6
65008+:10CA700000000000000000000000000000000000B6
65009+:10CA800000000000000000000000000000000000A6
65010+:10CA90000000000000000000000000000000000096
65011+:10CAA0000000000000000000000000000000000086
65012+:10CAB0000000000000000000000000000000000076
65013+:10CAC0000000000000000000000000000000000066
65014+:10CAD0000000000000000000000000000000000056
65015+:10CAE0000000000000000000000000000000000046
65016+:10CAF0000000000000000000000000000000000036
65017+:10CB00000000000000000000000000000000000025
65018+:10CB10000000000000000000000000000000000015
65019+:10CB20000000000000000000000000000000000005
65020+:10CB300000000000000000000000000000000000F5
65021+:10CB400000000000000000000000000000000000E5
65022+:10CB500000000000000000000000000000000000D5
65023+:10CB600000000000000000000000000000000000C5
65024+:10CB700000000000000000000000000000000000B5
65025+:10CB800000000000000000000000000000000000A5
65026+:10CB90000000000000000000000000000000000095
65027+:10CBA0000000000000000000000000000000000085
65028+:10CBB0000000000000000000000000000000000075
65029+:10CBC0000000000000000000000000000000000065
65030+:10CBD0000000000000000000000000000000000055
65031+:10CBE0000000000000000000000000000000000045
65032+:10CBF0000000000000000000000000000000000035
65033+:10CC00000000000000000000000000000000000024
65034+:10CC10000000000000000000000000000000000014
65035+:10CC20000000000000000000000000000000000004
65036+:10CC300000000000000000000000000000000000F4
65037+:10CC400000000000000000000000000000000000E4
65038+:10CC500000000000000000000000000000000000D4
65039+:10CC600000000000000000000000000000000000C4
65040+:10CC700000000000000000000000000000000000B4
65041+:10CC800000000000000000000000000000000000A4
65042+:10CC90000000000000000000000000000000000094
65043+:10CCA0000000000000000000000000000000000084
65044+:10CCB0000000000000000000000000000000000074
65045+:10CCC0000000000000000000000000000000000064
65046+:10CCD0000000000000000000000000000000000054
65047+:10CCE0000000000000000000000000000000000044
65048+:10CCF0000000000000000000000000000000000034
65049+:10CD00000000000000000000000000000000000023
65050+:10CD10000000000000000000000000000000000013
65051+:10CD20000000000000000000000000000000000003
65052+:10CD300000000000000000000000000000000000F3
65053+:10CD400000000000000000000000000000000000E3
65054+:10CD500000000000000000000000000000000000D3
65055+:10CD600000000000000000000000000000000000C3
65056+:10CD700000000000000000000000000000000000B3
65057+:10CD800000000000000000000000000000000000A3
65058+:10CD90000000000000000000000000000000000093
65059+:10CDA0000000000000000000000000000000000083
65060+:10CDB0000000000000000000000000000000000073
65061+:10CDC0000000000000000000000000000000000063
65062+:10CDD0000000000000000000000000000000000053
65063+:10CDE0000000000000000000000000000000000043
65064+:10CDF0000000000000000000000000000000000033
65065+:10CE00000000000000000000000000000000000022
65066+:10CE10000000000000000000000000000000000012
65067+:10CE20000000000000000000000000000000000002
65068+:10CE300000000000000000000000000000000000F2
65069+:10CE400000000000000000000000000000000000E2
65070+:10CE500000000000000000000000000000000000D2
65071+:10CE600000000000000000000000000000000000C2
65072+:10CE700000000000000000000000000000000000B2
65073+:10CE800000000000000000000000000000000000A2
65074+:10CE90000000000000000000000000000000000092
65075+:10CEA0000000000000000000000000000000000082
65076+:10CEB0000000000000000000000000000000000072
65077+:10CEC0000000000000000000000000000000000062
65078+:10CED0000000000000000000000000000000000052
65079+:10CEE0000000000000000000000000000000000042
65080+:10CEF0000000000000000000000000000000000032
65081+:10CF00000000000000000000000000000000000021
65082+:10CF10000000000000000000000000000000000011
65083+:10CF20000000000000000000000000000000000001
65084+:10CF300000000000000000000000000000000000F1
65085+:10CF400000000000000000000000000000000000E1
65086+:10CF500000000000000000000000000000000000D1
65087+:10CF600000000000000000000000000000000000C1
65088+:10CF700000000000000000000000000000000000B1
65089+:10CF800000000000000000000000000000000000A1
65090+:10CF90000000000000000000000000000000000091
65091+:10CFA0000000000000000000000000000000000081
65092+:10CFB0000000000000000000000000000000000071
65093+:10CFC0000000000000000000000000000000000061
65094+:10CFD0000000000000000000000000000000000051
65095+:10CFE0000000000000000000000000000000000041
65096+:10CFF0000000000000000000000000000000000031
65097+:10D000000000000000000000000000000000000020
65098+:10D010000000000000000000000000000000000010
65099+:10D020000000000000000000000000000000000000
65100+:10D0300000000000000000000000000000000000F0
65101+:10D0400000000000000000000000000000000000E0
65102+:10D0500000000000000000000000000000000000D0
65103+:10D0600000000000000000000000000000000000C0
65104+:10D0700000000000000000000000000000000000B0
65105+:10D0800000000000000000000000000000000000A0
65106+:10D090000000000000000000000000000000000090
65107+:10D0A0000000000000000000000000000000000080
65108+:10D0B0000000000000000000000000000000000070
65109+:10D0C0000000000000000000000000000000000060
65110+:10D0D0000000000000000000000000000000000050
65111+:10D0E0000000000000000000000000000000000040
65112+:10D0F0000000000000000000000000000000000030
65113+:10D10000000000000000000000000000000000001F
65114+:10D11000000000000000000000000000000000000F
65115+:10D1200000000000000000000000000000000000FF
65116+:10D1300000000000000000000000000000000000EF
65117+:10D1400000000000000000000000000000000000DF
65118+:10D1500000000000000000000000000000000000CF
65119+:10D1600000000000000000000000000000000000BF
65120+:10D1700000000000000000000000000000000000AF
65121+:10D18000000000000000000000000000000000009F
65122+:10D19000000000000000000000000000000000008F
65123+:10D1A000000000000000000000000000000000007F
65124+:10D1B000000000000000000000000000000000006F
65125+:10D1C000000000000000000000000000000000005F
65126+:10D1D000000000000000000000000000000000004F
65127+:10D1E000000000000000000000000000000000003F
65128+:10D1F000000000000000000000000000000000002F
65129+:10D20000000000000000000000000000000000001E
65130+:10D21000000000000000000000000000000000000E
65131+:10D2200000000000000000000000000000000000FE
65132+:10D2300000000000000000000000000000000000EE
65133+:10D2400000000000000000000000000000000000DE
65134+:10D2500000000000000000000000000000000000CE
65135+:10D2600000000000000000000000000000000000BE
65136+:10D2700000000000000000000000000000000000AE
65137+:10D28000000000000000000000000000000000009E
65138+:10D29000000000000000000000000000000000008E
65139+:10D2A000000000000000000000000000000000007E
65140+:10D2B000000000000000000000000000000000006E
65141+:10D2C000000000000000000000000000000000005E
65142+:10D2D000000000000000000000000000000000004E
65143+:10D2E000000000000000000000000000000000003E
65144+:10D2F000000000000000000000000000000000002E
65145+:10D30000000000000000000000000000000000001D
65146+:10D31000000000000000000000000000000000000D
65147+:10D3200000000000000000000000000000000000FD
65148+:10D3300000000000000000000000000000000000ED
65149+:10D3400000000000000000000000000000000000DD
65150+:10D3500000000000000000000000000000000000CD
65151+:10D3600000000000000000000000000000000000BD
65152+:10D3700000000000000000000000000000000000AD
65153+:10D38000000000000000000000000000000000009D
65154+:10D39000000000000000000000000000000000008D
65155+:10D3A000000000000000000000000000000000007D
65156+:10D3B000000000000000000000000000000000006D
65157+:10D3C000000000000000000000000000000000005D
65158+:10D3D000000000000000000000000000000000004D
65159+:10D3E000000000000000000000000000000000003D
65160+:10D3F000000000000000000000000000000000002D
65161+:10D40000000000000000000000000000000000001C
65162+:10D41000000000000000000000000000000000000C
65163+:10D4200000000000000000000000000000000000FC
65164+:10D4300000000000000000000000000000000000EC
65165+:10D4400000000000000000000000000000000000DC
65166+:10D4500000000000000000000000000000000000CC
65167+:10D4600000000000000000000000000000000000BC
65168+:10D4700000000000000000000000000000000000AC
65169+:10D48000000000000000000000000000000000009C
65170+:10D49000000000000000000000000000000000008C
65171+:10D4A000000000000000000000000000000000007C
65172+:10D4B000000000000000000000000000000000006C
65173+:10D4C000000000000000000000000000000000005C
65174+:10D4D000000000000000000000000000000000004C
65175+:10D4E000000000000000000000000000000000003C
65176+:10D4F000000000000000000000000000000000002C
65177+:10D50000000000000000000000000000000000001B
65178+:10D51000000000000000000000000000000000000B
65179+:10D5200000000000000000000000000000000000FB
65180+:10D5300000000000000000000000000000000000EB
65181+:10D5400000000000000000000000000000000000DB
65182+:10D5500000000000000000000000000000000000CB
65183+:10D5600000000000000000000000000000000000BB
65184+:10D5700000000000000000000000000000000000AB
65185+:10D58000000000000000000000000000000000009B
65186+:10D59000000000000000008000000000000000000B
65187+:10D5A000000000000000000000000000000000007B
65188+:10D5B00000000000000000000000000A0000000061
65189+:10D5C0000000000000000000100000030000000048
65190+:10D5D0000000000D0000000D3C02080024427340D2
65191+:10D5E0003C030800246377CCAC4000000043202BB0
65192+:10D5F0001480FFFD244200043C1D080037BD7FFC61
65193+:10D6000003A0F0213C100800261032103C1C08003A
65194+:10D61000279C73400E0010FE000000000000000D6B
65195+:10D6200030A5FFFF30C600FF274301808F4201B8BD
65196+:10D630000440FFFE24020002AC640000A465000860
65197+:10D64000A066000AA062000B3C021000AC67001844
65198+:10D6500003E00008AF4201B83C0360008C624FF861
65199+:10D660000440FFFE3C020200AC644FC0AC624FC4F9
65200+:10D670003C02100003E00008AC624FF89482000CFA
65201+:10D680002486001400A0382100021302000210803A
65202+:10D690000082402100C8102B1040005700000000FD
65203+:10D6A00090C300002C6200095040005190C200015C
65204+:10D6B000000310803C030800246372F00043102133
65205+:10D6C0008C420000004000080000000090C30001F0
65206+:10D6D0002402000A1462003A000000000106102330
65207+:10D6E0002C42000A1440003624C600028CE20000DE
65208+:10D6F00034420100ACE2000090C2000090C300017F
65209+:10D7000090C4000290C5000300031C000002160034
65210+:10D710000043102500042200004410250045102578
65211+:10D7200024C60004ACE2000490C2000090C30001D3
65212+:10D7300090C4000290C500030002160000031C0004
65213+:10D740000043102500042200004410250045102548
65214+:10D7500024C600040A000CB8ACE2000890C3000123
65215+:10D76000240200041462001624C6000290C20000C5
65216+:10D7700090C400018CE30000000212000044102558
65217+:10D780003463000424C60002ACE2000C0A000CB8AA
65218+:10D79000ACE3000090C300012402000314620008FF
65219+:10D7A00024C600028CE2000090C3000024C60001E1
65220+:10D7B00034420008A0E300100A000CB8ACE20000FC
65221+:10D7C00003E000082402000190C3000124020002CB
65222+:10D7D0001062000224C40002010020210A000CB8DB
65223+:10D7E000008030210A000CB824C6000190C200015C
65224+:10D7F0000A000CB800C2302103E00008000010212C
65225+:10D8000027BDFFE8AFBF0014AFB000100E00130239
65226+:10D8100000808021936200052403FFFE0200202186
65227+:10D82000004310248FBF00148FB00010A3620005C6
65228+:10D830000A00130B27BD001827BDFFE8AFB000108A
65229+:10D84000AFBF00140E000F3C0080802193620000E7
65230+:10D8500024030050304200FF14430004240201005E
65231+:10D86000AF4201800A000D3002002021AF4001804C
65232+:10D87000020020218FBF00148FB000100A000FE7B4
65233+:10D8800027BD001827BDFF80AFBE0078AFB700747A
65234+:10D89000AFB20060AFBF007CAFB60070AFB5006C38
65235+:10D8A000AFB40068AFB30064AFB1005CAFB0005874
65236+:10D8B0008F5001283C0208008C4231A02403FF80D5
65237+:10D8C0009365003F0202102100431024AF42002460
65238+:10D8D0003C0208008C4231A09364000530B200FF86
65239+:10D8E000020210213042007F034218210004202749
65240+:10D8F0003C02000A0062182130840001AF8300144A
65241+:10D900000000F0210000B82114800053AFA00050A7
65242+:10D9100093430116934401128F450104306300FFC5
65243+:10D920003C020001308400FF00A2282403431021A0
65244+:10D9300003441821245640002467400014A001CD60
65245+:10D940002402000193620000304300FF2402002003
65246+:10D950001062000524020050106200060000000062
65247+:10D960000A000D74000000000000000D0A000D7D8B
65248+:10D97000AFA000303C1E080027DE738C0A000D7D2E
65249+:10D98000AFA000303C0208008C4200DC24420001C1
65250+:10D990003C010800AC2200DC0E00139F00000000D8
65251+:10D9A0000A000F318FBF007C8F4201043C0300202E
65252+:10D9B00092D3000D004310240002202B00042140CC
65253+:10D9C000AFA400308F4301043C02004000621824E1
65254+:10D9D000146000023485004000802821326200205B
65255+:10D9E000AFA500301440000234A6008000A0302112
65256+:10D9F00010C0000BAFA6003093C500088F67004C25
65257+:10DA00000200202100052B0034A5008130A5F08103
65258+:10DA10000E000C9B30C600FF0A000F2E0000000015
65259+:10DA20009362003E304200401040000F2402000488
65260+:10DA300056420007240200120200202100E02821A3
65261+:10DA40000E0013F702C030210A000F318FBF007C97
65262+:10DA500016420005000000000E000D2100002021EC
65263+:10DA60000A000F318FBF007C9743011A96C4000E45
65264+:10DA700093620035326500043075FFFF00442004D6
65265+:10DA8000AFA400548ED1000410A000158ED400085D
65266+:10DA90009362003E3042004010400007000000004A
65267+:10DAA0000E0013E0022020211040000D00000000B5
65268+:10DAB0000A000F2E000000008F6200440222102393
65269+:10DAC0000440016A000000008F6200480222102317
65270+:10DAD00004410166240400160A000E218FC20004CE
65271+:10DAE0008F6200480222102304400008000000005A
65272+:10DAF0003C0208008C423100244200013C01080035
65273+:10DB0000AC2231000A000F23000000008F620040A9
65274+:10DB100002221023184000128F8400143C020800D7
65275+:10DB20008C423100327300FC0000A8212442000125
65276+:10DB30003C010800AC2231008F6300409482011C3C
65277+:10DB4000022318233042FFFF0043102A50400010E8
65278+:10DB50002402000C8F6200400A000DF20222102302
65279+:10DB60009483011C9762003C0043102B1040000678
65280+:10DB7000000000009482011C00551023A482011CA7
65281+:10DB80000A000DF72402000CA480011C2402000CE2
65282+:10DB9000AFA200308F620040005120231880000D9A
65283+:10DBA00002A4102A1440012600000000149500066B
65284+:10DBB00002A410233A620001304200011440012007
65285+:10DBC0000000000002A41023022488210A000E098C
65286+:10DBD0003055FFFF00002021326200021040001A81
65287+:10DBE000326200109362003E30420040504000110B
65288+:10DBF0008FC200040E00130202002021240200182C
65289+:10DC0000A362003F936200052403FFFE020020216F
65290+:10DC1000004310240E00130BA362000524040039F6
65291+:10DC2000000028210E0013C9240600180A000F3036
65292+:10DC300024020001240400170040F809000000003D
65293+:10DC40000A000F302402000110400108000000000B
65294+:10DC50008F63004C8F620054028210231C4001032A
65295+:10DC600002831023044200010060A021AFA4001829
65296+:10DC7000AFB10010AFB50014934201208F65004092
65297+:10DC80009763003C304200FF034210210044102102
65298+:10DC90008FA400543063FFFF244240000083182B00
65299+:10DCA0008FA40030AFA20020AFA50028008320255C
65300+:10DCB000AFA40030AFA50024AFA0002CAFB4003457
65301+:10DCC0009362003E30420008504000118FC20000B5
65302+:10DCD00002C0202127A500380E000CB2AFA00038EA
65303+:10DCE0005440000B8FC200008FA200383042010068
65304+:10DCF000504000078FC200008FA3003C8F6200607D
65305+:10DD00000062102304430001AF6300608FC2000073
65306+:10DD10000040F80927A400108FA200303042000212
65307+:10DD200054400001327300FE9362003E30420040D6
65308+:10DD3000104000378FA200248F6200541682001A10
65309+:10DD40003262000124020014124200102A4200151F
65310+:10DD500010400006240200162402000C12420007A4
65311+:10DD6000326200010A000E7D000000001242000530
65312+:10DD7000326200010A000E7D000000000A000E78E9
65313+:10DD80002417000E0A000E78241700100A000E7CDB
65314+:10DD900024170012936200232403FFBD00431024C4
65315+:10DDA000A362002332620001104000198FA20024F8
65316+:10DDB0002402000C1242000E2A42000D1040000600
65317+:10DDC0002402000E2402000A124200078FA200243F
65318+:10DDD0000A000E9524420001124200088FA200247E
65319+:10DDE0000A000E95244200010A000E932417000831
65320+:10DDF0002402000E16E20002241700162417001059
65321+:10DE00008FA2002424420001AFA200248FA200248C
65322+:10DE10008FA300148F76004000431021AF620040B2
65323+:10DE20008F8200149442011C104000090000000081
65324+:10DE30008F6200488F6400409763003C00441023C9
65325+:10DE40003063FFFF0043102A104000088FA20054E7
65326+:10DE5000936400368F6300403402FFFC008210049C
65327+:10DE600000621821AF6300488FA200548FA60030D3
65328+:10DE70000282902130C200081040000E0000000015
65329+:10DE80008F6200581642000430C600FF9742011A04
65330+:10DE90005040000134C6001093C500088FA700341D
65331+:10DEA0000200202100052B0034A500800E000C9BF1
65332+:10DEB00030A5F0808F620040005610231840001BF0
65333+:10DEC0008FA200183C0208008C42319830420010AA
65334+:10DED0001040000D24020001976200681440000AFF
65335+:10DEE000240200018F8200149442011C1440000699
65336+:10DEF00024020001A76200689742007A244200646D
65337+:10DF00000A000EE9A7620012A76200120E001302B7
65338+:10DF1000020020219362007D2403000102002021E1
65339+:10DF2000344200010A000EE7AFA300501840000A77
65340+:10DF3000000000000E001302020020219362007D09
65341+:10DF40002403000102002021AFA30050344200044A
65342+:10DF50000E00130BA362007D9362003E304200402E
65343+:10DF60001440000C326200011040000A0000000062
65344+:10DF70008F6300408FC20004240400182463000152
65345+:10DF80000040F809AF6300408FA200300A000F3054
65346+:10DF9000304200048F620058105200100000000050
65347+:10DFA0008F620018022210231C4000082404000184
65348+:10DFB0008F62001816220009000000008F62001C0A
65349+:10DFC000028210230440000500000000AF720058D8
65350+:10DFD000AFA40050AF710018AF74001C12E0000B2A
65351+:10DFE0008FA200500E00130202002021A377003FF1
65352+:10DFF0000E00130B0200202102E030212404003720
65353+:10E000000E0013C9000028218FA200501040000309
65354+:10E01000000000000E000CA90200202112A0000543
65355+:10E02000000018218FA2003030420004504000113F
65356+:10E0300000601021240300010A000F30006010214D
65357+:10E040000E001302020020219362007D02002021B5
65358+:10E05000344200040E00130BA362007D0E000CA9D5
65359+:10E06000020020210A000F3024020001AF400044CA
65360+:10E07000240200018FBF007C8FBE00788FB7007430
65361+:10E080008FB600708FB5006C8FB400688FB30064DA
65362+:10E090008FB200608FB1005C8FB0005803E00008C1
65363+:10E0A00027BD00808F4201B80440FFFE2402080013
65364+:10E0B000AF4201B803E00008000000003C02000885
65365+:10E0C00003421021944200483084FFFF2484001250
65366+:10E0D0003045FFFF10A0001700A4102B10400016C1
65367+:10E0E00024020003934201202403001AA343018B5E
65368+:10E0F000304200FF2446FFFE8F82000000A6182B4E
65369+:10E100003863000100021382004310241040000510
65370+:10E110008F84000434820001A746019403E00008C4
65371+:10E12000AF8200042402FFFE0082102403E00008F6
65372+:10E13000AF8200042402000303E00008A342018B25
65373+:10E1400027BDFFE0AFB10014AFB00010AFBF0018A3
65374+:10E1500030B0FFFF30D1FFFF8F4201B80440FFFE17
65375+:10E1600000000000AF440180AF4400200E000F42C9
65376+:10E17000020020218F8300008F840004A750019AA1
65377+:10E18000A750018EA74301908F8300083082800042
65378+:10E19000AF4301A8A75101881040000E8F820004F0
65379+:10E1A00093420116304200FC24420004005A102120
65380+:10E1B0008C4240003042FFFF144000068F82000472
65381+:10E1C0003C02FFFF34427FFF00821024AF82000434
65382+:10E1D0008F8200042403BFFF00431024A74201A63E
65383+:10E1E0009743010C8F42010400031C003042FFFFE3
65384+:10E1F00000621825AF4301AC3C021000AF4201B8E9
65385+:10E200008FBF00188FB100148FB0001003E000081A
65386+:10E2100027BD00208F470070934201128F830000BA
65387+:10E2200027BDFFF0304200FF00022882306201006B
65388+:10E23000000030211040004324A40003306240005D
65389+:10E24000104000103062200000041080005A10219D
65390+:10E250008C43400024A4000400041080AFA30000FD
65391+:10E26000005A10218C424000AFA2000493420116D4
65392+:10E27000304200FC005A10218C4240000A000FC0BE
65393+:10E28000AFA200081040002F0000302100041080D1
65394+:10E29000005A10218C43400024A400040004108084
65395+:10E2A000AFA30000005A10218C424000AFA000082C
65396+:10E2B000AFA200048FA80008000030210000202138
65397+:10E2C000240A00083C0908002529010003A41021A4
65398+:10E2D000148A000300042A001100000A0000000054
65399+:10E2E00090420000248400012C83000C00A2102125
65400+:10E2F00000021080004910218C4200001460FFF3DE
65401+:10E3000000C230263C0408008C8431048F42007027
65402+:10E310002C83002010600009004738233C030800CC
65403+:10E32000246331080004108000431021248300017D
65404+:10E33000AC4700003C010800AC233104AF86000864
65405+:10E340002406000100C0102103E0000827BD0010D2
65406+:10E350003C0208008C42003827BDFFD0AFB5002436
65407+:10E36000AFB40020AFB10014AFBF0028AFB3001CA2
65408+:10E37000AFB20018AFB00010000088213C150800B3
65409+:10E3800026B50038144000022454FFFF0000A021ED
65410+:10E390009742010E8F8400003042FFFF308340001F
65411+:10E3A0001060000A245200043C0200200082102465
65412+:10E3B00050400007308280008F8200042403BFFF9A
65413+:10E3C000008318240A0010103442100030828000AC
65414+:10E3D0001040000A3C020020008210241040000778
65415+:10E3E0008F8200043C03FFFF34637FFF0083182407
65416+:10E3F00034428000AF820004AF8300000E000F980B
65417+:10E400000000000014400007000000009743011EB8
65418+:10E410009742011C3063FFFF0002140000621825C0
65419+:10E42000AF8300089742010C8F4340003045FFFF47
65420+:10E430003402FFFF14620003000000000A001028ED
65421+:10E44000241100208F42400030420100544000015E
65422+:10E45000241100108F8400003082100050400014FE
65423+:10E4600036310001308200201440000B3C021000C5
65424+:10E47000008210245040000E363100013C030E0093
65425+:10E480003C020DFF008318243442FFFF0043102B91
65426+:10E4900050400007363100013C0208008C42002C3D
65427+:10E4A000244200013C010800AC22002C363100055A
65428+:10E4B0003C0608008CC6003454C000238F85000041
65429+:10E4C0008F820004304240005440001F8F850000BE
65430+:10E4D0003C021F01008210243C0310005443001A28
65431+:10E4E0008F85000030A20200144000178F850000C5
65432+:10E4F0003250FFFF363100028F4201B80440FFFE68
65433+:10E5000000000000AF400180020020210E000F42F9
65434+:10E51000AF4000208F8300042402BFFFA750019A60
65435+:10E52000006218248F820000A750018EA751018835
65436+:10E53000A74301A6A74201903C021000AF4201B8D8
65437+:10E540000A0010F5000010213C02100000A2102467
65438+:10E550001040003A0000000010C0000F0000000052
65439+:10E5600030A201001040000C3C0302003C020F00EE
65440+:10E5700000A2102410430008000000008F82000851
65441+:10E58000005410240055102190420004244200043D
65442+:10E590000A00109F000221C00000000000051602C2
65443+:10E5A0003050000F3A0300022E4203EF38420001C0
65444+:10E5B0002C6300010062182414600073240200011F
65445+:10E5C0003C0308008C6300D02E06000C386200016A
65446+:10E5D0002C4200010046102414400015001021C0F8
65447+:10E5E0002602FFFC2C4200045440001100002021B0
65448+:10E5F000386200022C420001004610241040000343
65449+:10E60000000512420A00109F000020210010182B64
65450+:10E610000043102450400006001021C000002021BB
65451+:10E620003245FFFF0E000F633226FFFB001021C0B2
65452+:10E630003245FFFF0A0010F2362600028F424000EA
65453+:10E640003C0308008C630024304201001040004667
65454+:10E6500030620001322200043070000D14400002CC
65455+:10E660002413000424130002000512C238420001E2
65456+:10E670002E4303EF304200013863000100431025B0
65457+:10E68000104000033231FFFB2402FFFB0202802412
65458+:10E6900010C000183202000130A201001040001525
65459+:10E6A000320200013C020F0000A210243C030200D1
65460+:10E6B0001043000F8F8200082403FFFE0203802412
65461+:10E6C00000541024005510219042000402333025DC
65462+:10E6D0002442000412000002000221C03226FFFF83
65463+:10E6E0000E000F633245FFFF1200002700001021CB
65464+:10E6F000320200011040000D320200042402000129
65465+:10E7000012020002023330253226FFFF00002021D2
65466+:10E710000E000F633245FFFF2402FFFE0202802439
65467+:10E7200012000019000010213202000410400016EF
65468+:10E7300024020001240200041202000202333025E8
65469+:10E740003226FFFF3245FFFF0E000F632404010055
65470+:10E750002402FFFB020280241200000B00001021A3
65471+:10E760000A0010F5240200011040000700001021EB
65472+:10E770003245FFFF36260002000020210E000F6305
65473+:10E7800000000000000010218FBF00288FB500247A
65474+:10E790008FB400208FB3001C8FB200188FB100140B
65475+:10E7A0008FB0001003E0000827BD003027BDFFD068
65476+:10E7B000AFB000103C04600CAFBF002CAFB6002817
65477+:10E7C000AFB50024AFB40020AFB3001CAFB2001847
65478+:10E7D000AFB100148C8250002403FF7F3C1A8000EC
65479+:10E7E000004310243442380CAC8250002402000351
65480+:10E7F0003C106000AF4200088E0208083C1B8008F5
65481+:10E800003C010800AC2000203042FFF038420010EC
65482+:10E810002C4200010E001B8DAF8200183C04FFFF4C
65483+:10E820003C020400348308063442000CAE0219484E
65484+:10E83000AE03194C3C0560168E0219808CA30000B3
65485+:10E840003442020000641824AE0219803C02535383
65486+:10E850001462000334A47C008CA200040050202128
65487+:10E860008C82007C8C830078AF820010AF83000C18
65488+:10E870008F55000032A200031040FFFD32A20001BC
65489+:10E880001040013D32A200028F420128AF42002019
65490+:10E890008F4201048F430100AF8200000E000F3C45
65491+:10E8A000AF8300043C0208008C4200C01040000806
65492+:10E8B0008F8400003C0208008C4200C42442000106
65493+:10E8C0003C010800AC2200C40A00126900000000EC
65494+:10E8D0003C020010008210241440010C8F830004BD
65495+:10E8E0003C0208008C4200203C0308008C63003886
65496+:10E8F00000008821244200013C010800AC220020D5
65497+:10E900003C16080026D60038146000022474FFFF6D
65498+:10E910000000A0219742010E308340003042FFFFEB
65499+:10E920001060000A245200043C02002000821024DF
65500+:10E9300050400007308280008F8200042403BFFF14
65501+:10E94000008318240A0011703442100030828000C5
65502+:10E950001040000A3C0200200082102410400007F2
65503+:10E960008F8200043C03FFFF34637FFF0083182481
65504+:10E9700034428000AF820004AF8300000E000F9885
65505+:10E980000000000014400007000000009743011E33
65506+:10E990009742011C3063FFFF00021400006218253B
65507+:10E9A000AF8300089742010C8F4340003045FFFFC2
65508+:10E9B0003402FFFF14620003000000000A00118807
65509+:10E9C000241100208F4240003042010054400001D9
65510+:10E9D000241100108F840000308210005040001479
65511+:10E9E00036310001308200201440000B3C02100040
65512+:10E9F000008210245040000E363100013C030E000E
65513+:10EA00003C020DFF008318243442FFFF0043102B0B
65514+:10EA100050400007363100013C0208008C42002CB7
65515+:10EA2000244200013C010800AC22002C36310005D4
65516+:10EA30003C0608008CC6003454C000238F850000BB
65517+:10EA40008F820004304240005440001F8F85000038
65518+:10EA50003C021F01008210243C0310005443001AA2
65519+:10EA60008F85000030A20200144000178F8500003F
65520+:10EA70003250FFFF363100028F4201B80440FFFEE2
65521+:10EA800000000000AF400180020020210E000F4274
65522+:10EA9000AF4000208F8300042402BFFFA750019ADB
65523+:10EAA000006218248F820000A750018EA7510188B0
65524+:10EAB000A74301A6A74201903C021000AF4201B853
65525+:10EAC0000A001267000010213C02100000A210246E
65526+:10EAD0001040003A0000000010C0000F00000000CD
65527+:10EAE00030A201001040000C3C0302003C020F0069
65528+:10EAF00000A2102410430008000000008F820008CC
65529+:10EB000000541024005610219042000424420004B6
65530+:10EB10000A0011FF000221C00000000000051602DB
65531+:10EB20003050000F3A0300022E4203EF384200013A
65532+:10EB30002C63000100621824146000852402000187
65533+:10EB40003C0308008C6300D02E06000C38620001E4
65534+:10EB50002C4200010046102414400015001021C072
65535+:10EB60002602FFFC2C42000454400011000020212A
65536+:10EB7000386200022C42000100461024504000037D
65537+:10EB8000000512420A0011FF000020210010182B7E
65538+:10EB90000043102450400006001021C00000202136
65539+:10EBA0003245FFFF0E000F633226FFFB001021C02D
65540+:10EBB0003245FFFF0A001252362600028F42400003
65541+:10EBC0003C0308008C6300243042010010400046E2
65542+:10EBD00030620001322200043070000D1440000247
65543+:10EBE0002413000424130002000512C2384200015D
65544+:10EBF0002E4303EF3042000138630001004310252B
65545+:10EC0000104000033231FFFB2402FFFB020280248C
65546+:10EC100010C000183202000130A20100104000159F
65547+:10EC2000320200013C020F0000A210243C0302004B
65548+:10EC30001043000F8F8200082403FFFE020380248C
65549+:10EC40000054102400561021904200040233302555
65550+:10EC50002442000412000002000221C03226FFFFFD
65551+:10EC60000E000F633245FFFF120000390000102133
65552+:10EC7000320200011040000D3202000424020001A3
65553+:10EC800012020002023330253226FFFF000020214D
65554+:10EC90000E000F633245FFFF2402FFFE02028024B4
65555+:10ECA0001200002B00001021320200041040002846
65556+:10ECB0002402000124020004120200020233302563
65557+:10ECC0003226FFFF3245FFFF0E000F6324040100D0
65558+:10ECD0002402FFFB020280241200001D000010210C
65559+:10ECE0000A001267240200015040001900001021A0
65560+:10ECF0003245FFFF36260002000020210E000F6380
65561+:10ED0000000000000A001267000010212402BFFF6B
65562+:10ED1000006210241040000800000000240287FF59
65563+:10ED200000621024144000083C020060008210249D
65564+:10ED300010400005000000000E000D34000000002F
65565+:10ED40000A001267000000000E0012C70000000059
65566+:10ED5000104000063C0240008F4301243C0260202A
65567+:10ED6000AC430014000000003C024000AF420138F8
65568+:10ED70000000000032A200021040FEBD00000000B2
65569+:10ED80008F4201403C044000AF4200208F430148C5
65570+:10ED90003C02700000621824106400420000000071
65571+:10EDA0000083102B144000063C0260003C0220004F
65572+:10EDB000106200073C0240000A0012C3000000007D
65573+:10EDC0001062003C3C0240000A0012C30000000038
65574+:10EDD0008F4501408F4601448F42014800021402D2
65575+:10EDE000304300FF240200041462000A274401801B
65576+:10EDF0008F4201B80440FFFE2402001CAC850000D5
65577+:10EE0000A082000B3C021000AF4201B80A0012C3FE
65578+:10EE10003C0240002402000914620012000616029F
65579+:10EE2000000229C0AF4500208F4201B80440FFFE18
65580+:10EE30002402000124030003AF450180A343018B9A
65581+:10EE4000A740018EA740019AA7400190AF4001A8BA
65582+:10EE5000A7420188A74201A6AF4001AC3C021000C6
65583+:10EE6000AF4201B88F4201B80440FFFE000000002D
65584+:10EE7000AC8500008F42014800021402A482000801
65585+:10EE800024020002A082000B8F420148A4820010DD
65586+:10EE90003C021000AC860024AF4201B80A0012C345
65587+:10EEA0003C0240000E001310000000000A0012C3D4
65588+:10EEB0003C0240000E001BC2000000003C0240006B
65589+:10EEC000AF420178000000000A00112F000000008E
65590+:10EED0008F4201003042003E144000112402000124
65591+:10EEE000AF4000488F420100304207C0104000058B
65592+:10EEF00000000000AF40004CAF40005003E00008AD
65593+:10EF000024020001AF400054AF4000408F42010096
65594+:10EF10003042380054400001AF4000442402000158
65595+:10EF200003E00008000000008F4201B80440FFFE2B
65596+:10EF300024020001AF440180AF400184A74501884D
65597+:10EF4000A342018A24020002A342018B9742014A94
65598+:10EF500014C00004A7420190AF4001A40A0012EFC0
65599+:10EF60003C0210008F420144AF4201A43C02100059
65600+:10EF7000AF4001A803E00008AF4201B88F4201B8DA
65601+:10EF80000440FFFE24020002AF440180AF4401842C
65602+:10EF9000A7450188A342018AA342018B9742014AF7
65603+:10EFA000A7420190AF4001A48F420144AF4201A8A3
65604+:10EFB0003C02100003E00008AF4201B83C029000A0
65605+:10EFC0003442000100822025AF4400208F420020FF
65606+:10EFD0000440FFFE0000000003E000080000000005
65607+:10EFE0003C028000344200010082202503E000083A
65608+:10EFF000AF44002027BDFFE8AFBF0014AFB0001042
65609+:10F000008F50014093430149934201489344014882
65610+:10F01000306300FF304200FF00021200006228252A
65611+:10F020002402001910620076308400802862001AE1
65612+:10F030001040001C24020020240200081062007707
65613+:10F04000286200091040000E2402000B2402000177
65614+:10F0500010620034286200025040000524020006BD
65615+:10F0600050600034020020210A00139A00000000C2
65616+:10F0700010620030020020210A00139A00000000F4
65617+:10F080001062003B2862000C504000022402000E77
65618+:10F090002402000910620056020020210A00139A7F
65619+:10F0A0000000000010620056286200211040000F8E
65620+:10F0B000240200382402001C106200582862001D3F
65621+:10F0C000104000062402001F2402001B1062004CA6
65622+:10F0D000000000000A00139A000000001062004ABD
65623+:10F0E000020020210A00139A00000000106200456F
65624+:10F0F0002862003910400007240200802462FFCB00
65625+:10F100002C42000210400045020020210A00139604
65626+:10F110000000302110620009000000000A00139A6C
65627+:10F12000000000001480003D020020210A0013901E
65628+:10F130008FBF00140A001396240600018F4201B805
65629+:10F140000440FFFE24020002A342018BA745018870
65630+:10F150009742014AA74201908F420144A74201927F
65631+:10F160003C021000AF4201B80A00139C8FBF00148C
65632+:10F170009742014A144000290000000093620005F4
65633+:10F180003042000414400025000000000E0013026D
65634+:10F190000200202193620005020020213442000475
65635+:10F1A0000E00130BA36200059362000530420004B9
65636+:10F1B00014400002000000000000000D93620000F7
65637+:10F1C00024030020304200FF14430014000000001C
65638+:10F1D0008F4201B80440FFFE24020005AF500180B9
65639+:10F1E000A342018B3C0210000A00139AAF4201B8FF
65640+:10F1F0008FBF00148FB000100A0012F227BD001854
65641+:10F200000000000D02002021000030218FBF0014FB
65642+:10F210008FB000100A0012DD27BD00180000000D9D
65643+:10F220008FBF00148FB0001003E0000827BD001846
65644+:10F2300027BDFFE8AFBF00100E000F3C000000002C
65645+:10F24000AF4001808FBF0010000020210A000FE7AF
65646+:10F2500027BD00183084FFFF30A5FFFF00001821F4
65647+:10F260001080000700000000308200011040000202
65648+:10F2700000042042006518210A0013AB0005284055
65649+:10F2800003E000080060102110C0000624C6FFFF44
65650+:10F290008CA2000024A50004AC8200000A0013B573
65651+:10F2A0002484000403E000080000000010A000080F
65652+:10F2B00024A3FFFFAC860000000000000000000057
65653+:10F2C0002402FFFF2463FFFF1462FFFA248400047A
65654+:10F2D00003E0000800000000308300FF30A500FFBD
65655+:10F2E00030C600FF274701808F4201B80440FFFE6F
65656+:10F2F000000000008F42012834634000ACE20000AF
65657+:10F3000024020001ACE00004A4E30008A0E2000A2B
65658+:10F3100024020002A0E2000B3C021000A4E5001051
65659+:10F32000ACE00024ACE00028A4E6001203E00008F2
65660+:10F33000AF4201B827BDFFE8AFBF00109362003FA6
65661+:10F3400024030012304200FF1043000D00803021E2
65662+:10F350008F620044008210230440000A8FBF001017
65663+:10F360008F620048240400390000282100C21023C5
65664+:10F3700004410004240600120E0013C9000000001E
65665+:10F380008FBF00102402000103E0000827BD001811
65666+:10F3900027BDFFC8AFB20030AFB1002CAFBF003403
65667+:10F3A000AFB0002890C5000D0080902130A400105F
65668+:10F3B0001080000B00C088218CC300088F620054AD
65669+:10F3C0001062000730A20005144000B524040001BB
65670+:10F3D0000E000D21000020210A0014BB0040202156
65671+:10F3E00030A200051040000930A30012108000ACCC
65672+:10F3F000240400018E2300088F620054146200A9C7
65673+:10F400008FBF00340A00142C240400382402001298
65674+:10F41000146200A3240400010220202127A500106B
65675+:10F420000E000CB2AFA000101040001102402021CD
65676+:10F430008E220008AF620084AF6000400E0013020D
65677+:10F44000000000009362007D024020213442002031
65678+:10F450000E00130BA362007D0E000CA902402021B8
65679+:10F46000240400382405008D0A0014B82406001274
65680+:10F470009362003E304200081040000F8FA200103F
65681+:10F4800030420100104000078FA300148F6200601B
65682+:10F490000062102304430008AF6300600A001441B7
65683+:10F4A00000000000AF6000609362003E2403FFF79D
65684+:10F4B00000431024A362003E9362003E30420008E5
65685+:10F4C000144000022406000300003021936200343F
65686+:10F4D000936300378F640084304200FF306300FF85
65687+:10F4E00000661821000318800043282100A4202B67
65688+:10F4F0001080000B000000009763003C8F620084C6
65689+:10F500003063FFFF004510230062182B14600004D5
65690+:10F51000000000008F6200840A00145D0045802313
65691+:10F520009762003C3050FFFF8FA300103062000450
65692+:10F5300010400004000628808FA2001C0A001465F9
65693+:10F540000202102B2E02021850400003240202185F
65694+:10F550000A00146E020510233063000410600003DB
65695+:10F56000004510238FA2001C00451023004080217D
65696+:10F570002C42008054400001241000800E00130231
65697+:10F580000240202124020001AF62000C9362003E81
65698+:10F59000001020403042007FA362003E8E22000413
65699+:10F5A00024420001AF620040A770003C8F6200500F
65700+:10F5B0009623000E00431021AF6200588F62005066
65701+:10F5C00000441021AF62005C8E220004AF6200187C
65702+:10F5D0008E220008AF62001C8FA20010304200088B
65703+:10F5E0005440000A93A20020A360003693620036C4
65704+:10F5F0002403FFDFA36200359362003E0043102422
65705+:10F60000A362003E0A0014988E220008A36200350F
65706+:10F610008E220008AF62004C8F6200248F6300408E
65707+:10F6200000431021AF6200489362000024030050A1
65708+:10F63000304200FF144300122403FF803C02080004
65709+:10F640008C4231A00242102100431024AF42002816
65710+:10F650003C0208008C4231A08E2400083C03000CC0
65711+:10F66000024210213042007F03421021004310214A
65712+:10F67000AC4400D88E230008AF820014AC4300DCF9
65713+:10F680000E00130B02402021240400380000282122
65714+:10F690002406000A0E0013C9000000002404000123
65715+:10F6A0008FBF00348FB200308FB1002C8FB0002894
65716+:10F6B0000080102103E0000827BD003827BDFFF8B7
65717+:10F6C00027420180AFA20000308A00FF8F4201B8BC
65718+:10F6D0000440FFFE000000008F4601283C020800A5
65719+:10F6E0008C4231A02403FF80AF86004800C2102165
65720+:10F6F00000431024AF4200243C0208008C4231A099
65721+:10F700008FA900008FA8000000C210213042007FA6
65722+:10F71000034218213C02000A00621821946400D4BC
65723+:10F720008FA700008FA5000024020002AF83001401
65724+:10F73000A0A2000B8FA30000354260003084FFFFC1
65725+:10F74000A4E200083C021000AD260000AD04000455
65726+:10F75000AC60002427BD0008AF4201B803E00008F8
65727+:10F76000240200018F88003C938200288F830014BC
65728+:10F770003C07080024E7779800481023304200FF38
65729+:10F78000304900FC246500888F860040304A000321
65730+:10F790001120000900002021248200048CA3000015
65731+:10F7A000304400FF0089102AACE3000024A50004C7
65732+:10F7B0001440FFF924E70004114000090000202153
65733+:10F7C0002482000190A30000304400FF008A102B27
65734+:10F7D000A0E3000024A500011440FFF924E7000184
65735+:10F7E00030C20003144000048F85003C3102000346
65736+:10F7F0001040000D0000000010A0000900002021B2
65737+:10F800002482000190C30000304400FF0085102BCB
65738+:10F81000A0E3000024C600011440FFF924E7000122
65739+:10F8200003E00008000000001100FFFD000020219F
65740+:10F83000248200048CC30000304400FF0088102B99
65741+:10F84000ACE3000024C600041440FFF924E70004E0
65742+:10F8500003E00008000000008F83003C9382002832
65743+:10F8600030C600FF30A500FF00431023304300FFE7
65744+:10F870008F820014008038210043102114C0000240
65745+:10F88000244800880083382130E20003144000053A
65746+:10F8900030A2000314400003306200031040000D4A
65747+:10F8A0000000000010A000090000202124820001B7
65748+:10F8B00090E30000304400FF0085102BA1030000FE
65749+:10F8C00024E700011440FFF92508000103E00008C7
65750+:10F8D0000000000010A0FFFD000020212482000491
65751+:10F8E0008CE30000304400FF0085102BAD030000C6
65752+:10F8F00024E700041440FFF92508000403E0000891
65753+:10F90000000000000080482130AAFFFF30C600FF41
65754+:10F9100030E7FFFF274801808F4201B80440FFFE17
65755+:10F920008F820048AD0200008F420124AD02000426
65756+:10F930008D220020A5070008A102000A240200165B
65757+:10F94000A102000B934301208D2200088D240004A6
65758+:10F95000306300FF004310219783003A00441021D8
65759+:10F960008D250024004310233C0308008C6331A044
65760+:10F970008F840014A502000C246300E82402FFFF1A
65761+:10F98000A50A000EA5030010A5060012AD0500187B
65762+:10F99000AD020024948201142403FFF73042FFFFDC
65763+:10F9A000AD0200288C820118AD02002C3C02100030
65764+:10F9B000AD000030AF4201B88D220020004310247A
65765+:10F9C00003E00008AD2200208F82001430E7FFFF23
65766+:10F9D00000804821904200D330A5FFFF30C600FFD1
65767+:10F9E0000002110030420F0000E238252748018054
65768+:10F9F0008F4201B80440FFFE8F820048AD02000034
65769+:10FA00008F420124AD0200048D220020A5070008CA
65770+:10FA1000A102000A24020017A102000B9343012057
65771+:10FA20008D2200088D240004306300FF0043102164
65772+:10FA30009783003A004410218F8400140043102360
65773+:10FA40003C0308008C6331A0A502000CA505000E44
65774+:10FA5000246300E8A5030010A5060012AD00001401
65775+:10FA60008D220024AD0200188C82005CAD02001CC7
65776+:10FA70008C820058AD0200202402FFFFAD0200245A
65777+:10FA8000948200E63042FFFFAD02002894820060BD
65778+:10FA9000948300BE30427FFF3063FFFF00021200FC
65779+:10FAA00000431021AD02002C3C021000AD000030DC
65780+:10FAB000AF4201B8948200BE2403FFF700A21021D8
65781+:10FAC000A48200BE8D2200200043102403E0000821
65782+:10FAD000AD220020274301808F4201B80440FFFE81
65783+:10FAE0008F8200249442001C3042FFFF000211C0AC
65784+:10FAF000AC62000024020019A062000B3C0210005E
65785+:10FB0000AC60003003E00008AF4201B88F87002CE2
65786+:10FB100030C300FF8F4201B80440FFFE8F820048CF
65787+:10FB200034636000ACA2000093820044A0A20005F0
65788+:10FB30008CE20010A4A20006A4A300088C8200207E
65789+:10FB40002403FFF7A0A2000A24020002A0A2000BD7
65790+:10FB50008CE20000ACA200108CE20004ACA2001405
65791+:10FB60008CE2001CACA200248CE20020ACA2002895
65792+:10FB70008CE2002CACA2002C8C820024ACA20018D9
65793+:10FB80003C021000AF4201B88C82002000431024D8
65794+:10FB900003E00008AC8200208F86001427BDFFE838
65795+:10FBA000AFBF0014AFB0001090C20063304200201D
65796+:10FBB0001040000830A500FF8CC2007C2403FFDF4A
65797+:10FBC00024420001ACC2007C90C2006300431024B8
65798+:10FBD000A0C2006310A000238F830014275001806F
65799+:10FBE000020028210E0015D6240600828F82001400
65800+:10FBF000904200633042004050400019A38000440E
65801+:10FC00008F83002C8F4201B80440FFFE8F82004892
65802+:10FC1000AE02000024026082A60200082402000254
65803+:10FC2000A202000B8C620008AE0200108C62000C75
65804+:10FC3000AE0200148C620014AE0200188C62001830
65805+:10FC4000AE0200248C620024AE0200288C620028E0
65806+:10FC5000AE02002C3C021000AF4201B8A380004469
65807+:10FC60008F8300148FBF00148FB000109062006368
65808+:10FC700027BD00183042007FA06200639782003ADF
65809+:10FC80008F86003C8F850014938300280046102344
65810+:10FC9000A782003AA4A000E490A400638F820040F1
65811+:10FCA000AF83003C2403FFBF0046102100832024C3
65812+:10FCB000AF820040A0A400638F820014A04000BD6A
65813+:10FCC0008F82001403E00008A44000BE8F8A001455
65814+:10FCD00027BDFFE0AFB10014AFB000108F88003C2B
65815+:10FCE000AFBF00189389001C954200E430D100FF9B
65816+:10FCF0000109182B0080802130AC00FF3047FFFF46
65817+:10FD00000000582114600003310600FF012030215B
65818+:10FD1000010958239783003A0068102B1440003CD7
65819+:10FD20000000000014680007240200018E02002079
65820+:10FD30002403FFFB34E7800000431024AE020020C0
65821+:10FD40002402000134E70880158200053165FFFFB9
65822+:10FD50000E001554020020210A00169102002021F5
65823+:10FD60000E001585020020218F8400482743018062
65824+:10FD70008F4201B80440FFFE24020018AC6400006A
65825+:10FD8000A062000B8F840014948200E6A46200102D
65826+:10FD90003C021000AC600030AF4201B894820060B9
65827+:10FDA00024420001A4820060948200603C030800A9
65828+:10FDB0008C63318830427FFF5443000F02002021C2
65829+:10FDC000948200602403800000431024A482006019
65830+:10FDD0009082006090830060304200FF000211C2F8
65831+:10FDE00000021027000211C03063007F0062182556
65832+:10FDF000A083006002002021022028218FBF00186C
65833+:10FE00008FB100148FB000100A0015F927BD002033
65834+:10FE1000914200632403FF8000431025A142006348
65835+:10FE20009782003A3048FFFF110000209383001CA6
65836+:10FE30008F840014004B1023304600FF948300E4AD
65837+:10FE40002402EFFF0168282B00621824A48300E439
65838+:10FE500014A000038E020020010058210000302170
65839+:10FE60002403FFFB34E7800000431024AE0200208F
65840+:10FE700024020001158200053165FFFF0E001554B4
65841+:10FE8000020020210A0016B99783003A0E0015855A
65842+:10FE9000020020219783003A8F82003CA780003A1D
65843+:10FEA00000431023AF82003C9383001C8F82001418
65844+:10FEB0008FBF00188FB100148FB0001027BD002035
65845+:10FEC00003E00008A04300BD938200442403000126
65846+:10FED00027BDFFE8004330042C420020AFB00010E3
65847+:10FEE000AFBF00142410FFFE10400005274501801D
65848+:10FEF0003C0208008C4231900A0016D600461024BD
65849+:10FF00003C0208008C423194004610241440000743
65850+:10FF1000240600848F8300142410FFFF9062006287
65851+:10FF20003042000F34420040A06200620E0015D63D
65852+:10FF300000000000020010218FBF00148FB00010DD
65853+:10FF400003E0000827BD00188F83002427BDFFE0D1
65854+:10FF5000AFB20018AFB10014AFB00010AFBF001CBB
65855+:10FF60009062000D00A0902130D100FF3042007F50
65856+:10FF7000A062000D8F8500148E4300180080802140
65857+:10FF80008CA2007C146200052402000E90A2006383
65858+:10FF9000344200200A0016FFA0A200630E0016C51E
65859+:10FFA000A38200442403FFFF104300472404FFFF03
65860+:10FFB00052200045000020218E4300003C0200102A
65861+:10FFC00000621024504000043C020008020020217E
65862+:10FFD0000A00170E24020015006210245040000988
65863+:10FFE0008E45000002002021240200140E0016C5D8
65864+:10FFF000A38200442403FFFF104300332404FFFFC7
65865+:020000021000EC
65866+:100000008E4500003C02000200A2102410400016A1
65867+:100010003C0200048F8600248CC200148CC30010A4
65868+:100020008CC40014004310230044102B50400005E2
65869+:10003000020020218E43002C8CC2001010620003AD
65870+:10004000020020210A00173F240200123C02000493
65871+:1000500000A210245040001C00002021020020219A
65872+:100060000A00173F2402001300A2102410400006CB
65873+:100070008F8300248C620010504000130000202168
65874+:100080000A001739020020218C6200105040000441
65875+:100090008E42002C020020210A00173F240200118A
65876+:1000A00050400009000020210200202124020017F6
65877+:1000B0000E0016C5A38200442403FFFF1043000274
65878+:1000C0002404FFFF000020218FBF001C8FB2001806
65879+:1000D0008FB100148FB000100080102103E00008E1
65880+:1000E00027BD00208F83001427BDFFD8AFB40020A8
65881+:1000F000AFB3001CAFB20018AFB10014AFB0001026
65882+:10010000AFBF0024906200638F91002C2412FFFF88
65883+:100110003442004092250000A06200638E2200104D
65884+:100120000080982130B0003F105200060360A021EB
65885+:100130002402000D0E0016C5A38200441052005484
65886+:100140002404FFFF8F8300148E2200188C63007C30
65887+:1001500010430007026020212402000E0E0016C585
65888+:10016000A38200442403FFFF104300492404FFFF3F
65889+:1001700024040020120400048F83001490620063A2
65890+:1001800034420020A06200638F85003410A000205C
65891+:1001900000000000560400048F8200140260202139
65892+:1001A0000A0017902402000A9683000A9442006015
65893+:1001B0003042FFFF144300048F8200202404FFFD1F
65894+:1001C0000A0017B7AF82003C3C0208008C42318C19
65895+:1001D0000045102B14400006026020210000282159
65896+:1001E0000E001646240600010A0017B70000202161
65897+:1001F0002402002D0E0016C5A38200442403FFFF35
65898+:10020000104300232404FFFF0A0017B70000202139
65899+:10021000160400058F8400148E2300142402FFFFAF
65900+:100220005062001802602021948200602442000184
65901+:10023000A4820060948200603C0308008C633188D3
65902+:1002400030427FFF5443000F0260202194820060FF
65903+:100250002403800000431024A48200609082006088
65904+:1002600090830060304200FF000211C2000210279C
65905+:10027000000211C03063007F00621825A083006077
65906+:10028000026020210E0015F9240500010000202144
65907+:100290008FBF00248FB400208FB3001C8FB20018D2
65908+:1002A0008FB100148FB000100080102103E000080F
65909+:1002B00027BD00288F83001427BDFFE8AFB00010D2
65910+:1002C000AFBF0014906200638F87002C00808021F4
65911+:1002D000344200408CE60010A06200633C0308003A
65912+:1002E0008C6331B030C23FFF0043102B1040004EF2
65913+:1002F0008F8500302402FF8090A3000D004310245E
65914+:10030000304200FF504000490200202100061382C5
65915+:10031000304800032402000255020044020020215C
65916+:1003200094A2001C8F85001424030023A4A20114AE
65917+:100330008CE60000000616023042003F1043001019
65918+:100340003C0300838CE300188CA2007C1062000642
65919+:100350002402000E0E0016C5A38200442403FFFFF2
65920+:10036000104300382404FFFF8F8300149062006361
65921+:1003700034420020A06200630A0017FC8F8300242F
65922+:1003800000C31024144300078F83002490A200624E
65923+:100390003042000F34420020A0A20062A38800383F
65924+:1003A0008F8300249062000D3042007FA062000D18
65925+:1003B0008F83003410600018020020218F840030E9
65926+:1003C0008C8200100043102B1040000924020018FA
65927+:1003D000020020210E0016C5A38200442403FFFF63
65928+:1003E000104300182404FFFF0A00182400002021F5
65929+:1003F0008C820010240500010200202100431023FC
65930+:100400008F830024240600010E001646AC62001003
65931+:100410000A001824000020210E0015F9240500010F
65932+:100420000A00182400002021020020212402000DCF
65933+:100430008FBF00148FB0001027BD00180A0016C52A
65934+:10044000A38200448FBF00148FB0001000801021E1
65935+:1004500003E0000827BD001827BDFFC8AFB2002089
65936+:10046000AFBF0034AFB60030AFB5002CAFB400283A
65937+:10047000AFB30024AFB1001CAFB000188F46012805
65938+:100480003C0308008C6331A02402FF80AF86004843
65939+:1004900000C318213065007F03452821006218241D
65940+:1004A0003C02000AAF43002400A2282190A200626F
65941+:1004B00000809021AF850014304200FF000211023D
65942+:1004C000A382003890A200BC304200021440000217
65943+:1004D00024030034240300308F820014A3830028F7
65944+:1004E000938300388C4200C0A3800044AF82003C5C
65945+:1004F000240200041062031C8F84003C8E4400041C
65946+:10050000508003198F84003C8E4200103083FFFF1F
65947+:10051000A784003A106002FFAF8200408F8400146D
65948+:100520002403FF809082006300621024304200FFA9
65949+:10053000144002CF9785003A9383003824020002CA
65950+:1005400030B6FFFF14620005000088219382002866
65951+:100550002403FFFD0A001B19AF82003C8F82003C80
65952+:1005600002C2102B144002A18F8400400E0014EC34
65953+:1005700000000000938300283C040800248477983E
65954+:10058000240200341462002EAF84002C3C0A0800C0
65955+:100590008D4A77C82402FFFFAFA2001000803821E7
65956+:1005A0002405002F3C09080025297398240800FF22
65957+:1005B0002406FFFF90E2000024A3FFFF00062202B2
65958+:1005C00000C21026304200FF0002108000491021B6
65959+:1005D0008C420000306500FF24E7000114A8FFF5FD
65960+:1005E0000082302600061027AFA20014AFA2001030
65961+:1005F0000000282127A7001027A6001400C51023FB
65962+:100600009044000324A2000100A71821304500FFF8
65963+:100610002CA200041440FFF9A06400008FA2001077
65964+:100620001142000724020005024020210E0016C5D9
65965+:10063000A38200442403FFFF104300642404FFFF4F
65966+:100640003C0208009042779C104000098F82001401
65967+:10065000024020212402000C0E0016C5A382004493
65968+:100660002403FFFF104300592404FFFF8F8200146E
65969+:10067000A380001C3C0308008C63779C8C440080A2
65970+:100680003C0200FF3442FFFF006218240083202B4D
65971+:1006900010800008AF83003402402021240200199A
65972+:1006A0000E0016C5A38200442403FFFF1043004739
65973+:1006B0002404FFFF8F87003C9782003A8F85003427
65974+:1006C000AF8700200047202310A0003BA784003AFA
65975+:1006D0008F86001430A200030002102390C300BCD8
65976+:1006E0003050000300B0282100031882307300014D
65977+:1006F0000013108000A228213C0308008C6331A065
65978+:100700008F8200483084FFFF0085202B004310219A
65979+:1007100010800011244200888F84002C1082000E6B
65980+:100720003C033F013C0208008C42779800431024B0
65981+:100730003C0325001443000630E500FF8C820000D6
65982+:10074000ACC200888C8200100A0018E9ACC2009884
65983+:100750000E001529000030219382001C8F850014A3
65984+:100760008F830040020238218F82003CA387001C47
65985+:1007700094A400E4006218218F82003434841000B5
65986+:10078000AF83004000503021A4A400E41260000EAA
65987+:10079000AF86003C24E20004A382001C94A200E483
65988+:1007A00024C30004AF83003C34422000A4A200E430
65989+:1007B0000A001906000020218F820040AF80003C13
65990+:1007C00000471021AF820040000020212414FFFFC9
65991+:1007D000109402112403FFFF3C0808008D0877A83D
65992+:1007E0003C0208008C4231B03C03080090637798CB
65993+:1007F00031043FFF0082102B1040001B3067003F88
65994+:100800003C0208008C4231A88F83004800042180FC
65995+:1008100000621821006418213062007F0342282101
65996+:100820003C02000C00A228213C020080344200015E
65997+:100830003066007800C230252402FF800062102458
65998+:10084000AF42002830640007AF4208048F820014D2
65999+:100850000344202124840940AF460814AF850024B6
66000+:10086000AF840030AC4301189383003824020003A6
66001+:10087000146201CF240200012402002610E201D1FB
66002+:1008800028E2002710400013240200322402002234
66003+:1008900010E201CC28E200231040000824020024CA
66004+:1008A0002402002010E201B82402002110E20147D6
66005+:1008B000024020210A001AFB2402000B10E201C1B1
66006+:1008C0002402002510E20010024020210A001AFB39
66007+:1008D0002402000B10E201AE28E2003310400006B3
66008+:1008E0002402003F2402003110E2009A024020213D
66009+:1008F0000A001AFB2402000B10E201A5024020218D
66010+:100900000A001AFB2402000B8F90002C3C03080005
66011+:100910008C6331B08F8500308E0400100000A82158
66012+:100920008CB3001430823FFF0043102B8CB10020A9
66013+:100930005040018F0240202190A3000D2402FF802F
66014+:1009400000431024304200FF504001890240202122
66015+:10095000000413823042000314400185024020212C
66016+:1009600094A3001C8F8200148E040028A443011459
66017+:100970008CA20010026218231064000302402021A0
66018+:100980000A00197C2402001F8F82003400621021AB
66019+:100990000262102B104000088F83002402402021A7
66020+:1009A000240200180E0016C5A382004410540174DE
66021+:1009B0002404FFFF8F8300248F8400348C62001096
66022+:1009C0000224882100441023AC6200108F8200149E
66023+:1009D000AC7100208C4200680051102B10400009BF
66024+:1009E0008F830030024020212402001D0E0016C516
66025+:1009F000A38200442403FFFF104301612404FFFF8E
66026+:100A00008F8300308E0200248C6300241043000783
66027+:100A1000024020212402001C0E0016C5A3820044BF
66028+:100A20002403FFFF104301562404FFFF8F8400249A
66029+:100A30008C82002424420001AC8200241233000482
66030+:100A40008F8200148C4200685622000E8E02000035
66031+:100A50008E0200003C030080004310241440000D6F
66032+:100A60002402001A024020210E0016C5A382004471
66033+:100A70002403FFFF104301422404FFFF0A0019BAB8
66034+:100A80008E0200143C0300800043102450400003F9
66035+:100A90008E020014AC8000208E0200142411FFFF8F
66036+:100AA0001051000E3C0308003C0208008C423190BB
66037+:100AB000004310242403001B14400007A3830044B8
66038+:100AC0000E0016C5024020211051012D2404FFFF05
66039+:100AD0000A0019CB8E030000A38000448E0300009F
66040+:100AE0003C02000100621024104000123C02008011
66041+:100AF0000062102414400008024020212402001A41
66042+:100B00000E0016C5A38200442403FFFF1043011CFE
66043+:100B10002404FFFF02402021020028210E0016E5D8
66044+:100B2000240600012403FFFF104301152404FFFFE6
66045+:100B3000241500018F83002402A0302102402021CF
66046+:100B40009462003624050001244200010A001ADFE5
66047+:100B5000A46200368F90002C3C0308008C6331B0F7
66048+:100B60008E13001032623FFF0043102B10400089AB
66049+:100B70008F8400302402FF809083000D00431024F6
66050+:100B8000304200FF104000842402000D0013138245
66051+:100B900030420003240300011443007F2402000DAF
66052+:100BA0009082000D30420008544000048F820034CF
66053+:100BB000024020210A001A102402002450400004A0
66054+:100BC0008E03000C024020210A001A102402002784
66055+:100BD0008C82002054620006024020218E0300080F
66056+:100BE0008C820024506200098E02001402402021F1
66057+:100BF000240200200E0016C5A38200441054007188
66058+:100C00002403FFFF0A001A458F8400242411FFFFEC
66059+:100C1000145100048F860014024020210A001A405B
66060+:100C2000240200258E0300188CC2007C1062000391
66061+:100C30002402000E0A001A40024020218E030024E4
66062+:100C40008C82002810620003240200210A001A404E
66063+:100C5000024020218E0500288C82002C10A2000367
66064+:100C60002402001F0A001A40024020218E03002C9B
66065+:100C700014600003240200230A001A4002402021CD
66066+:100C80008CC200680043102B104000032402002691
66067+:100C90000A001A40024020218C82001400651821AD
66068+:100CA0000043102B104000088F84002402402021B4
66069+:100CB000240200220E0016C5A382004410510041F8
66070+:100CC0002403FFFF8F8400242403FFF79082000D8C
66071+:100CD00000431024A082000D8F8600143C030800FE
66072+:100CE0008C6331AC8F82004894C400E08F8500246F
66073+:100CF0000043102130847FFF000420400044102175
66074+:100D00003043007F034320213C03000E0083202159
66075+:100D10002403FF8000431024AF42002CA493000062
66076+:100D20008CA2002824420001ACA200288CA2002C36
66077+:100D30008E03002C00431021ACA2002C8E02002C4C
66078+:100D4000ACA200308E020014ACA2003494A2003A8F
66079+:100D500024420001A4A2003A94C600E03C0208002C
66080+:100D60008C4231B024C4000130837FFF1462000F35
66081+:100D700000803021240280000082302430C2FFFF36
66082+:100D8000000213C2304200FF000210270A001A7E40
66083+:100D9000000233C02402000D024020210E0016C5BF
66084+:100DA000A38200440A001A84004018218F82001494
66085+:100DB00002402021240500010E0015F9A44600E0A0
66086+:100DC000000018210A001B16006088218F90002C5B
66087+:100DD0003C0308008C6331B08E05001030A23FFF49
66088+:100DE0000043102B104000612402FF808F840030EC
66089+:100DF0009083000D00431024304200FF5040005CFF
66090+:100E0000024020218F8200341040000B0005138225
66091+:100E10008F8200149763000A944200603042FFFF03
66092+:100E200014430005000513828F8200202404FFFD77
66093+:100E30000A001AF3AF82003C304200031440000E57
66094+:100E40000000000092020002104000058E03002402
66095+:100E500050600015920300030A001AAF02402021DF
66096+:100E60008C82002450620010920300030240202173
66097+:100E70000A001AB72402000F9082000D30420008C9
66098+:100E80005440000992030003024020212402001074
66099+:100E90000E0016C5A38200442403FFFF1043003850
66100+:100EA0002404FFFF92030003240200025462000C9A
66101+:100EB000920200038F820034544000099202000322
66102+:100EC000024020212402002C0E0016C5A3820044FB
66103+:100ED0002403FFFF1043002A2404FFFF92020003B3
66104+:100EE0000200282102402021384600102CC60001B3
66105+:100EF0002C4200010E0016E5004630252410FFFFAD
66106+:100F00001050001F2404FFFF8F8300341060001373
66107+:100F1000024020213C0208008C42318C0043102BFF
66108+:100F200014400007000000000000282124060001F2
66109+:100F30000E001646000000000A001AF300002021EF
66110+:100F40002402002D0E0016C5A38200441050000C90
66111+:100F50002404FFFF0A001AF3000020210E0015F9F7
66112+:100F6000240500010A001AF300002021024020217C
66113+:100F70002402000D0E0016C5A3820044004020216B
66114+:100F80000A001B16008088211514000E00000000C6
66115+:100F90000E00174C024020210A001B160040882139
66116+:100FA0000E0016C5A38200440A001B1600408821CB
66117+:100FB00014620017022018212402002314E2000505
66118+:100FC0002402000B0E0017C0024020210A001B164D
66119+:100FD0000040882102402021A38200440E0016C553
66120+:100FE0002411FFFF0A001B170220182130A500FF63
66121+:100FF0000E001529240600019783003A8F82003CD9
66122+:10100000A780003A00431023AF82003C0220182141
66123+:101010001220003E9782003A2402FFFD5462003EF7
66124+:101020008E4300208E4200048F830014005610234C
66125+:10103000AE420004906200633042007FA062006311
66126+:101040008E4200208F840014A780003A34420002B0
66127+:10105000AE420020A48000E4908200632403FFBF1E
66128+:1010600000431024A08200630A001B598E43002015
66129+:101070009082006300621024304200FF1040002381
66130+:101080009782003A90820088908300BD2485008872
66131+:101090003042003F2444FFE02C820020A383001C48
66132+:1010A00010400019AF85002C2402000100821804B2
66133+:1010B000306200191440000C3C02800034420002EF
66134+:1010C000006210241440000B306200201040000F1A
66135+:1010D0009782003A90A600010240202124050001D9
66136+:1010E0000A001B5330C60001024020210A001B5297
66137+:1010F00024050001024020210000282124060001CF
66138+:101100000E001646000000009782003A1440FD04CD
66139+:101110008F8400148E4300203062000410400012BF
66140+:101120008F84003C2402FFFB00621024AE420020AA
66141+:10113000274301808F4201B80440FFFE8F820048A0
66142+:10114000AC6200008F420124AC6200042402608380
66143+:10115000A462000824020002A062000B3C021000FE
66144+:10116000AF4201B88F84003C8F8300148FBF0034DE
66145+:101170008FB600308FB5002C8FB400288FB30024B9
66146+:101180008FB200208FB1001C8FB000182402000124
66147+:1011900027BD003803E00008AC6400C030A500FFA4
66148+:1011A0002403000124A900010069102B1040000C49
66149+:1011B00000004021240A000100A31023004A380443
66150+:1011C00024630001308200010069302B10400002CE
66151+:1011D000000420420107402554C0FFF800A310235B
66152+:1011E00003E00008010010213C020800244260A432
66153+:1011F0003C010800AC22738C3C02080024425308D6
66154+:101200003C010800AC2273902402000627BDFFE0D9
66155+:101210003C010800A02273943C021EDCAFB200180F
66156+:10122000AFB10014AFBF001CAFB0001034526F411B
66157+:1012300000008821240500080E001B7A02202021CE
66158+:10124000001180803C07080024E773980002160014
66159+:1012500002071821AC6200000000282124A200012E
66160+:101260003045FFFF8C6200002CA6000804410002FC
66161+:10127000000220400092202614C0FFF8AC64000059
66162+:10128000020780218E0400000E001B7A2405002036
66163+:10129000262300013071FFFF2E2301001460FFE5BB
66164+:1012A000AE0200008FBF001C8FB200188FB1001477
66165+:1012B0008FB0001003E0000827BD002027BDFFD835
66166+:1012C000AFB3001CAFB20018AFBF0020AFB1001425
66167+:1012D000AFB000108F5101408F48014800089402C0
66168+:1012E000324300FF311300FF8F4201B80440FFFE7C
66169+:1012F00027500180AE1100008F420144AE0200046D
66170+:1013000024020002A6120008A202000B240200140C
66171+:10131000AE1300241062002528620015104000085A
66172+:101320002402001524020010106200302402001272
66173+:10133000106200098FBF00200A001CB58FB3001C8B
66174+:101340001062007024020022106200378FBF00205C
66175+:101350000A001CB58FB3001C3C0208008C4231A06F
66176+:101360002403FF800222102100431024AF420024F6
66177+:101370003C0208008C4231A0022210213042007F42
66178+:10138000034218213C02000A00621821166000BCCA
66179+:10139000AF830014906200623042000F344200308C
66180+:1013A000A06200620A001CB48FBF00203C046000F1
66181+:1013B0008C832C083C02F0033442FFFF00621824A7
66182+:1013C000AC832C083C0208008C4231A08C832C0892
66183+:1013D000244200740002108200021480006218256A
66184+:1013E000AC832C080A001CB48FBF00203C0208000C
66185+:1013F0008C4231A02403FF800222102100431024DC
66186+:10140000AF4200243C0208008C4231A03C03000A99
66187+:10141000022210213042007F03421021004310219C
66188+:101420000A001CB3AF8200143C0208008C4231A0B9
66189+:101430002405FF800222102100451024AF42002421
66190+:101440003C0208008C4231A0022210213042007F71
66191+:10145000034218213C02000A0062182190620063D6
66192+:1014600000A21024304200FF10400085AF8300141A
66193+:1014700024620088944300123C0208008C4231A888
66194+:1014800030633FFF00031980022210210043102126
66195+:101490003043007F03432021004510243C03000C0F
66196+:1014A00000832021AF4200289082000D00A210246A
66197+:1014B000304200FF10400072AF8400249082000D83
66198+:1014C000304200101440006F8FBF00200E0015C87E
66199+:1014D000000000008F4201B80440FFFE0000000041
66200+:1014E000AE1100008F420144AE020004240200024B
66201+:1014F000A6120008A202000BAE1300240A001CB4BE
66202+:101500008FBF00202406FF8002261024AF42002057
66203+:101510003C0208008C4231A031043FFF00042180CE
66204+:101520000222102100461024AF4200243C03080090
66205+:101530008C6331A83C0208008C4231A03227007F26
66206+:101540000223182102221021006418213042007F5A
66207+:101550003064007F034228213C02000A0066182400
66208+:1015600000A22821034420213C02000C00822021FB
66209+:10157000AF4300283C020008034718210062902175
66210+:10158000AF850014AF8400240E0015C8010080212F
66211+:101590008F4201B80440FFFE8F8200248F84001424
66212+:1015A000274501809042000DACB10000A4B00006B8
66213+:1015B000000216000002160300021027000237C2C4
66214+:1015C00014C00016248200889442001232033FFFA8
66215+:1015D00030423FFF14430012240260829083006374
66216+:1015E0002402FF8000431024304200FF5040000CD2
66217+:1015F00024026082908200623042000F3442004038
66218+:10160000A082006224026084A4A200082402000DCB
66219+:10161000A0A200050A001C9E3C0227002402608252
66220+:10162000A4A20008A0A000053C02270000061C00A0
66221+:101630000062182524020002A0A2000BACA3001037
66222+:10164000ACA00014ACA00024ACA00028ACA0002CDE
66223+:101650008E42004C8F840024ACA200189083000DB1
66224+:101660002402FF8000431024304200FF1040000598
66225+:101670008FBF00209082000D3042007FA082000DBD
66226+:101680008FBF00208FB3001C8FB200188FB10014E1
66227+:101690008FB000103C02100027BD002803E00008B6
66228+:1016A000AF4201B80800343008003430080033A8D5
66229+:1016B000080033E0080034140800343808003438D7
66230+:1016C00008003438080033180A0001240000000024
66231+:1016D000000000000000000D747061362E322E33C1
66232+:1016E00000000000060203010000000000000000EE
66233+:1016F00000000000000000000000000000000000EA
66234+:1017000000000000000000000000000000000000D9
66235+:1017100000000000000000000000000000000000C9
66236+:1017200000000000000000000000000000000000B9
66237+:1017300000000000000000000000000000000000A9
66238+:101740000000000000000000000000000000000099
66239+:101750000000000000000000000000001000000376
66240+:10176000000000000000000D0000000D3C02080019
66241+:1017700024421C003C03080024632094AC40000079
66242+:101780000043202B1480FFFD244200043C1D080070
66243+:1017900037BD2FFC03A0F0213C1008002610049058
66244+:1017A0003C1C0800279C1C000E00015C000000008F
66245+:1017B0000000000D3084FFFF308200078F85001885
66246+:1017C00010400002248300073064FFF800853021B8
66247+:1017D00030C41FFF03441821247B4000AF85001C48
66248+:1017E000AF84001803E00008AF4400843084FFFF9A
66249+:1017F000308200078F8500208F860028104000026D
66250+:10180000248300073064FFF8008520210086182B10
66251+:1018100014600002AF8500240086202303442821A1
66252+:1018200034068000AF840020AF44008000A6202151
66253+:1018300003E00008AF84003827BDFFD8AFB3001C19
66254+:10184000AFB20018AFB00010AFBF0024AFB400209B
66255+:10185000AFB100143C0860088D1450002418FF7FBD
66256+:101860003C1A8000029898243672380CAD12500051
66257+:101870008F5100083C07601C3C08600036300001B6
66258+:10188000AF500008AF800018AF400080AF40008428
66259+:101890008CE600088D0F08083C0760168CEC0000F1
66260+:1018A00031EEFFF039CA00103C0DFFFF340B800011
66261+:1018B0003C030080034B48212D440001018D282466
66262+:1018C0003C0253533C010800AC230420AF8900388C
66263+:1018D000AF860028AF840010275B400014A20003ED
66264+:1018E00034E37C008CF90004032818218C7F007CF1
66265+:1018F0008C6500783C0280003C0B08008D6B048CEA
66266+:101900003C0A08008D4A048834520070AF85003CC0
66267+:10191000AF9F00403C13080026731C440240A021E6
66268+:101920008E4800008F46000038C30001306400017B
66269+:1019300010800017AF880034028048218D2F0000EE
66270+:101940003C0508008CA5045C3C1808008F1804585E
66271+:1019500001E8102300A280210000C8210202402BD0
66272+:1019600003198821022838213C010800AC30045CAE
66273+:101970003C010800AC2704588F4E000039CD00010F
66274+:1019800031AC00011580FFED01E04021AF8F003444
66275+:101990008E5100003C0708008CE7045C3C0D0800F9
66276+:1019A0008DAD04580228802300F0602100007021D2
66277+:1019B0000190302B01AE1821006620213C01080067
66278+:1019C000AC2C045C3C010800AC2404588F46010890
66279+:1019D0008F47010030C92000AF860000AF87000CA0
66280+:1019E0001120000A00C040213C1808008F18042C68
66281+:1019F000270800013C010800AC28042C3C184000DA
66282+:101A0000AF5801380A000196000000009749010410
66283+:101A100000002821014550213122FFFF0162582199
66284+:101A20000162F82B015F502130D902003C0108000F
66285+:101A3000AC2B048C3C010800AC2A0488172000154C
66286+:101A400024040F0010E400130000000024080D001F
66287+:101A500010E8023B30CD000611A0FFE93C18400021
66288+:101A6000936E00002409001031C400F01089027147
66289+:101A700024020070108202E58F880014250F0001F7
66290+:101A8000AF8F00143C184000AF5801380A0001968F
66291+:101A900000000000974C01041180FFD93C18400061
66292+:101AA00030C34000146000A1000000008F460178A0
66293+:101AB00004C0FFFE8F87003824100800240F0008A0
66294+:101AC0008CE30008AF500178A74F0140A7400142C6
66295+:101AD000974E01048F86000031C9FFFF30CD000111
66296+:101AE00011A002E1012040212531FFFE241800024F
66297+:101AF000A75801463228FFFFA75101483C190800AA
66298+:101B00008F39043C172002D08F8C000C30DF00206E
66299+:101B100017E00002240400092404000130C20C0074
66300+:101B2000240504005045000134840004A744014A00
66301+:101B30003C1108008E3104203C1800483C10000184
66302+:101B40000238182530CF00020070282511E000046B
66303+:101B5000000018213C19010000B9282524030001C8
66304+:101B600030DF000453E00005AF8300083C0600109E
66305+:101B700000A6282524030001AF830008AF4510000C
66306+:101B80000000000000000000000000000000000055
66307+:101B90008F83000810600023000000008F451000B4
66308+:101BA00004A1FFFE000000001060001E0000000005
66309+:101BB0008F4410003C0C0020008C102410400019B1
66310+:101BC0008F8E000031CD000211A000160000000031
66311+:101BD000974F101415E000130000000097591008EB
66312+:101BE0003338FFFF271100060011188200033080F0
66313+:101BF00000C7282132300001322300031200032CD9
66314+:101C00008CA200000000000D00C7F821AFE2000028
66315+:101C10003C0508008CA5043024A600013C01080006
66316+:101C2000AC2604308F6D00003402FFFFAF8D00043E
66317+:101C30008CEC0000118202A6000020218CED000037
66318+:101C400031AC01001180028A000000003C02080053
66319+:101C50008C4204743C0308008C63044C3C1F080055
66320+:101C60008FFF04703C1808008F1804480048382182
66321+:101C70000068802100E8282B03E430210208402B73
66322+:101C80000304882100C57021022878213C01080046
66323+:101C9000AC30044C3C010800AC2F04483C01080067
66324+:101CA000AC2704743C010800AC2E04708F8400182B
66325+:101CB0000120302131290007249F000833F91FFF3C
66326+:101CC00003594021AF84001CAF990018251B400028
66327+:101CD000AF590084112000038F83002024C2000725
66328+:101CE0003046FFF88F84002800C3282100A4302B41
66329+:101CF00014C00002AF83002400A428230345602100
66330+:101D0000340D8000018D10213C0F1000AF850020A4
66331+:101D1000AF820038AF450080AF4F01788F88001444
66332+:101D2000250F00010A0001EFAF8F00148F62000839
66333+:101D30008F670000240500300007760231C300F0F1
66334+:101D4000106500A7240F0040546FFF4C8F880014CB
66335+:101D50008F4B01780560FFFE0000000030CA0200D2
66336+:101D600015400003000612820000000D00061282DA
66337+:101D7000304D0003000D4900012D18210003808023
66338+:101D8000020D402100086080019380218E1F000019
66339+:101D900017E00002000000000000000D8F6E00043C
66340+:101DA00005C202BD92070006920E000592020004D1
66341+:101DB0003C090001000E18800070F8218FED00181A
66342+:101DC000277100082448000501A96021000830821D
66343+:101DD000AFEC0018022020210E00059E26050014FD
66344+:101DE000920A00068F7900043C0B7FFF000A2080D6
66345+:101DF000009178218DF800043566FFFF0326282422
66346+:101E000003053821ADE70004920E0005920D000491
66347+:101E1000960C0008000E10800051C8218F2300008E
66348+:101E2000974901043C07FFFF006758243128FFFF52
66349+:101E3000010DF82103EC50233144FFFF01643025EC
66350+:101E4000AF260000920300072418000110780275E5
66351+:101E5000240F0003106F0285000000008E050010A3
66352+:101E60002419000AA7590140A7450142921800040D
66353+:101E70008F860000240F0001A7580144A7400146A7
66354+:101E80009747010430D100023C050041A7470148B3
66355+:101E900000001821A74F014A1220000330CB000494
66356+:101EA0003C0501412403000151600005AF83000897
66357+:101EB0003C06001000A6282524030001AF8300087B
66358+:101EC000AF4510000000000000000000000000000E
66359+:101ED000000000008F8A000811400004000000008C
66360+:101EE0008F4410000481FFFE000000008F6B000093
66361+:101EF000920800043C1108008E310444AF8B0004AA
66362+:101F000097590104311800FF3C0E08008DCE0440A3
66363+:101F10003325FFFF0305382102276021000010212F
66364+:101F2000250F000A31E8FFFF0187482B01C2682115
66365+:101F300001A9F821311000073C010800AC2C044431
66366+:101F40003C010800AC3F0440120000038F8C0018D5
66367+:101F50002506000730C8FFF8010C682131BF1FFFBC
66368+:101F6000AF8C001CAF9F0018AF5F00849744010442
66369+:101F7000035F80213084FFFF308A00071140000397
66370+:101F8000261B4000248900073124FFF88F8200209F
66371+:101F90008F850028008220210085702B15C000024B
66372+:101FA000AF820024008520233C0B08008D6B048C3D
66373+:101FB0003C0A08008D4A04880344882134038000C9
66374+:101FC000022310213C0F1000AF840020AF820038A4
66375+:101FD000AF440080AF4F01780A0002968F8800144A
66376+:101FE0008F5001780600FFFE30D10200162000035A
66377+:101FF000000612820000000D00061282305F00030E
66378+:10200000001F1900007F302100062080009FC8219A
66379+:1020100000194880013380218E180000130000024F
66380+:10202000000000000000000D8F6C000C058001FB1B
66381+:102030008F870038240E0001AE0E00008CE30008EC
66382+:10204000A20000078F65000400055402314D00FF17
66383+:1020500025A80005000830822CCB00411560000245
66384+:10206000A20A00040000000D8F7800043C03FFFF6B
66385+:1020700000E02821330BFFFF256C000B000C1082C1
66386+:1020800000022080008748218D3F000026040014B4
66387+:10209000A618000803E3C8240E00059EAD39000011
66388+:1020A0008F4F01083C11100001F1382410E001AB02
66389+:1020B00000000000974D01049208000725AAFFECDC
66390+:1020C000350600023144FFFFA2060007960600080D
66391+:1020D0002CC7001354E0000592030007921100077B
66392+:1020E000362F0001A20F00079203000724180001F9
66393+:1020F000107801C224090003106901D58F880038C7
66394+:1021000030CBFFFF257100020011788331E400FF1E
66395+:1021100000042880A20F000500A848218D2D000092
66396+:10212000974A01043C0EFFFF01AEF8243143FFFF44
66397+:10213000006B1023244CFFFE03ECC825AD390000D2
66398+:10214000920600053C03FFF63462FFFF30D800FF23
66399+:102150000018388000F08821922F00143C04FF7F83
66400+:102160003487FFFF31EE000F01C65821316500FFB3
66401+:1021700000055080015068218DAC00200148F821F5
66402+:10218000A20B00060182C824AE0C000CAFF9000CB3
66403+:10219000920900068E11000C032778240009C080E4
66404+:1021A0000310702195C60026030828210227202449
66405+:1021B000AE04000CADCF0020ADC60024ACA60010CC
66406+:1021C0008F8800003C0B08008D6B048C3C0A0800D3
66407+:1021D0008D4A0488241F001024190002A75F0140C3
66408+:1021E000A7400142A7400144A7590146974901046D
66409+:1021F00024070001310600022538FFFEA7580148D8
66410+:102200003C050009A747014A10C00003000018213F
66411+:102210003C05010924030001310C00045180000534
66412+:10222000AF8300083C08001000A828252403000103
66413+:10223000AF830008AF451000000000000000000060
66414+:1022400000000000000000009205000424AE00021F
66415+:1022500031CD0007000D182330620007AE020010D8
66416+:102260008F90000812000004000000008F4F100043
66417+:1022700005E1FFFE000000008F7100008F8E001846
66418+:102280003C0308008C630444AF91000497450104AB
66419+:1022900025CF001031E61FFF30A2FFFFAF8E001CDC
66420+:1022A000AF860018AF4600842449FFFE3C0C0800AE
66421+:1022B0008D8C0440974D010401208021000947C303
66422+:1022C0000070C02131A9FFFF0310F82B0188C8213D
66423+:1022D000033F202103463821313100073C0108002B
66424+:1022E000AC3804443C010800AC2404401220000334
66425+:1022F00024FB40002527000730E9FFF88F860020E7
66426+:102300008F8400280126382100E4C02B170000022A
66427+:10231000AF86002400E438230347202134198000CD
66428+:10232000009910213C0F1000AF870020AF820038C9
66429+:10233000AF470080AF4F01780A0002968F880014E3
66430+:102340009747010410E0FDAE3C1840008F5801781B
66431+:102350000700FFFE30C5400010A000033C1F00082E
66432+:102360000000000D3C1F0008AF5F01402410080072
66433+:102370008F860000AF5001789744010430D90001E6
66434+:10238000132000ED3086FFFF24CCFFFE240D000259
66435+:10239000A74D0146A74C01488F9100182408000D55
66436+:1023A000A748014A8F630000262F000831E21FFF73
66437+:1023B0000342702130C90007AF830004AF91001CB5
66438+:1023C000AF82001800C03821AF4200841120000302
66439+:1023D00025DB400024D800073307FFF88F85002055
66440+:1023E0008F84002800E5302100C4382B14E000025F
66441+:1023F000AF85002400C430238F8400140346F821E5
66442+:10240000340C8000AF86002003EC8021AF460080B2
66443+:10241000249900013C0610003C184000AF460178AA
66444+:10242000AF900038AF990014AF5801380A000196F8
66445+:10243000000000008F630000975101043067FFFF28
66446+:102440003228FFFF8F4F017805E0FFFE30EC0007D8
66447+:10245000000CF82333F0000724F9FFFE2404000ADF
66448+:10246000A7440140A7500142A7590144A740014693
66449+:10247000A74801488F45010830B800201700000226
66450+:10248000240300092403000130CD0002A743014AC0
66451+:102490003C04004111A00003000018213C0401414C
66452+:1024A0002403000130C9000451200005AF83000857
66453+:1024B0003C0600100086202524030001AF8300089D
66454+:1024C000AF44100000000000000000000000000009
66455+:1024D000000000008F8E000811C000040000000002
66456+:1024E0008F4210000441FFFE000000008F7F0000BB
66457+:1024F000276400088F91003CAF9F0004948500087A
66458+:102500009490000A9499000C30AFFFFF0010C400B3
66459+:102510003323FFFF11F100A6030320253C0E080022
66460+:102520008DCE04443C0C08008D8C044000E88821CA
66461+:102530002626FFFE01C628210000682100A6F82BF0
66462+:10254000018D2021009F80213C010800AC2504441E
66463+:102550003C010800AC30044024E200083042FFFF98
66464+:102560003047000710E000038F830018244F000756
66465+:1025700031E2FFF83106FFFF30C800070043802139
66466+:1025800032191FFF0359C021AF83001CAF990018F7
66467+:10259000271B4000AF590084110000038F8C0020DE
66468+:1025A00024C5000730A6FFF88F84002800CC28211E
66469+:1025B00000A4F82B17E00002AF8C002400A428230D
66470+:1025C000AF850020AF4500803C0408008C840434B3
66471+:1025D00003454821340E8000012E6821108000053B
66472+:1025E000AF8D0038939100172406000E12260011BB
66473+:1025F0002407043F3C021000AF4201788F8800148A
66474+:10260000250F00010A0001EFAF8F00140E0005C472
66475+:1026100000E020218F8800143C0B08008D6B048C97
66476+:102620003C0A08008D4A0488250F00010A0001EFCA
66477+:10263000AF8F00143C021000A7470148AF42017859
66478+:102640000A0004CE8F88001424040F001184003D7A
66479+:1026500030CE002015C0000224030009240300012D
66480+:102660000A00021AA743014A0A00020DA7400146C8
66481+:1026700094EF000894F1000A94F0000C8F8C003C59
66482+:10268000001174003207FFFF31EDFFFF11AC00377E
66483+:1026900001C720253C1808008F1804443C0F08008F
66484+:1026A0008DEF0440000080210308682101A8382B29
66485+:1026B00001F0702101C760213C010800AC2D0444E9
66486+:1026C0003C010800AC2C04400A00027A8F840018F8
66487+:1026D0003C0208008C42047C3C0308008C630454D8
66488+:1026E0003C1F08008FFF04783C1808008F18045026
66489+:1026F000004838210068802100E8282B03E43021BD
66490+:102700000208402B0304882100C57021022878218B
66491+:102710003C010800AC3004543C010800AC2F0450CC
66492+:102720003C010800AC27047C3C010800AC2E047876
66493+:102730000A00027A8F840018A74001460A00043577
66494+:102740008F91001830CD002015A0FFC52403000D87
66495+:10275000240300050A00021AA743014A974E010408
66496+:1027600025C5FFF00A00038130A4FFFF8F980040C9
66497+:102770001498FFC8000010213C0508008CA5046CCB
66498+:102780003C1F08008FFF046800A8C8210328302BD5
66499+:1027900003E22021008640213C010800AC39046C92
66500+:1027A0003C010800AC2804680A00027A8F840018F3
66501+:1027B0008F8C0040148CFF5900E8C8213C18080099
66502+:1027C0008F18046C3C1108008E3104682723FFFE2B
66503+:1027D00003034821000010210123302B0222702125
66504+:1027E00001C668213C010800AC29046C3C010800CA
66505+:1027F000AC2D04680A0004A524E200088F88003884
66506+:102800003C03FFFF8D02000C0043F82403E4C825BD
66507+:10281000AD19000C0A00038F30CBFFFF0A0003C381
66508+:10282000AE000000974A0104920400048E26000CBA
66509+:10283000014458212579FFF200C7C0243325FFFF4A
66510+:1028400003053825AE27000C0A0002E68E050010AD
66511+:102850003C0DFFFF8D0A0010014D582401646025D6
66512+:10286000AD0C00100A00038F30CBFFFF974301042B
66513+:10287000920E00048E290010006E1021244DFFEEF0
66514+:102880000127602431A8FFFF0188F825AE3F001022
66515+:102890000A0002E68E0500108E0F000CAE0000004C
66516+:1028A00000078880023028210A0002B8ACAF00205F
66517+:1028B0001460000D3058FFFF3C04FFFF0044682403
66518+:1028C00001A47026000E602B000D102B004CF82484
66519+:1028D00013E00002000000000000000D8CAF0000BB
66520+:1028E0000A00025001E410253B03FFFF0003882B80
66521+:1028F0000018802B0211202410800002000000002C
66522+:102900000000000D8CB900000A0002503722FFFFC2
66523+:102910003084FFFF30A5FFFF108000070000182162
66524+:10292000308200011040000200042042006518219E
66525+:102930001480FFFB0005284003E000080060102120
66526+:1029400010C00007000000008CA2000024C6FFFF9A
66527+:1029500024A50004AC82000014C0FFFB2484000402
66528+:1029600003E000080000000010A0000824A3FFFFFF
66529+:10297000AC86000000000000000000002402FFFF01
66530+:102980002463FFFF1462FFFA2484000403E00008BC
66531+:1029900000000000308EFFFF30D8FFFF00057C00F4
66532+:1029A00001F8602539CDFFFF01AC5021014C582BB7
66533+:1029B000014B4821000944023127FFFF00E8302184
66534+:1029C0000006240230C5FFFF00A418213862FFFF73
66535+:1029D00003E000083042FFFF3C0C08008D8C0484AB
66536+:1029E000240BFF8027BDFFD001845021014B4824D8
66537+:1029F000AF4900203C0808008D080484AFB20020D5
66538+:102A0000AFB00018AFBF0028AFB30024AFB1001CB7
66539+:102A1000936600040104382130E4007F009A1021FD
66540+:102A20003C0300080043902130C500200360802152
66541+:102A30003C080111277B000814A000022646007004
66542+:102A40002646006C9213000497510104920F000473
66543+:102A50003267000F322EFFFF31ED004001C72823FF
66544+:102A600011A0000500004821925900BC3338000431
66545+:102A70001700009000000000924300BC307F00046B
66546+:102A800013E0000F0000000010A0000D0000000087
66547+:102A9000960E0002240AFF8000A7602125CDFFFECC
66548+:102AA000A74D1016920B0004014B2024308200FF2A
66549+:102AB00010400085010C40253C0F0400010F40250B
66550+:102AC0008F5301780660FFFE2404000AA7440140EA
66551+:102AD000960D00022404000931AC0007000C5823B5
66552+:102AE000316A0007A74A0142960200022443FFFE12
66553+:102AF000A7430144A7400146975F0104A75F01482F
66554+:102B00008F590108333800205300000124040001CC
66555+:102B1000920F000431EE001015C000023483001043
66556+:102B200000801821A743014A0000000000000000B7
66557+:102B30000000000000000000AF481000000000008E
66558+:102B40000000000000000000000000008F51100095
66559+:102B50000621FFFE3113FFFF12600003000000009A
66560+:102B60008F481018ACC8000096030006307FFFFFA6
66561+:102B700027F900020019988200138880023B302157
66562+:102B80008CD800001520005700183402920300046E
66563+:102B90002405FF8000A3F82433F100FF1220002C4D
66564+:102BA00000000000924700BC30F2000212400028F2
66565+:102BB00000000000974B100C2562FFFEA742101684
66566+:102BC000000000003C0A040035490030AF49100005
66567+:102BD00000000000000000000000000000000000F5
66568+:102BE0008F4C10000581FFFE000000009749100C7B
66569+:102BF0008F51101C00C020213127FFFF24F200302C
66570+:102C0000001218820003288000BBF8213226FFFF43
66571+:102C1000AFF100000E0005B300112C020013C880B4
66572+:102C2000033B98218E78000000027400AFB80010BA
66573+:102C30008FA80010310FFFFFAFAF00108FA400105E
66574+:102C400001C46825AFAD00108FA60010AE6600006D
66575+:102C500097730008976D000A9766000C8F8A003CF6
66576+:102C6000000D5C0030CCFFFF3262FFFF104A0036DF
66577+:102C7000016C2025960600023C10100024D30008A9
66578+:102C80000E00013B3264FFFF974C01040E00014926
66579+:102C90003184FFFFAF5001788FBF00288FB300242D
66580+:102CA0008FB200208FB1001C8FB0001803E0000825
66581+:102CB00027BD003010A0FF700000000024A5FFFC1D
66582+:102CC0000A0005EC240900048CD10000AF51101853
66583+:102CD0008F5301780660FF7A2404000A0A00060177
66584+:102CE0000000000000A7C8218F8800388F4E101CFC
66585+:102CF0000019C0820018788001E82021AC8E000005
66586+:102D0000000E2C0200C020210E0005B331C6FFFFCB
66587+:102D1000023B28218CAD000000025400004030210D
66588+:102D2000AFAD00108FAC0010318BFFFFAFAB0010C8
66589+:102D30008FA2001001424825AFA900108FA70010F4
66590+:102D40000A000631ACA700008F8F0040148FFFC926
66591+:102D50000000000097420104960B00023C050800A9
66592+:102D60008CA5046C3049FFFF316AFFFF3C1108005D
66593+:102D70008E310468012A382124F2FFFE00B240217E
66594+:102D80000012FFC30112C82B023FC02103192021EA
66595+:102D90003C010800AC28046C3C010800AC24046829
66596+:102DA0000A00066B0000000000A4102B1040000970
66597+:102DB000240300010005284000A4102B04A00003F8
66598+:102DC000000318405440FFFC000528401060000735
66599+:102DD000000000000085302B14C0000200031842E0
66600+:102DE000008520231460FFFB0005284203E0000853
66601+:102DF000008010218F85002C27BDFFE800053027BB
66602+:102E00002CC300012CA400020083102510400003F5
66603+:102E1000AFBF00102405007FAF85002C00052827D8
66604+:102E200030A5FFFF0E000592240426F58F830030A5
66605+:102E3000240402BD004030210083382B10E000093B
66606+:102E400024050001000420400083102B04800003AF
66607+:102E5000000528405440FFFC0004204010A000085A
66608+:102E600000C350210064402B1500000200052842D9
66609+:102E70000064182314A0FFFB0004204200C350216B
66610+:102E80008FBF0010000A4C02312200FF27BD00183E
66611+:102E9000AF8A002C03E00008AF8900300A00002A46
66612+:102EA00000000000000000000000000D7478703683
66613+:102EB0002E322E3300000000060203000000000046
66614+:102EC000000001360000EA60000000000000000081
66615+:102ED00000000000000000000000000000000000F2
66616+:102EE00000000000000000000000000000000000E2
66617+:102EF00000000000000000000000000000000016BC
66618+:102F000000000000000000000000000000000000C1
66619+:102F100000000000000000000000000000000000B1
66620+:102F200000000000000000000000000000000000A1
66621+:102F3000000000000000138800000000000005DC15
66622+:102F4000000000000000000010000003000000006E
66623+:102F50000000000D0000000D3C02080024423C204F
66624+:102F60003C03080024633DD4AC4000000043202B08
66625+:102F70001480FFFD244200043C1D080037BD7FFC87
66626+:102F800003A0F0213C100800261000A83C1C0800FB
66627+:102F9000279C3C200E0002BA000000000000000D3B
66628+:102FA0008F8300383C088000350700708CE50000F6
66629+:102FB000008330253C02900000C22025AF85003000
66630+:102FC000AF4400208F4900200520FFFE3C03800015
66631+:102FD000346200708C4500008F8600303C19080078
66632+:102FE0008F39007C3C0E08008DCE007800A620238F
66633+:102FF00003245821000078210164682B01CF60214F
66634+:10300000018D50213C010800AC2B007C3C010800E4
66635+:10301000AC2A007803E00008000000000A0000412C
66636+:10302000240400018F8400383C05800034A2000194
66637+:103030000082182503E00008AF43002003E00008E9
66638+:10304000000010213084FFFF30A5FFFF1080000733
66639+:1030500000001821308200011040000200042042CC
66640+:10306000006518211480FFFB0005284003E00008DC
66641+:103070000060102110C00007000000008CA20000BA
66642+:1030800024C6FFFF24A50004AC82000014C0FFFB8F
66643+:103090002484000403E000080000000010A00008E1
66644+:1030A00024A3FFFFAC860000000000000000000029
66645+:1030B0002402FFFF2463FFFF1462FFFA248400044C
66646+:1030C00003E0000800000000308AFFFF93A800130F
66647+:1030D000A74A014497490E1630C600FF3C02100073
66648+:1030E000A7490146AF450148A3460152A748015AE6
66649+:1030F000AF4701608FA400188FA30014A7440158A4
66650+:10310000AF43015403E00008AF42017803E0000838
66651+:10311000000000003C038000346200708C49000015
66652+:103120008F8800002484000727BDFFF83084FFF853
66653+:10313000AF890030974D008A31ACFFFFAFAC000083
66654+:103140008FAB0000016850232547FFFF30E61FFFCB
66655+:1031500000C4282B14A0FFF73C0C8000358B0070B6
66656+:103160008D6A00003C0708008CE700843C060800DC
66657+:103170008CC6008000081082014918230002788064
66658+:1031800000E370210000202101C3C82B00C4C0212E
66659+:1031900001FA4021031948212502400027BD0008FB
66660+:1031A0003C010800AC2E00843C010800AC290080E2
66661+:1031B00003E00008000000008F8200002486000762
66662+:1031C00030C5FFF800A2182130641FFF03E000089B
66663+:1031D000AF8400008F8700388F8A004027BDFFB87A
66664+:1031E0008F860044AFB60040AFBF0044AFB5003C8F
66665+:1031F000AFB40038AFB30034AFB20030AFB1002C81
66666+:10320000AFB000288F4501048D4900ACAF47008066
66667+:103210008CC8002000A938230000B021AF480E1050
66668+:103220008F440E1000004821AF440E148CC20024BD
66669+:10323000AF420E188F430E18AF430E1C10E001254D
66670+:103240002D230001936B0008116000D400000000E2
66671+:10325000976E001031CDFFFF00ED602B158000CF81
66672+:103260000000000097700010320FFFFFAF4F0E00FC
66673+:103270008F520000325100081220FFFD00000000B4
66674+:1032800097540E088F460E043285FFFF30B30001BD
66675+:1032900012600132000000000000000D30B8A040B4
66676+:1032A00024150040131500C030A9A0001120012DE5
66677+:1032B00000000000937F000813E0000800000000F9
66678+:1032C00097630010306BFFFF00CB402B1100000311
66679+:1032D00030AC00401180012300000000A785003CB5
66680+:1032E000AF8600349366000800E02821AFA70020D5
66681+:1032F00014C0012427B30020AF60000C9782003C6B
66682+:103300003047400014E00002240300162403000E9E
66683+:1033100024194007A363000AAF790014938A003E82
66684+:103320008F740014315800070018AA4002959025A8
66685+:10333000AF7200149784003C8F700014309100101D
66686+:1033400002117825AF6F0014978E003C31CD000834
66687+:1033500011A00147000028218F6700143C021000D3
66688+:103360003C0C810000E22825AF65001497460E0A48
66689+:103370002408000E3405FFFC30C3FFFF006C582505
66690+:10338000AF6B0004A3680002937F000A27E90004E2
66691+:10339000A369000A9786003C9363000A30CC1F00A3
66692+:1033A000000C598301634021251F0028A37F0009D9
66693+:1033B00097490E0CA769001093790009272A00028B
66694+:1033C000315800070018A82332B10007A371000B81
66695+:1033D00093740009976400108F910034978F003C1C
66696+:1033E000329200FF024480210205702131ED00403D
66697+:1033F00011A0000531C4FFFF0091282B3C12800072
66698+:1034000010A000140000A0210224382B14E0011B9E
66699+:103410008FA500208F4D0E14AF4D0E108F420E1C45
66700+:10342000AF420E18AF440E008F4F000031EE00087F
66701+:1034300011C0FFFD0000000097540E080080882195
66702+:1034400000009021A794003C8F500E04241400012A
66703+:10345000AF900034976400103095FFFF8E68000035
66704+:103460000111F82317E00009AE7F00008F650014FA
66705+:103470008F8B004434A60040AF6600148F4C0E10B2
66706+:10348000AD6C00208F430E18AD63002493670008D5
66707+:1034900014E000D2000000000E00009E2404001082
66708+:1034A0008F8900483C08320000402821312600FF67
66709+:1034B0000006FC0003E8502525390001AF990048BB
66710+:1034C000AC4A0000937800099370000A330400FFAF
66711+:1034D00000047400320F00FF01CF6825AC4D0004DA
66712+:1034E0008F820048064000EAACA20008ACA0000CA5
66713+:1034F0009783003C306B0008156000022628000608
66714+:1035000026280002974E0E148F450E1C8F6700046C
66715+:10351000936D000231C4FFFF31A200FFAFA2001083
66716+:103520008F6C0014AFA800180E00008BAFAC001415
66717+:10353000240400100E0000C7000000008E7200007E
66718+:1035400016400005000000008F6400142405FFBF32
66719+:1035500000859824AF7300148F79000C033538214F
66720+:10356000AF67000C9375000816A00008000000006B
66721+:1035700012800006000000008F7F00143C0BEFFF5C
66722+:103580003568FFFE03E84824AF690014A3740008FF
66723+:103590008FA500200A00024602202021AF470E001E
66724+:1035A0000A0000F5000000008F5901780720FFFE97
66725+:1035B000241F08008F840000AF5F0178974B008ABA
66726+:1035C000316AFFFF014448232528FFFF31021FFF16
66727+:1035D0002C4300081460FFF9000000008F8E0048A3
66728+:1035E0008F8D003800C048210344202125C60001EA
66729+:1035F000240C0F00AF86004800E9382324864000E1
66730+:1036000031CA00FF11AC0005240800019391003E6F
66731+:103610003230000700107A4035E80001000AAC00A3
66732+:103620003C18010002B8A025AC9440008F930048DC
66733+:1036300030B2003630A40008ACD3000410800097EC
66734+:1036400001123025974E0E0A8F8D00003C0281003A
66735+:1036500031CCFFFF25AB0008018240253C03100060
66736+:1036600031651FFF25390006241F000EAF48016099
66737+:1036700000C33025A75F015AAF850000A759015844
66738+:1036800014E0000A8F93003824120F0052720002D7
66739+:103690002416000134C600408F580E108F94004449
66740+:1036A000AE9800208F550E18AE9500248F450E144D
66741+:1036B000AF4501448F590E1CAF590148A34A01522E
66742+:1036C0003C0A1000AF460154AF4A017814E0FEDD19
66743+:1036D0002D2300010076A025128000178FBF004423
66744+:1036E0008F84003824160F0010960084000000001C
66745+:1036F0008F45017804A0FFFE24150F001095006E81
66746+:10370000000000008F470E14240202403C1F1000EE
66747+:10371000AF4701448F440E1CAF440148A3400152FF
66748+:10372000A740015AAF400160A7400158AF42015481
66749+:10373000AF5F01788FBF00448FB600408FB5003C6B
66750+:103740008FB400388FB300348FB200308FB1002CAB
66751+:103750008FB0002803E0000827BD004814C0FED049
66752+:1037600030B8A0408F420E148F84004400004821DE
66753+:10377000AC8200208F510E1CAC9100240A00020E76
66754+:103780002D2300018F910034978A003C3C12800069
66755+:103790000220A821315800401700FF300000A0216E
66756+:1037A000976900108F9200343139FFFF13320035D2
66757+:1037B00000002021008048211480FEA000A03821B4
66758+:1037C0008F420E148F840044AC8200208F510E1C57
66759+:1037D000AC9100240A00020E2D230001936A000917
66760+:1037E0009378000B315000FF330F00FF020F702160
66761+:1037F00025C2000A3050FFFF0E00009E020020216B
66762+:103800008F8600483C1F410024CD0001AF8D004849
66763+:10381000936C000930C600FF00064400318300FFAE
66764+:10382000246B0002010B4825013FC825AC5900005C
66765+:103830008F67000C97440E1400F22825AC45000455
66766+:103840008F450E1C8F670004936A00023084FFFFCF
66767+:10385000315800FFAFB800108F6F0014AFB10018DF
66768+:103860000E00008BAFAF00140A0001A60200202159
66769+:10387000AF6000040A00013EA36000020A00024695
66770+:1038800000002021000090210A0001702414000192
66771+:103890003C1280000A000195ACB2000C8F91000030
66772+:1038A00025240002A744015826300008320F1FFFCC
66773+:1038B0000A0001F9AF8F0000AF40014C1120002C2D
66774+:1038C000000000008F590E10AF5901448F430E18AD
66775+:1038D000240200403C1F1000AF430148A3400152A6
66776+:1038E000A740015AAF400160A7400158AF420154C0
66777+:1038F000AF5F01780A0002278FBF00441120000645
66778+:103900000000000097460E0830CC004015800002F1
66779+:10391000000000000000000D8F4D017805A0FFFEA3
66780+:103920000000000097530E103C120500240E2000EA
66781+:10393000326AFFFF0152C025AF58014C8F4F0E1461
66782+:103940003C021000AF4F01448F500E1CAF50014895
66783+:10395000A34001528F840038A740015AAF40016054
66784+:10396000A7400158AF4E01540A000215AF4201783A
66785+:103970008F490E14AF4901448F430E1C0A00028E7A
66786+:10398000240200403C0E20FF27BDFFE03C1A8000CF
66787+:103990003C0F800835CDFFFDAFBF001CAFB2001853
66788+:1039A000AFB10014AFB00010AF8F0040AF4D0E00AC
66789+:1039B0000000000000000000000000000000000007
66790+:1039C000000000003C0C00FF358BFFFDAF4B0E00EC
66791+:1039D0003C0660048CC95000240AFF7F3C11600043
66792+:1039E000012A40243507380CACC750008E24043817
66793+:1039F00024050009AF4500083083FFFF38622F71AE
66794+:103A00002450C0B3AF8000480E000068AF800000B3
66795+:103A100052000001AE20442C0E0004353C11800001
66796+:103A20000E000ED9363000708F8A00403C1208001C
66797+:103A300026523C88020088218E0800008F5F00001B
66798+:103A40003BF900013338000113000017AF88003044
66799+:103A5000022048218D2700003C0F08008DEF006CEC
66800+:103A60003C0C08008D8C006800E8C02301F8282178
66801+:103A70000000682100B8302B018D582101664021DB
66802+:103A80003C010800AC25006C3C010800AC28006833
66803+:103A90008F44000038830001306200011440FFEDC4
66804+:103AA00000E04021AF8700308E0C00003C0508008C
66805+:103AB0008CA5006C3C0408008C84006801883023CD
66806+:103AC00000A638210000102100E6402B00821821BA
66807+:103AD0000068F8213C010800AC27006C3C0108009C
66808+:103AE000AC3F00688F49010025590088AF99004418
66809+:103AF000AF890038AF4900208E070000AF87003043
66810+:103B00008F4D017805A0FFFE000000008E0600002A
66811+:103B10003C0B08008D6B00743C0408008C84007022
66812+:103B200000C728230165F8210000102103E5402B80
66813+:103B30000082382100E8C821240908003C0108005F
66814+:103B4000AC3F00743C010800AC390070AF4901780B
66815+:103B500093580108A398003E938F003E31EE000178
66816+:103B600015C000158F830038240E0D00106E00194B
66817+:103B7000240F0F00106F001D00000000915900007D
66818+:103B800024180050332900FF113800043C1F400066
66819+:103B9000AF5F01380A0002E7000000000E00090EC6
66820+:103BA000000000008F8A00403C1F4000AF5F0138DA
66821+:103BB0000A0002E700000000938D003E31AC0006D1
66822+:103BC000000C51000E0000CE0152D8210A00034320
66823+:103BD0008F8A00403C1B0800277B3D080E0000CE6A
66824+:103BE000000000000A0003438F8A00403C1B0800CD
66825+:103BF000277B3D280E0000CE000000000A00034392
66826+:103C00008F8A004090AA00018FAB00108CAC00108E
66827+:103C10003C0300FF8D680004AD6C00208CAD0014E7
66828+:103C200000E060213462FFFFAD6D00248CA7001816
66829+:103C30003C09FF000109C024AD6700288CAE001CC0
66830+:103C40000182C82403197825AD6F0004AD6E002CE5
66831+:103C50008CAD0008314A00FFAD6D001C94A9000234
66832+:103C60003128FFFFAD68001090A70000A56000029A
66833+:103C7000A1600004A167000090A30002306200FF71
66834+:103C80000002198210600005240500011065000E75
66835+:103C90000000000003E00008A16A00018CD80028A1
66836+:103CA000354A0080AD7800188CCF0014AD6F001439
66837+:103CB0008CCE0030AD6E00088CC4002CA16A0001CF
66838+:103CC00003E00008AD64000C8CCD001CAD6D001845
66839+:103CD0008CC90014AD6900148CC80024AD680008BC
66840+:103CE0008CC70020AD67000C8CC200148C8300646C
66841+:103CF0000043C82B13200007000000008CC20014F2
66842+:103D0000144CFFE400000000354A008003E0000886
66843+:103D1000A16A00018C8200640A000399000000007F
66844+:103D200090AA000027BDFFF88FA9001CA3AA0000DD
66845+:103D30008FAE00003C0FFF808FA8001835E2FFFF18
66846+:103D40008CCD002C01C26024AFAC0000A120000487
66847+:103D500000E06021A7A000028FB800008D270004BA
66848+:103D60000188182100A0582100C05021006D28268C
66849+:103D70003C06FF7F3C0F00FF2CAD000135EEFFFF3E
66850+:103D800034D9FFFF3C02FF0003193024000D1DC091
66851+:103D9000010EC82400E2C02400C370250319782551
66852+:103DA000AD2E0000AD2F00048D450024AFAE000005
66853+:103DB000AD2500088D4D00202405FFFFAD2D000C22
66854+:103DC000956800023107FFFFAD27001091660018CB
66855+:103DD00030C200FF000219C2506000018D4500345E
66856+:103DE000AD2500148D67000827BD0008AD27001C15
66857+:103DF0008C8B00CCAD2C0028AD20002CAD2B0024EA
66858+:103E0000AD20001803E00008AD20002027BDFFE032
66859+:103E1000AFB20018AFB10014AFB00010AFBF001CBC
66860+:103E20009098000000C088213C0D00FF330F007FF8
66861+:103E3000A0CF0000908E000135ACFFFF3C0AFF00D0
66862+:103E4000A0CE000194A6001EA22000048CAB00149A
66863+:103E50008E29000400A08021016C2824012A40241E
66864+:103E60000080902101052025A6260002AE24000432
66865+:103E700026050020262400080E00007624060002F5
66866+:103E800092470000260500282624001400071E0083
66867+:103E90000003160324060004044000032403FFFF6C
66868+:103EA000965900023323FFFF0E000076AE23001068
66869+:103EB000262400248FBF001C8FB200188FB100147D
66870+:103EC0008FB0001024050003000030210A0000809C
66871+:103ED00027BD002027BDFFD8AFB1001CAFB0001830
66872+:103EE000AFBF002090A80000240200018FB0003C6A
66873+:103EF0003103003F00808821106200148FAA00382F
66874+:103F0000240B0005506B0016AFAA001000A0202162
66875+:103F100000C028210E0003DC02003021922400BCE6
66876+:103F2000308300021060000326060030ACC00000A1
66877+:103F300024C600048FBF00208FB1001C8FB0001872
66878+:103F400000C0102103E0000827BD002801403821EF
66879+:103F50000E00035AAFB000100A0004200000000059
66880+:103F60000E0003A1AFB000140A00042000000000FE
66881+:103F70003C02000A034218213C04080024843D6CE2
66882+:103F80002405001A000030210A000080AF8300548D
66883+:103F90003C038000346200708C48000000A058216F
66884+:103FA00000C04821308A00FFAF8800308F4401787C
66885+:103FB0000480FFFE3C0C8000358600708CC500003C
66886+:103FC0003C0308008C6300743C1808008F180070D4
66887+:103FD00000A82023006468210000C82101A4782BD8
66888+:103FE0000319702101CF60213C010800AC2D007441
66889+:103FF0003C010800AC2C00708F480E14AF480144FF
66890+:10400000AF47014CA34A0152A74B01589346010800
66891+:1040100030C5000854A0000135291000934B090059
66892+:1040200024070050316A00FF11470007000000001C
66893+:104030008F450E1CAF450148AF4901543C091000A3
66894+:1040400003E00008AF490178934D010831A800084A
66895+:104050001100001000000000934F010831EE001025
66896+:1040600051C00001352900083C04080090843DD06F
66897+:10407000A34401508F4309A4AF4301488F4209A0D4
66898+:10408000AF420144AF4901543C09100003E000086D
66899+:10409000AF4901783C1908008F393D8C333800084E
66900+:1040A0005700FFF1352900080A00047300000000E2
66901+:1040B00024070040AF470814AF4008108F4209445E
66902+:1040C0008F4309508F4409548F45095C8F46094C32
66903+:1040D000AF820064AF830050AF84004CAF85005CBA
66904+:1040E00003E00008AF8600609346010930C5007FF9
66905+:1040F000000518C0000521400083102103E00008DE
66906+:10410000244200883C09080091293D9124A800021E
66907+:104110003C05110000093C0000E8302500C51825C9
66908+:1041200024820008AC83000003E00008AC80000497
66909+:104130009347010B8F4A002C974F09083C18000E3B
66910+:104140000358482131EEFFFF000E41C0AF48002C5C
66911+:1041500097430908952C001A008040212403000190
66912+:10416000318BFFFFAC8B00008D2D001C00A058216F
66913+:1041700000C06021AC8D00048D24002030E7004099
66914+:10418000AD04000891220019304400031083004858
66915+:104190002885000214A00062240600021086005642
66916+:1041A00024190003109900660000000010E0003A96
66917+:1041B000000000003C07080094E73D8624E200016F
66918+:1041C000934F0934934709219525002A31EE00FFCA
66919+:1041D000000E488230ED00FF978700580009360036
66920+:1041E000000D1C003044FFFF00C310250044C02513
66921+:1041F00000A778213C19400003197025000F4C00DE
66922+:10420000AD090004AD0E0000934D09203C030006EB
66923+:1042100025090014000D360000C32025AD04000858
66924+:104220008F59092C24E5000130A27FFFAD19000C45
66925+:104230008F580930A782005825020028AD180010B9
66926+:104240008F4F0938AD0F0014AD2B00048F4E09407D
66927+:10425000AD2E0008934D09373C05080090A53D9010
66928+:104260008F4409488F46094031A700FF00EC182110
66929+:10427000008678230003C7000005CC0003196025E1
66930+:1042800031E8FFFC01885825AD2B000CAD20001053
66931+:1042900003E00008AF4A002C3C0D080095AD3D86B8
66932+:1042A0003C0E080095CE3D800A0004C901AE1021E5
66933+:1042B0003C05080094A53D8A3C06080094C63D8054
66934+:1042C0003C18080097183D7C952E002400A6782104
66935+:1042D00001F86823000E240025A2FFF200821825B1
66936+:1042E00024190800AD03000CAD190014AD00001036
66937+:1042F0000A0004C4250800189526002495250028E6
66938+:104300000006C40000057C00370E810035ED080072
66939+:10431000AD0E000CAD0D00100A0004C425080014F9
66940+:104320001480FFA200000000952400240004140063
66941+:1043300034430800AD03000C0A0004C42508001033
66942+:104340003C03080094633D8A3C05080094A53D8029
66943+:104350003C06080094C63D7C953900249538002819
66944+:10436000006520210086782300196C000018740075
66945+:1043700025E2FFEE01C2202535A3810024190800A3
66946+:10438000AD03000CAD040010AD190018AD00001411
66947+:104390000A0004C42508001C03E00008240201F4FC
66948+:1043A00027BDFFE8AFB00010AFBF00140E000060E3
66949+:1043B0000080802124050040AF4508148F83005001
66950+:1043C0008F84004C8F85005C0070182100641023DE
66951+:1043D00018400004AF830050AF6300548F66005450
66952+:1043E000AF86004C1200000C000000008F440074E7
66953+:1043F000936800813409FA002D07000710E00005DA
66954+:1044000000891021936C0081240B01F4018B50046E
66955+:1044100001441021AF62000C8F4E095C01C5682376
66956+:1044200019A000048FBF00148F4F095CAF8F005C90
66957+:104430008FBF00148FB000100A00006227BD001863
66958+:104440008F8400648F8300508F82004CAF640044DF
66959+:10445000AF63005003E00008AF6200543C038000EB
66960+:10446000346200708C43000027BDFFF8308700FFE6
66961+:1044700030A900FF30C800FFAF8300308F440178BF
66962+:104480000480FFFE3C028000345900708F38000029
66963+:10449000A3A700033C0708008CE700748FAC000062
66964+:1044A0003C0608008CC60070030378233C0E7FFF97
66965+:1044B00000EFC82135CDFFFF00005021018D2824D9
66966+:1044C00000CA1821000847C0032F202B00A8102580
66967+:1044D0000064C021AFA200003C010800AC390074A8
66968+:1044E0003C010800AC380070934F010AA3A0000201
66969+:1044F0003C0E80FFA3AF00018FAC0000312B007F8A
66970+:1045000035CDFFFF018D4824000B5600012A4025C0
66971+:10451000240730002406FF803C05100027BD00085A
66972+:10452000AF48014CAF470154A7400158A346015280
66973+:1045300003E00008AF45017827BDFFE8AFBF0014D6
66974+:10454000AFB000108F6500743C068000309000FF13
66975+:1045500000A620250E000060AF6400749363000580
66976+:10456000346200080E000062A362000502002021F0
66977+:104570008FBF00148FB00010240500052406000131
66978+:104580000A00057027BD001827BDFFE03C0380002E
66979+:10459000AFB00010AFBF0018AFB1001434620070AC
66980+:1045A0008C470000309000FF30A800FFAF8700303C
66981+:1045B0008F4401780480FFFE3C18800037110070A2
66982+:1045C0008E2F00003C0D08008DAD00743C0A0800E1
66983+:1045D0008D4A007001E7702301AE282100005821A8
66984+:1045E00000AE302B014B4821012638213C01080048
66985+:1045F000AC250074000088213C010800AC27007045
66986+:104600001100000F000000008F6200742619FFFFE8
66987+:104610003208007F0002FE0233E5007F150000062D
66988+:10462000332200FF2407FF800207202624A3FFFF78
66989+:1046300000838025320200FF0040802124111008F1
66990+:104640000E000060000000008F49081831250004AA
66991+:1046500014A0FFFD3218007F001878C000187140C8
66992+:1046600001CF682125AC0088AF4C0818274A098083
66993+:104670008D4B0020AF4B01448D460024AF460148CE
66994+:10468000A35001500E000062A740015802201021E3
66995+:104690008FBF00188FB100148FB0001003E0000826
66996+:1046A00027BD002027BDFFE8308400FFAFBF00100A
66997+:1046B0000E0005BB30A500FF8F8300508FBF001098
66998+:1046C000344500402404FF903C02100027BD001830
66999+:1046D000AF43014CA3440152AF45015403E000082D
67000+:1046E000AF4201789343093E306200081040000D4C
67001+:1046F0003C0901013528080AAC8800008F47007486
67002+:10470000AC8700043C06080090C63D9030C5001000
67003+:1047100050A00006AC8000088F6A0060AC8A0008D8
67004+:104720002484000C03E00008008010210A00062207
67005+:104730002484000C27BDFFE8AFBF0014AFB0001009
67006+:104740009346093F00A050210005288000853823AA
67007+:1047500030C200FF240300063C09080095293D866D
67008+:1047600024E8FFD824050004104300372406000283
67009+:104770009750093C3C0F020400063400320EFFFF44
67010+:1047800001CF6825AC8D0000934C093E318B002091
67011+:104790001160000800000000934309363C02010349
67012+:1047A000345F0300307900FF033FC0252405000873
67013+:1047B000AC98000493430934935909210005F88209
67014+:1047C000306200FF0002C082332F00FF00186E002D
67015+:1047D000000F740001AE6025018920253C094000CE
67016+:1047E00000898025ACF0FFD8934309378F4F0948E3
67017+:1047F0008F580940306200FF004AC821033F7021F2
67018+:1048000001F86023000E6F0001A650253185FFFCE2
67019+:10481000001F58800145482501683821AD09002056
67020+:104820000E00006024F00028240400040E00006242
67021+:10483000A364003F020010218FBF00148FB000104E
67022+:1048400003E0000827BD00180A0006352406001200
67023+:1048500027BDFFD024090010AFB60028AFB5002453
67024+:10486000AFB40020AFB10014AFB000103C0108009D
67025+:10487000A0293D90AFBF002CAFB3001CAFB2001811
67026+:1048800097480908309400FF3C02000E3107FFFFF3
67027+:10489000000731C0AF46002C974409089344010B30
67028+:1048A00030B500FF03428021308300300000B0218A
67029+:1048B0001060012500008821240C00043C01080040
67030+:1048C000A02C3D90934B093E000B5600000A2E038E
67031+:1048D00004A0016000000000AF400048934F010BAE
67032+:1048E00031EE002011C00006000000009358093E80
67033+:1048F00000189E0000139603064001890000000086
67034+:104900009344010B30830040106000038F930050EC
67035+:104910008F8200502453FFFF9347093E30E6000882
67036+:1049200014C0000224120003000090219619002CEC
67037+:1049300093580934934F0937A7990058330C00FF57
67038+:1049400031EE00FF024E6821000D5880016C5021AD
67039+:10495000015140213C010800A4283D869205001821
67040+:1049600030A900FF010918213C010800A4233D885B
67041+:104970009211001816200002000000000000000D37
67042+:104980003C010800A4233D8A3C010800A4203D808E
67043+:104990003C010800A4203D7C935F010B3063FFFFC6
67044+:1049A00033F00040120000022464000A2464000B6B
67045+:1049B0003091FFFF0E00009E022020219358010B32
67046+:1049C0003C08080095083D8A0040202100185982C3
67047+:1049D000316700010E00049A01072821934C010B56
67048+:1049E0008F4B002C974E09083C0F000E034F4021BF
67049+:1049F00031CDFFFF000D51C0AF4A002C974309088D
67050+:104A00009505001A004038212404000130A9FFFF59
67051+:104A1000AC4900008D06001C00404821318A00404E
67052+:104A2000AC4600048D020020ACE20008910300199E
67053+:104A300030630003106400EC28790002172001188D
67054+:104A4000241000021070010C241F0003107F011EAF
67055+:104A500000000000114000DE000000003C090800DA
67056+:104A600095293D8625220001935F0934934E092143
67057+:104A70009504002A33F900FF0019C08231CF00FFEE
67058+:104A8000978E005800184600000F6C00010D80251D
67059+:104A90003045FFFF02051025008E50213C034000E9
67060+:104AA00000433025000A6400ACEC0004ACE60000D2
67061+:104AB000935F09203C19000624EC0014001FC60077
67062+:104AC00003197825ACEF00088F48092C25CD00018B
67063+:104AD00031A57FFFACE8000C8F500930A785005846
67064+:104AE00024E80028ACF000108F4409380100802130
67065+:104AF000ACE40014AD9300048F530940AD9300085B
67066+:104B0000934A09373C19080093393D908F4309486F
67067+:104B10008F460940314200FF0052F82100667023A1
67068+:104B2000001F7F000019C40001F8282531CDFFFCCB
67069+:104B300000AD2025AD84000CAD800010AF4B002CE3
67070+:104B4000934B093E317300081260000D3C060101D1
67071+:104B500034CC080AACEC00288F530074AD13000469
67072+:104B60003C0B0800916B3D903167001050E0000352
67073+:104B7000AD0000088F6A0060AD0A00082510000C27
67074+:104B800012C0003D000000009343093F24160006B8
67075+:104B900024060004306200FF105600C924070002FA
67076+:104BA0009758093C3C0F0204330DFFFF01AF40252D
67077+:104BB000AE0800009345093E30A400201080000894
67078+:104BC00000000000935309363C0B0103357F0300BE
67079+:104BD000327900FF033F7025AE0E00042406000862
67080+:104BE000934F093493480921312AFFFF31ED00FF2B
67081+:104BF000000D1082310300FF0002B60000032C00FC
67082+:104C000002C56025018A9825001220803C094000D9
67083+:104C10000204502302695825AD4BFFD8935F093732
67084+:104C20008F4F09488F58094033F900FF0332702134
67085+:104C30000006B08201D668210007440001F828234D
67086+:104C4000000D1F000068302530A2FFFC2547FFD86B
67087+:104C500000C260250016808002074821ACEC0020CD
67088+:104C6000253000280E00006024120004A372003FCB
67089+:104C70000E000062000000009347010B30F200407C
67090+:104C8000124000053C1900FF8E180000372EFFFF70
67091+:104C9000030E3024AE0600000E0000C702202021C3
67092+:104CA0003C10080092103D90321100031220000FBA
67093+:104CB00002A028218F89005025330001AF930050B6
67094+:104CC000AF7300508F6B00540173F8231BE0000298
67095+:104CD000026020218F640054AF6400548F4C007434
67096+:104CE000258401F4AF64000C02A028210280202159
67097+:104CF000A76000680E0005BB3C1410008F850050B3
67098+:104D000034550006AF45014C8F8A00488FBF002CF8
67099+:104D10008FB3001C25560001AF9600488FB20018D3
67100+:104D2000A34A01528FB60028AF5501548FB1001429
67101+:104D3000AF5401788FB500248FB400208FB00010DD
67102+:104D400003E0000827BD00309358093E00189E007C
67103+:104D500000139603064200362411000293440923EF
67104+:104D6000308300021060FEDD8F8600608F8200506D
67105+:104D700014C2FEDA000000000E0000600000000017
67106+:104D80009369003F24070016312800FF1107000C2B
67107+:104D9000240500083C0C0800918C3D90358B0001E7
67108+:104DA0003C010800A02B3D90936A003F314300FF77
67109+:104DB00010650065240D000A106D005E2402000CD1
67110+:104DC0000E000062000000000A00069000000000D3
67111+:104DD0003C09080095293D863C0A0800954A3D801B
67112+:104DE0000A0006F3012A10213C09080095293D8A92
67113+:104DF0003C04080094843D803C06080094C63D7C39
67114+:104E000095030024012410210046F8230003CC0060
67115+:104E100027F0FFF20330C025240F0800ACF8000C87
67116+:104E2000ACEF0014ACE000100A0006EE24E7001816
67117+:104E30003C010800A0313D90935F093E241600011B
67118+:104E400033F900201720FEA5241100080A0006905F
67119+:104E5000241100048F6E00848F4D094011A0FE9E26
67120+:104E6000AF8E0050240F00143C010800A02F3D908D
67121+:104E70000A00068F00000000950E0024950D002802
67122+:104E8000000E6400000D2C003589810034A6080056
67123+:104E9000ACE9000CACE600100A0006EE24E70014B2
67124+:104EA0001460FEEC000000009502002400021C00CB
67125+:104EB00034640800ACE4000C0A0006EE24E700109D
67126+:104EC0000A000741240700123C02080094423D8A70
67127+:104ED0003C06080094C63D803C03080094633D7C7A
67128+:104EE00095100024951900280046F82103E3C023FB
67129+:104EF00000106C0000197400270FFFEE01CF282569
67130+:104F000035AC8100ACEC000CACE5001024070800C7
67131+:104F1000AD2700182527001C0A0006EEAD2000145E
67132+:104F20008F7F004CAF7F00548F7900540A000699A0
67133+:104F3000AF790050A362003F0E0000620000000045
67134+:104F40000A00069000000000240200140A0008274E
67135+:104F5000A362003F27BDFFE8308400FFAFBF001011
67136+:104F60000E0005BB30A500FF9378007E9379007F8B
67137+:104F7000936E00809368007A332F00FF001866005C
67138+:104F8000000F6C0031CB00FF018D4825000B520053
67139+:104F90008FBF0010012A3825310600FF344470000D
67140+:104FA00000E628252402FF813C03100027BD0018DD
67141+:104FB000AF45014CAF440154A342015203E0000845
67142+:104FC000AF43017827BDFFD8AFB20018AFB10014CE
67143+:104FD000AFB00010AFBF0020AFB3001C9342010977
67144+:104FE000308600FF30B000FF000618C23204000215
67145+:104FF0003071000114800005305200FF93670005F6
67146+:1050000030E5000810A0000D30C80010024020213B
67147+:105010000E0005A702202821240400018FBF0020D4
67148+:105020008FB3001C8FB200188FB100148FB0001026
67149+:105030000080102103E0000827BD00281500003281
67150+:105040000000000093430109000028213062007F26
67151+:10505000000220C00002F94003E49821267900886C
67152+:10506000033B98218E7800248E6F0008130F0046B2
67153+:10507000000000008F640084241800020004FD82F8
67154+:1050800033F900031338007C0000000093660083AE
67155+:10509000934A0109514600043205007C10A00060CB
67156+:1050A000000000003205007C14A0005302402021C3
67157+:1050B00016200006320400018E7F00248F5901045F
67158+:1050C00017F9FFD600002021320400011080000AE9
67159+:1050D000024020218F4209408F9300641053000644
67160+:1050E000000000000E00066D022028218F430940B9
67161+:1050F000AF630044024020210E0006020220282156
67162+:105100000A000860240400013C0908008D2900649D
67163+:10511000252600013C010800AC26006416000012A0
67164+:10512000000000008F6D00843C0E00C001AE6024C2
67165+:1051300015800005024020210E00082E02202821A3
67166+:105140000A00086024040001240500040E00057014
67167+:1051500024060001024020210E00082E02202821F2
67168+:105160000A000860240400010E000041240400012C
67169+:10517000936B007D020B50250E000062A36A007D38
67170+:105180000A0008A38F6D00848F6600748F480104A5
67171+:105190008E67002400064E021507FFB63126007FF9
67172+:1051A000936B008326440001308A007F1146004340
67173+:1051B000316300FF5464FFB08F6400842645000112
67174+:1051C00030B1007F30A200FF122600042405000148
67175+:1051D000004090210A00087624110001240FFF806E
67176+:1051E000024F702401CF9026324200FF00409021F0
67177+:1051F0000A000876241100010E00066D0220282105
67178+:10520000321800301300FFAA321000820240202121
67179+:105210000E0005A7022028210A00086024040001CE
67180+:105220008F6E00743C0F80002405000301CF902591
67181+:10523000AF72007493710083240600010E000570A4
67182+:10524000322400FF0E00004124040001936D007D14
67183+:10525000020D60250E000062A36C007D3C0B08006F
67184+:105260008D6B0054257000013C010800AC300054E7
67185+:105270000A000860240400018F6800743C09800063
67186+:105280002405000401093825AF6700749363008387
67187+:10529000240600010E000570306400FF0E0000417E
67188+:1052A000240400019362007D020298250E00006232
67189+:1052B000A373007D0A00086024040001324D0080C1
67190+:1052C00039AC0080546CFF6C8F6400840A0008C9FC
67191+:1052D0002645000127BDFFC83C0A0008AFBF0030CB
67192+:1052E000AFB5002CAFB40028AFB30024AFB200209C
67193+:1052F000AFB1001CAFB00018034AD8212409004008
67194+:10530000AF490814AF4008108F4209448F43095039
67195+:105310008F4609548F47095C8F48094C9344010814
67196+:105320009345010BAF820064308400FF30A500FF7D
67197+:10533000AF830050AF86004CAF87005C0E00084A78
67198+:10534000AF8800601440017D8FBF0030A760006807
67199+:10535000934D0900240B00503C15080026B53D482C
67200+:1053600031AC00FF3C12080026523D58118B00035F
67201+:10537000000000000000A8210000902193510109C5
67202+:105380008F9F005024040010322E007F000E68C052
67203+:10539000000E6140018D282124B40088AF54081804
67204+:1053A0008F4901048F4A09A43C0B000E034BC02116
67205+:1053B000012A10233C010800AC223D6C8F430958A0
67206+:1053C0003C010800A0243D9097470908007F302346
67207+:1053D0003C010800AC263D7030E8FFFF0008C9C062
67208+:1053E0003C010800AC3F3D94AF59002C974209089E
67209+:1053F0009710002C8EB10000930F001803749821B1
67210+:10540000A7900058AF9300440220F80931F000FF44
67211+:10541000304E000215C001B2304F000111E0014FC3
67212+:10542000000000009343093E3066000814C00002EB
67213+:10543000241400030000A0218F5809A424130001A4
67214+:105440003C010800AC383D98934F0934935109371B
67215+:1054500031EC00FF322E00FF028E6821000D288003
67216+:1054600000AC5021015058213C010800A42B3D887C
67217+:105470003C010800A42A3D8693490934312200FFEB
67218+:1054800002022021249000103C010800A4303D8439
67219+:10549000240700068F9F00503C010800AC273D8C7C
67220+:1054A0008F88005C8F59095800008021011F282334
67221+:1054B00004A00149033F20230480014700A4302BAE
67222+:1054C00010C00149000000003C010800AC253D70FF
67223+:1054D0008E4200000040F809000000003043000246
67224+:1054E000146000F80040882130440001548000100E
67225+:1054F0008E4200043C0908008D293D743C0AC0001E
67226+:10550000012A8025AF500E008F45000030AB000807
67227+:105510001160FFFD00000000974D0E0824100001EF
67228+:10552000A78D003C8F4C0E04AF8C00348E420004DB
67229+:105530000040F8090000000002228825322E0002F7
67230+:1055400015C00180000000003C09080095293D7C41
67231+:105550003C06080094C63D883C0A0800954A3D7EFA
67232+:105560003C1908008F393D74012660213C18080061
67233+:105570008F183D983C03080094633D92018A2021D6
67234+:105580008F4E09400329F821248F000203E32821CC
67235+:10559000031968213C010800A42C3D8AAF8E0064E9
67236+:1055A0003C010800AC2D3D983C010800A4253D803D
67237+:1055B0000E00009E31E4FFFF8F870048004020214D
67238+:1055C0003C010800A0273D918E42000824E800011C
67239+:1055D000AF8800480040F809000000009344010B28
67240+:1055E0008F4C002C974A09083C0B000E034B4021BE
67241+:1055F0003149FFFF000919C08F8B0050AF43002CC9
67242+:10560000974309089506001A00403821308A004067
67243+:1056100030DFFFFFAC5F00008D19001C0040482107
67244+:10562000AC5900048D180020AC580008910F0019E7
67245+:1056300031E30003107300F0000000002862000254
67246+:105640001440010924050002106500FD240D00032B
67247+:10565000106D010D00000000114000D90000000095
67248+:105660003C0A0800954A3D8625420001934D0934C5
67249+:1056700093580921950E002A31A300FF00032082D0
67250+:10568000331F00FF9798005800047E00001FCC00D5
67251+:1056900001F940253049FFFF0109102501D83021CB
67252+:1056A0003C0540000045502500066C00ACED0004B0
67253+:1056B000ACEA0000934309203C04000624ED0014EA
67254+:1056C0000003FE0003E4C825ACF900088F49092C4B
67255+:1056D000270F000131EE7FFFACE9000C8F48093045
67256+:1056E000A78E005824E90028ACE800108F4509383F
67257+:1056F00001204021ACE50014ADAB00048F4209400D
67258+:10570000ADA20008934B09373C1F080093FF3D9062
67259+:105710008F4309488F4A0940316600FF00D4202199
67260+:10572000006A78230004C700001FCC000319282555
67261+:1057300031EEFFFC00AE1025ADA2000CADA00010B4
67262+:10574000AF4C002C934C093E318B00085160000F88
67263+:105750008E58000C3C06010134CA080AACEA002845
67264+:105760008F4B0074AD2B00043C0C0800918C3D90D5
67265+:105770003187001050E00003AD2000088F62006008
67266+:10578000AD2200082528000C8E58000C0300F809F3
67267+:10579000010020213C19080097393D8A3C1F080070
67268+:1057A00097FF3D7E033F782125E900020E0000C7E8
67269+:1057B0003124FFFF3C0E08008DCE3D6C3C080800F4
67270+:1057C0008D083D7401C828233C010800AC253D6CC0
67271+:1057D00014A00006000000003C0308008C633D8C10
67272+:1057E000346400403C010800AC243D8C1200007081
67273+:1057F0008F8C00448F470E108F900044AE0700201E
67274+:105800008F4D0E18AE0D00243C10080096103D8000
67275+:105810000E0000600000000024020040AF420814A7
67276+:105820008F8600508F8A004C00D01821006A5823C0
67277+:1058300019600004AF830050AF6300548F650054BB
67278+:10584000AF85004C1200000C000000008F44007473
67279+:10585000936800813409FA002D0E000711C000057D
67280+:1058600000891821937F0081241901F403F9780439
67281+:1058700001E41821AF63000C8F44095C8F83005C46
67282+:105880000083C0231B000003000000008F50095C50
67283+:10589000AF90005C0E000062000000008F8C005092
67284+:1058A0008E4700103C010800AC2C3D9400E0F80944
67285+:1058B000000000003C0D08008DAD3D6C55A0FEF5CC
67286+:1058C000240700068F450024975909088F8B006430
67287+:1058D0008F9400503C0F001F978200588F86005411
67288+:1058E0008F93004C3328FFFF35E9FF8000A9502437
67289+:1058F000000871C032320100AF4E0024A4C2002C57
67290+:10590000AF4A0024AF6B0044AF740050AF73005433
67291+:105910001640008032380010570000868EA4000424
67292+:10592000322300405460001B8EB100088EB0000C82
67293+:105930000200F809000000008FBF00308FB5002C76
67294+:105940008FB400288FB300248FB200208FB1001CC9
67295+:105950008FB0001803E0000827BD00389347010905
67296+:105960008F8800380007FE0003E8C825AF59008083
67297+:105970008F5809A08F5309A4AFB80010AF580E1468
67298+:105980008FB40010AF540E10AF530E1C0A00096202
67299+:10599000AF530E180220F809000000008EB0000C72
67300+:1059A0000200F809000000000A000AA88FBF0030BA
67301+:1059B000A5800020A59300220A000A5BAD93002475
67302+:1059C0003C09080095293D863C06080094C63D80A8
67303+:1059D0000A0009F4012610213C010800AC203D70AA
67304+:1059E0000A00098E8E4200003C010800AC243D7084
67305+:1059F0000A00098E8E4200003C03080094633D8A31
67306+:105A00003C04080094843D803C1F080097FF3D7CC7
67307+:105A1000951800240064C821033F782300186C0007
67308+:105A200025EEFFF201AE2825AC45000C240208004B
67309+:105A3000ACE20014ACE000100A0009EF24E7001803
67310+:105A400095060024950900280006240000091C0082
67311+:105A5000349F810034790800ACFF000CACF90010D1
67312+:105A60000A0009EF24E700141460FEFB00000000A8
67313+:105A70009518002400187C0035EE0800ACEE000CF0
67314+:105A80000A0009EF24E700103C07080094E73D8076
67315+:105A90003C04080094843D8A3C03080094633D7CE8
67316+:105AA00095190024951800280087F82103E378232E
67317+:105AB0002407080000192C0000186C0025EEFFEEEA
67318+:105AC00001AE302534A28100AD2700182527001C27
67319+:105AD000AD22000CAD2600100A0009EFAD20001425
67320+:105AE00093520109000028210E000602324400FFF3
67321+:105AF0008FBF00308FB5002C8FB400288FB30024E7
67322+:105B00008FB200208FB1001C8FB0001803E0000896
67323+:105B100027BD0038935F010933E400FF0E00066DD6
67324+:105B200000002821323800105300FF7E322300404D
67325+:105B30008EA400040080F809000000000A000AA2F8
67326+:105B4000322300401200FF5F000000008F540E144B
67327+:105B50008F920044AE5400208F530E1C0A000A8A14
67328+:105B6000AE5300248F82001C008040213C040100C1
67329+:105B70009047008530E3002010600009000000001D
67330+:105B80003C0708008CE73D948F83001800E3202336
67331+:105B9000048000089389000414E30003010020211D
67332+:105BA00003E00008008010213C04010003E000082D
67333+:105BB000008010211120000B006738238F8C0020FB
67334+:105BC00024090034918B00BC316A0002514000016D
67335+:105BD0002409003000E9682B15A0FFF10100202105
67336+:105BE00000E938232419FFFC00B9C02400F9782407
67337+:105BF00000F8702B15C0FFEA01E8202130C2000335
67338+:105C00000002182314C00012306900030000302184
67339+:105C100000A9702101C6682100ED602B1180FFE012
67340+:105C20003C0401002D2F00010006482B01053821FE
67341+:105C300001E9302414C0FFDA24E4FFFC2419FFFC3E
67342+:105C400000B9C0240308202103E0000800801021CF
67343+:105C50008F8B002024060004916A00BC31440004AC
67344+:105C60001480FFEC00A970210A000B5E00003021B7
67345+:105C700027BDFFE8AFBF00108F460100934A01091E
67346+:105C80003C1F08008FFF00902407FF80314F00FF6A
67347+:105C900031E8007F0008614003E6C821032CC021E1
67348+:105CA00027090120012770243C010800A02F3DD0C6
67349+:105CB000AF4E080C3C0D08008DAD00903C040080F8
67350+:105CC0003482000301A65821016C182124650120AB
67351+:105CD00030AA007801424025AF48081C3C1F08004C
67352+:105CE0008FFF00908F88004003E6C0213319000722
67353+:105CF00003074824033A7821AF49002825E909C061
67354+:105D0000952E00023C0D08008DAD008C3C0A080069
67355+:105D10008D4A009031CC3FFF01A61821000C59801C
67356+:105D2000006B282100A72024AF44002C95220002FC
67357+:105D30003C1F08008FFF008C9107008530593FFF02
67358+:105D400003E678210019C1800146702101F868211D
67359+:105D500031CC007F31AB007F019A2821017A50219C
67360+:105D60003C03000C3C04000E00A328210144102138
67361+:105D700030E6002027470980AF82002CAF88001C46
67362+:105D8000AF890024AF85002010C00006AF8700282F
67363+:105D90008D0200508CA4010C0044302318C0007701
67364+:105DA00000000000910C0085240DFFDF018D3824D8
67365+:105DB000A10700858F8B001C8F8900248F87002806
67366+:105DC0008D65004CAF850018912F000D31EE00203D
67367+:105DD00011C000170000000024090001A38900047D
67368+:105DE000AF80000C8CE400248F85000C240A00088E
67369+:105DF000AF800008AF8000103C010800A42A3D7E5F
67370+:105E00003C010800A4203D920E000B32000030211E
67371+:105E10008F8500248FBF0010AF82001490A8000D62
67372+:105E200027BD00180008394203E0000830E20001F5
67373+:105E3000913F00022418000133F900FF001921826C
67374+:105E400010980039240800021088005B8F86002C0F
67375+:105E50008CE5002414A0001B8F9F002091220000DD
67376+:105E6000240A00053046003F10CA00472404000100
67377+:105E70008F860008A3840004AF860010AF86000C54
67378+:105E80008CE400248F85000C240A00083C010800E3
67379+:105E9000A42A3D7E3C010800A4203D920E000B3256
67380+:105EA000000000008F8500248FBF0010AF82001417
67381+:105EB00090A8000D27BD00180008394203E0000833
67382+:105EC00030E200018CF800088CF900248FEE00C449
67383+:105ED000A38000048CE40024AF8E000C8F85000C9E
67384+:105EE0008F86000803197823240A0008AF8F00105A
67385+:105EF0003C010800A42A3D7E3C010800A4203D92FC
67386+:105F00000E000B32000000008F8500248FBF0010B0
67387+:105F1000AF82001490A8000D27BD00180008394278
67388+:105F200003E0000830E20001912300003062003FEE
67389+:105F3000104400278F8500208CE400241480002169
67390+:105F4000000000008D2E00183C187FFF8F85002078
67391+:105F5000370FFFFF01CF1824AF8300088F9F000881
67392+:105F60008CA8008403E8C82B1720000203E020213E
67393+:105F70008CA400840A000BEDAF8400088CA3010CF4
67394+:105F80000A000BCBAF8300188D2C00188F860008F9
67395+:105F90003C0D7FFF8F89002035A3FFFF018358242C
67396+:105FA00024040001AF8B0010AD2000CCA3840004BA
67397+:105FB0000A000BF9AF86000C8CCA00140A000BED26
67398+:105FC000AF8A00088CA300C80A000C30AF83000819
67399+:105FD0008F84002C8CAC00648C8D0014018D582BA8
67400+:105FE00011600004000000008CA200640A000C3064
67401+:105FF000AF8200088C8200140A000C30AF820008C7
67402+:106000008F85000C27BDFFE0AFBF0018AFB10014B3
67403+:1060100014A00007AFB000108F86002424020005F2
67404+:1060200090C400003083003F106200B68F840020CF
67405+:106030008F91000800A080218F8C00283C0508006B
67406+:106040008CA53D708D8B000431663FFF00C5502B41
67407+:106050005540000100C02821938D000411A0007359
67408+:1060600000B0F82B8F98002024040034930F00BC5C
67409+:1060700031EE000251C000012404003000A4C82BFE
67410+:10608000172000D10000000000A4282300B0F82B46
67411+:106090003C010800A4243D7C17E000680200202198
67412+:1060A0003C0308008C633D6C0083102B54400001BE
67413+:1060B000008018218F8800243C010800AC233D7427
67414+:1060C000000048219104000D308300205060000141
67415+:1060D0008F490E188F8300140123382B10E00059CC
67416+:1060E000000000003C0408008C843D7400895821A5
67417+:1060F000006B502B114000560090602B006930233C
67418+:1061000000C020213C010800AC263D7412000003B1
67419+:10611000241FFFFC1090008A32270003009FC82430
67420+:106120003C010800AC393D743C010800A4203D92BC
67421+:106130008F84000C120400078F830020AF910008A9
67422+:10614000020020218C7100CCAF90000C26300001A1
67423+:10615000AC7000CC3C0208008C423D748F8A001069
67424+:10616000240700180082202301422823AF84000C5A
67425+:1061700010800002AF850010240700108F86001CDD
67426+:106180003C010800A0273D902407004090CC0085EA
67427+:10619000318B00C0116700408F8D001414A00015D2
67428+:1061A00000002021934A01098F420974314500FF04
67429+:1061B0000002260224A300013090007F3071007F8E
67430+:1061C0001230007A2407FF80A0C300833C09080036
67431+:1061D0008D293D8C8F880024240D0002352C000869
67432+:1061E0003C010800A02D3DD13C010800AC2C3D8CA9
67433+:1061F00024040010910E000D31C6002010C00005CF
67434+:1062000000801821240800013C010800AC283D74DE
67435+:10621000348300018FBF00188FB100148FB00010BD
67436+:106220000060102103E0000827BD00203C010800A9
67437+:10623000A4203D7C13E0FF9A020020210A000C817B
67438+:1062400000A020213C0408008C843D740090602B49
67439+:106250001180FFAE000000003C0F080095EF3D7C70
67440+:1062600001E4702101C6682B11A000072C820004F4
67441+:106270003C1F60008FF954043338003F1700FFE5DE
67442+:10628000240300422C8200041040FFA0240300429B
67443+:106290000A000CDF8FBF0018152DFFC000000000A2
67444+:1062A0008CDF00743C0380002405FF8003E3C825D5
67445+:1062B000ACD9007490D80085240E0004240400108A
67446+:1062C000330F003F01E54025A0C800858F880024DA
67447+:1062D0003C010800A02E3DD1240300019106000DD1
67448+:1062E00030C9002015200003000000003C03080016
67449+:1062F0008C633D743C010800AC233D6C0A000CD655
67450+:10630000000000008F8700108C88008400E8282B94
67451+:1063100014A0000200E088218C910084240900016F
67452+:10632000A38900048F440E18022028210E000B328E
67453+:1063300002203021022080210A000C67AF82001465
67454+:1063400000071823306600033C010800A4263D9294
67455+:10635000122000058F8C0020918B00BC316A000454
67456+:106360001540001524CD00043C0F080095EF3D9228
67457+:1063700001E4702100AE302B50C0FF6E8F84000C02
67458+:106380002C85000514A0FFA32403004230980003CD
67459+:1063900017000002009818232483FFFC3C0108002A
67460+:1063A000AC233D740A000CA30000000000A7582491
67461+:1063B0000A000CCB016718263C010800A42D3D9271
67462+:1063C0000A000D33000000003C010800AC203D74C1
67463+:1063D0000A000CDE240300428F83001014600007C3
67464+:1063E000000010218F88002424050005910600007C
67465+:1063F00030C400FF108500030000000003E0000827
67466+:1064000000000000910A0018314900FF000939C25C
67467+:1064100014E0FFFA8F85001C3C04080094843D7C46
67468+:106420003C0308008C633D943C1908008F393D748F
67469+:106430003C0F080095EF3D920064C0218CAD0054E4
67470+:106440000319702101CF6021018D58231960001DAF
67471+:1064500000000000910E001C8F8C002C974B0E103A
67472+:1064600031CD00FF8D850004016D30238D88000043
67473+:1064700030CEFFFF000E510000AAC82100003821D5
67474+:1064800001072021032A182B0083C021AD990004A5
67475+:10649000AD980000918F000A01CF6821A18D000AFC
67476+:1064A0008F88002C974B0E12A50B0008950A003818
67477+:1064B00025490001A50900389107000D34E60008C0
67478+:1064C000A106000D03E000080000000027BDFFE06A
67479+:1064D000938700048F8F00248FAD00143C0E7FFF44
67480+:1064E0008F89000C35C8FFFFAFBF001CAFB000188C
67481+:1064F00001A8182491EA000D000717C03C1FBFFF38
67482+:10650000006258252D2E00018F90001837F9FFFFEB
67483+:106510003C1808008F183D943C0F080095EF3D8A09
67484+:1065200001796824000E47803C07EFFF3C05F0FF2F
67485+:1065300001A818253149002034E2FFFF34ACFFFFE9
67486+:106540000310582327A500102406000225EA0002A4
67487+:1065500000621824008080211520000200004021E4
67488+:106560008F480E1CA7AA0012056000372407000000
67489+:1065700030FF00FF001FCF008F8B001C00793825F3
67490+:10658000AFA70014916F00853C08080091083D9169
67491+:106590003C18DFFF31EE00C0370AFFFF000E182B5A
67492+:1065A0003C1F080097FF3D8400EA6824A3A800115F
67493+:1065B0000003174001A248258FB90010AFA90014AD
67494+:1065C0003C0A0800914A3D93A7BF00168FA800140B
67495+:1065D000032CC0243C0B01003C0F0FFF030B1825BC
67496+:1065E0003147000335EEFFFF010C68240007160059
67497+:1065F000006EF8243C09700001A2C82503E9582563
67498+:10660000AFB90014AFAB00100E000076A3A00015C8
67499+:106610008F8C0024260200089186000D30C40020D3
67500+:10662000108000068FBF001C3C05080094A53D802B
67501+:1066300024B0FFFF3C010800A4303D808FB000185B
67502+:1066400003E0000827BD00208F9800140118502B8C
67503+:106650005540FFC7240700010A000DB630FF00FFB8
67504+:106660009382000427BDFFE0AFBF00181040000F69
67505+:10667000008050218F880024240B00058F8900089A
67506+:10668000910700008F8400200100282130E3003FA3
67507+:106690008F86002C106B000800003821AFA9001075
67508+:1066A0000E00040EAFAA0014A38000048FBF0018D0
67509+:1066B00003E0000827BD00208D1900183C0F0800DA
67510+:1066C0008DEF3D748F9800103C027FFF8D08001401
67511+:1066D000345FFFFF033F682401F8702101AE60239F
67512+:1066E00001883821AFA900100E00040EAFAA0014D3
67513+:1066F0000A000E04A38000048F8700243C050800D4
67514+:1067000094A53D923C0208008C423D8C90E6000D21
67515+:106710000005240030C300201060002C00444025F8
67516+:106720008F85001C00006021240B000190A30085D0
67517+:1067300000004821240A00013C0F800035EE007063
67518+:106740008DC70000AF8700308F5801780700FFFE2B
67519+:106750003C038000347900708F3800003C0508004D
67520+:106760008CA500743C0D08008DAD007003077823E4
67521+:1067700000AF38210000102100EF302B01A22021B2
67522+:10678000008618213C010800AC2700743C01080079
67523+:10679000AC230070AF4B01483C1908008F393D9481
67524+:1067A000A7490144A74A0146AF59014C3C0B0800D8
67525+:1067B000916B3D91A34B0152AF4801543C0810002E
67526+:1067C000A74C015803E00008AF4801788F4B0E1C1E
67527+:1067D0003C0A08008D4A3D7497490E16974D0E14D9
67528+:1067E00001456021312AFFFF0A000E2731A9FFFF72
67529+:1067F0008F8300249064000D308200201040002917
67530+:10680000000000000000482100005021000040214D
67531+:106810003C07800034EB00708D670000AF870030CC
67532+:106820008F4C01780580FFFE3C0D800035AC007078
67533+:106830008D8B00003C0508008CA500743C0408000A
67534+:106840008C8400700167302300A67821000010219D
67535+:1068500001E6C82B0082C021031970213C01080009
67536+:10686000AC2F00743C010800AC2E0070AF49014809
67537+:106870003C0D08008DAD3D94A7480144240900401B
67538+:10688000A74A01463C081000240AFF91AF4D014C75
67539+:10689000A34A0152AF490154A740015803E0000840
67540+:1068A000AF4801788F490E1897460E1297450E1083
67541+:1068B00030CAFFFF0A000E5D30A8FFFF8F8300245F
67542+:1068C00027BDFFF89064000D308200201040003A90
67543+:1068D00000000000240B000100004821240A0001F0
67544+:1068E0003C088000350700708CE30000AF83003067
67545+:1068F0008F4C01780580FFFE3C0E80003C040800B0
67546+:1069000090843DD035C700708CEC00003C05080039
67547+:106910008CA50074A3A400033C1908008F390070F3
67548+:106920008FAD00000183302300A638210000102124
67549+:106930000322782100E6C02B01F8602101AE40253A
67550+:10694000AFA800003C010800AC2700743C0108001F
67551+:10695000AC2C00709346010A3C04080090843DD1A1
67552+:10696000A3A00002A3A600018FA300003C0580FFA6
67553+:106970003099007F34A2FFFF006278240019C6001E
67554+:1069800001F87025240D3000AF4E014C27BD0008E2
67555+:10699000AF4D0154A7400158AF4B0148A7490144EE
67556+:1069A000A74A01463C091000240AFF80A34A01526D
67557+:1069B00003E00008AF4901788F4B0E1897460E127E
67558+:1069C00097450E1030CAFFFF0A000E9130A9FFFF55
67559+:1069D0008F85001C2402008090A40085308300C0B5
67560+:1069E000106200058F8600208F8800088F87000CBA
67561+:1069F000ACC800C8ACC700C403E000080000000039
67562+:106A00003C0A0800254A39543C09080025293A2047
67563+:106A10003C08080025082DD43C07080024E73B3437
67564+:106A20003C06080024C637C43C05080024A5353CB4
67565+:106A30003C040800248431643C0308002463385C6F
67566+:106A40003C020800244236303C010800AC2A3D508C
67567+:106A50003C010800AC293D4C3C010800AC283D48F5
67568+:106A60003C010800AC273D543C010800AC263D64C5
67569+:106A70003C010800AC253D5C3C010800AC243D58BD
67570+:106A80003C010800AC233D683C010800AC223D609D
67571+:086A900003E000080000000013
67572+:00000001FF
67573diff --git a/firmware/bnx2/bnx2-mips-09-6.2.1b.fw.ihex b/firmware/bnx2/bnx2-mips-09-6.2.1b.fw.ihex
67574new file mode 100644
67575index 0000000..43d7c4f
67576--- /dev/null
67577+++ b/firmware/bnx2/bnx2-mips-09-6.2.1b.fw.ihex
67578@@ -0,0 +1,6496 @@
67579+:10000000080001180800000000005594000000C816
67580+:1000100000000000000000000000000008005594EF
67581+:10002000000000380000565C080000A00800000036
67582+:100030000000574400005694080059200000008436
67583+:100040000000ADD808005744000001C00000AE5CBD
67584+:100050000800321008000000000092580000B01C98
67585+:10006000000000000000000000000000080092589E
67586+:100070000000033C000142740800049008000400E2
67587+:10008000000012FC000145B000000000000000006C
67588+:1000900000000000080016FC00000004000158AC3D
67589+:1000A000080000A80800000000003D00000158B052
67590+:1000B00000000000000000000000000008003D00FB
67591+:1000C00000000030000195B00A000046000000006A
67592+:1000D000000000000000000D636F6D362E322E31DF
67593+:1000E00062000000060201020000000000000003A0
67594+:1000F000000000C800000032000000030000000003
67595+:1001000000000000000000000000000000000000EF
67596+:1001100000000010000001360000EA600000000549
67597+:1001200000000000000000000000000000000008C7
67598+:1001300000000000000000000000000000000000BF
67599+:1001400000000000000000000000000000000000AF
67600+:10015000000000000000000000000000000000009F
67601+:10016000000000020000000000000000000000008D
67602+:10017000000000000000000000000000000000007F
67603+:10018000000000000000000000000010000000005F
67604+:10019000000000000000000000000000000000005F
67605+:1001A000000000000000000000000000000000004F
67606+:1001B000000000000000000000000000000000003F
67607+:1001C000000000000000000000000000000000002F
67608+:1001D000000000000000000000000000000000001F
67609+:1001E0000000000010000003000000000000000DEF
67610+:1001F0000000000D3C020800244256083C030800A1
67611+:1002000024635754AC4000000043202B1480FFFDB2
67612+:10021000244200043C1D080037BD9FFC03A0F021D0
67613+:100220003C100800261001183C1C0800279C5608AA
67614+:100230000E000256000000000000000D27BDFFB4B4
67615+:10024000AFA10000AFA20004AFA30008AFA4000C50
67616+:10025000AFA50010AFA60014AFA70018AFA8001CF0
67617+:10026000AFA90020AFAA0024AFAB0028AFAC002C90
67618+:10027000AFAD0030AFAE0034AFAF0038AFB8003C28
67619+:10028000AFB90040AFBC0044AFBF00480E001544FA
67620+:10029000000000008FBF00488FBC00448FB90040B1
67621+:1002A0008FB8003C8FAF00388FAE00348FAD003078
67622+:1002B0008FAC002C8FAB00288FAA00248FA90020C0
67623+:1002C0008FA8001C8FA700188FA600148FA5001000
67624+:1002D0008FA4000C8FA300088FA200048FA1000040
67625+:1002E00027BD004C3C1B60108F7A5030377B502864
67626+:1002F00003400008AF7A00008F82002427BDFFE092
67627+:10030000AFB00010AFBF0018AFB100148C42000CAA
67628+:100310003C1080008E110100104000348FBF001887
67629+:100320000E000D84000000008F85002024047FFF54
67630+:100330000091202BACB100008E030104960201084D
67631+:1003400000031C003042FFFF00621825ACA300042C
67632+:100350009202010A96030114304200FF3063FFFF4E
67633+:100360000002140000431025ACA200089603010C03
67634+:100370009602010E00031C003042FFFF00621825A8
67635+:10038000ACA3000C960301109602011200031C009E
67636+:100390003042FFFF00621825ACA300108E02011846
67637+:1003A000ACA200148E02011CACA20018148000083C
67638+:1003B0008F820024978200003C0420050044182509
67639+:1003C00024420001ACA3001C0A0000C6A782000062
67640+:1003D0003C0340189442001E00431025ACA2001CB0
67641+:1003E0000E000DB8240400018FBF00188FB1001457
67642+:1003F0008FB000100000102103E0000827BD00208E
67643+:100400003C0780008CE202B834E50100044100089A
67644+:10041000240300013C0208008C42006024420001D9
67645+:100420003C010800AC22006003E0000800601021DD
67646+:100430003C0208008C42005C8CA4002094A30016AF
67647+:100440008CA6000494A5000E24420001ACE40280B6
67648+:100450002463FFFC3C010800AC22005C3C0210005D
67649+:10046000A4E30284A4E5028600001821ACE6028819
67650+:10047000ACE202B803E000080060102127BDFFE0F5
67651+:100480003C028000AFB0001034420100AFBF001C3E
67652+:10049000AFB20018AFB100148C43000094450008BF
67653+:1004A0002462FE002C42038110400003000381C23D
67654+:1004B0000A00010226100004240201001462000553
67655+:1004C0003C1180003C02800890420004305000FF44
67656+:1004D0003C11800036320100964300143202000FB6
67657+:1004E00000021500004310253C0308008C63004403
67658+:1004F00030A40004AE220080246300013C01080007
67659+:10050000AC2300441080000730A200028FBF001C03
67660+:100510008FB200188FB100148FB000100A0000CE07
67661+:1005200027BD00201040002D0000182130A20080BF
67662+:1005300010400005362200708E44001C0E000C672F
67663+:10054000240500A0362200708C4400008F82000C2D
67664+:10055000008210232C43012C10600004AF82001095
67665+:10056000240300010A000145AF84000C8E42000400
67666+:100570003C036020AF84000CAC6200143C02080015
67667+:100580008C42005850400015000018218C62000475
67668+:10059000240301FE304203FF144300100000182121
67669+:1005A0002E020004104000032E0200080A00014041
67670+:1005B0000000802114400003000000000A000140F8
67671+:1005C0002610FFF90000000D2402000202021004B0
67672+:1005D0003C036000AC626914000018218FBF001C4E
67673+:1005E0008FB200188FB100148FB00010006010217E
67674+:1005F00003E0000827BD00203C0480008C8301003C
67675+:1006000024020100506200033C0280080000000D3B
67676+:100610003C02800890430004000010213063000F6A
67677+:1006200000031D0003E00008AC8300800004188074
67678+:100630002782FF9C00621821000410C00044102390
67679+:100640008C640000000210C03C030800246356E4E0
67680+:10065000004310213C038000AC64009003E00008DC
67681+:10066000AF8200243C0208008C42011410400019A3
67682+:100670003084400030A2007F000231C03C02020002
67683+:100680001080001400A218253C026020AC43001426
67684+:100690003C0408008C8456B83C0308008C630110AD
67685+:1006A0003C02800024050900AC4500200086202182
67686+:1006B000246300013C028008AC4400643C01080053
67687+:1006C000AC2301103C010800AC2456B803E000083C
67688+:1006D000000000003C02602003E00008AC4500146C
67689+:1006E00003E000080000102103E0000800001021D2
67690+:1006F00030A2000810400008240201003C0208005B
67691+:100700008C42010C244200013C010800AC22010C87
67692+:1007100003E0000800000000148200080000000050
67693+:100720003C0208008C4200FC244200013C0108000D
67694+:10073000AC2200FC0A0001A330A200203C02080009
67695+:100740008C420084244200013C010800AC22008459
67696+:1007500030A200201040000830A200103C02080027
67697+:100760008C420108244200013C010800AC2201082F
67698+:1007700003E0000800000000104000080000000036
67699+:100780003C0208008C420104244200013C010800A4
67700+:10079000AC22010403E00008000000003C02080055
67701+:1007A0008C420100244200013C010800AC220100FF
67702+:1007B00003E000080000000027BDFFE0AFB1001417
67703+:1007C0003C118000AFB20018AFBF001CAFB00010EA
67704+:1007D0003632010096500008320200041040000733
67705+:1007E000320300028FBF001C8FB200188FB10014BB
67706+:1007F0008FB000100A0000CE27BD00201060000B53
67707+:10080000020028218E2401000E00018A0000000051
67708+:100810003202008010400003240500A10E000C6786
67709+:100820008E44001C0A0001E3240200018E2301040F
67710+:100830008F82000810430006020028218E24010048
67711+:100840000E00018A000000008E220104AF82000821
67712+:10085000000010218FBF001C8FB200188FB1001450
67713+:100860008FB0001003E0000827BD00202C82000498
67714+:1008700014400002000018212483FFFD240200021E
67715+:10088000006210043C03600003E00008AC626914DD
67716+:1008900027BDFFE0AFBF001CAFB20018AFB100141E
67717+:1008A000AFB000103C048000948201083043700017
67718+:1008B000240220001062000A2862200154400052E5
67719+:1008C0008FBF001C24024000106200482402600018
67720+:1008D0001062004A8FBF001C0A0002518FB200183C
67721+:1008E00034820100904300098C5000189451000C90
67722+:1008F000240200091062001C0000902128620009F7
67723+:10090000144000218F8200242402000A5062001249
67724+:10091000323100FF2402000B1062000F00000000C3
67725+:100920002402000C146200188F8200243C0208008C
67726+:100930008C4256B824030900AC83002000501021DB
67727+:100940003C038008AC6200643C010800AC2256B84D
67728+:100950000A0002508FBF001C0E0001E900102602A1
67729+:100960000A0002308F8200240E0001E900102602E6
67730+:100970003C0380089462001A8C72000C3042FFFF26
67731+:10098000020280258F8200248C42000C5040001E01
67732+:100990008FBF001C0E000D84000000003C02800090
67733+:1009A00034420100944300088F82002400031C009D
67734+:1009B0009444001E8F82002000641825AC50000073
67735+:1009C00024040001AC510004AC520008AC40000CFF
67736+:1009D000AC400010AC400014AC4000180E000DB844
67737+:1009E000AC43001C0A0002508FBF001C0E000440E4
67738+:1009F000000000000A0002508FBF001C0E000C9F78
67739+:100A0000000000008FBF001C8FB200188FB10014CF
67740+:100A10008FB000100000102103E0000827BD002067
67741+:100A200027BDFFD8AFB400203C036010AFBF002447
67742+:100A3000AFB3001CAFB20018AFB10014AFB00010DC
67743+:100A40008C6450002402FF7F3C1408002694563822
67744+:100A5000008220243484380CAC6450003C028000B6
67745+:100A6000240300370E0014B0AC4300083C07080014
67746+:100A700024E70618028010212404001D2484FFFFAF
67747+:100A8000AC4700000481FFFD244200043C02080042
67748+:100A9000244207C83C010800AC2256403C02080032
67749+:100AA000244202303C030800246306203C04080072
67750+:100AB000248403B43C05080024A506F03C06080085
67751+:100AC00024C62C9C3C010800AC2256803C02080045
67752+:100AD000244205303C010800AC2756843C01080044
67753+:100AE000AC2656943C010800AC23569C3C010800FF
67754+:100AF000AC2456A03C010800AC2556A43C010800DB
67755+:100B0000AC2256A83C010800AC23563C3C0108002E
67756+:100B1000AC2456443C010800AC2056603C0108005F
67757+:100B2000AC2556643C010800AC2056703C0108001E
67758+:100B3000AC27567C3C010800AC2656903C010800CE
67759+:100B4000AC2356980E00056E00000000AF80000C2C
67760+:100B50003C0280008C5300008F8300043C0208009C
67761+:100B60008C420020106200213262000700008821C0
67762+:100B70002792FF9C3C100800261056E43C02080017
67763+:100B80008C42002024050001022518040043202483
67764+:100B90008F820004004310245044000C26310001D1
67765+:100BA00010800008AF9000248E4300003C028000BB
67766+:100BB000AC4300900E000D4BAE05000C0A0002C1C4
67767+:100BC00026310001AE00000C263100012E22000269
67768+:100BD000261000381440FFE9265200043C020800A9
67769+:100BE0008C420020AF820004326200071040FFD91F
67770+:100BF0003C028000326200011040002D326200028F
67771+:100C00003C0580008CA2010000002021ACA2002045
67772+:100C10008CA301042C42078110400008ACA300A85B
67773+:100C200094A2010824032000304270001443000302
67774+:100C30003C02800890420005304400FF0E0001593C
67775+:100C4000000000003C0280009042010B304300FF96
67776+:100C50002C62001E54400004000310800E00018628
67777+:100C60000A0002EC00000000005410218C42000039
67778+:100C70000040F80900000000104000043C02800021
67779+:100C80008C4301043C026020AC4300143C02080089
67780+:100C90008C4200343C0440003C03800024420001AC
67781+:100CA000AC6401383C010800AC220034326200021E
67782+:100CB00010400010326200043C1080008E0201409F
67783+:100CC000000020210E000159AE0200200E00038317
67784+:100CD000000000003C024000AE0201783C02080027
67785+:100CE0008C420038244200013C010800AC2200384C
67786+:100CF000326200041040FF973C0280003C108000EC
67787+:100D00008E020180000020210E000159AE02002059
67788+:100D10008E03018024020F00546200073C02800809
67789+:100D20008E0201883C0300E03042FFFF00431025A3
67790+:100D30000A000328AE020080344200809042000086
67791+:100D400024030050304200FF14430007000000005D
67792+:100D50000E000362000000001440000300000000C9
67793+:100D60000E000971000000003C0208008C42003CAB
67794+:100D70003C0440003C03800024420001AC6401B804
67795+:100D80003C010800AC22003C0A0002A33C028000A7
67796+:100D90003C02900034420001008220253C02800089
67797+:100DA000AC4400203C0380008C6200200440FFFE25
67798+:100DB0000000000003E00008000000003C0280008A
67799+:100DC000344300010083202503E00008AC440020E8
67800+:100DD00027BDFFE0AFB10014AFB000100080882144
67801+:100DE000AFBF00180E00033230B000FF8F83FF94B6
67802+:100DF000022020219062002502028025A07000259B
67803+:100E00008C7000183C0280000E00033D020280241A
67804+:100E10001600000B8FBF00183C0480008C8201F884
67805+:100E20000440FFFE348201C024030002AC510000E4
67806+:100E3000A04300043C021000AC8201F88FBF0018F0
67807+:100E40008FB100148FB0001003E0000827BD002010
67808+:100E500027BDFFE83C028000AFBF00103442018094
67809+:100E6000944300048C4400083063020010600005C5
67810+:100E7000000028210E00100C000000000A0003787A
67811+:100E8000240500013C02FF000480000700821824B2
67812+:100E90003C02040014620004240500018F82FF94C8
67813+:100EA00090420008240500018FBF001000A010210F
67814+:100EB00003E0000827BD00188F82FF982405000179
67815+:100EC000A040001A3C028000344201400A00034264
67816+:100ED0008C4400008F85FF9427BDFFE0AFBF001C4E
67817+:100EE000AFB20018AFB10014AFB0001090A2000074
67818+:100EF000304400FF38830020388200300003182B74
67819+:100F00000002102B0062182410600003240200501D
67820+:100F1000148200A88FBF001C90A20005304200017F
67821+:100F2000104000A48FBF001C3C02800034420140EE
67822+:100F3000904200082443FFFF2C6200051040009EF1
67823+:100F40008FB20018000310803C030800246355ACE6
67824+:100F5000004310218C420000004000080000000007
67825+:100F60003C028000345101400E0003328E24000008
67826+:100F70008F92FF948E2200048E50000C1602000205
67827+:100F800024020001AE42000C0E00033D8E2400003E
67828+:100F90008E220004145000068FBF001C8FB2001870
67829+:100FA0008FB100148FB000100A000F7827BD002009
67830+:100FB0008E42000C0A000419000000003C0480006E
67831+:100FC0003482014094A300108C4200043063FFFF80
67832+:100FD0001443001C0000000024020001A4A2001021
67833+:100FE0008C8202380441000F3C0380003C02003F29
67834+:100FF0003448F0003C0760003C06FFC08CE22BBC8C
67835+:1010000000461824004810240002130200031D8229
67836+:10101000106200583C0280008C8202380440FFF7C6
67837+:101020003C038000346201408C44000034620200C2
67838+:10103000AC4400003C021000AC6202380A00043BE1
67839+:101040008FBF001C94A200100A00041900000000C9
67840+:10105000240200201482000F3C0280003C03800028
67841+:1010600094A20012346301408C6300043042FFFFFD
67842+:10107000146200050000000024020001A4A2001276
67843+:101080000A0004028FBF001C94A200120A00041977
67844+:1010900000000000345101400E0003328E24000095
67845+:1010A0008F92FF948E230004964200123050FFFF6F
67846+:1010B0001603000224020001A64200120E00033DA6
67847+:1010C0008E2400008E220004160200068FBF001C32
67848+:1010D0008FB200188FB100148FB000100A00037C8B
67849+:1010E00027BD0020964200120A00041900000000EB
67850+:1010F0003C03800094A20014346301408C6300041C
67851+:101100003042FFFF14620008240200018FBF001C60
67852+:101110008FB200188FB100148FB00010A4A2001479
67853+:101120000A00146327BD002094A20014144000217B
67854+:101130008FBF001C0A000435000000003C03800043
67855+:1011400094A20016346301408C6300043042FFFF18
67856+:101150001462000D240200018FBF001C8FB2001822
67857+:101160008FB100148FB00010A4A200160A000B1457
67858+:1011700027BD00209442007824420004A4A200105D
67859+:101180000A00043B8FBF001C94A200162403000138
67860+:101190003042FFFF144300078FBF001C3C020800D1
67861+:1011A0008C420070244200013C010800AC22007017
67862+:1011B0008FBF001C8FB200188FB100148FB00010C9
67863+:1011C00003E0000827BD002027BDFFD8AFB20018FC
67864+:1011D0008F92FF94AFB10014AFBF0020AFB3001CDB
67865+:1011E000AFB000103C028000345101008C5001006F
67866+:1011F0009242000092230009304400FF2402001FA5
67867+:10120000106200AB28620020104000192402003850
67868+:101210002862000A1040000D2402000B286200081A
67869+:101220001040002E8F820024046001042862000216
67870+:101230001440002A8F820024240200061062002637
67871+:101240008FBF00200A00055F8FB3001C1062006092
67872+:101250002862000B144000FA8FBF00202402000E09
67873+:10126000106200788F8200240A00055F8FB3001C93
67874+:10127000106200D2286200391040000A2402008067
67875+:1012800024020036106200E528620037104000C3D7
67876+:1012900024020035106200D98FBF00200A00055FCC
67877+:1012A0008FB3001C1062002D2862008110400006E0
67878+:1012B000240200C824020039106200C98FBF002038
67879+:1012C0000A00055F8FB3001C106200A28FBF0020D0
67880+:1012D0000A00055F8FB3001C8F8200248C42000C33
67881+:1012E000104000D78FBF00200E000D8400000000CA
67882+:1012F0003C038000346301008C6200008F85002075
67883+:10130000946700089466000CACA200008C64000492
67884+:101310008F82002400063400ACA400049448001E10
67885+:101320008C62001800073C0000E83825ACA20008D9
67886+:101330008C62001C24040001ACA2000C9062000A24
67887+:1013400000C23025ACA60010ACA00014ACA0001860
67888+:10135000ACA7001C0A00051D8FBF00208F8200244F
67889+:101360008C42000C104000B68FBF00200E000D8490
67890+:10137000000000008F820024962400089625000CAF
67891+:101380009443001E000422029626000E8F82002045
67892+:10139000000426000083202500052C003C0300806B
67893+:1013A00000A6282500832025AC400000AC400004A6
67894+:1013B000AC400008AC40000CAC450010AC40001440
67895+:1013C000AC400018AC44001C0A00051C24040001B9
67896+:1013D0009622000C14400018000000009242000504
67897+:1013E0003042001014400014000000000E000332D0
67898+:1013F0000200202192420005020020213442001008
67899+:101400000E00033DA242000592420000240300208A
67900+:10141000304200FF10430089020020218FBF0020CE
67901+:101420008FB3001C8FB200188FB100148FB0001062
67902+:101430000A00107527BD00280000000D0A00055E97
67903+:101440008FBF00208C42000C1040007D8FBF002019
67904+:101450000E000D84000000008E2200048F84002006
67905+:101460009623000CAC8200003C0280089445002CBE
67906+:101470008F82002400031C0030A5FFFF9446001E4D
67907+:101480003C02400E0065182500C23025AC830004E4
67908+:10149000AC800008AC80000CAC800010AC80001464
67909+:1014A000AC800018AC86001C0A00051C2404000156
67910+:1014B0000E000332020020218F93FF9802002021AA
67911+:1014C0000E00033DA660000C020020210E00034226
67912+:1014D000240500018F8200248C42000C104000582B
67913+:1014E0008FBF00200E000D84000000009622000C2B
67914+:1014F0008F83002000021400AC700000AC62000476
67915+:10150000AC6000088E4400388F820024AC64000C6C
67916+:101510008E46003C9445001E3C02401FAC66001005
67917+:1015200000A228258E62000424040001AC6200148D
67918+:10153000AC600018AC65001C8FBF00208FB3001C8E
67919+:101540008FB200188FB100148FB000100A000DB8D0
67920+:1015500027BD0028240200201082003A8FB3001C0F
67921+:101560000E000F5E00000000104000358FBF00200D
67922+:101570003C0480008C8201F80440FFFE348201C0EC
67923+:1015800024030002AC500000A04300043C02100001
67924+:10159000AC8201F80A00055E8FBF00200200202106
67925+:1015A0008FBF00208FB3001C8FB200188FB10014C2
67926+:1015B0008FB000100A000EA727BD00289625000C4A
67927+:1015C000020020218FBF00208FB3001C8FB20018B3
67928+:1015D0008FB100148FB000100A000ECC27BD002878
67929+:1015E000020020218FB3001C8FB200188FB10014AD
67930+:1015F0008FB000100A000EF727BD00289225000DBD
67931+:10160000020020218FB3001C8FB200188FB100148C
67932+:101610008FB000100A000F4827BD002802002021CB
67933+:101620008FBF00208FB3001C8FB200188FB1001441
67934+:101630008FB000100A000F1F27BD00288FBF0020A9
67935+:101640008FB3001C8FB200188FB100148FB0001040
67936+:1016500003E0000827BD00283C0580008CA202782A
67937+:101660000440FFFE34A2024024030002AC44000008
67938+:10167000A04300043C02100003E00008ACA2027882
67939+:10168000A380001803E00008A38000193C03800039
67940+:101690008C6202780440FFFE8F82001CAC62024024
67941+:1016A00024020002A06202443C02100003E0000891
67942+:1016B000AC6202783C02600003E000088C425404F3
67943+:1016C0009083003024020005008040213063003FF9
67944+:1016D0000000482114620005000050219082004C57
67945+:1016E0009483004E304900FF306AFFFFAD00000CCC
67946+:1016F000AD000010AD000024950200148D05001C03
67947+:101700008D0400183042FFFF004910230002110031
67948+:10171000000237C3004038210086202300A2102B8E
67949+:101720000082202300A72823AD05001CAD0400186B
67950+:10173000A5090014A5090020A50A001603E0000869
67951+:10174000A50A002203E000080000000027BDFFD822
67952+:10175000AFB200183C128008AFB40020AFB3001C39
67953+:10176000AFB10014AFBF0024AFB00010365101007C
67954+:101770003C0260008C4254049222000C3C1408008D
67955+:10178000929400F7304300FF2402000110620032FF
67956+:101790000080982124020002146200353650008037
67957+:1017A0000E00143D000000009202004C2403FF8054
67958+:1017B0003C0480003042007F000211C024420240FD
67959+:1017C0000262102100431824AC8300949245000863
67960+:1017D0009204004C3042007F3C03800614850007D1
67961+:1017E000004380212402FFFFA22200112402FFFFF8
67962+:1017F000A62200120A0005D22402FFFF9602002052
67963+:10180000A222001196020022A62200128E020024BB
67964+:101810003C048008AE2200143485008090A2004C65
67965+:1018200034830100A06200108CA2003CAC6200185E
67966+:101830008C820068AC6200F48C820064AC6200F0C0
67967+:101840008C82006CAC6200F824020001A0A2006847
67968+:101850000A0005EE3C0480080E001456000000004B
67969+:1018600036420080A04000680A0005EE3C04800873
67970+:10187000A2000068A20000690A0006293C02800854
67971+:10188000348300808C62003834850100AC62006CC7
67972+:1018900024020001A062006990A200D59083000894
67973+:1018A000305100FF3072007F12320019001111C058
67974+:1018B00024420240026210212403FF8000431824C6
67975+:1018C0003C048000AC8300943042007F3C038006DF
67976+:1018D000004380218E02000C1040000D02002021E8
67977+:1018E0000E00057E0000000026220001305100FF9E
67978+:1018F0009203003C023410260002102B0002102339
67979+:101900003063007F022288240A0005F8A203003C0D
67980+:101910003C088008350401008C8200E03507008017
67981+:10192000ACE2003C8C8200E0AD02000090E5004C8F
67982+:10193000908600D590E3004C908400D52402FF806F
67983+:1019400000A228243063007F308400FF00A62825F1
67984+:101950000064182A1060000230A500FF38A500803E
67985+:10196000A0E5004CA10500093C0280089043000E50
67986+:10197000344400803C058000A043000A8C8300189A
67987+:101980003C027FFF3442FFFF00621824AC83001842
67988+:101990008CA201F80440FFFE00000000ACB301C0BF
67989+:1019A0008FBF00248FB400208FB3001C8FB20018AB
67990+:1019B0008FB100148FB0001024020002A0A201C455
67991+:1019C00027BD00283C02100003E00008ACA201F88B
67992+:1019D00090A2000024420001A0A200003C030800E5
67993+:1019E0008C6300F4304200FF144300020080302179
67994+:1019F000A0A0000090A200008F84001C000211C073
67995+:101A00002442024024830040008220212402FF80DF
67996+:101A1000008220243063007F3C02800A006218218B
67997+:101A20003C028000AC44002403E00008ACC300008A
67998+:101A300094820006908300058C85000C8C86001033
67999+:101A40008C8700188C88001C8C8400203C010800C6
68000+:101A5000A42256C63C010800A02356C53C0108003C
68001+:101A6000AC2556CC3C010800AC2656D03C01080001
68002+:101A7000AC2756D83C010800AC2856DC3C010800D5
68003+:101A8000AC2456E003E00008000000003C0280089F
68004+:101A9000344201008C4400343C038000346504006F
68005+:101AA000AC6400388C420038AF850028AC62003C42
68006+:101AB0003C020005AC6200300000000000000000A5
68007+:101AC00003E00008000000003C020006308400FF34
68008+:101AD000008220253C028000AC4400300000000061
68009+:101AE00000000000000000003C0380008C62000049
68010+:101AF000304200101040FFFD3462040003E0000893
68011+:101B0000AF82002894C200003C080800950800CA73
68012+:101B100030E7FFFF0080482101021021A4C200002D
68013+:101B200094C200003042FFFF00E2102B544000013D
68014+:101B3000A4C7000094A200003C0308008C6300CC02
68015+:101B400024420001A4A2000094A200003042FFFF42
68016+:101B5000144300073C0280080107102BA4A00000DA
68017+:101B60005440000101003821A4C700003C02800855
68018+:101B7000344601008CC3002894A200003C0480007D
68019+:101B80003042FFFE000210C000621021AC82003C17
68020+:101B90008C82003C006218231860000400000000E2
68021+:101BA0008CC200240A0006BA244200018CC2002420
68022+:101BB000AC8200383C020050344200103C038000EC
68023+:101BC000AC620030000000000000000000000000D7
68024+:101BD0008C620000304200201040FFFD0000000039
68025+:101BE00094A200003C04800030420001000210C0BA
68026+:101BF000004410218C430400AD2300008C420404F7
68027+:101C0000AD2200043C02002003E00008AC8200305A
68028+:101C100027BDFFE0AFB20018AFB10014AFB00010A5
68029+:101C2000AFBF001C94C2000000C080213C1208001D
68030+:101C3000965200C624420001A6020000960300004E
68031+:101C400094E2000000E03021144300058FB1003021
68032+:101C50000E00068F024038210A0006F10000000045
68033+:101C60008C8300048C82000424420040046100073D
68034+:101C7000AC8200048C8200040440000400000000D8
68035+:101C80008C82000024420001AC8200009602000019
68036+:101C90003042FFFF50520001A600000096220000D3
68037+:101CA00024420001A62200003C02800834420100C8
68038+:101CB000962300009442003C144300048FBF001C94
68039+:101CC00024020001A62200008FBF001C8FB2001862
68040+:101CD0008FB100148FB0001003E0000827BD002072
68041+:101CE00027BDFFE03C028008AFBF0018344201006E
68042+:101CF0008C4800343C03800034690400AC68003830
68043+:101D00008C42003830E700FFAF890028AC62003C0D
68044+:101D10003C020005AC620030000000000000000042
68045+:101D200000000000000000000000000000000000B3
68046+:101D30008C82000C8C82000C97830016AD22000070
68047+:101D40008C82001000604021AD2200048C820018BB
68048+:101D5000AD2200088C82001CAD22000C8CA2001465
68049+:101D6000AD2200108C820020AD220014908200056C
68050+:101D7000304200FF00021200AD2200188CA20018B1
68051+:101D8000AD22001C8CA2000CAD2200208CA2001001
68052+:101D9000AD2200248CA2001CAD2200288CA20020C1
68053+:101DA000AD22002C3402FFFFAD260030AD20003400
68054+:101DB000506200013408FFFFAD28003850E00011E8
68055+:101DC0003C0280083C048008348401009482005066
68056+:101DD0003042FFFFAD22003C9483004494850044D0
68057+:101DE000240200013063FFFF000318C200641821C1
68058+:101DF0009064006430A5000700A210040A00075C8C
68059+:101E00000044102534420100AD20003C94430044BE
68060+:101E1000944400443063FFFF000318C2006218219D
68061+:101E200030840007906500642402000100821004E1
68062+:101E30000002102700451024A0620064000000008A
68063+:101E400000000000000000003C0200063442004098
68064+:101E50003C038000AC620030000000000000000085
68065+:101E6000000000008C620000304200101040FFFDB6
68066+:101E70003C06800834C201503463040034C7014A70
68067+:101E800034C4013434C5014034C60144AFA200104B
68068+:101E90000E0006D2AF8300288FBF001803E00008B1
68069+:101EA00027BD00208F8300143C0608008CC600E884
68070+:101EB0008F82001C30633FFF000319800046102111
68071+:101EC000004310212403FF80004318243C068000B7
68072+:101ED000ACC300283042007F3C03800C004330211B
68073+:101EE00090C2000D30A500FF0000382134420010E0
68074+:101EF000A0C2000D8F8900143C028008344201000A
68075+:101F00009443004400091382304800032402000176
68076+:101F1000A4C3000E1102000B2902000210400005AC
68077+:101F2000240200021100000C240300010A0007A48F
68078+:101F30000000182111020006000000000A0007A49A
68079+:101F4000000018218CC2002C0A0007A424430001C1
68080+:101F50008CC20014244300018CC200180043102BD3
68081+:101F60005040000A240700012402002714A20003A5
68082+:101F70003C0380080A0007B1240700013463010014
68083+:101F80009462004C24420001A462004C00091382B8
68084+:101F9000304300032C620002104000090080282119
68085+:101FA000146000040000000094C200340A0007C15D
68086+:101FB0003046FFFF8CC600380A0007C10080282188
68087+:101FC000000030213C040800248456C00A000706A3
68088+:101FD0000000000027BDFF90AFB60068AFB50064F9
68089+:101FE000AFB40060AFB3005CAFB20058AFB1005403
68090+:101FF000AFBF006CAFB000508C9000000080B021EB
68091+:102000003C0208008C4200E8960400328F83001CDA
68092+:102010002414FF8030843FFF0062182100042180D7
68093+:1020200000641821007410243C13800000A090214B
68094+:1020300090A50000AE620028920400323C02800CA1
68095+:102040003063007F00628821308400C02402004099
68096+:10205000148200320000A8218E3500388E2200182C
68097+:102060001440000224020001AE2200189202003C3B
68098+:10207000304200201440000E8F83001C000511C068
68099+:102080002442024000621821306400783C02008043
68100+:102090000082202500741824AE630800AE64081086
68101+:1020A0008E2200188E03000800431021AE22001873
68102+:1020B0008E22002C8E230018244200010062182B6F
68103+:1020C0001060004300000000924200002442000122
68104+:1020D000A24200003C0308008C6300F4304200FF81
68105+:1020E00050430001A2400000924200008F84001C77
68106+:1020F000000211C024420240248300403063007F6C
68107+:10210000008220213C02800A0094202400621821D1
68108+:10211000AE6400240A0008D2AEC30000920300326D
68109+:102120002402FFC000431024304200FF1440000589
68110+:1021300024020001AE220018962200340A00084250
68111+:102140003055FFFF8E22001424420001AE220018F9
68112+:102150009202003000021600000216030441001C27
68113+:10216000000000009602003227A400100080282101
68114+:10217000A7A20016960200320000302124070001B9
68115+:102180003042FFFFAF8200140E000706AFA0001C14
68116+:10219000960200328F83001C3C0408008C8400E807
68117+:1021A00030423FFF000211800064182100621821B4
68118+:1021B00000741024AE62002C3063007F3C02800E5D
68119+:1021C000006218219062000D3042007FA062000D75
68120+:1021D0009222000D304200105040007892420000E0
68121+:1021E0003C028008344401009482004C8EC30000FD
68122+:1021F0003C130800967300C62442FFFFA482004CE3
68123+:10220000946200329623000E3054FFFF3070FFFFBF
68124+:102210003C0308008C6300D000701807A7A30038A7
68125+:102220009482003E3063FFFF3042FFFF14620007DC
68126+:10223000000000008C8200303C038000244200300B
68127+:10224000AC62003C0A00086A8C82002C9482004038
68128+:102250003042FFFF5462000927A400408C820038FE
68129+:102260003C03800024420030AC62003C8C8200348D
68130+:10227000AC6200380A0008793C03800027A50038CA
68131+:1022800027A60048026038210E00068FA7A000484C
68132+:102290008FA300403C02800024630030AC43003830
68133+:1022A0008FA30044AC43003C3C0380003C0200058B
68134+:1022B000AC6200303C028008344401009482004249
68135+:1022C000346304003042FFFF0202102B1440000769
68136+:1022D000AF8300289482004E9483004202021021B2
68137+:1022E000004310230A00088F3043FFFF9483004E01
68138+:1022F00094820042026318210050102300621823C8
68139+:102300003063FFFF3C028008344401009482003CAB
68140+:102310003042FFFF14430003000000000A00089F42
68141+:10232000240300019482003C3042FFFF0062102B26
68142+:10233000144000058F8200289482003C0062102324
68143+:102340003043FFFF8F820028AC550000AC400004F2
68144+:10235000AC540008AC43000C3C02000634420010B0
68145+:102360003C038000AC620030000000000000000070
68146+:10237000000000008C620000304200101040FFFDA1
68147+:102380003C04800834840100001018C20064182145
68148+:102390009065006432020007240600010046100424
68149+:1023A00000451025A0620064948300429622000E2E
68150+:1023B00050430001A386001892420000244200010D
68151+:1023C000A24200003C0308008C6300F4304200FF8E
68152+:1023D00050430001A2400000924200008F84001C84
68153+:1023E000000211C0244202402483004000822021C8
68154+:1023F0002402FF80008220243063007F3C02800A98
68155+:10240000006218213C028000AC440024AEC30000EE
68156+:102410008FBF006C8FB600688FB500648FB400600A
68157+:102420008FB3005C8FB200588FB100548FB0005052
68158+:1024300003E0000827BD007027BDFFD8AFB3001C24
68159+:10244000AFB20018AFB10014AFB00010AFBF0020A2
68160+:102450000080982100E0802130B1FFFF0E000D8444
68161+:1024600030D200FF0000000000000000000000006B
68162+:102470008F8200208F830024AC510000AC520004F6
68163+:10248000AC530008AC40000CAC400010AC40001451
68164+:10249000AC4000189463001E02038025AC50001C61
68165+:1024A0000000000000000000000000002404000103
68166+:1024B0008FBF00208FB3001C8FB200188FB10014A3
68167+:1024C0008FB000100A000DB827BD002830A5FFFF0F
68168+:1024D0000A0008DC30C600FF3C02800834430100DB
68169+:1024E0009462000E3C080800950800C63046FFFFC5
68170+:1024F00014C000043402FFFF946500EA0A000929B1
68171+:102500008F84001C10C20027000000009462004E5F
68172+:102510009464003C3045FFFF00A6102300A6182B52
68173+:102520003087FFFF106000043044FFFF00C5102318
68174+:1025300000E210233044FFFF0088102B1040000EF3
68175+:1025400000E810233C028008344401002403000109
68176+:1025500034420080A44300162402FFFFA482000E30
68177+:10256000948500EA8F84001C0000302130A5FFFF15
68178+:102570000A0009013C0760200044102A10400009AD
68179+:102580003C0280083443008094620016304200010F
68180+:10259000104000043C0280009442007E244200145B
68181+:1025A000A462001603E000080000000027BDFFE061
68182+:1025B0003C028008AFBF001CAFB0001834420100DD
68183+:1025C000944300429442004C104000193068FFFFD1
68184+:1025D0009383001824020001146200298FBF001C9D
68185+:1025E0003C06800834D00100000810C200501021C1
68186+:1025F000904200643103000734C70148304200FFB5
68187+:10260000006210073042000134C9014E34C4012C6D
68188+:1026100034C5013E1040001634C601420E0006D2F9
68189+:10262000AFA90010960200420A0009463048FFFF99
68190+:102630003C028008344401009483004494820042A8
68191+:102640001043000F8FBF001C94820044A4820042FC
68192+:1026500094820050A482004E8C820038AC820030FC
68193+:1026600094820040A482003E9482004AA4820048E2
68194+:102670008FBF001C8FB000180A00090427BD00207E
68195+:102680008FB0001803E0000827BD002027BDFFA081
68196+:10269000AFB1004C3C118000AFBF0058AFB3005445
68197+:1026A000AFB20050AFB000483626018890C2000398
68198+:1026B0003044007FA3A400108E32018090C200003D
68199+:1026C0003043007F240200031062003BAF92001CE5
68200+:1026D00028620004104000062402000424020002C4
68201+:1026E000106200098FBF00580A000B0F8FB300540F
68202+:1026F0001062004D240200051062014E8FBF005889
68203+:102700000A000B0F8FB30054000411C002421021C5
68204+:102710002404FF8024420240004410242643004049
68205+:10272000AE2200243063007F3C02800A0062182140
68206+:102730009062003CAFA3003C00441025A062003C26
68207+:102740008FA3003C9062003C304200401040016C7E
68208+:102750008FBF00583C108008A3800018361001007D
68209+:102760008E0200E08C63003427A4003C27A50010F3
68210+:10277000004310210E0007C3AE0200E093A2001038
68211+:102780003C038000A20200D58C6202780440FFFE68
68212+:102790008F82001CAC62024024020002A06202444C
68213+:1027A0003C021000AC6202780E0009390000000003
68214+:1027B0000A000B0E8FBF00583C05800890C3000133
68215+:1027C00090A2000B1443014E8FBF005834A4008028
68216+:1027D0008C8200189082004C90A200083C0260009D
68217+:1027E0008C4254048C8300183C027FFF3442FFFF6C
68218+:1027F000006218243C0208008C4200B4AC8300182C
68219+:102800003C038000244200013C010800AC2200B4DB
68220+:102810008C6201F80440FFFE8F82001CAC6201C094
68221+:102820000A000AD6240200023C10800890C300016E
68222+:102830009202000B144301328FBF005827A40018E6
68223+:1028400036050110240600033C0260008C4254044B
68224+:102850000E000E470000000027A40028360501F0F6
68225+:102860000E000E47240600038FA200283603010045
68226+:10287000AE0200648FA2002CAE0200688FA200306E
68227+:10288000AE02006C93A40018906300D52402FF8070
68228+:102890000082102400431025304900FF3084007F5F
68229+:1028A0003122007F0082102A544000013929008023
68230+:1028B000000411C0244202402403FF800242102180
68231+:1028C00000431024AE220094264200403042007F94
68232+:1028D0003C038006004340218FA3001C2402FFFF1D
68233+:1028E000AFA800403C130800927300F71062003359
68234+:1028F00093A2001995030014304400FF3063FFFFDA
68235+:102900000064182B106000100000000095040014F3
68236+:102910008D07001C8D0600183084FFFF0044202323
68237+:102920000004210000E438210000102100E4202BE5
68238+:1029300000C2302100C43021AD07001CAD060018D4
68239+:102940000A000A2F93A20019950400148D07001C99
68240+:102950008D0600183084FFFF008220230004210030
68241+:10296000000010210080182100C2302300E4202B39
68242+:1029700000C4302300E33823AD07001CAD06001867
68243+:1029800093A200198FA30040A462001497A2001A1A
68244+:10299000A46200168FA2001CAC6200108FA2001C63
68245+:1029A000AC62000C93A20019A462002097A2001A46
68246+:1029B000A46200228FA2001CAC6200243C048008A8
68247+:1029C000348300808C6200388FA20020012088218F
68248+:1029D000AC62003C8FA20020AC82000093A20018E1
68249+:1029E000A062004C93A20018A0820009A0600068B9
68250+:1029F00093A20018105100512407FF803229007F54
68251+:102A0000000911C024420240024210213046007FDA
68252+:102A10003C03800000471024AC6200943C02800616
68253+:102A200000C2302190C2003CAFA60040000020212F
68254+:102A300000471025A0C2003C8FA80040950200026C
68255+:102A4000950300148D07001C3042FFFF3063FFFF29
68256+:102A50008D060018004310230002110000E2382107
68257+:102A600000E2102B00C4302100C23021AD07001C51
68258+:102A7000AD06001895020002A5020014A50000167C
68259+:102A80008D020008AD0200108D020008AD02000C9E
68260+:102A900095020002A5020020A50000228D02000878
68261+:102AA000AD0200249102003C304200401040001A68
68262+:102AB000262200013C108008A3A90038A38000183A
68263+:102AC000361001008E0200E08D03003427A4004080
68264+:102AD00027A50038004310210E0007C3AE0200E016
68265+:102AE00093A200383C038000A20200D58C620278D9
68266+:102AF0000440FFFE8F82001CAC62024024020002F0
68267+:102B0000A06202443C021000AC6202780E00093957
68268+:102B100000000000262200013043007F14730004EF
68269+:102B2000004020212403FF8002231024004320269C
68270+:102B300093A200180A000A4B309100FF93A40018DA
68271+:102B40008FA3001C2402FFFF1062000A308900FFDF
68272+:102B500024820001248300013042007F14530005C9
68273+:102B6000306900FF2403FF800083102400431026F7
68274+:102B7000304900FF3C028008904200080120882173
68275+:102B8000305000FF123000193222007F000211C0C5
68276+:102B900002421021244202402403FF8000431824F3
68277+:102BA0003C048000AC8300943042007F3C038006EC
68278+:102BB000004310218C43000C004020211060000BCA
68279+:102BC000AFA200400E00057E000000002623000199
68280+:102BD0002405FF803062007F145300020225202468
68281+:102BE000008518260A000AAF307100FF3C048008F7
68282+:102BF000348400808C8300183C027FFF3442FFFF46
68283+:102C000000621824AC8300183C0380008C6201F839
68284+:102C10000440FFFE00000000AC7201C0240200026C
68285+:102C2000A06201C43C021000AC6201F80A000B0E65
68286+:102C30008FBF00583C04800890C300019082000BB5
68287+:102C40001443002F8FBF0058349000809202000878
68288+:102C500030420040104000200000000092020008B6
68289+:102C60000002160000021603044100050240202164
68290+:102C70000E000ECC240500930A000B0E8FBF0058E7
68291+:102C80009202000924030018304200FF1443000D93
68292+:102C900002402021240500390E000E64000030217E
68293+:102CA0000E0003328F84001C8F82FF9424030012D5
68294+:102CB000A04300090E00033D8F84001C0A000B0E88
68295+:102CC0008FBF0058240500360E000E64000030212E
68296+:102CD0000A000B0E8FBF00580E0003320240202165
68297+:102CE000920200058F84001C344200200E00033D38
68298+:102CF000A20200050E0010758F84001C8FBF0058C3
68299+:102D00008FB300548FB200508FB1004C8FB0004889
68300+:102D100003E0000827BD00603C0280083445010044
68301+:102D20003C0280008C42014094A3000E0000302140
68302+:102D300000402021AF82001C3063FFFF3402FFFF00
68303+:102D4000106200063C0760202402FFFFA4A2000ED0
68304+:102D500094A500EA0A00090130A5FFFF03E000087E
68305+:102D60000000000027BDFFC83C0280003C06800830
68306+:102D7000AFB5002CAFB1001CAFBF0030AFB400281E
68307+:102D8000AFB30024AFB20020AFB00018345101003F
68308+:102D900034C501008C4301008E2200148CA400E491
68309+:102DA0000000A821AF83001C0044102318400052EB
68310+:102DB000A38000188E22001400005021ACA200E471
68311+:102DC00090C3000890A200D53073007FA3A200102A
68312+:102DD0008CB200E08CB400E4304200FF1053003BA2
68313+:102DE00093A200108F83001C2407FF80000211C0F3
68314+:102DF0000062102124420240246300400047102456
68315+:102E00003063007F3C0980003C08800A006818217C
68316+:102E1000AD2200248C62003427A4001427A50010E2
68317+:102E2000024280210290102304400028AFA3001426
68318+:102E30009062003C00E21024304200FF1440001970
68319+:102E4000020090219062003C34420040A062003CAD
68320+:102E50008F86001C93A3001024C200403042007FE4
68321+:102E6000004828213C0208008C4200F42463000141
68322+:102E7000306400FF14820002A3A30010A3A000107E
68323+:102E800093A20010AFA50014000211C0244202401A
68324+:102E900000C2102100471024AD2200240A000B4577
68325+:102EA00093A200100E0007C3000000003C0280083F
68326+:102EB00034420100AC5000E093A30010240A00014A
68327+:102EC000A04300D50A000B4593A200102402000184
68328+:102ED000154200093C0380008C6202780440FFFE2A
68329+:102EE0008F82001CAC62024024020002A0620244F5
68330+:102EF0003C021000AC6202789222000B2403000214
68331+:102F0000304200FF144300720000000096220008C7
68332+:102F1000304300FF24020082146200402402008437
68333+:102F20003C028000344901008D22000C95230006EC
68334+:102F3000000216023063FFFF3045003F24020027E5
68335+:102F400010A2000FAF83001428A200281040000830
68336+:102F5000240200312402002110A2000924020025CD
68337+:102F600010A20007938200190A000BBD00000000A8
68338+:102F700010A20007938200190A000BBD0000000098
68339+:102F80000E000777012020210A000C3D0000000000
68340+:102F90003C0380008C6202780440FFFE8F82001C9C
68341+:102FA000AC62024024020002A06202443C02100013
68342+:102FB000AC6202780A000C3D000000009523000678
68343+:102FC000912400058D25000C8D2600108D270018FA
68344+:102FD0008D28001C8D290020244200013C0108009E
68345+:102FE000A42356C63C010800A02456C53C01080095
68346+:102FF000AC2556CC3C010800AC2656D03C0108005C
68347+:10300000AC2756D83C010800AC2856DC3C0108002F
68348+:10301000AC2956E00A000C3DA38200191462000A94
68349+:10302000240200813C02800834420100944500EAF9
68350+:10303000922600058F84001C30A5FFFF30C600FFDC
68351+:103040000A000BFE3C0760211462005C00000000D7
68352+:103050009222000A304300FF306200201040000737
68353+:10306000306200403C02800834420100944500EA8E
68354+:103070008F84001C0A000BFC24060040104000074F
68355+:10308000000316003C02800834420100944500EA27
68356+:103090008F84001C0A000BFC24060041000216036A
68357+:1030A000044100463C02800834420100944500EA95
68358+:1030B0008F84001C2406004230A5FFFF3C076019E6
68359+:1030C0000E000901000000000A000C3D0000000095
68360+:1030D0009222000B24040016304200FF1044000628
68361+:1030E0003C0680009222000B24030017304200FFB0
68362+:1030F000144300320000000034C5010090A2000B10
68363+:10310000304200FF1444000B000080218CA20020FC
68364+:103110008CA400202403FF800043102400021140EF
68365+:103120003084007F004410253C032000004310251C
68366+:10313000ACC2083094A2000800021400000214037C
68367+:10314000044200012410000194A2000830420080D3
68368+:103150005040001A0200A82194A20008304220002A
68369+:10316000504000160200A8218CA300183C021C2D20
68370+:10317000344219ED106200110200A8213C0208003F
68371+:103180008C4200D4104000053C0280082403000457
68372+:1031900034420100A04300FC3C028008344201009C
68373+:1031A000944500EA8F84001C2406000630A5FFFF2A
68374+:1031B0000E0009013C0760210200A8210E00093918
68375+:1031C000000000009222000A304200081040000473
68376+:1031D00002A010210E0013790000000002A01021AF
68377+:1031E0008FBF00308FB5002C8FB400288FB3002420
68378+:1031F0008FB200208FB1001C8FB0001803E00008D0
68379+:1032000027BD00382402FF80008220243C02900069
68380+:1032100034420007008220253C028000AC4400209C
68381+:103220003C0380008C6200200440FFFE0000000090
68382+:1032300003E00008000000003C0380002402FF803F
68383+:10324000008220243462000700822025AC64002024
68384+:103250008C6200200440FFFE0000000003E0000834
68385+:103260000000000027BDFFD8AFB3001CAFB10014B1
68386+:10327000AFB00010AFBF0020AFB200183C1180000B
68387+:103280003C0280088E32002034530100AE2400201E
68388+:10329000966300EA000514003C074000004738250B
68389+:1032A00000A08021000030210E0009013065FFFFE1
68390+:1032B000240200A1160200022402FFFFA2620009FC
68391+:1032C000AE3200208FBF00208FB3001C8FB20018D9
68392+:1032D0008FB100148FB0001003E0000827BD002854
68393+:1032E0003C0280082403000527BDFFE834420100AA
68394+:1032F000A04300FCAFBF00103C0280008C420100E4
68395+:10330000240500A1004020210E000C67AF82001CA4
68396+:103310003C0380008C6202780440FFFE8F82001C18
68397+:103320008FBF001027BD0018AC62024024020002CB
68398+:10333000A06202443C021000AC62027803E0000884
68399+:103340000000000027BDFFE83C068000AFBF001072
68400+:1033500034C7010094E20008304400FF3883008243
68401+:10336000388200842C6300012C4200010062182581
68402+:103370001060002D24020083938200195040003B0E
68403+:103380008FBF00103C020800904256CC8CC4010054
68404+:103390003C06080094C656C63045003F38A30032AC
68405+:1033A00038A2003F2C6300012C4200010062182566
68406+:1033B000AF84001CAF860014A380001914600007BE
68407+:1033C00000E020212402002014A2001200000000CE
68408+:1033D0003402FFFF14C2000F00000000240200208E
68409+:1033E00014A2000500E028218CE300142402FFFF52
68410+:1033F0005062000B8FBF00103C040800248456C0AC
68411+:10340000000030210E000706240700010A000CD638
68412+:103410008FBF00100E000777000000008FBF001064
68413+:103420000A00093927BD001814820004240200850F
68414+:103430008CC501040A000CE1000020211482000662
68415+:103440002482FF808CC50104240440008FBF00103B
68416+:103450000A00016727BD0018304200FF2C4200021D
68417+:1034600010400004240200228FBF00100A000B2726
68418+:1034700027BD0018148200048F8200248FBF001023
68419+:103480000A000C8627BD00188C42000C1040001E5C
68420+:1034900000E0282190E300092402001814620003D0
68421+:1034A000240200160A000CFC240300081462000722
68422+:1034B00024020017240300123C02800834420080DA
68423+:1034C000A04300090A000D0994A7000854620007F0
68424+:1034D00094A700088F82FF942404FFFE9043000508
68425+:1034E00000641824A043000594A7000890A6001BC0
68426+:1034F0008CA4000094A500068FBF001000073C00BC
68427+:103500000A0008DC27BD00188FBF001003E0000888
68428+:1035100027BD00188F8500243C04800094A2002A57
68429+:103520008CA30034000230C02402FFF000C210243B
68430+:1035300000621821AC83003C8CA200303C03800068
68431+:10354000AC8200383C02005034420010AC620030C3
68432+:103550000000000000000000000000008C6200007D
68433+:10356000304200201040FFFD30C20008104000062D
68434+:103570003C0280008C620408ACA200208C62040C27
68435+:103580000A000D34ACA200248C430400ACA300203C
68436+:103590008C420404ACA200243C0300203C028000C6
68437+:1035A000AC4300303C0480008C8200300043102487
68438+:1035B0001440FFFD8F8600243C020040AC820030A6
68439+:1035C00094C3002A94C2002894C4002C94C5002EF1
68440+:1035D00024630001004410213064FFFFA4C20028CE
68441+:1035E00014850002A4C3002AA4C0002A03E0000836
68442+:1035F000000000008F84002427BDFFE83C05800404
68443+:1036000024840010AFBF00100E000E472406000AED
68444+:103610008F840024948200129483002E3042000F85
68445+:10362000244200030043180424027FFF0043102BB0
68446+:1036300010400002AC8300000000000D0E000D13CE
68447+:10364000000000008F8300248FBF001027BD0018EA
68448+:10365000946200149463001A3042000F00021500B7
68449+:10366000006218253C02800003E00008AC4300A083
68450+:103670008F8300243C028004944400069462001A64
68451+:103680008C650000A4640016004410233042FFFF44
68452+:103690000045102B03E00008384200018F8400240D
68453+:1036A0003C0780049486001A8C85000094E2000692
68454+:1036B000A482001694E3000600C310233042FFFFEB
68455+:1036C0000045102B384200011440FFF8A483001677
68456+:1036D00003E00008000000008F8400243C02800406
68457+:1036E000944200069483001A8C850000A482001680
68458+:1036F000006210233042FFFF0045102B38420001CA
68459+:103700005040000D8F850024006030213C0780046C
68460+:1037100094E20006A482001694E3000600C310237E
68461+:103720003042FFFF0045102B384200011440FFF8E3
68462+:10373000A48300168F8500243C03800034620400BB
68463+:103740008CA40020AF820020AC6400388CA200243E
68464+:10375000AC62003C3C020005AC62003003E00008B3
68465+:10376000ACA000048F8400243C0300068C8200047B
68466+:1037700000021140004310253C038000AC62003081
68467+:103780000000000000000000000000008C6200004B
68468+:10379000304200101040FFFD34620400AC80000491
68469+:1037A00003E00008AF8200208F86002427BDFFE0E1
68470+:1037B000AFB10014AFB00010AFBF00188CC300044D
68471+:1037C0008CC500248F820020309000FF94C4001A22
68472+:1037D00024630001244200202484000124A7002047
68473+:1037E000ACC30004AF820020A4C4001AACC70024FC
68474+:1037F00004A100060000882104E2000594C2001A1A
68475+:103800008CC2002024420001ACC2002094C2001AE5
68476+:1038100094C300282E040001004310262C4200010E
68477+:10382000004410245040000594C2001A24020001F4
68478+:10383000ACC2000894C2001A94C300280010202BC8
68479+:10384000004310262C4200010044102514400007BC
68480+:10385000000000008CC20008144000042402001084
68481+:103860008CC300041462000F8F8500240E000DA786
68482+:10387000241100018F820024944300289442001AEE
68483+:1038800014430003000000000E000D1300000000B0
68484+:10389000160000048F8500240E000D840000000037
68485+:1038A0008F85002494A2001E94A4001C24420001D1
68486+:1038B0003043FFFF14640002A4A2001EA4A0001E57
68487+:1038C0001200000A3C02800494A2001494A3001A7F
68488+:1038D0003042000F00021500006218253C028000F3
68489+:1038E000AC4300A00A000E1EACA0000894420006E3
68490+:1038F00094A3001A8CA40000A4A200160062102356
68491+:103900003042FFFF0044102B384200011040000DF0
68492+:1039100002201021006030213C07800494E2000660
68493+:10392000A4A2001694E3000600C310233042FFFF58
68494+:103930000044102B384200011440FFF8A4A30016E5
68495+:10394000022010218FBF00188FB100148FB000101B
68496+:1039500003E0000827BD002003E00008000000008D
68497+:103960008F82002C3C03000600021140004310250A
68498+:103970003C038000AC62003000000000000000004A
68499+:10398000000000008C620000304200101040FFFD7B
68500+:1039900034620400AF82002803E00008AF80002CEE
68501+:1039A00003E000080000102103E000080000000010
68502+:1039B0003084FFFF30A5FFFF0000182110800007B2
68503+:1039C000000000003082000110400002000420428C
68504+:1039D000006518210A000E3D0005284003E000089C
68505+:1039E0000060102110C0000624C6FFFF8CA200005A
68506+:1039F00024A50004AC8200000A000E4724840004C1
68507+:103A000003E000080000000010A0000824A3FFFF4E
68508+:103A1000AC86000000000000000000002402FFFF50
68509+:103A20002463FFFF1462FFFA2484000403E000080B
68510+:103A3000000000003C0280083442008024030001A2
68511+:103A4000AC43000CA4430010A4430012A443001490
68512+:103A500003E00008A44300168F82002427BDFFD88E
68513+:103A6000AFB3001CAFB20018AFB10014AFB000107C
68514+:103A7000AFBF00208C47000C248200802409FF8007
68515+:103A80003C08800E3043007F008080213C0A80008B
68516+:103A9000004920240068182130B100FF30D200FF17
68517+:103AA00010E000290000982126020100AD44002CFE
68518+:103AB000004928243042007F004820219062000005
68519+:103AC00024030050304200FF1443000400000000B3
68520+:103AD000AD45002C948200EA3053FFFF0E000D84A8
68521+:103AE000000000008F8200248F83002000112C0032
68522+:103AF0009442001E001224003484000100A22825F4
68523+:103B00003C02400000A22825AC7000008FBF0020BE
68524+:103B1000AC6000048FB20018AC7300088FB10014C1
68525+:103B2000AC60000C8FB3001CAC6400108FB00010B0
68526+:103B3000AC60001424040001AC60001827BD00280C
68527+:103B40000A000DB8AC65001C8FBF00208FB3001CAD
68528+:103B50008FB200188FB100148FB0001003E000087E
68529+:103B600027BD00283C06800034C201009043000FAE
68530+:103B7000240200101062000E2865001110A000073A
68531+:103B800024020012240200082405003A10620006F4
68532+:103B90000000302103E0000800000000240500358B
68533+:103BA0001462FFFC000030210A000E6400000000D7
68534+:103BB0008CC200748F83FF9424420FA003E000089E
68535+:103BC000AC62000C27BDFFE8AFBF00100E0003423F
68536+:103BD000240500013C0480088FBF0010240200016E
68537+:103BE00034830080A462001227BD00182402000163
68538+:103BF00003E00008A080001A27BDFFE0AFB2001864
68539+:103C0000AFB10014AFB00010AFBF001C30B2FFFF67
68540+:103C10000E000332008088213C028008345000806E
68541+:103C20009202000924030004304200FF1443000CF8
68542+:103C30003C028008124000082402000A0E000E5BBD
68543+:103C400000000000920200052403FFFE0043102440
68544+:103C5000A202000524020012A20200093C02800810
68545+:103C600034420080022020210E00033DA0400027A6
68546+:103C700016400003022020210E000EBF00000000AD
68547+:103C800002202021324600FF8FBF001C8FB2001897
68548+:103C90008FB100148FB00010240500380A000E64A4
68549+:103CA00027BD002027BDFFE0AFBF001CAFB200184A
68550+:103CB000AFB10014AFB000100E00033200808021BD
68551+:103CC0000E000E5B000000003C02800834450080BE
68552+:103CD00090A2000924120018305100FF1232000394
68553+:103CE0000200202124020012A0A2000990A20005D7
68554+:103CF0002403FFFE004310240E00033DA0A2000594
68555+:103D00000200202124050020163200070000302187
68556+:103D10008FBF001C8FB200188FB100148FB000103D
68557+:103D20000A00034227BD00208FBF001C8FB200187D
68558+:103D30008FB100148FB00010240500390A000E6402
68559+:103D400027BD002027BDFFE83C028000AFB0001077
68560+:103D5000AFBF0014344201009442000C2405003629
68561+:103D60000080802114400012304600FF0E00033214
68562+:103D7000000000003C02800834420080240300124E
68563+:103D8000A043000990430005346300100E000E5B51
68564+:103D9000A04300050E00033D020020210200202167
68565+:103DA0000E000342240500200A000F3C0000000022
68566+:103DB0000E000E64000000000E00033202002021FD
68567+:103DC0003C0280089043001B2405FF9F0200202135
68568+:103DD000006518248FBF00148FB00010A043001B93
68569+:103DE0000A00033D27BD001827BDFFE0AFBF001844
68570+:103DF000AFB10014AFB0001030B100FF0E000332BD
68571+:103E0000008080213C02800824030012344200809C
68572+:103E10000E000E5BA04300090E00033D02002021AE
68573+:103E200002002021022030218FBF00188FB1001422
68574+:103E30008FB00010240500350A000E6427BD002055
68575+:103E40003C0480089083000E9082000A1443000B0B
68576+:103E5000000028218F82FF942403005024050001D4
68577+:103E600090420000304200FF1443000400000000B4
68578+:103E70009082000E24420001A082000E03E00008A0
68579+:103E800000A010213C0380008C6201F80440FFFE7A
68580+:103E900024020002AC6401C0A06201C43C02100014
68581+:103EA00003E00008AC6201F827BDFFE0AFB20018E4
68582+:103EB0003C128008AFB10014AFBF001CAFB00010BF
68583+:103EC00036510080922200092403000A304200FF8C
68584+:103ED0001443003E000000008E4300048E22003890
68585+:103EE000506200808FBF001C92220000240300500B
68586+:103EF000304200FF144300253C0280008C42014008
68587+:103F00008E4300043642010002202821AC43001CED
68588+:103F10009622005C8E2300383042FFFF00021040E2
68589+:103F200000621821AE23001C8E4300048E2400384A
68590+:103F30009622005C006418233042FFFF0003184300
68591+:103F4000000210400043102A10400006000000004C
68592+:103F50008E4200048E230038004310230A000FAA6B
68593+:103F6000000220439622005C3042FFFF0002204006
68594+:103F70003C0280083443010034420080ACA4002C91
68595+:103F8000A040002424020001A062000C0E000F5E7D
68596+:103F900000000000104000538FBF001C3C02800056
68597+:103FA0008C4401403C0380008C6201F80440FFFE19
68598+:103FB00024020002AC6401C0A06201C43C021000F3
68599+:103FC000AC6201F80A0010078FBF001C92220009A2
68600+:103FD00024030010304200FF144300043C02800020
68601+:103FE0008C4401400A000FEE0000282192220009B3
68602+:103FF00024030016304200FF14430006240200147C
68603+:10400000A22200093C0280008C4401400A001001F9
68604+:104010008FBF001C8E2200388E23003C00431023EB
68605+:10402000044100308FBF001C92220027244200016F
68606+:10403000A2220027922200272C42000414400016DE
68607+:104040003C1080009222000924030004304200FF4B
68608+:10405000144300093C0280008C4401408FBF001CC7
68609+:104060008FB200188FB100148FB000102405009398
68610+:104070000A000ECC27BD00208C440140240500938B
68611+:104080008FBF001C8FB200188FB100148FB00010CA
68612+:104090000A000F4827BD00208E0401400E000332A5
68613+:1040A000000000008E4200042442FFFFAE420004E4
68614+:1040B0008E22003C2442FFFFAE22003C0E00033D56
68615+:1040C0008E0401408E0401408FBF001C8FB2001887
68616+:1040D0008FB100148FB00010240500040A000342C1
68617+:1040E00027BD00208FB200188FB100148FB00010D0
68618+:1040F00003E0000827BD00203C0680008CC2018838
68619+:104100003C038008346500809063000E00021402B6
68620+:10411000304400FF306300FF1464000E3C0280084E
68621+:1041200090A20026304200FF104400098F82FF94C5
68622+:10413000A0A400262403005090420000304200FF5B
68623+:1041400014430006000000000A0005A18CC4018091
68624+:104150003C02800834420080A044002603E00008AE
68625+:104160000000000027BDFFE030E700FFAFB20018FD
68626+:10417000AFBF001CAFB10014AFB0001000809021A1
68627+:1041800014E0000630C600FF000000000000000D33
68628+:10419000000000000A001060240001163C038008A3
68629+:1041A0009062000E304200FF14460023346200800B
68630+:1041B00090420026304200FF1446001F000000001D
68631+:1041C0009062000F304200FF1446001B0000000008
68632+:1041D0009062000A304200FF144600038F90FF9463
68633+:1041E0000000000D8F90FF948F82FF983C1180009B
68634+:1041F000AE05003CAC450000A066000A0E0003328C
68635+:104200008E240100A20000240E00033D8E24010034
68636+:104210003C0380008C6201F80440FFFE240200028F
68637+:10422000AC7201C0A06201C43C021000AC6201F893
68638+:104230000A0010618FBF001C000000000000000D8C
68639+:10424000000000002400013F8FBF001C8FB2001847
68640+:104250008FB100148FB0001003E0000827BD0020CC
68641+:104260008F83FF943C0280008C44010034420100A3
68642+:104270008C65003C9046001B0A00102724070001B3
68643+:104280003C0280089043000E9042000A0043102632
68644+:10429000304200FF03E000080002102B27BDFFE0C2
68645+:1042A0003C028008AFB10014AFB00010AFBF0018DF
68646+:1042B0003450008092020005240300303042003068
68647+:1042C00014430085008088218F8200248C42000CDA
68648+:1042D000104000828FBF00180E000D840000000007
68649+:1042E0008F860020ACD100009202000892030009E2
68650+:1042F000304200FF00021200306300FF004310252F
68651+:10430000ACC200049202004D000216000002160327
68652+:1043100004410005000000003C0308008C630048D5
68653+:104320000A00109F3C1080089202000830420040B2
68654+:10433000144000030000182192020027304300FFC0
68655+:104340003C108008361100809222004D00031E00B0
68656+:10435000304200FF0002140000621825ACC30008C0
68657+:104360008E2400308F820024ACC4000C8E250034D3
68658+:104370009443001E3C02C00BACC50010006218251F
68659+:104380008E22003800002021ACC200148E22003C96
68660+:10439000ACC200180E000DB8ACC3001C8E020004A5
68661+:1043A0008F8400203C058000AC8200008E2200201B
68662+:1043B000AC8200048E22001CAC8200088E220058C1
68663+:1043C0008CA3007400431021AC82000C8E22002CC0
68664+:1043D000AC8200108E2200408E23004400021400A4
68665+:1043E00000431025AC8200149222004D240300806B
68666+:1043F000304200FF1443000400000000AC800018AD
68667+:104400000A0010E38F8200248E23000C2402000196
68668+:104410001062000E2402FFFF92220008304200408A
68669+:104420001440000A2402FFFF8E23000C8CA20074AB
68670+:10443000006218233C0208000062102414400002AD
68671+:10444000000028210060282100051043AC820018DC
68672+:104450008F820024000020219443001E3C02C00CE7
68673+:10446000006218258F8200200E000DB8AC43001C9E
68674+:104470003C038008346201008C4200008F850020DC
68675+:10448000346300808FBF0018ACA20000ACA0000411
68676+:104490008C6400488F8200248FB10014ACA4000803
68677+:1044A000ACA0000CACA00010906300059446001E68
68678+:1044B0003C02400D00031E0000C23025ACA30014D6
68679+:1044C0008FB00010ACA0001824040001ACA6001CA2
68680+:1044D0000A000DB827BD00208FBF00188FB100144F
68681+:1044E0008FB0001003E0000827BD00203C028000D0
68682+:1044F0009443007C3C02800834460100308400FF75
68683+:104500003065FFFF2402000524A34650A0C4000C20
68684+:104510005482000C3065FFFF90C2000D2C42000752
68685+:104520001040000724A30A0090C3000D24020014C9
68686+:104530000062100400A210210A00111F3045FFFF85
68687+:104540003065FFFF3C0280083442008003E0000831
68688+:10455000A44500143C03800834680080AD05003891
68689+:10456000346701008CE2001C308400FF00A210239D
68690+:104570001840000330C600FF24A2FFFCACE2001C80
68691+:1045800030820001504000083C0380088D02003C4E
68692+:1045900000A2102304410012240400058C620004D0
68693+:1045A00010A2000F3C0380088C62000414A2001EBD
68694+:1045B000000000003C0208008C4200D8304200207D
68695+:1045C000104000093C0280083462008090630008BB
68696+:1045D0009042004C144300043C0280082404000470
68697+:1045E0000A00110900000000344300803442010039
68698+:1045F000A040000C24020001A462001410C0000AB4
68699+:104600003C0280008C4401003C0380008C6201F875
68700+:104610000440FFFE24020002AC6401C0A06201C499
68701+:104620003C021000AC6201F803E00008000000004A
68702+:1046300027BDFFE800A61823AFBF00101860008058
68703+:10464000308800FF3C02800834470080A0E000244E
68704+:1046500034440100A0E000278C82001C00A210233B
68705+:1046600004400056000000008CE2003C94E3005C33
68706+:104670008CE4002C004530233063FFFF00C3182179
68707+:104680000083202B1080000400E018218CE2002C15
68708+:104690000A00117800A2102194E2005C3042FFFF72
68709+:1046A00000C2102100A21021AC62001C3C02800854
68710+:1046B000344400809482005C8C83001C3042FFFFF5
68711+:1046C0000002104000A210210043102B10400004F3
68712+:1046D000000000008C82001C0A00118B3C06800840
68713+:1046E0009482005C3042FFFF0002104000A21021C3
68714+:1046F0003C06800834C3010034C70080AC82001C33
68715+:10470000A060000CACE500388C62001C00A21023F5
68716+:104710001840000224A2FFFCAC62001C3102000120
68717+:10472000104000083C0380088CE2003C00A21023EB
68718+:1047300004410012240400058CC2000410A20010E1
68719+:104740008FBF00108C62000414A2004F8FBF0010B6
68720+:104750003C0208008C4200D8304200201040000A81
68721+:104760003C02800834620080906300089042004C54
68722+:10477000144300053C028008240400048FBF00108D
68723+:104780000A00110927BD001834430080344201009B
68724+:10479000A040000C24020001A46200143C0280002E
68725+:1047A0008C4401003C0380008C6201F80440FFFE51
68726+:1047B000240200020A0011D8000000008CE2001C54
68727+:1047C000004610230043102B54400001ACE5001CB0
68728+:1047D00094E2005C3042FFFF0062102B144000079F
68729+:1047E0002402000294E2005C8CE3001C3042FFFFD4
68730+:1047F00000621821ACE3001C24020002ACE5003882
68731+:104800000E000F5EA082000C1040001F8FBF001032
68732+:104810003C0280008C4401003C0380008C6201F863
68733+:104820000440FFFE24020002AC6401C0A06201C487
68734+:104830003C021000AC6201F80A0011F08FBF0010BA
68735+:1048400031020010104000108FBF00103C028008A1
68736+:10485000344500808CA3001C94A2005C00661823E1
68737+:104860003042FFFF006218213C023FFF3444FFFF4B
68738+:104870000083102B544000010080182100C3102138
68739+:10488000ACA2001C8FBF001003E0000827BD001879
68740+:1048900027BDFFE800C0402100A63023AFBF0010B5
68741+:1048A00018C00026308A00FF3C028008344900808E
68742+:1048B0008D24001C8D23002C008820230064182BDD
68743+:1048C0001060000F344701008CE2002000461021E8
68744+:1048D000ACE200208CE200200044102B1440000BBE
68745+:1048E0003C023FFF8CE2002000441023ACE2002099
68746+:1048F0009522005C3042FFFF0A0012100082202146
68747+:10490000ACE00020008620213C023FFF3443FFFF43
68748+:104910000064102B54400001006020213C028008FC
68749+:104920003442008000851821AC43001CA0400024C4
68750+:10493000A04000270A0012623C03800831420010A8
68751+:10494000104000433C0380083C06800834C40080CB
68752+:104950008C82003C004810235840003E34660080A2
68753+:104960009082002424420001A0820024908200242E
68754+:104970003C0308008C630024304200FF0043102BEE
68755+:10498000144000688FBF001034C201008C42001C2C
68756+:1049900000A2102318400063000000008CC3000434
68757+:1049A0009482005C006818233042FFFF0003184324
68758+:1049B000000210400043102A1040000500000000D3
68759+:1049C0008CC20004004810230A0012450002104364
68760+:1049D0009482005C3042FFFF000210403C068008D9
68761+:1049E000AC82002C34C5008094A2005C8CA4002C06
68762+:1049F00094A3005C3042FFFF00021040008220219F
68763+:104A00003063FFFF0083202101041021ACA2001CB1
68764+:104A10008CC2000434C60100ACC2001C2402000297
68765+:104A20000E000F5EA0C2000C1040003E8FBF0010B1
68766+:104A30003C0280008C4401003C0380008C6201F841
68767+:104A40000440FFFE240200020A001292000000004F
68768+:104A500034660080ACC50038346401008C82001CD0
68769+:104A600000A210231840000224A2FFFCAC82001C0C
68770+:104A7000314200015040000A3C0380088CC2003CD7
68771+:104A800000A2102304430014240400058C620004D7
68772+:104A900014A200033C0380080A00128424040005C9
68773+:104AA0008C62000414A2001F8FBF00103C0208009B
68774+:104AB0008C4200D8304200201040000A3C0280089E
68775+:104AC00034620080906300089042004C144300055B
68776+:104AD0003C028008240400048FBF00100A00110962
68777+:104AE00027BD00183443008034420100A040000C70
68778+:104AF00024020001A46200143C0280008C440100E6
68779+:104B00003C0380008C6201F80440FFFE2402000296
68780+:104B1000AC6401C0A06201C43C021000AC6201F8A8
68781+:104B20008FBF001003E0000827BD001827BDFFE875
68782+:104B30003C0A8008AFBF0010354900808D22003C40
68783+:104B400000C04021308400FF004610231840009D23
68784+:104B500030E700FF354701002402000100A63023A2
68785+:104B6000A0E0000CA0E0000DA522001418C0002455
68786+:104B7000308200108D23001C8D22002C0068182329
68787+:104B80000043102B1040000F000000008CE20020BA
68788+:104B900000461021ACE200208CE200200043102BE4
68789+:104BA0001440000B3C023FFF8CE200200043102326
68790+:104BB000ACE200209522005C3042FFFF0A0012C1E7
68791+:104BC00000621821ACE00020006618213C023FFF83
68792+:104BD0003446FFFF00C3102B5440000100C01821D1
68793+:104BE0003C0280083442008000651821AC43001C60
68794+:104BF000A0400024A04000270A00130F3C038008B7
68795+:104C0000104000403C0380088D22003C00481023E7
68796+:104C10005840003D34670080912200242442000166
68797+:104C2000A1220024912200243C0308008C6300246C
68798+:104C3000304200FF0043102B1440009A8FBF001039
68799+:104C40008CE2001C00A21023184000960000000017
68800+:104C50008D4300049522005C006818233042FFFF5A
68801+:104C600000031843000210400043102A10400005C2
68802+:104C7000012020218D420004004810230A0012F276
68803+:104C8000000210439522005C3042FFFF00021040FA
68804+:104C90003C068008AC82002C34C5008094A2005CE5
68805+:104CA0008CA4002C94A3005C3042FFFF0002104053
68806+:104CB000008220213063FFFF0083182101031021AF
68807+:104CC000ACA2001C8CC2000434C60100ACC2001CA3
68808+:104CD000240200020E000F5EA0C2000C1040007102
68809+:104CE0008FBF00103C0280008C4401003C03800018
68810+:104CF0008C6201F80440FFFE240200020A0013390E
68811+:104D00000000000034670080ACE500383466010024
68812+:104D10008CC2001C00A210231840000224A2FFFC39
68813+:104D2000ACC2001C30820001504000083C038008E7
68814+:104D30008CE2003C00A2102304430051240400052F
68815+:104D40008C62000410A2003E3C0380088C620004C8
68816+:104D500054A200548FBF00103C0208008C4200D8BF
68817+:104D600030420020104000063C028008346200807F
68818+:104D7000906300089042004C104300403C028008C1
68819+:104D80003443008034420100A040000C24020001A2
68820+:104D9000A46200143C0280008C4401003C038000AB
68821+:104DA0008C6201F80440FFFE24020002AC6401C0E2
68822+:104DB000A06201C43C021000AC6201F80A00137743
68823+:104DC0008FBF001024020005A120002714E2000A72
68824+:104DD0003C038008354301009062000D2C42000620
68825+:104DE000504000053C0380089062000D2442000101
68826+:104DF000A062000D3C03800834670080ACE50038F9
68827+:104E0000346601008CC2001C00A21023184000026E
68828+:104E100024A2FFFCACC2001C308200015040000AFA
68829+:104E20003C0380088CE2003C00A2102304410014E3
68830+:104E3000240400058C62000414A200033C038008D3
68831+:104E40000A00136E240400058C62000414A20015ED
68832+:104E50008FBF00103C0208008C4200D83042002076
68833+:104E60001040000A3C028008346200809063000811
68834+:104E70009042004C144300053C02800824040004C6
68835+:104E80008FBF00100A00110927BD001834430080AD
68836+:104E900034420100A040000C24020001A46200146E
68837+:104EA0008FBF001003E0000827BD00183C0B8008EE
68838+:104EB00027BDFFE83C028000AFBF00103442010074
68839+:104EC000356A00809044000A356901008C45001461
68840+:104ED0008D4800389123000C308400FF0105102319
68841+:104EE0001C4000B3306700FF2CE20006504000B1C8
68842+:104EF0008FBF00102402000100E2300430C2000322
68843+:104F00005440000800A8302330C2000C144000A117
68844+:104F100030C20030144000A38FBF00100A00143BC1
68845+:104F20000000000018C00024308200108D43001CD7
68846+:104F30008D42002C006818230043102B1040000FF6
68847+:104F4000000000008D22002000461021AD2200202C
68848+:104F50008D2200200043102B1440000B3C023FFF29
68849+:104F60008D22002000431023AD2200209542005CDA
68850+:104F70003042FFFF0A0013AF00621821AD2000206D
68851+:104F8000006618213C023FFF3446FFFF00C3102B90
68852+:104F90005440000100C018213C02800834420080C7
68853+:104FA00000651821AC43001CA0400024A04000274D
68854+:104FB0000A0013FD3C038008104000403C038008B9
68855+:104FC0008D42003C004810231840003D34670080AB
68856+:104FD0009142002424420001A14200249142002475
68857+:104FE0003C0308008C630024304200FF0043102B78
68858+:104FF000144000708FBF00108D22001C00A21023EF
68859+:105000001840006C000000008D6300049542005CB5
68860+:10501000006818233042FFFF0003184300021040CD
68861+:105020000043102A10400005014020218D62000439
68862+:10503000004810230A0013E0000210439542005C70
68863+:105040003042FFFF000210403C068008AC82002C7A
68864+:1050500034C5008094A2005C8CA4002C94A3005C56
68865+:105060003042FFFF00021040008220213063FFFF2A
68866+:105070000083182101031021ACA2001C8CC2000483
68867+:1050800034C60100ACC2001C240200020E000F5EF8
68868+:10509000A0C2000C104000478FBF00103C028000EF
68869+:1050A0008C4401003C0380008C6201F80440FFFE48
68870+:1050B000240200020A00142D000000003467008062
68871+:1050C000ACE50038346601008CC2001C00A210233D
68872+:1050D0001840000224A2FFFCACC2001C3082000178
68873+:1050E0005040000A3C0380088CE2003C00A21023E0
68874+:1050F00004430014240400058C62000414A200037D
68875+:105100003C0380080A00141F240400058C6200047C
68876+:1051100014A200288FBF00103C0208008C4200D867
68877+:10512000304200201040000A3C02800834620080B7
68878+:10513000906300089042004C144300053C02800834
68879+:10514000240400048FBF00100A00110927BD0018B5
68880+:105150003443008034420100A040000C24020001CE
68881+:10516000A46200143C0280008C4401003C038000D7
68882+:105170008C6201F80440FFFE24020002AC6401C00E
68883+:10518000A06201C43C021000AC6201F80A00143BAA
68884+:105190008FBF00108FBF0010010030210A00115A8C
68885+:1051A00027BD0018010030210A00129927BD001800
68886+:1051B0008FBF001003E0000827BD00183C038008E3
68887+:1051C0003464010024020003A082000C8C620004FD
68888+:1051D00003E00008AC82001C3C05800834A300807A
68889+:1051E0009062002734A501002406004324420001F8
68890+:1051F000A0620027906300273C0208008C42004810
68891+:10520000306300FF146200043C07602194A500EAAB
68892+:105210000A00090130A5FFFF03E0000800000000BC
68893+:1052200027BDFFE8AFBF00103C0280000E00144411
68894+:105230008C4401803C02800834430100A060000CD3
68895+:105240008C4200048FBF001027BD001803E0000847
68896+:10525000AC62001C27BDFFE03C028008AFBF001815
68897+:10526000AFB10014AFB000103445008034460100E7
68898+:105270003C0880008D09014090C3000C8CA4003CC8
68899+:105280008CA200381482003B306700FF9502007C3E
68900+:1052900090A30027146000093045FFFF2402000599
68901+:1052A00054E200083C04800890C2000D2442000132
68902+:1052B000A0C2000D0A00147F3C048008A0C0000DAD
68903+:1052C0003C048008348201009042000C2403000555
68904+:1052D000304200FF1443000A24A205DC348300801E
68905+:1052E000906200272C4200075040000524A20A00CB
68906+:1052F00090630027240200140062100400A2102111
68907+:105300003C108008361000803045FFFF012020212E
68908+:105310000E001444A60500149602005C8E030038AB
68909+:105320003C1180003042FFFF000210400062182153
68910+:10533000AE03001C0E0003328E24014092020025B1
68911+:1053400034420040A20200250E00033D8E2401409D
68912+:105350008E2401403C0380008C6201F80440FFFE73
68913+:1053600024020002AC6401C0A06201C43C0210002F
68914+:10537000AC6201F88FBF00188FB100148FB000101D
68915+:1053800003E0000827BD00203C0360103C02080039
68916+:1053900024420174AC62502C8C6250003C048000AA
68917+:1053A00034420080AC6250003C0208002442547C2D
68918+:1053B0003C010800AC2256003C020800244254384C
68919+:1053C0003C010800AC2256043C020002AC840008F8
68920+:1053D000AC82000C03E000082402000100A0302190
68921+:1053E0003C1C0800279C56083C0200023C050400B7
68922+:1053F00000852826008220260004102B2CA5000101
68923+:105400002C840001000210803C0308002463560035
68924+:105410000085202500431821108000030000102182
68925+:10542000AC6600002402000103E000080000000058
68926+:105430003C1C0800279C56083C0200023C05040066
68927+:1054400000852826008220260004102B2CA50001B0
68928+:105450002C840001000210803C03080024635600E5
68929+:105460000085202500431821108000050000102130
68930+:105470003C02080024425438AC62000024020001BF
68931+:1054800003E00008000000003C0200023C030400AE
68932+:1054900000821026008318262C4200012C63000194
68933+:1054A000004310251040000B000028213C1C080080
68934+:1054B000279C56083C0380008C62000824050001EC
68935+:1054C00000431025AC6200088C62000C00441025DB
68936+:1054D000AC62000C03E0000800A010213C1C080096
68937+:1054E000279C56083C0580008CA3000C0004202754
68938+:1054F000240200010064182403E00008ACA3000C9F
68939+:105500003C020002148200063C0560008CA208D018
68940+:105510002403FFFE0043102403E00008ACA208D0DF
68941+:105520003C02040014820005000000008CA208D098
68942+:105530002403FFFD00431024ACA208D003E00008C0
68943+:10554000000000003C02601A344200108C430080CE
68944+:1055500027BDFFF88C440084AFA3000093A3000094
68945+:10556000240200041462001AAFA4000493A20001F4
68946+:105570001040000797A300023062FFFC3C0380004C
68947+:10558000004310218C4200000A001536AFA200042F
68948+:105590003062FFFC3C03800000431021AC4400005B
68949+:1055A000A3A000003C0560008CA208D02403FFFEED
68950+:1055B0003C04601A00431024ACA208D08FA300045E
68951+:1055C0008FA2000034840010AC830084AC82008081
68952+:1055D00003E0000827BD000827BDFFE8AFBF0010AB
68953+:1055E0003C1C0800279C56083C0280008C43000CA1
68954+:1055F0008C420004004318243C0200021060001496
68955+:10560000006228243C0204003C04000210A00005B3
68956+:10561000006210243C0208008C4256000A00155B10
68957+:1056200000000000104000073C0404003C02080099
68958+:105630008C4256040040F809000000000A00156082
68959+:10564000000000000000000D3C1C0800279C5608CC
68960+:105650008FBF001003E0000827BD0018800802403B
68961+:1056600080080100800800808008000000000C8095
68962+:105670000000320008000E9808000EF408000F88A1
68963+:1056800008001028080010748008010080080080BD
68964+:10569000800800000A000028000000000000000050
68965+:1056A0000000000D6370362E322E316200000000C3
68966+:1056B00006020104000000000000000000000000DD
68967+:1056C000000000000000000038003C000000000066
68968+:1056D00000000000000000000000000000000020AA
68969+:1056E00000000000000000000000000000000000BA
68970+:1056F00000000000000000000000000000000000AA
68971+:10570000000000000000000021003800000000013F
68972+:105710000000002B000000000000000400030D400A
68973+:105720000000000000000000000000000000000079
68974+:105730000000000000000000100000030000000056
68975+:105740000000000D0000000D3C020800244259AC8E
68976+:105750003C03080024635BF4AC4000000043202BB2
68977+:105760001480FFFD244200043C1D080037BD9FFC4F
68978+:1057700003A0F0213C100800261000A03C1C0800EB
68979+:10578000279C59AC0E0002F6000000000000000D3E
68980+:1057900027BDFFB4AFA10000AFA20004AFA3000873
68981+:1057A000AFA4000CAFA50010AFA60014AFA700185F
68982+:1057B000AFA8001CAFA90020AFAA0024AFAB0028FF
68983+:1057C000AFAC002CAFAD0030AFAE0034AFAF00389F
68984+:1057D000AFB8003CAFB90040AFBC0044AFBF004819
68985+:1057E0000E000820000000008FBF00488FBC00445E
68986+:1057F0008FB900408FB8003C8FAF00388FAE0034B7
68987+:105800008FAD00308FAC002C8FAB00288FAA002406
68988+:105810008FA900208FA8001C8FA700188FA6001446
68989+:105820008FA500108FA4000C8FA300088FA2000486
68990+:105830008FA1000027BD004C3C1B60188F7A5030B0
68991+:10584000377B502803400008AF7A000000A01821E1
68992+:1058500000801021008028213C0460003C0760008B
68993+:105860002406000810600006348420788C42000072
68994+:10587000ACE220088C63000003E00008ACE3200CDD
68995+:105880000A000F8100000000240300403C02600079
68996+:1058900003E00008AC4320003C0760008F86000452
68997+:1058A0008CE520740086102100A2182B14600007DC
68998+:1058B000000028218F8AFDA024050001A1440013C7
68999+:1058C0008F89000401244021AF88000403E0000810
69000+:1058D00000A010218F84FDA08F8500049086001306
69001+:1058E00030C300FF00A31023AF82000403E00008D0
69002+:1058F000A08000138F84FDA027BDFFE8AFB000108B
69003+:10590000AFBF001490890011908700112402002875
69004+:10591000312800FF3906002830E300FF2485002CE1
69005+:105920002CD00001106200162484001C0E00006EB2
69006+:10593000000000008F8FFDA03C05600024020204DF
69007+:1059400095EE003E95ED003C000E5C0031ACFFFF93
69008+:10595000016C5025ACAA2010520000012402000462
69009+:10596000ACA22000000000000000000000000000C9
69010+:105970008FBF00148FB0001003E0000827BD00188F
69011+:105980000A0000A6000028218F85FDA027BDFFD8B2
69012+:10599000AFBF0020AFB3001CAFB20018AFB100140E
69013+:1059A000AFB000100080982190A4001124B0001C1A
69014+:1059B00024B1002C308300FF386200280E000090D4
69015+:1059C0002C5200010E00009800000000020020216F
69016+:1059D0001240000202202821000028210E00006E43
69017+:1059E000000000008F8DFDA03C0880003C05600099
69018+:1059F00095AC003E95AB003C02683025000C4C0095
69019+:105A0000316AFFFF012A3825ACA7201024020202C8
69020+:105A1000ACA6201452400001240200028FBF0020D7
69021+:105A20008FB3001C8FB200188FB100148FB000101C
69022+:105A300027BD002803E00008ACA2200027BDFFE03E
69023+:105A4000AFB20018AFB10014AFB00010AFBF001C70
69024+:105A50003C1160008E2320748F82000430D0FFFF41
69025+:105A600030F2FFFF1062000C2406008F0E00006E63
69026+:105A7000000000003C06801F0010440034C5FF00F9
69027+:105A80000112382524040002AE2720100000302126
69028+:105A9000AE252014AE2420008FBF001C8FB200184A
69029+:105AA0008FB100148FB0001000C0102103E0000877
69030+:105AB00027BD002027BDFFE0AFB0001030D0FFFFB2
69031+:105AC000AFBF0018AFB100140E00006E30F1FFFF41
69032+:105AD00000102400009180253C036000AC70201071
69033+:105AE0008FBF00188FB100148FB000102402000483
69034+:105AF000AC62200027BD002003E000080000102158
69035+:105B000027BDFFE03C046018AFBF0018AFB1001420
69036+:105B1000AFB000108C8850002403FF7F34028071E6
69037+:105B20000103382434E5380C241F00313C1980006F
69038+:105B3000AC8550003C11800AAC8253BCAF3F0008DA
69039+:105B40000E00054CAF9100400E00050A3C116000AC
69040+:105B50000E00007D000000008E3008083C0F570941
69041+:105B60002418FFF00218602435EEE00035EDF00057
69042+:105B7000018E5026018D58262D4600012D69000109
69043+:105B8000AF86004C0E000D09AF8900503C06601630
69044+:105B90008CC700003C0860148D0500A03C03FFFF8B
69045+:105BA00000E320243C02535300052FC2108200550D
69046+:105BB00034D07C00960201F2A780006C10400003F4
69047+:105BC000A780007C384B1E1EA78B006C960201F844
69048+:105BD000104000048F8D0050384C1E1EA78C007C96
69049+:105BE0008F8D005011A000058F83004C240E0020E3
69050+:105BF000A78E007CA78E006C8F83004C1060000580
69051+:105C00009785007C240F0020A78F007CA78F006C55
69052+:105C10009785007C2CB8008153000001240500808A
69053+:105C20009784006C2C91040152200001240404008C
69054+:105C30001060000B3C0260008FBF00188FB1001491
69055+:105C40008FB0001027BD0020A784006CA785007CC2
69056+:105C5000A380007EA780007403E00008A780009264
69057+:105C60008C4704382419103C30FFFFFF13F9000360
69058+:105C700030A8FFFF1100004624030050A380007EDF
69059+:105C80009386007E50C00024A785007CA780007CFE
69060+:105C90009798007CA780006CA7800074A780009272
69061+:105CA0003C010800AC3800800E00078700000000AF
69062+:105CB0003C0F60008DED0808240EFFF03C0B600ED9
69063+:105CC000260C0388356A00100000482100002821B6
69064+:105CD00001AE20243C105709AF8C0010AF8A004859
69065+:105CE000AF89001810900023AF8500148FBF0018F3
69066+:105CF0008FB100148FB0001027BD002003E0000812
69067+:105D0000AF80005400055080014648218D260004D4
69068+:105D10000A00014800D180219798007CA784006C7C
69069+:105D2000A7800074A78000923C010800AC38008076
69070+:105D30000E000787000000003C0F60008DED080892
69071+:105D4000240EFFF03C0B600E260C0388356A001011
69072+:105D5000000048210000282101AE20243C105709F2
69073+:105D6000AF8C0010AF8A0048AF8900181490FFDF95
69074+:105D7000AF85001424110001AF9100548FBF0018AB
69075+:105D80008FB100148FB0001003E0000827BD002081
69076+:105D90000A00017BA383007E3083FFFF8F880040D1
69077+:105DA0008F87003C000321403C0580003C020050EE
69078+:105DB000008248253C0660003C0A010034AC040027
69079+:105DC0008CCD08E001AA58241160000500000000F5
69080+:105DD0008CCF08E024E7000101EA7025ACCE08E092
69081+:105DE0008D19001001805821ACB900388D180014AD
69082+:105DF000ACB8003CACA9003000000000000000007E
69083+:105E00000000000000000000000000000000000092
69084+:105E100000000000000000003C0380008C640000D3
69085+:105E2000308200201040FFFD3C0F60008DED08E047
69086+:105E30003C0E010001AE18241460FFE100000000D8
69087+:105E4000AF87003C03E00008AF8B00588F8500400F
69088+:105E5000240BFFF03C06800094A7001A8CA90024B4
69089+:105E600030ECFFFF000C38C000EB5024012A402129
69090+:105E7000ACC8003C8CA400248CC3003C00831023DD
69091+:105E800018400033000000008CAD002025A2000166
69092+:105E90003C0F0050ACC2003835EE00103C068000CC
69093+:105EA000ACCE003000000000000000000000000048
69094+:105EB00000000000000000000000000000000000E2
69095+:105EC000000000003C0480008C9900003338002062
69096+:105ED0001300FFFD30E20008104000173C0980006D
69097+:105EE0008C880408ACA800108C83040CACA30014AC
69098+:105EF0003C1900203C188000AF19003094AE001807
69099+:105F000094AF001C01CF3021A4A6001894AD001A54
69100+:105F100025A70001A4A7001A94AB001A94AC001E98
69101+:105F2000118B00030000000003E0000800000000E7
69102+:105F300003E00008A4A0001A8D2A0400ACAA0010F7
69103+:105F40008D240404ACA400140A0002183C1900209B
69104+:105F50008CA200200A0002003C0F00500A0001EE53
69105+:105F60000000000027BDFFE8AFBF00100E000232A6
69106+:105F7000000000008F8900408FBF00103C038000AC
69107+:105F8000A520000A9528000A9527000427BD0018BF
69108+:105F90003105FFFF30E6000F0006150000A22025A6
69109+:105FA00003E00008AC6400803C0508008CA50020DC
69110+:105FB0008F83000C27BDFFE8AFB00010AFBF001407
69111+:105FC00010A300100000802124040001020430040A
69112+:105FD00000A6202400C3102450440006261000010F
69113+:105FE000001018802787FDA41480000A006718217C
69114+:105FF000261000012E0900025520FFF38F83000CAC
69115+:10600000AF85000C8FBF00148FB0001003E00008B4
69116+:1060100027BD00188C6800003C058000ACA8002457
69117+:106020000E000234261000013C0508008CA500205B
69118+:106030000A0002592E0900022405000100851804F7
69119+:106040003C0408008C84002027BDFFC8AFBF00348B
69120+:1060500000831024AFBE0030AFB7002CAFB60028CD
69121+:10606000AFB50024AFB40020AFB3001CAFB200182E
69122+:10607000AFB1001410400051AFB000108F84004049
69123+:10608000948700069488000A00E8302330D5FFFF8B
69124+:1060900012A0004B8FBF0034948B0018948C000A20
69125+:1060A000016C50233142FFFF02A2482B1520000251
69126+:1060B00002A02021004020212C8F000515E00002C5
69127+:1060C00000809821241300040E0001C102602021E9
69128+:1060D0008F87004002609021AF80004494F4000A52
69129+:1060E000026080211260004E3291FFFF3C1670006A
69130+:1060F0003C1440003C1E20003C1760008F99005863
69131+:106100008F380000031618241074004F0283F82BF8
69132+:1061100017E0003600000000107E00478F86004424
69133+:1061200014C0003A2403000102031023022320219B
69134+:106130003050FFFF1600FFF13091FFFF8F870040C6
69135+:106140003C1100203C108000AE11003094EB000A9E
69136+:106150003C178000024B5021A4EA000A94E9000A8F
69137+:1061600094E800043123FFFF3106000F00062D00E4
69138+:106170000065F025AEFE008094F3000A94F6001846
69139+:1061800012D30036001221408CFF00148CF4001052
69140+:1061900003E468210000C02101A4782B029870213B
69141+:1061A00001CF6021ACED0014ACEC001002B238233A
69142+:1061B00030F5FFFF16A0FFB88F8400408FBF00347A
69143+:1061C0008FBE00308FB7002C8FB600288FB500240B
69144+:1061D0008FB400208FB3001C8FB200188FB1001451
69145+:1061E0008FB0001003E0000827BD00381477FFCC03
69146+:1061F0008F8600440E000EE202002021004018218C
69147+:106200008F86004410C0FFC9020310230270702360
69148+:106210008F87004001C368210A0002E431B2FFFF0A
69149+:106220008F86004414C0FFC93C1100203C10800040
69150+:106230000A0002AEAE1100300E00046602002021FA
69151+:106240000A0002DB00401821020020210E0009395B
69152+:10625000022028210A0002DB004018210E0001EE76
69153+:10626000000000000A0002C702B2382327BDFFC8A1
69154+:10627000AFB7002CAFB60028AFB50024AFB40020F4
69155+:10628000AFB3001CAFB20018AFB10014AFB0001034
69156+:10629000AFBF00300E00011B241300013C047FFF40
69157+:1062A0003C0380083C0220003C010800AC20007048
69158+:1062B0003496FFFF34770080345200033C1512C03F
69159+:1062C000241400013C1080002411FF800E000245C0
69160+:1062D000000000008F8700488F8B00188F89001402
69161+:1062E0008CEA00EC8CE800E8014B302B01092823F4
69162+:1062F00000A6102314400006014B18231440000E82
69163+:106300003C05800002A3602B1180000B0000000000
69164+:106310003C0560008CEE00EC8CED00E88CA4180CC1
69165+:10632000AF8E001804800053AF8D00148F8F0010C3
69166+:10633000ADF400003C0580008CBF00003BF900017B
69167+:10634000333800011700FFE13C0380008C6201003C
69168+:1063500024060C0010460009000000008C680100B3
69169+:106360002D043080548000103C0480008C690100B2
69170+:106370002D2331811060000C3C0480008CAA0100A8
69171+:1063800011460004000020218CA6010024C5FF81D5
69172+:1063900030A400FF8E0B01000E000269AE0B00243A
69173+:1063A0000A00034F3C0480008C8D01002DAC3300AB
69174+:1063B00011800022000000003C0708008CE70098D4
69175+:1063C00024EE00013C010800AC2E00983C04800043
69176+:1063D0008C8201001440000300000000566000148D
69177+:1063E0003C0440008C9F01008C9801000000982123
69178+:1063F00003F1C82400193940330F007F00EF7025E6
69179+:1064000001D26825AC8D08308C8C01008C85010090
69180+:10641000258B0100017130240006514030A3007F1C
69181+:106420000143482501324025AC8808303C04400037
69182+:10643000AE0401380A00030E000000008C99010030
69183+:10644000240F0020AC99002092F80000330300FFD5
69184+:10645000106F000C241F0050547FFFDD3C048000AF
69185+:106460008C8401000E00154E000000000A00034F4E
69186+:106470003C04800000963824ACA7180C0A000327BF
69187+:106480008F8F00108C8501000E0008F72404008017
69188+:106490000A00034F3C04800000A4102B24030001D9
69189+:1064A00010400009000030210005284000A4102BF6
69190+:1064B00004A00003000318405440FFFC00052840DE
69191+:1064C0005060000A0004182B0085382B54E00004AB
69192+:1064D0000003184200C33025008520230003184222
69193+:1064E0001460FFF9000528420004182B03E000089F
69194+:1064F00000C310213084FFFF30C600FF3C0780003E
69195+:106500008CE201B80440FFFE00064C000124302557
69196+:106510003C08200000C820253C031000ACE00180AE
69197+:10652000ACE50184ACE4018803E00008ACE301B809
69198+:106530003C0660008CC5201C2402FFF03083020062
69199+:10654000308601001060000E00A2282434A500014E
69200+:106550003087300010E0000530830C0034A50004C3
69201+:106560003C04600003E00008AC85201C1060FFFDC7
69202+:106570003C04600034A5000803E00008AC85201C42
69203+:1065800054C0FFF334A500020A0003B03087300086
69204+:1065900027BDFFE8AFB00010AFBF00143C0760009C
69205+:1065A000240600021080001100A080218F83005873
69206+:1065B0000E0003A78C6400188F8200580000202171
69207+:1065C000240600018C45000C0E000398000000001A
69208+:1065D0001600000224020003000010218FBF0014E7
69209+:1065E0008FB0001003E0000827BD00188CE8201CC5
69210+:1065F0002409FFF001092824ACE5201C8F870058EE
69211+:106600000A0003CD8CE5000C3C02600E00804021A6
69212+:1066100034460100240900180000000000000000BA
69213+:10662000000000003C0A00503C0380003547020097
69214+:10663000AC68003834640400AC65003CAC670030E2
69215+:106640008C6C0000318B00201160FFFD2407FFFFE0
69216+:106650002403007F8C8D00002463FFFF248400044A
69217+:10666000ACCD00001467FFFB24C60004000000004E
69218+:10667000000000000000000024A402000085282B78
69219+:106680003C0300203C0E80002529FFFF010540212E
69220+:10669000ADC300301520FFE00080282103E0000892
69221+:1066A000000000008F82005827BDFFD8AFB3001C48
69222+:1066B000AFBF0020AFB20018AFB10014AFB00010F0
69223+:1066C00094460002008098218C5200182CC300814F
69224+:1066D0008C4800048C4700088C51000C8C49001039
69225+:1066E000106000078C4A00142CC4000414800013AE
69226+:1066F00030EB000730C5000310A0001000000000C0
69227+:106700002410008B02002021022028210E00039873
69228+:10671000240600031660000224020003000010217A
69229+:106720008FBF00208FB3001C8FB200188FB10014F0
69230+:106730008FB0001003E0000827BD00281560FFF1AE
69231+:106740002410008B3C0C80003C030020241F00011F
69232+:10675000AD830030AF9F0044000000000000000047
69233+:10676000000000002419FFF024D8000F031978243A
69234+:106770003C1000D0AD88003801F0702524CD000316
69235+:106780003C08600EAD87003C35850400AD8E0030BE
69236+:10679000000D38823504003C3C0380008C6B000007
69237+:1067A000316200201040FFFD0000000010E00008F2
69238+:1067B00024E3FFFF2407FFFF8CA800002463FFFFF2
69239+:1067C00024A50004AC8800001467FFFB24840004A7
69240+:1067D0003C05600EACA60038000000000000000080
69241+:1067E000000000008F8600543C0400203C0780001D
69242+:1067F000ACE4003054C000060120202102402021DA
69243+:106800000E0003A7000080210A00041D02002021C1
69244+:106810000E0003DD01402821024020210E0003A7C5
69245+:10682000000080210A00041D0200202127BDFFE096
69246+:10683000AFB200183092FFFFAFB10014AFBF001C21
69247+:10684000AFB000101640000D000088210A0004932C
69248+:106850000220102124050003508500278CE5000C40
69249+:106860000000000D262800013111FFFF24E2002066
69250+:106870000232802B12000019AF8200588F82004430
69251+:10688000144000168F8700583C0670003C0320001F
69252+:106890008CE5000000A62024148300108F84006083
69253+:1068A000000544023C09800000A980241480FFE90F
69254+:1068B000310600FF2CCA000B5140FFEB26280001D7
69255+:1068C000000668803C0E080025CE575801AE6021B6
69256+:1068D0008D8B0000016000080000000002201021E4
69257+:1068E0008FBF001C8FB200188FB100148FB0001042
69258+:1068F00003E0000827BD00200E0003982404008454
69259+:106900001600FFD88F8700580A000474AF8000601B
69260+:10691000020028210E0003BF240400018F870058C5
69261+:106920000A000474AF820060020028210E0003BF39
69262+:10693000000020210A0004A38F8700580E000404E1
69263+:10694000020020218F8700580A000474AF82006083
69264+:1069500030AFFFFF000F19C03C0480008C9001B8DD
69265+:106960000600FFFE3C1920043C181000AC83018097
69266+:10697000AC800184AC990188AC9801B80A00047518
69267+:106980002628000190E2000390E30002000020218D
69268+:106990000002FE0000033A0000FF2825240600083C
69269+:1069A0000E000398000000001600FFDC2402000324
69270+:1069B0008F870058000010210A000474AF82006025
69271+:1069C00090E8000200002021240600090A0004C308
69272+:1069D00000082E0090E4000C240900FF308500FF21
69273+:1069E00010A900150000302190F9000290F8000372
69274+:1069F000308F00FF94EB000400196E000018740043
69275+:106A0000000F62000186202501AE5025014B28258C
69276+:106A10003084FF8B0A0004C32406000A90E30002BE
69277+:106A200090FF0004000020210003360000DF28252D
69278+:106A30000A0004C32406000B0A0004D52406008BB8
69279+:106A4000000449C23127003F000443423C02800059
69280+:106A500000082040240316802CE60020AC43002CC4
69281+:106A600024EAFFE02482000114C0000330A900FFE3
69282+:106A700000801021314700FF000260803C0D800043
69283+:106A8000240A0001018D20213C0B000E00EA28049D
69284+:106A9000008B302111200005000538278CCE000026
69285+:106AA00001C5382503E00008ACC700008CD8000001
69286+:106AB0000307782403E00008ACCF000027BDFFE007
69287+:106AC000AFB10014AFB00010AFBF00183C076000BA
69288+:106AD0008CE408083402F0003C1160003083F000C0
69289+:106AE000240501C03C04800E000030211062000625
69290+:106AF000241000018CEA08083149F0003928E00030
69291+:106B00000008382B000780403C0D0200AE2D081411
69292+:106B1000240C16803C0B80008E2744000E000F8B47
69293+:106B2000AD6C002C120000043C02169124050001FB
69294+:106B3000120500103C023D2C345800E0AE384408E9
69295+:106B40003C1108008E31007C8FBF00183C066000AD
69296+:106B500000118540360F16808FB100148FB00010E1
69297+:106B60003C0E020027BD0020ACCF442003E000080B
69298+:106B7000ACCE08103C0218DA345800E0AE384408B5
69299+:106B80003C1108008E31007C8FBF00183C0660006D
69300+:106B900000118540360F16808FB100148FB00010A1
69301+:106BA0003C0E020027BD0020ACCF442003E00008CB
69302+:106BB000ACCE08100A0004EB240500010A0004EB27
69303+:106BC0000000282124020400A7820024A780001CC2
69304+:106BD000000020213C06080024C65A582405FFFF67
69305+:106BE00024890001000440803124FFFF01061821A0
69306+:106BF0002C87002014E0FFFAAC6500002404040098
69307+:106C0000A7840026A780001E000020213C06080063
69308+:106C100024C65AD82405FFFF248D0001000460809B
69309+:106C200031A4FFFF018658212C8A00201540FFFA6D
69310+:106C3000AD650000A7800028A7800020A780002263
69311+:106C4000000020213C06080024C65B582405FFFFF5
69312+:106C5000249900010004C0803324FFFF030678213B
69313+:106C60002C8E000415C0FFFAADE500003C05600065
69314+:106C70008CA73D002403E08F00E31024344601403C
69315+:106C800003E00008ACA63D002487007F000731C266
69316+:106C900024C5FFFF000518C2246400013082FFFFF5
69317+:106CA000000238C0A78400303C010800AC27003047
69318+:106CB000AF80002C0000282100002021000030219E
69319+:106CC0002489000100A728213124FFFF2CA81701E7
69320+:106CD000110000032C8300801460FFF924C600011A
69321+:106CE00000C02821AF86002C10C0001DA786002AF6
69322+:106CF00024CAFFFF000A11423C08080025085B581F
69323+:106D00001040000A00002021004030212407FFFF2E
69324+:106D1000248E00010004688031C4FFFF01A86021B7
69325+:106D20000086582B1560FFFAAD87000030A2001FC7
69326+:106D30005040000800043080240300010043C804D0
69327+:106D400000041080004878212738FFFF03E0000886
69328+:106D5000ADF8000000C820212405FFFFAC8500002D
69329+:106D600003E000080000000030A5FFFF30C6FFFF71
69330+:106D700030A8001F0080602130E700FF0005294295
69331+:106D80000000502110C0001D24090001240B000147
69332+:106D900025180001010B2004330800FF0126782686
69333+:106DA000390E00202DED00012DC2000101A2182591
69334+:106DB0001060000D014450250005C880032C4021BF
69335+:106DC0000100182110E0000F000A20278D040000A8
69336+:106DD000008A1825AD03000024AD00010000402109
69337+:106DE0000000502131A5FFFF252E000131C9FFFF12
69338+:106DF00000C9102B1040FFE72518000103E0000830
69339+:106E0000000000008D0A0000014440240A0005D162
69340+:106E1000AC68000027BDFFE830A5FFFF30C6FFFFCC
69341+:106E2000AFB00010AFBF001430E7FFFF00005021EB
69342+:106E30003410FFFF0000602124AF001F00C0482174
69343+:106E4000241800012419002005E0001601E010219B
69344+:106E50000002F943019F682A0009702B01AE40240B
69345+:106E600011000017000C18800064102110E00005CC
69346+:106E70008C4B000000F840040008382301675824B8
69347+:106E800000003821154000410000402155600016E7
69348+:106E90003169FFFF258B0001316CFFFF05E1FFEC3D
69349+:106EA00001E0102124A2003E0002F943019F682A5C
69350+:106EB0000009702B01AE40241500FFEB000C188078
69351+:106EC000154600053402FFFF020028210E0005B51B
69352+:106ED00000003821020010218FBF00148FB0001075
69353+:106EE00003E0000827BD00181520000301601821E9
69354+:106EF000000B1C0224080010306A00FF154000053A
69355+:106F0000306E000F250D000800031A0231A800FFA3
69356+:106F1000306E000F15C00005307F000325100004FF
69357+:106F200000031902320800FF307F000317E000055C
69358+:106F3000386900012502000200031882304800FF72
69359+:106F4000386900013123000110600004310300FFA3
69360+:106F5000250A0001314800FF310300FF000C6940A1
69361+:106F600001A34021240A000110CAFFD53110FFFF00
69362+:106F7000246E000131C800FF1119FFC638C9000195
69363+:106F80002D1F002053E0001C258B0001240D000163
69364+:106F90000A000648240E002051460017258B0001E8
69365+:106FA00025090001312800FF2D0900205120001281
69366+:106FB000258B000125430001010D5004014B1024D5
69367+:106FC000250900011440FFF4306AFFFF3127FFFF5D
69368+:106FD00010EE000C2582FFFF304CFFFF0000502117
69369+:106FE0003410FFFF312800FF2D0900205520FFF24B
69370+:106FF00025430001258B0001014648260A000602B0
69371+:10700000316CFFFF00003821000050210A000654B7
69372+:107010003410FFFF27BDFFD8AFB0001030F0FFFFE6
69373+:10702000AFB10014001039423211FFE000071080A8
69374+:10703000AFB3001C00B1282330D3FFFFAFB200185C
69375+:1070400030A5FFFF00809021026030210044202104
69376+:10705000AFBF00200E0005E03207001F022288218A
69377+:107060003403FFFF0240202102002821026030216A
69378+:1070700000003821104300093231FFFF02201021A7
69379+:107080008FBF00208FB3001C8FB200188FB1001487
69380+:107090008FB0001003E0000827BD00280E0005E0B7
69381+:1070A0000000000000408821022010218FBF002036
69382+:1070B0008FB3001C8FB200188FB100148FB0001076
69383+:1070C00003E0000827BD0028000424003C03600002
69384+:1070D000AC603D0810A00002348210063482101605
69385+:1070E00003E00008AC623D0427BDFFE0AFB0001034
69386+:1070F000309000FF2E020006AFBF001810400008BD
69387+:10710000AFB10014001030803C03080024635784A2
69388+:1071100000C328218CA400000080000800000000AB
69389+:10712000000020218FBF00188FB100148FB0001015
69390+:107130000080102103E0000827BD00209791002A5D
69391+:1071400016200051000020213C020800904200332C
69392+:107150000A0006BB00000000978D002615A0003134
69393+:10716000000020210A0006BB2402000897870024A3
69394+:1071700014E0001A00001821006020212402000100
69395+:107180001080FFE98FBF0018000429C2004530219C
69396+:1071900000A6582B1160FFE43C0880003C0720004B
69397+:1071A000000569C001A76025AD0C00203C038008E4
69398+:1071B0002402001F2442FFFFAC6000000441FFFDD9
69399+:1071C0002463000424A5000100A6702B15C0FFF560
69400+:1071D000000569C00A0006A58FBF00189787001C2C
69401+:1071E0003C04080024845A58240504000E0006605C
69402+:1071F00024060001978B002424440001308AFFFFFD
69403+:107200002569FFFF2D48040000402821150000409B
69404+:10721000A789002424AC3800000C19C00A0006B964
69405+:10722000A780001C9787001E3C04080024845AD8BD
69406+:10723000240504000E00066024060001979900262C
69407+:10724000244400013098FFFF272FFFFF2F0E04007A
69408+:107250000040882115C0002CA78F0026A780001EA3
69409+:107260003A020003262401003084FFFF0E00068D41
69410+:107270002C4500010011F8C027F00100001021C0CA
69411+:107280000A0006BB240200089785002E978700227B
69412+:107290003C04080024845B580E00066024060001AC
69413+:1072A0009787002A8F89002C2445000130A8FFFF12
69414+:1072B00024E3FFFF0109302B0040802114C0001897
69415+:1072C000A783002AA7800022978500300E000F7543
69416+:1072D00002002021244A05003144FFFF0E00068DE4
69417+:1072E000240500013C05080094A500320E000F752E
69418+:1072F00002002021244521003C0208009042003376
69419+:107300000A0006BB000521C00A0006F3A784001E80
69420+:1073100024AC3800000C19C00A0006B9A784001C70
69421+:107320000A00070DA7850022308400FF27BDFFE873
69422+:107330002C820006AFBF0014AFB000101040001543
69423+:1073400000A03821000440803C0308002463579CBF
69424+:10735000010328218CA40000008000080000000028
69425+:1073600024CC007F000751C2000C59C23170FFFFCE
69426+:107370002547C40030E5FFFF2784001C02003021B0
69427+:107380000E0005B52407000197860028020620217B
69428+:10739000A78400288FBF00148FB0001003E00008FE
69429+:1073A00027BD00183C0508008CA50030000779C2F5
69430+:1073B0000E00038125E4DF003045FFFF3C04080098
69431+:1073C00024845B58240600010E0005B52407000143
69432+:1073D000978E002A8FBF00148FB0001025CD0001BA
69433+:1073E00027BD001803E00008A78D002A0007C9C2C6
69434+:1073F0002738FF00001878C231F0FFFF3C04080076
69435+:1074000024845AD802002821240600010E0005B564
69436+:1074100024070001978D0026260E0100000E84002F
69437+:1074200025AC00013C0B6000A78C0026AD603D0838
69438+:1074300036040006000030213C0760008CE23D0469
69439+:10744000305F000617E0FFFD24C9000100061B00A5
69440+:10745000312600FF006440252CC50004ACE83D0443
69441+:1074600014A0FFF68FBF00148FB0001003E00008D7
69442+:1074700027BD0018000751C22549C8002406000195
69443+:10748000240700013C04080024845A580E0005B566
69444+:107490003125FFFF978700248FBF00148FB00010A5
69445+:1074A00024E6000127BD001803E00008A786002499
69446+:1074B0003C0660183C090800252900FCACC9502C8A
69447+:1074C0008CC850003C0580003C020002350700805B
69448+:1074D000ACC750003C04080024841FE03C030800B3
69449+:1074E00024631F98ACA50008ACA2000C3C01080066
69450+:1074F000AC2459A43C010800AC2359A803E00008BF
69451+:107500002402000100A030213C1C0800279C59AC3B
69452+:107510003C0C04003C0B0002008B3826008C4026FB
69453+:107520002CE200010007502B2D050001000A4880C5
69454+:107530003C030800246359A4004520250123182199
69455+:107540001080000300001021AC660000240200013E
69456+:1075500003E00008000000003C1C0800279C59AC18
69457+:107560003C0B04003C0A0002008A3026008B3826BF
69458+:107570002CC200010006482B2CE5000100094080C8
69459+:107580003C030800246359A4004520250103182169
69460+:1075900010800005000010213C0C0800258C1F986D
69461+:1075A000AC6C00002402000103E0000800000000B1
69462+:1075B0003C0900023C080400008830260089382677
69463+:1075C0002CC30001008028212CE400010083102539
69464+:1075D0001040000B000030213C1C0800279C59ACD7
69465+:1075E0003C0A80008D4E00082406000101CA68256F
69466+:1075F000AD4D00088D4C000C01855825AD4B000C9D
69467+:1076000003E0000800C010213C1C0800279C59AC76
69468+:107610003C0580008CA6000C0004202724020001F9
69469+:1076200000C4182403E00008ACA3000C3C020002D4
69470+:107630001082000B3C0560003C070400108700032B
69471+:107640000000000003E00008000000008CA908D042
69472+:10765000240AFFFD012A402403E00008ACA808D05A
69473+:107660008CA408D02406FFFE0086182403E000083E
69474+:10767000ACA308D03C05601A34A600108CC300806F
69475+:1076800027BDFFF88CC50084AFA3000093A40000C1
69476+:107690002402001010820003AFA5000403E00008DC
69477+:1076A00027BD000893A7000114E0001497AC000266
69478+:1076B00097B800023C0F8000330EFFFC01CF682119
69479+:1076C000ADA50000A3A000003C0660008CC708D058
69480+:1076D0002408FFFE3C04601A00E82824ACC508D04A
69481+:1076E0008FA300048FA200003499001027BD00086A
69482+:1076F000AF22008003E00008AF2300843C0B800031
69483+:10770000318AFFFC014B48218D2800000A00080C3B
69484+:10771000AFA8000427BDFFE8AFBF00103C1C080065
69485+:10772000279C59AC3C0580008CA4000C8CA2000462
69486+:107730003C0300020044282410A0000A00A31824DF
69487+:107740003C0604003C0400021460000900A610245A
69488+:107750001440000F3C0404000000000D3C1C080015
69489+:10776000279C59AC8FBF001003E0000827BD00180C
69490+:107770003C0208008C4259A40040F80900000000B7
69491+:107780003C1C0800279C59AC0A0008358FBF00102C
69492+:107790003C0208008C4259A80040F8090000000093
69493+:1077A0000A00083B000000003C0880008D0201B880
69494+:1077B0000440FFFE35090180AD2400003C031000A9
69495+:1077C00024040040AD250004A1240008A1260009DE
69496+:1077D000A527000A03E00008AD0301B83084FFFFCD
69497+:1077E0000080382130A5FFFF000020210A00084555
69498+:1077F000240600803087FFFF8CA400002406003898
69499+:107800000A000845000028218F8300788F860070C9
69500+:107810001066000B008040213C07080024E75B68ED
69501+:10782000000328C000A710218C440000246300013D
69502+:10783000108800053063000F5466FFFA000328C06B
69503+:1078400003E00008000010213C07080024E75B6CFF
69504+:1078500000A7302103E000088CC200003C03900028
69505+:1078600034620001008220253C038000AC640020CB
69506+:107870008C65002004A0FFFE0000000003E000086B
69507+:10788000000000003C0280003443000100832025FA
69508+:1078900003E00008AC44002027BDFFE0AFB10014B6
69509+:1078A0003091FFFFAFB00010AFBF001812200013DF
69510+:1078B00000A080218CA20000240400022406020003
69511+:1078C0001040000F004028210E0007250000000096
69512+:1078D00000001021AE000000022038218FBF0018E8
69513+:1078E0008FB100148FB0001000402021000028212B
69514+:1078F000000030210A00084527BD00208CA20000AE
69515+:10790000022038218FBF00188FB100148FB00010F3
69516+:107910000040202100002821000030210A000845F5
69517+:1079200027BD002000A010213087FFFF8CA5000498
69518+:107930008C4400000A000845240600068F83FD9C45
69519+:1079400027BDFFE8AFBF0014AFB00010906700087C
69520+:10795000008010210080282130E600400000202116
69521+:1079600010C000088C5000000E0000BD0200202155
69522+:10797000020020218FBF00148FB000100A000548BC
69523+:1079800027BD00180E0008A4000000000E0000BD76
69524+:1079900002002021020020218FBF00148FB00010B0
69525+:1079A0000A00054827BD001827BDFFE0AFB0001052
69526+:1079B0008F90FD9CAFBF001CAFB20018AFB1001498
69527+:1079C00092060001008088210E00087230D2000467
69528+:1079D00092040005001129C2A6050000348300406E
69529+:1079E000A20300050E00087C022020210E00054A9B
69530+:1079F0000220202124020001AE02000C02202821D6
69531+:107A0000A602001024040002A602001224060200AE
69532+:107A1000A60200140E000725A60200161640000F4D
69533+:107A20008FBF001C978C00743C0B08008D6B007896
69534+:107A30002588FFFF3109FFFF256A0001012A382B45
69535+:107A400010E00006A78800743C0F6006240E0016A4
69536+:107A500035ED0010ADAE00508FBF001C8FB2001886
69537+:107A60008FB100148FB0001003E0000827BD002084
69538+:107A700027BDFFE0AFB10014AFBF0018AFB00010DA
69539+:107A80001080000400A088212402008010820007DA
69540+:107A9000000000000000000D8FBF00188FB100141F
69541+:107AA0008FB0001003E0000827BD00200E00087210
69542+:107AB00000A020218F86FD9C0220202190C500057A
69543+:107AC0000E00087C30B000FF2403003E1603FFF1D7
69544+:107AD0003C0680008CC401780480FFFE34C801405D
69545+:107AE000240900073C071000AD11000002202021EE
69546+:107AF000A10900048FBF00188FB100148FB00010CF
69547+:107B0000ACC701780A0008C527BD002027BDFFE0EB
69548+:107B1000AFB00010AFBF0018AFB100143C10800030
69549+:107B20008E110020000000000E00054AAE04002067
69550+:107B3000AE1100208FBF00188FB100148FB000105D
69551+:107B400003E0000827BD00203084FFFF00803821BB
69552+:107B50002406003500A020210A0008450000282145
69553+:107B60003084FFFF008038212406003600A0202149
69554+:107B70000A0008450000282127BDFFD0AFB500242A
69555+:107B80003095FFFFAFB60028AFB40020AFBF002C88
69556+:107B9000AFB3001CAFB20018AFB10014AFB000100B
69557+:107BA00030B6FFFF12A000270000A0218F920058DE
69558+:107BB0008E4300003C0680002402004000033E0289
69559+:107BC00000032C0230E4007F006698241482001D1C
69560+:107BD00030A500FF8F8300682C68000A1100001098
69561+:107BE0008F8D0044000358803C0C0800258C57B84A
69562+:107BF000016C50218D4900000120000800000000A8
69563+:107C000002D4302130C5FFFF0E0008522404008446
69564+:107C1000166000028F920058AF8000688F8D00447C
69565+:107C20002659002026980001032090213314FFFFDD
69566+:107C300015A00004AF9900580295202B1480FFDC9A
69567+:107C400000000000028010218FBF002C8FB600289A
69568+:107C50008FB500248FB400208FB3001C8FB20018A2
69569+:107C60008FB100148FB0001003E0000827BD003072
69570+:107C70002407003414A70149000000009247000EB9
69571+:107C80008F9FFDA08F90FD9C24181600A3E700197C
69572+:107C90009242000D3C0880003C07800CA3E20018D3
69573+:107CA000964A00123C0D60003C117FFFA60A005C62
69574+:107CB000964400103623FFFF240200053099FFFF91
69575+:107CC000AE1900548E46001CAD1800288CEF000041
69576+:107CD0008DAE444801E6482601C93021AE06003881
69577+:107CE0008E05003824CB00013C0E7F00AE05003C21
69578+:107CF0008E0C003CAFEC0004AE0B00208E13002075
69579+:107D0000AE13001CA3E0001BAE03002CA3E2001284
69580+:107D10008E4A001424130050AE0A00348E0400343E
69581+:107D2000AFE400148E590018AE1900489258000CA8
69582+:107D3000A218004E920D000835AF0020A20F0008D7
69583+:107D40008E090018012E282434AC4000AE0C001817
69584+:107D5000920B0000317200FF1253027F2403FF8058
69585+:107D60003C04080024845BE80E0008AA0000000020
69586+:107D70003C1108008E315BE80E00087202202021C1
69587+:107D80002405000424080001A2050025022020216A
69588+:107D90000E00087CA20800053C0580008CB001782C
69589+:107DA0000600FFFE8F92005834AE0140240F0002FF
69590+:107DB0003C091000ADD10000A1CF0004ACA90178AE
69591+:107DC0000A000962AF8000682CAD003751A0FF9413
69592+:107DD0008F8D0044000580803C110800263157E05B
69593+:107DE000021178218DEE000001C0000800000000A3
69594+:107DF0002411000414B1008C3C0780003C080800EA
69595+:107E00008D085BE88F86FD9CACE800208E4500085D
69596+:107E10008F99FDA0240D0050ACC500308E4C000899
69597+:107E2000ACCC00508E4B000CACCB00348E43001019
69598+:107E3000ACC300388E4A0010ACCA00548E42001405
69599+:107E4000ACC2003C8E5F0018AF3F00048E50001C97
69600+:107E5000ACD0002090C40000309800FF130D024AFF
69601+:107E6000000000008CC400348CD00030009030231F
69602+:107E700004C000F12404008C126000EE2402000310
69603+:107E80000A000962AF8200682419000514B900666F
69604+:107E90003C0580003C0808008D085BE88F86FD9C4F
69605+:107EA000ACA800208E4C00048F8AFDA0240720007F
69606+:107EB000ACCC001C924B000824120008A14B001906
69607+:107EC0008F82005890430009A14300188F85005805
69608+:107ED00090BF000A33E400FF1092001028890009C7
69609+:107EE000152000BA240E0002240D0020108D000B76
69610+:107EF000340780002898002117000008240740005C
69611+:107F000024100040109000053C0700012419008057
69612+:107F1000109900023C070002240740008CC20018A0
69613+:107F20003C03FF00004350240147F825ACDF001854
69614+:107F300090B2000BA0D200278F8300589464000CED
69615+:107F4000108001FE000000009467000C3C1F8000C0
69616+:107F50002405FFBFA4C7005C9063000E2407000443
69617+:107F6000A0C300088F820058904A000FA0CA0009E1
69618+:107F70008F8900588D3200108FE400740244C823AA
69619+:107F8000ACD900588D300014ACD0002C95380018B6
69620+:107F9000330DFFFFACCD00409531001A322FFFFFAB
69621+:107FA000ACCF00448D2E001CACCE00489128000EB2
69622+:107FB000A0C8000890CC000801855824126001B6C2
69623+:107FC000A0CB00088F9200580A000962AF870068B2
69624+:107FD0002406000614A600143C0E80003C0F080086
69625+:107FE0008DEF5BE88F85FD98ADCF00208E4900189E
69626+:107FF0008F86FD9C8F8BFDA0ACA900008CC800383B
69627+:1080000024040005ACA800048CCC003C1260008164
69628+:10801000AD6C00000A000962AF84006824110007FB
69629+:1080200010B1004B240400063C05080024A55BE8C1
69630+:108030000E000881240400818F9200580013102B39
69631+:108040000A000962AF820068241F002314BFFFF6F4
69632+:108050003C0C80003C0508008CA55BE88F8BFDA0E4
69633+:10806000AD8500208F91FD9C8E4600042564002084
69634+:1080700026450014AE260028240600030E000F81BA
69635+:10808000257000308F87005802002021240600034D
69636+:108090000E000F8124E500083C04080024845BE8FE
69637+:1080A0000E0008AA0000000092230000240A0050DD
69638+:1080B000306200FF544AFFE18F9200580E000F6CAF
69639+:1080C000000000000A000A6A8F920058240800335A
69640+:1080D00014A800323C0380003C1108008E315BE89C
69641+:1080E0008F8FFDA0AC7100208E420008240D002867
69642+:1080F0008F89FD9CADE200308E4A000C24060009F9
69643+:10810000ADEA00348E5F0010ADFF00388E440014DD
69644+:10811000ADE400208E590018ADF900248E58001CE3
69645+:10812000ADF80028A1ED00118E4E00041260003160
69646+:10813000AD2E00288F9200580A000962AF860068B1
69647+:10814000240D002214ADFFB8000000002404000735
69648+:108150003C1008008E105BE83C188000AF10002037
69649+:108160005660FEAEAF8400683C04080024845BE8DF
69650+:108170000E0008AA241300508F84FD9C90920000EA
69651+:10818000325900FF1333014B000000008F9200585A
69652+:10819000000020210A000962AF8400683C05080045
69653+:1081A00024A55BE80E000858240400810A000A6A2E
69654+:1081B0008F92005802D498213265FFFF0E000852BA
69655+:1081C000240400840A0009628F920058108EFF5325
69656+:1081D000240704002887000310E00179241100041B
69657+:1081E000240F0001548FFF4D240740000A000A228B
69658+:1081F000240701003C05080024A55BE80E0008A444
69659+:10820000240400828F920058000030210A00096285
69660+:10821000AF8600683C04080024845BE88CC2003808
69661+:108220000E0008AA8CC3003C8F9200580A000AC0B6
69662+:1082300000002021240400823C05080024A55BE8FE
69663+:108240000E0008A4000000008F92005800001021CA
69664+:108250000A000962AF8200688E5000048F91FD9C75
69665+:108260003C078000ACF00020922C00050200282181
69666+:10827000318B0002156001562404008A8F92FDA004
69667+:108280002404008D9245001B30A6002014C001502C
69668+:1082900002002821922E00092408001231C900FF93
69669+:1082A0001128014B240400810E00087202002021D5
69670+:1082B0009258001B240F000402002021370D0042B9
69671+:1082C000A24D001B0E00087CA22F00253C0580005B
69672+:1082D0008CA401780480FFFE34B90140241F000201
69673+:1082E000AF300000A33F00048F9200583C101000F4
69674+:1082F000ACB001780A000A6B0013102B8E500004FA
69675+:108300008F91FD9C3C038000AC700020922A0005F8
69676+:108310000200282131420002144000172404008A80
69677+:10832000922C00092412000402002821318B00FF46
69678+:1083300011720011240400810E0008720200202135
69679+:108340008F89FDA0240800122405FFFE912F001B39
69680+:108350000200202135EE0020A12E001BA2280009DA
69681+:108360009226000500C538240E00087CA2270005CF
69682+:1083700002002821000020210E0009330000000027
69683+:108380000A000A6A8F9200588E4C00043C07800055
69684+:108390003C10080026105BE8ACEC00203C01080013
69685+:1083A000AC2C5BE8924B0003317100041220013BBE
69686+:1083B0008F84FD9C24020006A0820009924F001BBE
69687+:1083C000240EFFC031E9003F012E4025A08800089F
69688+:1083D0009245000330A6000114C0013200000000E5
69689+:1083E0008E420008AE0200083C0208008C425BF09E
69690+:1083F000104001318F90FDA0000219C28F8DFD9CAD
69691+:10840000A603000C8E4A000C24180001240400145A
69692+:10841000AE0A002C8E420010AE02001C965F0016C1
69693+:10842000A61F003C96590014A619003EADB8000CDA
69694+:10843000A5B80010A5B80012A5B80014A5B800167C
69695+:1084400012600144A2040011925100033232000272
69696+:108450002E5300018F920058266200080A0009621C
69697+:10846000AF8200688E4400043C1980003C068008FE
69698+:10847000AF2400208E45000890D80000240D005045
69699+:10848000331100FF122D009C2407008824060009E8
69700+:108490000E000845000000000A000A6A8F9200588A
69701+:1084A0008E5000043C0980003C118008AD30002053
69702+:1084B0009228000024050050310400FF10850110AF
69703+:1084C0002407008802002021000028210E00084512
69704+:1084D0002406000E922D00002418FF80020028219F
69705+:1084E00001B8802524040004240600300E0007256E
69706+:1084F000A23000000A000A6A8F9200588E500004D1
69707+:108500008F91FDA03C028000AC500020923F001BE8
69708+:1085100033F900101320006C240700810200202191
69709+:10852000000028212406001F0E000845000000005E
69710+:108530000A000A6A8F9200588E44001C0E00085DE3
69711+:1085400000000000104000E3004048218F880058E0
69712+:1085500024070089012020218D05001C240600012C
69713+:108560000E000845000000000A000A6A8F920058B9
69714+:10857000964900023C10080026105BE831280004F0
69715+:10858000110000973C0460008E4E001C3C0F8000E0
69716+:10859000ADEE00203C010800AC2E5BE896470002DF
69717+:1085A00030E40001148000E6000000008E42000468
69718+:1085B000AE0200083C1008008E105BF0120000ECC8
69719+:1085C0003C0F80008F92FD9C241000018E4E0018FD
69720+:1085D0008F8DFDA08F9FFD9801CF4825AE490018D3
69721+:1085E000A2400005AE50000C3C0808008D085BF06E
69722+:1085F0008F840058A6500010000839C2A6500012FF
69723+:10860000A6500014A6500016A5A7000C8C8C0008DC
69724+:108610008F8B00588F8A0058ADAC002C8D63000CF6
69725+:1086200024070002ADA3001C91460010A1A6001172
69726+:108630008F82005890450011A3E500088F990058DB
69727+:1086400093380012A258004E8F910058922F0013B9
69728+:10865000A1AF00128F920058964E0014A5AE003CB8
69729+:1086600096490016A5A9003E8E480018ADA8001432
69730+:108670005660FD6AAF8700683C05080024A55BE8EA
69731+:108680000E000881000020218F9200580000382140
69732+:108690000A000962AF8700683C05080024A55BE872
69733+:1086A0000E0008A4240400828F9200580A000A4D8C
69734+:1086B000000038210E000F6C000000008F9200585F
69735+:1086C0000A000AC0000020210E00087202002021CA
69736+:1086D0009223001B02002021346A00100E00087C47
69737+:1086E000A22A001B000038210200202100002821BE
69738+:1086F0000A000BA52406001F9242000C305F000107
69739+:1087000013E0000300000000964A000EA4CA002CEB
69740+:10871000924B000C316300025060000600003821CB
69741+:108720008E470014964C0012ACC7001CA4CC001A53
69742+:10873000000038210A000B7F240600093C050800D0
69743+:1087400024A55BE80E0008A42404008B8F92005837
69744+:108750000A000A4D0013382B3C0C08008D8C5BE896
69745+:1087600024DFFFFE25930100326B007F016790211B
69746+:1087700002638824AD110028AE4600E0AE4000E45C
69747+:108780000A0009B3AE5F001CACC000543C0D0800E9
69748+:108790008DAD5BE83C18800C37090100ACED00287A
69749+:1087A0008E510014AD3100E08E4F0014AD2F00E467
69750+:1087B0008E4E001025C7FFFE0A0009F4AD27001CED
69751+:1087C0005491FDD6240740000A000A222407100015
69752+:1087D0000E00092D000000000A000A6A8F9200585E
69753+:1087E0008C83442C3C12DEAD3651BEEF3C010800B8
69754+:1087F000AC205BE810710062000000003C196C6264
69755+:1088000037387970147800082404000297850074C2
69756+:108810009782006C2404009200A2F82B13E0001948
69757+:1088200002002821240400020E00069524050200FF
69758+:108830003C068000ACC200203C010800AC225BE892
69759+:108840001040000D8F8C0058240A002824040003D7
69760+:10885000918B0010316300FF546A00012404000171
69761+:108860000E0000810000000010400004240400837A
69762+:108870000A000BC28F920058240400833C050800B4
69763+:1088800024A55BE80E000881000000008F920058CC
69764+:108890000013382B0A000962AF8700680A000B49F1
69765+:1088A000240200128E4400080E00085D0000000043
69766+:1088B0000A000B55AE0200083C05080024A55BE841
69767+:1088C0000E000858240400878F9200580A000B728B
69768+:1088D0000013102B240400040E000695240500301C
69769+:1088E0001440002A004048218F8800582407008344
69770+:1088F000012020218D05001C0A000BB32406000175
69771+:108900008F8300788F8600701066FEEE000038219D
69772+:108910003C07080024E75B6C000320C00087282187
69773+:108920008CAE000011D0005D246F000131E3000F18
69774+:108930005466FFFA000320C00A000B8C00003821A7
69775+:108940008E4400040E00085D000000000A000BC801
69776+:10895000AE0200083C05080024A55BE80E0008A450
69777+:10896000240400828F9200580A000B72000010212C
69778+:108970003C05080024A55BE80A000C7C2404008761
69779+:108980008C83442C0A000C5B3C196C628F88005865
69780+:108990003C0780083C0C8000240B0050240A000196
69781+:1089A000AD820020A0EB0000A0EA000191030004CA
69782+:1089B000A0E3001891040005A0E400199106000648
69783+:1089C0003C04080024845B6CA0E6001A91020007B6
69784+:1089D0003C06080024C65B68A0E2001B9105000865
69785+:1089E000A0E5001C911F0009A0FF001D9119000ABD
69786+:1089F000A0F9001E9118000BA0F8001F9112000CA6
69787+:108A0000A0F200209111000DA0F100219110000EA4
69788+:108A1000A0F00022910F000FA0EF0023910E001094
69789+:108A2000A0EE0024910D0011A0ED0025950C00147E
69790+:108A3000A4EC0028950B00168F8A00708F920078A6
69791+:108A4000A4EB002A95030018000A10C02545000178
69792+:108A5000A4E3002C8D1F001C0044C0210046C82147
69793+:108A600030A5000FAF3F0000AF09000010B20006B4
69794+:108A7000AF850070000038218D05001C01202021E9
69795+:108A80000A000BB32406000124AD000131A7000F3A
69796+:108A9000AF8700780A000CF9000038213C06080076
69797+:108AA00024C65B680086902100003821ACA000003D
69798+:108AB0000A000B8CAE4000003C0482013C036000C5
69799+:108AC00034820E02AC603D68AF80009803E000087D
69800+:108AD000AC623D6C27BDFFE8AFB000103090FFFFE7
69801+:108AE000001018422C620041AFBF00141440000275
69802+:108AF00024040080240300403C010800AC300060E6
69803+:108B00003C010800AC2300640E000F7500602821B2
69804+:108B1000244802BF2409FF8001092824001039805D
69805+:108B2000001030408FBF00148FB0001000A720212C
69806+:108B300000861821AF8300803C010800AC25005856
69807+:108B40003C010800AC24005C03E0000827BD0018CD
69808+:108B5000308300FF30C6FFFF30E400FF3C08800098
69809+:108B60008D0201B80440FFFE000354000144382583
69810+:108B70003C09600000E920253C031000AD050180A0
69811+:108B8000AD060184AD04018803E00008AD0301B81F
69812+:108B90008F8500583C0A6012354800108CAC0004E8
69813+:108BA0003C0D600E35A60010318B00062D690001CA
69814+:108BB000AD0900C48CA70004ACC731808CA20008AA
69815+:108BC00094A40002ACC231848CA3001C0460000396
69816+:108BD000A784009003E00008000000008CAF00189C
69817+:108BE000ACCF31D08CAE001C03E00008ACCE31D449
69818+:108BF0008F8500588F87FF288F86FF308CAE00044A
69819+:108C00003C0F601235E80010ACEE00788CAD000827
69820+:108C1000ACED007C8CAC0010ACCC004C8CAB000CF0
69821+:108C2000ACCB004894CA00543C0208008C4200447B
69822+:108C300025490001A4C9005494C400543083FFFFA7
69823+:108C400010620017000000003C0208008C42004047
69824+:108C5000A4C200528CA30018ACE300308CA2001414
69825+:108C6000ACE2002C8CB90018ACF900388CB80014B8
69826+:108C700024050001ACF800348D0600BC50C5001975
69827+:108C80008D0200B48D0200B8A4E2004894E40048CC
69828+:108C9000A4E4004A94E800EA03E000083102FFFF80
69829+:108CA0003C0208008C420024A4C00054A4C200521C
69830+:108CB0008CA30018ACE300308CA20014ACE2002CB2
69831+:108CC0008CB90018ACF900388CB8001424050001E8
69832+:108CD000ACF800348D0600BC54C5FFEB8D0200B823
69833+:108CE0008D0200B4A4E2004894E40048A4E4004AE1
69834+:108CF00094E800EA03E000083102FFFF8F86005885
69835+:108D00003C0480008CC900088CC80008000929C0F8
69836+:108D1000000839C0AC87002090C30007306200040F
69837+:108D20001040003EAF85009490CB0007316A0008E8
69838+:108D30001140003D8F87FF2C8CCD000C8CCE001491
69839+:108D400001AE602B11800036000000008CC2000CC8
69840+:108D5000ACE200708CCB00188F85FF288F88FF3025
69841+:108D6000ACEB00748CCA00102402FFF8ACAA00D847
69842+:108D70008CC9000CAD0900608CC4001CACA400D0F0
69843+:108D800090E3007C0062C824A0F9007C90D8000722
69844+:108D9000330F000811E000040000000090ED007C9B
69845+:108DA00035AC0001A0EC007C90CF000731EE000153
69846+:108DB00011C000060000000090E3007C241800347D
69847+:108DC00034790002A0F9007CACB800DC90C2000746
69848+:108DD0003046000210C000040000000090E8007C53
69849+:108DE00035040004A0E4007C90ED007D3C0B600E97
69850+:108DF000356A001031AC003FA0EC007D8D4931D4C4
69851+:108E00003127000110E00002240E0001A0AE00098D
69852+:108E100094AF00EA03E0000831E2FFFF8F87FF2CE8
69853+:108E20000A000DAF8CC200140A000DB0ACE0007057
69854+:108E30008F8C005827BDFFD8AFB3001CAFB200180D
69855+:108E4000AFB00010AFBF0020AFB10014918F00157C
69856+:108E50003C13600E3673001031EB000FA38B009CA7
69857+:108E60008D8F00048D8B0008959F0012959900103E
69858+:108E70009584001A9598001E958E001C33EDFFFF17
69859+:108E8000332AFFFF3089FFFF3308FFFF31C7FFFFA1
69860+:108E90003C010800AC2D00243C010800AC29004432
69861+:108EA0003C010800AC2A0040AE683178AE67317CE6
69862+:108EB00091850015959100163C12601236520010F3
69863+:108EC00030A200FF3230FFFFAE623188AE5000B4F6
69864+:108ED00091830014959F0018240600010066C804C1
69865+:108EE00033F8FFFFAE5900B8AE5800BC918E0014A5
69866+:108EF000AF8F00843C08600631CD00FFAE4D00C04E
69867+:108F0000918A00159584000E3C07600A314900FFE4
69868+:108F1000AF8B00883084FFFFAE4900C835110010C8
69869+:108F20000E000D1034F004103C0208008C4200606A
69870+:108F30003C0308008C6300643C0608008CC60058A3
69871+:108F40003C0508008CA5005C8F8400808FBF00204A
69872+:108F5000AE23004CAE65319CAE030054AE4500DC40
69873+:108F6000AE6231A0AE6331A4AE663198AE22004845
69874+:108F70008FB3001CAE0200508FB10014AE4200E06F
69875+:108F8000AE4300E4AE4600D88FB000108FB2001898
69876+:108F90000A00057D27BD0028978500929783007CF5
69877+:108FA00027BDFFE8AFB0001000A3102BAFBF001427
69878+:108FB000240400058F900058104000552409000239
69879+:108FC0000E0006958F850080AF8200942404000374
69880+:108FD0001040004F240900023C0680000E00008172
69881+:108FE000ACC2002024070001240820001040004DDE
69882+:108FF00024040005978E00928F8AFF2C24090050CC
69883+:1090000025C50001A7850092A14900003C0D08007C
69884+:109010008DAD0064240380008F84FF28000D66005E
69885+:10902000AD4C0018A5400006954B000A8F85FF3017
69886+:109030002402FF8001633024A546000A915F000AE4
69887+:109040000000482103E2C825A159000AA0A0000899
69888+:10905000A140004CA08000D5961800029783009094
69889+:109060003C020004A49800EA960F00022418FFBFF7
69890+:1090700025EE2401A48E00BE8E0D0004ACAD00448C
69891+:109080008E0C0008ACAC0040A4A00050A4A000547A
69892+:109090008E0B000C240C0030AC8B00288E060010C8
69893+:1090A000AC860024A480003EA487004EA487005014
69894+:1090B000A483003CAD420074AC8800D8ACA800602A
69895+:1090C000A08700FC909F00D433F9007FA09900D4C2
69896+:1090D000909000D402187824A08F00D4914E007C88
69897+:1090E00035CD0001A14D007C938B009CAD480070F4
69898+:1090F000AC8C00DCA08B00D68F8800888F87008422
69899+:10910000AC8800C4AC8700C8A5400078A540007AB0
69900+:109110008FBF00148FB000100120102103E0000861
69901+:1091200027BD00188F8500940E0007258F860080CC
69902+:109130000A000E9F2409000227BDFFE0AFB0001017
69903+:109140008F900058AFB10014AFBF00188E09000413
69904+:109150000E00054A000921C08E0800048F84FF28F4
69905+:109160008F82FF30000839C03C068000ACC7002069
69906+:10917000948500EA904300131460001C30B1FFFF97
69907+:109180008F8CFF2C918B0008316A00401540000B3A
69908+:10919000000000008E0D0004022030218FBF001857
69909+:1091A0008FB100148FB00010240400220000382179
69910+:1091B000000D29C00A000D2F27BD00200E000098C9
69911+:1091C000000000008E0D0004022030218FBF001827
69912+:1091D0008FB100148FB00010240400220000382149
69913+:1091E000000D29C00A000D2F27BD00200E000090A1
69914+:1091F000000000008E0D0004022030218FBF0018F7
69915+:109200008FB100148FB00010240400220000382118
69916+:10921000000D29C00A000D2F27BD002027BDFFE04B
69917+:10922000AFB200183092FFFFAFB00010AFBF001C0C
69918+:10923000AFB100141240001E000080218F8600583C
69919+:109240008CC500002403000600053F02000514023F
69920+:1092500030E4000714830016304500FF2CA80006F8
69921+:1092600011000040000558803C0C0800258C58BCBB
69922+:10927000016C50218D490000012000080000000011
69923+:109280008F8E0098240D000111CD005024020002A1
69924+:10929000AF820098260900013130FFFF24C800206A
69925+:1092A0000212202B010030211480FFE5AF88005806
69926+:1092B000020010218FBF001C8FB200188FB1001464
69927+:1092C0008FB0001003E0000827BD00209387007EC8
69928+:1092D00054E00034000030210E000DE700000000D3
69929+:1092E0008F8600580A000EFF240200018F87009825
69930+:1092F0002405000210E50031240400130000282199
69931+:1093000000003021240700010E000D2F0000000096
69932+:109310000A000F008F8600588F83009824020002F5
69933+:109320001462FFF6240400120E000D9A00000000E3
69934+:109330008F85009400403021240400120E000D2F70
69935+:10934000000038210A000F008F8600588F83009894
69936+:109350002411000310710029241F0002107FFFCE8A
69937+:1093600026090001240400100000282100003021FB
69938+:109370000A000F1D240700018F91009824060002A7
69939+:109380001626FFF9240400100E000E410000000014
69940+:10939000144000238F9800588F8600580A000EFF53
69941+:1093A00024020003240400140E000D2F00002821C5
69942+:1093B0008F8600580A000EFF240200020E000EA93C
69943+:1093C000000000000A000F008F8600580E000D3FBD
69944+:1093D00000000000241900022404001400002821C9
69945+:1093E0000000302100003821AF9900980E000D2FA9
69946+:1093F000000000000A000F008F8600580E000D5775
69947+:10940000000000008F8500942419000200403021E4
69948+:1094100024040010000038210A000F56AF9900986C
69949+:109420000040382124040010970F0002000028217A
69950+:109430000E000D2F31E6FFFF8F8600580A000F0047
69951+:10944000AF9100988F84FF2C3C077FFF34E6FFFF2D
69952+:109450008C8500182402000100A61824AC83001893
69953+:1094600003E00008A08200053084FFFF30A5FFFF65
69954+:109470001080000700001821308200011040000217
69955+:1094800000042042006518211480FFFB00052840DD
69956+:1094900003E000080060102110C000070000000079
69957+:1094A0008CA2000024C6FFFF24A50004AC820000AB
69958+:1094B00014C0FFFB2484000403E000080000000047
69959+:1094C00010A0000824A3FFFFAC86000000000000ED
69960+:1094D000000000002402FFFF2463FFFF1462FFFA74
69961+:1094E0002484000403E0000800000000000411C010
69962+:1094F00003E000082442024027BDFFE8AFB000109F
69963+:1095000000808021AFBF00140E000F9600A0202124
69964+:1095100000504821240AFF808FBF00148FB0001034
69965+:10952000012A30243127007F3C08800A3C042100B6
69966+:1095300000E8102100C428253C03800027BD001846
69967+:10954000AC650024AF820038AC400000AC6500245C
69968+:1095500003E00008AC4000403C0D08008DAD005811
69969+:1095600000056180240AFF8001A45821016C482174
69970+:10957000012A30243127007F3C08800C3C04210064
69971+:1095800000E8102100C428253C038000AC650028B9
69972+:10959000AF82003403E00008AC40002430A5FFFF98
69973+:1095A0003C0680008CC201B80440FFFE3C086015F8
69974+:1095B00000A838253C031000ACC40180ACC0018475
69975+:1095C000ACC7018803E00008ACC301B83C0D08003B
69976+:1095D0008DAD005800056180240AFF8001A4582148
69977+:1095E000016C4021010A4824000931403107007F05
69978+:1095F00000C728253C04200000A418253C02800058
69979+:10960000AC43083003E00008AF80003427BDFFE81A
69980+:10961000AFB0001000808021AFBF00140E000F9685
69981+:1096200000A0202100504821240BFF80012B502452
69982+:10963000000A39403128007F3C0620008FBF00140B
69983+:109640008FB0001000E8282534C2000100A21825C0
69984+:109650003C04800027BD0018AC83083003E00008FC
69985+:10966000AF8000383C0580088CA700603C0680086D
69986+:109670000087102B144000112C8340008CA8006040
69987+:109680002D0340001060000F240340008CC90060CF
69988+:109690000089282B14A00002008018218CC30060D0
69989+:1096A00000035A42000B30803C0A0800254A59202A
69990+:1096B00000CA202103E000088C8200001460FFF340
69991+:1096C0002403400000035A42000B30803C0A08008B
69992+:1096D000254A592000CA202103E000088C8200009E
69993+:1096E0003C05800890A60008938400AB24C20001CA
69994+:1096F000304200FF3043007F1064000C0002382726
69995+:10970000A0A200083C0480008C85017804A0FFFE24
69996+:109710008F8A00A0240900023C081000AC8A014096
69997+:10972000A089014403E00008AC8801780A00101BFE
69998+:1097300030E2008027BDFFD8AFB200188F9200A49E
69999+:10974000AFBF0020AFB3001CAFB00010AFB100142A
70000+:109750008F9300348E5900283C1000803C0EFFEFA0
70001+:10976000AE7900008E580024A260000A35CDFFFFBC
70002+:10977000AE7800049251002C3C0BFF9F356AFFFF2E
70003+:10978000A271000C8E6F000C3C080040A271000B0F
70004+:1097900001F06025018D4824012A382400E8302595
70005+:1097A000AE66000C8E450004AE6000183C0400FF5D
70006+:1097B000AE6500148E43002C3482FFFFA6600008C3
70007+:1097C0000062F824AE7F00108E5900088F9000A030
70008+:1097D000964E0012AE7900208E51000C31D83FFF1A
70009+:1097E00000187980AE7100248E4D001401F06021C4
70010+:1097F00031CB0001AE6D00288E4A0018000C41C22A
70011+:10980000000B4B80AE6A002C8E46001C01093821EB
70012+:10981000A667001CAE660030964500028E4400200C
70013+:10982000A665001EAE64003492430033306200042B
70014+:1098300054400006924700003C0280083443010077
70015+:109840008C7F00D0AE7F0030924700008F860038BA
70016+:10985000A0C700309245003330A4000250800007BA
70017+:10986000925100018F880038240BFF80910A00304C
70018+:10987000014B4825A1090030925100018F9000381A
70019+:10988000240CFFBF2404FFDFA21100318F8D0038AC
70020+:109890003C1880083711008091AF003C31EE007F0A
70021+:1098A000A1AE003C8F890038912B003C016C502404
70022+:1098B000A12A003C8F9F00388E68001493E6003C7C
70023+:1098C0002D0700010007114000C4282400A218251C
70024+:1098D000A3E3003C8F87003896590012A4F90032A8
70025+:1098E0008E450004922E007C30B0000300107823D7
70026+:1098F00031ED000300AD102131CC000215800002D3
70027+:1099000024460034244600303C0280083443008062
70028+:10991000907F007C00BFC824333800041700000289
70029+:1099200024C2000400C010218F98003824190002BE
70030+:10993000ACE20034A3190000924F003F8F8E003834
70031+:109940003C0C8008358B0080A1CF00018F9100383E
70032+:10995000924D003F8E440004A62D0002956A005CE3
70033+:109960000E000FF43150FFFF00024B800209382532
70034+:109970003C08420000E82825AE2500048E4400384B
70035+:109980008F850038ACA400188E460034ACA6001CAD
70036+:10999000ACA0000CACA00010A4A00014A4A0001661
70037+:1099A000A4A00020A4A00022ACA000248E62001479
70038+:1099B00050400001240200018FBF00208FB3001C23
70039+:1099C0008FB200188FB100148FB00010ACA2000845
70040+:1099D0000A00101327BD002827BDFFC83C058008DA
70041+:1099E00034A40080AFBF0034AFBE0030AFB7002C4E
70042+:1099F000AFB60028AFB50024AFB40020AFB3001C51
70043+:109A0000AFB20018AFB10014AFB00010948300786B
70044+:109A10009482007A104300512405FFFF0080F0215A
70045+:109A20000A0011230080B821108B004D8FBF003435
70046+:109A30008F8600A03C1808008F18005C2411FF805E
70047+:109A40003C1680000306782101F18024AED0002C62
70048+:109A500096EE007A31EC007F3C0D800E31CB7FFF1B
70049+:109A6000018D5021000B4840012AA82196A4000036
70050+:109A70003C0808008D0800582405FF8030953FFF02
70051+:109A800001061821001539800067C8210325F82434
70052+:109A90003C02010003E290253338007F3C11800C2A
70053+:109AA000AED20028031190219250000D320F000415
70054+:109AB00011E0003702E0982196E3007A96E8007AF8
70055+:109AC00096E5007A2404800031077FFF24E300013B
70056+:109AD00030627FFF00A4F82403E2C825A6F9007ACB
70057+:109AE00096E6007A3C1408008E94006030D67FFF22
70058+:109AF00012D400C1000000008E5800188F8400A00E
70059+:109B000002A028212713FFFF0E000FCEAE53002C1A
70060+:109B100097D5007897D4007A12950010000028217C
70061+:109B20003C098008352401003C0A8008914800085F
70062+:109B3000908700D53114007F30E400FF0284302B81
70063+:109B400014C0FFB9268B0001938E00AB268C000158
70064+:109B5000008E682115ACFFB78F8600A08FBF003440
70065+:109B60008FBE00308FB7002C8FB600288FB5002431
70066+:109B70008FB400208FB3001C8FB200188FB1001477
70067+:109B80008FB0001000A0102103E0000827BD0038AE
70068+:109B900000C020210E000F99028028218E4B00105A
70069+:109BA0008E4C00308F84003824090002016C502351
70070+:109BB000AE4A0010A089000096E3005C8E4400309D
70071+:109BC0008F9100380E000FF43070FFFF00024380C9
70072+:109BD000020838253C02420000E22825AE25000498
70073+:109BE0008E5F00048F8A00388E590000240B000815
70074+:109BF000AD5F001CAD590018AD40000CAD40001029
70075+:109C00009246000A240400052408C00030D000FF5A
70076+:109C1000A550001496580008A55800169251000A45
70077+:109C20003C188008322F00FFA54F0020964E0008F8
70078+:109C300037110100A54E0022AD400024924D000BCB
70079+:109C400031AC00FFA54C0002A14B00018E49003051
70080+:109C50008F830038240BFFBFAC690008A06400307C
70081+:109C60008F9000382403FFDF9607003200E8282495
70082+:109C700000B51025A6020032921F003233F9003FD2
70083+:109C800037260040A20600328F8C0038AD800034A9
70084+:109C90008E2F00D0AD8F0038918E003C3C0F7FFF9F
70085+:109CA00031CD007FA18D003C8F84003835EEFFFF61
70086+:109CB000908A003C014B4824A089003C8F850038E5
70087+:109CC00090A8003C01033824A0A7003C8E42003439
70088+:109CD0008F9100383C038008AE2200408E59002C42
70089+:109CE0008E5F0030033F3023AE26004492300048A0
70090+:109CF0003218007FA23800488F8800388E4D00301F
70091+:109D00008D0C004801AE582401965024014B482583
70092+:109D1000AD0900489244000AA104004C964700088F
70093+:109D20008F850038A4A7004E8E5000308E4400303E
70094+:109D30000E0003818C65006092F9007C0002F940FE
70095+:109D4000004028210002110003E2302133360002D6
70096+:109D500012C00003020680210005B0800216802197
70097+:109D6000926D007C31B30004126000020005708027
70098+:109D7000020E80218E4B00308F8800382405800031
70099+:109D8000316A0003000A4823312400030204182129
70100+:109D9000AD03003496E4007A96F0007A96F1007AEA
70101+:109DA00032027FFF2447000130FF7FFF0225C824D5
70102+:109DB000033F3025A6E6007A96F8007A3C120800A8
70103+:109DC0008E520060330F7FFF11F200180000000078
70104+:109DD0008F8400A00E000FCE02A028218F8400A047
70105+:109DE0000E000FDE028028210E001013000000007C
70106+:109DF0000A00111F0000000096F1007A022480245E
70107+:109E0000A6F0007A92EF007A92EB007A31EE00FF32
70108+:109E1000000E69C2000D6027000C51C03169007F3F
70109+:109E2000012A20250A001119A2E4007A96E6007A98
70110+:109E300000C5C024A6F8007A92EF007A92F3007A67
70111+:109E400031F200FF001271C2000E6827000DB1C090
70112+:109E5000326C007F01962825A2E5007A0A0011D015
70113+:109E60008F8400A03C0380003084FFFF30A5FFFFFB
70114+:109E7000AC640018AC65001C03E000088C620014A0
70115+:109E800027BDFFA03C068008AFBF005CAFBE0058F6
70116+:109E9000AFB70054AFB60050AFB5004CAFB40048F8
70117+:109EA000AFB30044AFB20040AFB1003CAFB0003838
70118+:109EB00034C80100910500D590C700083084FFFF29
70119+:109EC00030A500FF30E2007F0045182AAFA4001043
70120+:109ED000A7A00018A7A0002610600055AFA000148E
70121+:109EE00090CA00083149007F00A9302324D3FFFF26
70122+:109EF0000013802B8FB400100014902B02128824C2
70123+:109F0000522000888FB300143C03800894790052DB
70124+:109F1000947E00508FB60010033EC0230018BC0092
70125+:109F2000001714030016FC0002C2A82A16A00002A3
70126+:109F3000001F2C030040282100133C0000072403CD
70127+:109F400000A4102A5440000100A020212885000907
70128+:109F500014A000020080A021241400083C0C8008FA
70129+:109F60008D860048001459808D88004C3C03800089
70130+:109F70003169FFFF3C0A0010012A202534710400DA
70131+:109F8000AC660038AF9100A4AC68003CAC64003013
70132+:109F900000000000000000000000000000000000C1
70133+:109FA00000000000000000000000000000000000B1
70134+:109FB0008C6E000031CD002011A0FFFD0014782A26
70135+:109FC00001F01024104000390000A8213C16800840
70136+:109FD00092D700083C1280008E44010032F6007FC8
70137+:109FE0000E000F9902C028218E3900108E44010006
70138+:109FF0000000902133373FFF0E000FB102E028210F
70139+:10A00000923800003302003F2C500008520000102C
70140+:10A0100000008821000210803C030800246358E4FB
70141+:10A020000043F8218FFE000003C00008000000007C
70142+:10A0300090CF0008938C00AB31EE007F00AE682318
70143+:10A04000018D58210A0012172573FFFF0000882197
70144+:10A050003C1E80008FC401000E000FCE02E02821BC
70145+:10A060008FC401000E000FDE02C028211220000F55
70146+:10A070000013802B8F8B00A426A400010004AC00E9
70147+:10A08000027298230015AC032578004002B4B02A70
70148+:10A090000013802B241700010300882102D0102414
70149+:10A0A000AF9800A41440FFC9AFB700143C07800864
70150+:10A0B00094E200508FAE00103C05800002A288217F
70151+:10A0C0003C060020A4F10050ACA6003094F40050EF
70152+:10A0D00094EF005201D51823306CFFFF11F4001EDD
70153+:10A0E000AFAC00108CEF004C001561808CF500487F
70154+:10A0F00001EC28210000202100AC582B02A4C02133
70155+:10A10000030BB021ACE5004CACF600488FB4001056
70156+:10A110000014902B021288241620FF7C3C03800838
70157+:10A120008FB300148FBF005C8FBE00583A620001ED
70158+:10A130008FB700548FB600508FB5004C8FB40048D5
70159+:10A140008FB300448FB200408FB1003C8FB0003815
70160+:10A1500003E0000827BD006094FE00548CF2004428
70161+:10A1600033C9FFFE0009C8C00259F821ACBF003C4A
70162+:10A170008CE800448CAD003C010D50231940003B9D
70163+:10A18000000000008CF7004026E20001ACA200387D
70164+:10A190003C05005034A700103C038000AC67003041
70165+:10A1A00000000000000000000000000000000000AF
70166+:10A1B000000000000000000000000000000000009F
70167+:10A1C0008C7800003316002012C0FFFD3C1180087F
70168+:10A1D000962200543C1580003C068008304E000159
70169+:10A1E000000E18C0007578218DEC04003C070800B3
70170+:10A1F0008CE700443C040020ACCC00488DF40404FF
70171+:10A20000240B0001ACD4004C10EB0260AEA4003073
70172+:10A21000963900523C0508008CA5004000B99021F9
70173+:10A22000A6320052963F005427ED0001A62D00549F
70174+:10A230009626005430C4FFFF5487FF2F8FB40010C0
70175+:10A2400030A5FFFF0E0011F4A62000543C070800C3
70176+:10A250008CE70024963E00520047B82303D74823DA
70177+:10A26000A62900520A0012198FB400108CE2004097
70178+:10A270000A0012BE00000000922400012407000121
70179+:10A280003085007F14A7001C97AD00268E2B00148C
70180+:10A29000240CC000316A3FFF01AC48243C06080092
70181+:10A2A0008CC60060012A402531043FFF0086882BC0
70182+:10A2B00012200011A7A800263C0508008CA5005814
70183+:10A2C0008F9100A0000439802402FF8000B1182182
70184+:10A2D0000067F82103E2F02433F8007F3C1280008D
70185+:10A2E0003C19800EAE5E002C0319702191D0000D38
70186+:10A2F000360F0004A1CF000D0E001028241200011B
70187+:10A30000241100013C1E80008FC401000E000FCEFE
70188+:10A3100002E028218FC401000E000FDE02C02821B8
70189+:10A320001620FF558F8B00A40A0012860013802B85
70190+:10A330008F8600A490C80001310400201080019194
70191+:10A34000241000013C048008348B0080916A007C5A
70192+:10A350008F9E0034AFA0002C314900011120000F66
70193+:10A36000AFB000288CCD00148C8E006001AE602B45
70194+:10A370001580000201A038218C8700603C188008FD
70195+:10A38000370300808C70007000F0782B15E000021D
70196+:10A3900000E020218C640070AFA4002C3C028008F7
70197+:10A3A000344500808CD200148CBF0070025FC82B33
70198+:10A3B00017200002024020218CA400708FA7002CDF
70199+:10A3C0000087182310600003AFA3003024050002AB
70200+:10A3D000AFA500288FA400280264882B162000BA9D
70201+:10A3E000000018218CD000388FCE000C3C0F00806C
70202+:10A3F000AFD000008CCD00343C0CFF9F01CF58251E
70203+:10A40000AFCD000490CA003F3586FFFF01662024CF
70204+:10A410003C0900203C08FFEFA3CA000B0089382547
70205+:10A420003511FFFF00F118243C0500088F8700A4B8
70206+:10A430000065C825AFD9000C8CE20014AFC000182D
70207+:10A440008FA60030AFC200148CF800188FB0002C1B
70208+:10A450003C1FFFFBAFD8001C8CEF000837F2FFFF5A
70209+:10A4600003326824AFCF00248CEC000C020670216C
70210+:10A47000AFCD000CA7C00038A7C0003AAFCE002C6B
70211+:10A48000AFCC0020AFC000288CEA00148FAB002CAA
70212+:10A49000014B48230126402311000011AFC80010D2
70213+:10A4A00090EB003D8FC900048FC80000000B5100E5
70214+:10A4B000012A28210000102100AA882B010218215E
70215+:10A4C0000071F821AFC50004AFDF000090F2003D3D
70216+:10A4D000A3D2000A8F9900A497380006A7D80008D5
70217+:10A4E0008F910038240800023C038008A228000055
70218+:10A4F0003465008094BF005C8FA4002C33F0FFFF14
70219+:10A500000E000FF48F9200380002CB808F8500A4DC
70220+:10A51000021978253C18420001F87025AE4E00045F
70221+:10A520008F8400388CAD0038AC8D00188CAC0034B2
70222+:10A53000AC8C001CAC80000CAC800010A48000141B
70223+:10A54000A4800016A4800020A4800022AC800024F7
70224+:10A5500090A6003F8FA7002CA486000250E0019235
70225+:10A56000240700018FA200305040000290A2003D5D
70226+:10A5700090A2003E244A0001A08A00018F84003886
70227+:10A580008FA9002CAC8900083C128008364D008051
70228+:10A5900091AC007C3186000214C000022407003414
70229+:10A5A000240700308F8500A43C198008373F0080C5
70230+:10A5B00090B0000093F9007C240E0004A0900030BD
70231+:10A5C0008F8F00A48FB8002C8F8D003891F200017E
70232+:10A5D0003304000301C46023A1B200318F8E003820
70233+:10A5E0008F8600A42402C00095CA003294C90012CC
70234+:10A5F0008FAB002C0142402431233FFF010388250B
70235+:10A60000A5D1003291D000323185000300EBF82152
70236+:10A610003218003F370F0040A1CF00328FA4002C2A
70237+:10A6200003E5382133280004108000028F850038AC
70238+:10A6300000E838213C0A8008ACA700343549010005
70239+:10A640008D2800D08FA3002C2419FFBFACA80038A0
70240+:10A6500090B1003C2C640001240FFFDF3227007F03
70241+:10A66000A0A7003C8F98003800049140931F003C45
70242+:10A6700003F98024A310003C8F8C0038918E003C9D
70243+:10A6800001CF682401B23025A186003C8F8900A447
70244+:10A690008F8800388D2B0020AD0B00408D220024C8
70245+:10A6A000AD0200448D2A0028AD0A00488D23002CFD
70246+:10A6B0000E001013AD03004C8FB1002824070002D8
70247+:10A6C000122700118FA300280003282B00058023E8
70248+:10A6D0000270982400608021006090210A00126FAF
70249+:10A6E0000010882B962900128F8400A00000902172
70250+:10A6F0003125FFFFA7A900180E000FC22411000189
70251+:10A700000A00131D3C1E80003C0B80003C12800898
70252+:10A710008D640100924900088F92FF340E000F995A
70253+:10A720003125007F8F9900388FA700288FA4003033
70254+:10A73000A3270000965F005C33F0FFFF0E000FF4CC
70255+:10A740008F91003800026B80020D80253C0842008A
70256+:10A750008F8D00A402085025AE2A00048DA5003874
70257+:10A760008F8A003800007821000F1100AD450018D5
70258+:10A770008DB800343C047FFF3488FFFFAD58001CC7
70259+:10A7800091A6003E8D4C001C8D4900180006190052
70260+:10A79000000677020183C821004E58250323882B29
70261+:10A7A000012B382100F1F821AD59001CAD5F0018D4
70262+:10A7B000AD40000CAD40001091B0003E8FA40030C1
70263+:10A7C00024090005A550001495A500042419C00013
70264+:10A7D00000884024A545001691B8003EA5580020E9
70265+:10A7E00095AF0004A54F0022AD40002491AE003F7C
70266+:10A7F000A54E000291A6003E91AC003D01861023BB
70267+:10A80000244B0001A14B00018F9100388FA3003031
70268+:10A810003C028008344B0100AE230008A22900301E
70269+:10A820008F8C00388F8700A4959F003294F000121F
70270+:10A830002407FFBF033FC02432053FFF03057825EF
70271+:10A84000A58F0032918E00322418FFDF31CD003FFA
70272+:10A8500035A60040A18600328F910038240DFFFFFD
70273+:10A86000240CFF80AE2000348D6A00D0AE2A003860
70274+:10A870009223003C3069007FA229003C8F90003871
70275+:10A880003C0380009219003C0327F824A21F003CDF
70276+:10A890008F8E003891C5003C00B87824A1CF003CD1
70277+:10A8A0008F8A00383C0E8008AD4D00408FA6002CEA
70278+:10A8B000AD46004491420048004C5825A14B004849
70279+:10A8C0008F9000388F9900A48E09004801238824B6
70280+:10A8D00002283825AE070048933F003EA21F004CD7
70281+:10A8E0008F9800A48F8F003897050004A5E5004ECF
70282+:10A8F0000E0003818DC500609246007C8FAC003055
70283+:10A9000000026940000291000040282130CB000283
70284+:10A9100001B21021156000AA018230213C0E80088E
70285+:10A9200035C20080904C007C31830004106000032D
70286+:10A930008FB900300005788000CF3021241F00043B
70287+:10A940008F910038332D000303ED8023320800037C
70288+:10A9500000C85021AE2A00343C188000A7C500383A
70289+:10A960003C0680088F04010090DE00080E000FDE18
70290+:10A9700033C5007F0E001013000000000A00140D04
70291+:10A980008FA300288F9800348CC90038241F00033F
70292+:10A99000A7000008AF0900008CC50034A300000A1E
70293+:10A9A0008F9900A4AF0500043C080080932D003F60
70294+:10A9B000A31F000C8F0A000C3C02FF9FA30D000B8D
70295+:10A9C0000148F0253451FFFF3C12FFEF8F9900A49E
70296+:10A9D00003D170243646FFFF01C61824AF03000CD4
70297+:10A9E0008F2C0014972900128F8400A0AF0C001048
70298+:10A9F0008F2F0014AF000018AF000020AF0F00141D
70299+:10AA0000AF0000248F270018312F3FFF000F59801F
70300+:10AA1000AF0700288F2500080164F821312D0001BF
70301+:10AA2000AF0500308F31000C8F920038001F51C2EB
70302+:10AA3000000D438001481021241E00023C068008BE
70303+:10AA4000A702001CA7000034AF11002CA25E00007A
70304+:10AA500034D20080964E005C8F9900383C0342004F
70305+:10AA600031CCFFFF01833825AF2700048F8B00A472
70306+:10AA7000240500012402C0008D640038240700343E
70307+:10AA8000AF2400188D690034AF29001CAF20000CE2
70308+:10AA9000AF200010A7200014A7200016A720002038
70309+:10AAA000A7200022AF200024A7300002A325000128
70310+:10AAB0008F8800388F9F00A4AD10000893ED000030
70311+:10AAC000A10D00308F8A00A48F98003891510001A9
70312+:10AAD000A31100318F8B0038957E003203C27024A1
70313+:10AAE00001CF6025A56C0032916300323064003FD5
70314+:10AAF000A16400329249007C3125000214A00002BA
70315+:10AB00008F840038240700303C198008AC8700345B
70316+:10AB1000373201008E5F00D0240AFFBF020090216F
70317+:10AB2000AC9F0038908D003C31A8007FA088003C8D
70318+:10AB30008F9E003893C2003C004A8824A3D1003C79
70319+:10AB40008F8300380010882B9066003C34CE0020A4
70320+:10AB5000A06E003C8F8400A48F9800388C8C00205D
70321+:10AB6000AF0C00408C8F0024AF0F00448C8700286E
70322+:10AB7000AF0700488C8B002CAF0B004C0E0010135D
70323+:10AB80003C1E80000A0012700000000094C80052B1
70324+:10AB90003C0A08008D4A002401488821A4D10052B3
70325+:10ABA0000A0012198FB40010A08700018F840038AA
70326+:10ABB000240B0001AC8B00080A0013BE3C12800875
70327+:10ABC000000520800A0014A200C4302127BDFFE048
70328+:10ABD0003C0D8008AFB20018AFB00010AFBF001C32
70329+:10ABE000AFB1001435B200808E4C001835A80100BA
70330+:10ABF000964B000695A70050910900FC000C5602E8
70331+:10AC0000016728233143007F312600FF240200031F
70332+:10AC1000AF8300A8AF8400A010C2001B30B0FFFFBC
70333+:10AC2000910600FC2412000530C200FF10520033D0
70334+:10AC300000000000160000098FBF001C8FB2001832
70335+:10AC40008FB100148FB00010240D0C003C0C80005C
70336+:10AC500027BD002003E00008AD8D00240E0011FB8D
70337+:10AC6000020020218FBF001C8FB200188FB100148A
70338+:10AC70008FB00010240D0C003C0C800027BD00207C
70339+:10AC800003E00008AD8D0024965800789651007AB4
70340+:10AC9000924E007D0238782631E8FFFF31C400C0B3
70341+:10ACA000148000092D11000116000037000000007B
70342+:10ACB0005620FFE28FBF001C0E0010D100000000E4
70343+:10ACC0000A00156A8FBF001C1620FFDA0000000082
70344+:10ACD0000E0010D1000000001440FFD88FBF001CF0
70345+:10ACE0001600002200000000925F007D33E2003F6A
70346+:10ACF000A242007D0A00156A8FBF001C950900EA78
70347+:10AD00008F86008000802821240400050E0007257E
70348+:10AD10003130FFFF978300923C0480002465FFFFE1
70349+:10AD2000A78500928C8A01B80540FFFE0000000054
70350+:10AD3000AC8001808FBF001CAC9001848FB20018E2
70351+:10AD40008FB100148FB000103C0760133C0B100053
70352+:10AD5000240D0C003C0C800027BD0020AC8701882E
70353+:10AD6000AC8B01B803E00008AD8D00240E0011FB90
70354+:10AD7000020020215040FFB18FBF001C925F007D78
70355+:10AD80000A00159733E2003F0E0011FB020020215C
70356+:10AD90001440FFAA8FBF001C122000070000000013
70357+:10ADA0009259007D3330003F36020040A242007DC0
70358+:10ADB0000A00156A8FBF001C0E0010D100000000B1
70359+:10ADC0005040FF9E8FBF001C9259007D3330003FE2
70360+:10ADD0000A0015C636020040000000000000001BFB
70361+:10ADE0000000000F0000000A00000008000000063C
70362+:10ADF0000000000500000005000000040000000441
70363+:10AE00000000000300000003000000030000000336
70364+:10AE10000000000300000002000000020000000229
70365+:10AE2000000000020000000200000002000000021A
70366+:10AE3000000000020000000200000002000000020A
70367+:10AE400000000002000000020000000200000002FA
70368+:10AE50000000000100000001000000018008010066
70369+:10AE6000800800808008000000000C000000308096
70370+:10AE7000080011D00800127C08001294080012A8E3
70371+:10AE8000080012BC080011D0080011D0080012F010
70372+:10AE90000800132C080013400800138808001A8CBF
70373+:10AEA00008001A8C08001AC408001AC408001AD82E
70374+:10AEB00008001AA808001D0008001CCC08001D5836
70375+:10AEC00008001D5808001DE008001D108008024001
70376+:10AED000080027340800256C0800275C080027F4C8
70377+:10AEE0000800293C0800298808002AAC080029B479
70378+:10AEF00008002A38080025DC08002EDC08002EA4F3
70379+:10AF000008002588080025880800258808002B20CF
70380+:10AF100008002B20080025880800258808002DD06F
70381+:10AF2000080025880800258808002588080025884D
70382+:10AF300008002E0C080025880800258808002588B0
70383+:10AF4000080025880800258808002588080025882D
70384+:10AF5000080025880800258808002588080025881D
70385+:10AF6000080025880800258808002588080029A8E9
70386+:10AF7000080025880800258808002E680800258814
70387+:10AF800008002588080025880800258808002588ED
70388+:10AF900008002588080025880800258808002588DD
70389+:10AFA00008002588080025880800258808002588CD
70390+:10AFB00008002588080025880800258808002588BD
70391+:10AFC00008002CF4080025880800258808002C6853
70392+:10AFD00008002BC408003CE408003CB808003C848E
70393+:10AFE00008003C5808003C3808003BEC8008010091
70394+:10AFF00080080080800800008008008008004C6401
70395+:10B0000008004C9C08004BE408004C6408004C64A9
70396+:10B01000080049B808004C64080050500A000C842D
70397+:10B0200000000000000000000000000D7278703683
70398+:10B030002E322E31620000000602010300000000E3
70399+:10B0400000000001000000000000000000000000FF
70400+:10B0500000000000000000000000000000000000F0
70401+:10B0600000000000000000000000000000000000E0
70402+:10B0700000000000000000000000000000000000D0
70403+:10B0800000000000000000000000000000000000C0
70404+:10B0900000000000000000000000000000000000B0
70405+:10B0A00000000000000000000000000000000000A0
70406+:10B0B0000000000000000000000000000000000090
70407+:10B0C0000000000000000000000000000000000080
70408+:10B0D0000000000000000000000000000000000070
70409+:10B0E0000000000000000000000000000000000060
70410+:10B0F0000000000000000000000000000000000050
70411+:10B10000000000000000000000000000000000003F
70412+:10B11000000000000000000000000000000000002F
70413+:10B12000000000000000000000000000000000001F
70414+:10B13000000000000000000000000000000000000F
70415+:10B1400000000000000000000000000000000000FF
70416+:10B1500000000000000000000000000000000000EF
70417+:10B1600000000000000000000000000000000000DF
70418+:10B1700000000000000000000000000000000000CF
70419+:10B1800000000000000000000000000000000000BF
70420+:10B1900000000000000000000000000000000000AF
70421+:10B1A000000000000000000000000000000000009F
70422+:10B1B000000000000000000000000000000000008F
70423+:10B1C000000000000000000000000000000000007F
70424+:10B1D000000000000000000000000000000000006F
70425+:10B1E000000000000000000000000000000000005F
70426+:10B1F000000000000000000000000000000000004F
70427+:10B20000000000000000000000000000000000003E
70428+:10B21000000000000000000000000000000000002E
70429+:10B22000000000000000000000000000000000001E
70430+:10B23000000000000000000000000000000000000E
70431+:10B2400000000000000000000000000000000000FE
70432+:10B2500000000000000000000000000000000000EE
70433+:10B2600000000000000000000000000000000000DE
70434+:10B2700000000000000000000000000000000000CE
70435+:10B2800000000000000000000000000000000000BE
70436+:10B2900000000000000000000000000000000000AE
70437+:10B2A000000000000000000000000000000000009E
70438+:10B2B000000000000000000000000000000000008E
70439+:10B2C000000000000000000000000000000000007E
70440+:10B2D000000000000000000000000000000000006E
70441+:10B2E000000000000000000000000000000000005E
70442+:10B2F000000000000000000000000000000000004E
70443+:10B30000000000000000000000000000000000003D
70444+:10B31000000000000000000000000000000000002D
70445+:10B32000000000000000000000000000000000001D
70446+:10B33000000000000000000000000000000000000D
70447+:10B3400000000000000000000000000000000000FD
70448+:10B3500000000000000000000000000000000000ED
70449+:10B3600000000000000000000000000000000000DD
70450+:10B3700000000000000000000000000000000000CD
70451+:10B3800000000000000000000000000000000000BD
70452+:10B3900000000000000000000000000000000000AD
70453+:10B3A000000000000000000000000000000000009D
70454+:10B3B000000000000000000000000000000000008D
70455+:10B3C000000000000000000000000000000000007D
70456+:10B3D000000000000000000000000000000000006D
70457+:10B3E000000000000000000000000000000000005D
70458+:10B3F000000000000000000000000000000000004D
70459+:10B40000000000000000000000000000000000003C
70460+:10B41000000000000000000000000000000000002C
70461+:10B42000000000000000000000000000000000001C
70462+:10B43000000000000000000000000000000000000C
70463+:10B4400000000000000000000000000000000000FC
70464+:10B4500000000000000000000000000000000000EC
70465+:10B4600000000000000000000000000000000000DC
70466+:10B4700000000000000000000000000000000000CC
70467+:10B4800000000000000000000000000000000000BC
70468+:10B4900000000000000000000000000000000000AC
70469+:10B4A000000000000000000000000000000000009C
70470+:10B4B000000000000000000000000000000000008C
70471+:10B4C000000000000000000000000000000000007C
70472+:10B4D000000000000000000000000000000000006C
70473+:10B4E000000000000000000000000000000000005C
70474+:10B4F000000000000000000000000000000000004C
70475+:10B50000000000000000000000000000000000003B
70476+:10B51000000000000000000000000000000000002B
70477+:10B52000000000000000000000000000000000001B
70478+:10B53000000000000000000000000000000000000B
70479+:10B5400000000000000000000000000000000000FB
70480+:10B5500000000000000000000000000000000000EB
70481+:10B5600000000000000000000000000000000000DB
70482+:10B5700000000000000000000000000000000000CB
70483+:10B5800000000000000000000000000000000000BB
70484+:10B5900000000000000000000000000000000000AB
70485+:10B5A000000000000000000000000000000000009B
70486+:10B5B000000000000000000000000000000000008B
70487+:10B5C000000000000000000000000000000000007B
70488+:10B5D000000000000000000000000000000000006B
70489+:10B5E000000000000000000000000000000000005B
70490+:10B5F000000000000000000000000000000000004B
70491+:10B60000000000000000000000000000000000003A
70492+:10B61000000000000000000000000000000000002A
70493+:10B62000000000000000000000000000000000001A
70494+:10B63000000000000000000000000000000000000A
70495+:10B6400000000000000000000000000000000000FA
70496+:10B6500000000000000000000000000000000000EA
70497+:10B6600000000000000000000000000000000000DA
70498+:10B6700000000000000000000000000000000000CA
70499+:10B6800000000000000000000000000000000000BA
70500+:10B6900000000000000000000000000000000000AA
70501+:10B6A000000000000000000000000000000000009A
70502+:10B6B000000000000000000000000000000000008A
70503+:10B6C000000000000000000000000000000000007A
70504+:10B6D000000000000000000000000000000000006A
70505+:10B6E000000000000000000000000000000000005A
70506+:10B6F000000000000000000000000000000000004A
70507+:10B700000000000000000000000000000000000039
70508+:10B710000000000000000000000000000000000029
70509+:10B720000000000000000000000000000000000019
70510+:10B730000000000000000000000000000000000009
70511+:10B7400000000000000000000000000000000000F9
70512+:10B7500000000000000000000000000000000000E9
70513+:10B7600000000000000000000000000000000000D9
70514+:10B7700000000000000000000000000000000000C9
70515+:10B7800000000000000000000000000000000000B9
70516+:10B7900000000000000000000000000000000000A9
70517+:10B7A0000000000000000000000000000000000099
70518+:10B7B0000000000000000000000000000000000089
70519+:10B7C0000000000000000000000000000000000079
70520+:10B7D0000000000000000000000000000000000069
70521+:10B7E0000000000000000000000000000000000059
70522+:10B7F0000000000000000000000000000000000049
70523+:10B800000000000000000000000000000000000038
70524+:10B810000000000000000000000000000000000028
70525+:10B820000000000000000000000000000000000018
70526+:10B830000000000000000000000000000000000008
70527+:10B8400000000000000000000000000000000000F8
70528+:10B8500000000000000000000000000000000000E8
70529+:10B8600000000000000000000000000000000000D8
70530+:10B8700000000000000000000000000000000000C8
70531+:10B8800000000000000000000000000000000000B8
70532+:10B8900000000000000000000000000000000000A8
70533+:10B8A0000000000000000000000000000000000098
70534+:10B8B0000000000000000000000000000000000088
70535+:10B8C0000000000000000000000000000000000078
70536+:10B8D0000000000000000000000000000000000068
70537+:10B8E0000000000000000000000000000000000058
70538+:10B8F0000000000000000000000000000000000048
70539+:10B900000000000000000000000000000000000037
70540+:10B910000000000000000000000000000000000027
70541+:10B920000000000000000000000000000000000017
70542+:10B930000000000000000000000000000000000007
70543+:10B9400000000000000000000000000000000000F7
70544+:10B9500000000000000000000000000000000000E7
70545+:10B9600000000000000000000000000000000000D7
70546+:10B9700000000000000000000000000000000000C7
70547+:10B9800000000000000000000000000000000000B7
70548+:10B9900000000000000000000000000000000000A7
70549+:10B9A0000000000000000000000000000000000097
70550+:10B9B0000000000000000000000000000000000087
70551+:10B9C0000000000000000000000000000000000077
70552+:10B9D0000000000000000000000000000000000067
70553+:10B9E0000000000000000000000000000000000057
70554+:10B9F0000000000000000000000000000000000047
70555+:10BA00000000000000000000000000000000000036
70556+:10BA10000000000000000000000000000000000026
70557+:10BA20000000000000000000000000000000000016
70558+:10BA30000000000000000000000000000000000006
70559+:10BA400000000000000000000000000000000000F6
70560+:10BA500000000000000000000000000000000000E6
70561+:10BA600000000000000000000000000000000000D6
70562+:10BA700000000000000000000000000000000000C6
70563+:10BA800000000000000000000000000000000000B6
70564+:10BA900000000000000000000000000000000000A6
70565+:10BAA0000000000000000000000000000000000096
70566+:10BAB0000000000000000000000000000000000086
70567+:10BAC0000000000000000000000000000000000076
70568+:10BAD0000000000000000000000000000000000066
70569+:10BAE0000000000000000000000000000000000056
70570+:10BAF0000000000000000000000000000000000046
70571+:10BB00000000000000000000000000000000000035
70572+:10BB10000000000000000000000000000000000025
70573+:10BB20000000000000000000000000000000000015
70574+:10BB30000000000000000000000000000000000005
70575+:10BB400000000000000000000000000000000000F5
70576+:10BB500000000000000000000000000000000000E5
70577+:10BB600000000000000000000000000000000000D5
70578+:10BB700000000000000000000000000000000000C5
70579+:10BB800000000000000000000000000000000000B5
70580+:10BB900000000000000000000000000000000000A5
70581+:10BBA0000000000000000000000000000000000095
70582+:10BBB0000000000000000000000000000000000085
70583+:10BBC0000000000000000000000000000000000075
70584+:10BBD0000000000000000000000000000000000065
70585+:10BBE0000000000000000000000000000000000055
70586+:10BBF0000000000000000000000000000000000045
70587+:10BC00000000000000000000000000000000000034
70588+:10BC10000000000000000000000000000000000024
70589+:10BC20000000000000000000000000000000000014
70590+:10BC30000000000000000000000000000000000004
70591+:10BC400000000000000000000000000000000000F4
70592+:10BC500000000000000000000000000000000000E4
70593+:10BC600000000000000000000000000000000000D4
70594+:10BC700000000000000000000000000000000000C4
70595+:10BC800000000000000000000000000000000000B4
70596+:10BC900000000000000000000000000000000000A4
70597+:10BCA0000000000000000000000000000000000094
70598+:10BCB0000000000000000000000000000000000084
70599+:10BCC0000000000000000000000000000000000074
70600+:10BCD0000000000000000000000000000000000064
70601+:10BCE0000000000000000000000000000000000054
70602+:10BCF0000000000000000000000000000000000044
70603+:10BD00000000000000000000000000000000000033
70604+:10BD10000000000000000000000000000000000023
70605+:10BD20000000000000000000000000000000000013
70606+:10BD30000000000000000000000000000000000003
70607+:10BD400000000000000000000000000000000000F3
70608+:10BD500000000000000000000000000000000000E3
70609+:10BD600000000000000000000000000000000000D3
70610+:10BD700000000000000000000000000000000000C3
70611+:10BD800000000000000000000000000000000000B3
70612+:10BD900000000000000000000000000000000000A3
70613+:10BDA0000000000000000000000000000000000093
70614+:10BDB0000000000000000000000000000000000083
70615+:10BDC0000000000000000000000000000000000073
70616+:10BDD0000000000000000000000000000000000063
70617+:10BDE0000000000000000000000000000000000053
70618+:10BDF0000000000000000000000000000000000043
70619+:10BE00000000000000000000000000000000000032
70620+:10BE10000000000000000000000000000000000022
70621+:10BE20000000000000000000000000000000000012
70622+:10BE30000000000000000000000000000000000002
70623+:10BE400000000000000000000000000000000000F2
70624+:10BE500000000000000000000000000000000000E2
70625+:10BE600000000000000000000000000000000000D2
70626+:10BE700000000000000000000000000000000000C2
70627+:10BE800000000000000000000000000000000000B2
70628+:10BE900000000000000000000000000000000000A2
70629+:10BEA0000000000000000000000000000000000092
70630+:10BEB0000000000000000000000000000000000082
70631+:10BEC0000000000000000000000000000000000072
70632+:10BED0000000000000000000000000000000000062
70633+:10BEE0000000000000000000000000000000000052
70634+:10BEF0000000000000000000000000000000000042
70635+:10BF00000000000000000000000000000000000031
70636+:10BF10000000000000000000000000000000000021
70637+:10BF20000000000000000000000000000000000011
70638+:10BF30000000000000000000000000000000000001
70639+:10BF400000000000000000000000000000000000F1
70640+:10BF500000000000000000000000000000000000E1
70641+:10BF600000000000000000000000000000000000D1
70642+:10BF700000000000000000000000000000000000C1
70643+:10BF800000000000000000000000000000000000B1
70644+:10BF900000000000000000000000000000000000A1
70645+:10BFA0000000000000000000000000000000000091
70646+:10BFB0000000000000000000000000000000000081
70647+:10BFC0000000000000000000000000000000000071
70648+:10BFD0000000000000000000000000000000000061
70649+:10BFE0000000000000000000000000000000000051
70650+:10BFF0000000000000000000000000000000000041
70651+:10C000000000000000000000000000000000000030
70652+:10C010000000000000000000000000000000000020
70653+:10C020000000000000000000000000000000000010
70654+:10C030000000000000000000000000000000000000
70655+:10C0400000000000000000000000000000000000F0
70656+:10C0500000000000000000000000000000000000E0
70657+:10C0600000000000000000000000000000000000D0
70658+:10C0700000000000000000000000000000000000C0
70659+:10C0800000000000000000000000000000000000B0
70660+:10C0900000000000000000000000000000000000A0
70661+:10C0A0000000000000000000000000000000000090
70662+:10C0B0000000000000000000000000000000000080
70663+:10C0C0000000000000000000000000000000000070
70664+:10C0D0000000000000000000000000000000000060
70665+:10C0E0000000000000000000000000000000000050
70666+:10C0F0000000000000000000000000000000000040
70667+:10C10000000000000000000000000000000000002F
70668+:10C11000000000000000000000000000000000001F
70669+:10C12000000000000000000000000000000000000F
70670+:10C1300000000000000000000000000000000000FF
70671+:10C1400000000000000000000000000000000000EF
70672+:10C1500000000000000000000000000000000000DF
70673+:10C1600000000000000000000000000000000000CF
70674+:10C1700000000000000000000000000000000000BF
70675+:10C1800000000000000000000000000000000000AF
70676+:10C19000000000000000000000000000000000009F
70677+:10C1A000000000000000000000000000000000008F
70678+:10C1B000000000000000000000000000000000007F
70679+:10C1C000000000000000000000000000000000006F
70680+:10C1D000000000000000000000000000000000005F
70681+:10C1E000000000000000000000000000000000004F
70682+:10C1F000000000000000000000000000000000003F
70683+:10C20000000000000000000000000000000000002E
70684+:10C21000000000000000000000000000000000001E
70685+:10C22000000000000000000000000000000000000E
70686+:10C2300000000000000000000000000000000000FE
70687+:10C2400000000000000000000000000000000000EE
70688+:10C2500000000000000000000000000000000000DE
70689+:10C2600000000000000000000000000000000000CE
70690+:10C2700000000000000000000000000000000000BE
70691+:10C2800000000000000000000000000000000000AE
70692+:10C29000000000000000000000000000000000009E
70693+:10C2A000000000000000000000000000000000008E
70694+:10C2B000000000000000000000000000000000007E
70695+:10C2C000000000000000000000000000000000006E
70696+:10C2D000000000000000000000000000000000005E
70697+:10C2E000000000000000000000000000000000004E
70698+:10C2F000000000000000000000000000000000003E
70699+:10C30000000000000000000000000000000000002D
70700+:10C31000000000000000000000000000000000001D
70701+:10C32000000000000000000000000000000000000D
70702+:10C3300000000000000000000000000000000000FD
70703+:10C3400000000000000000000000000000000000ED
70704+:10C3500000000000000000000000000000000000DD
70705+:10C3600000000000000000000000000000000000CD
70706+:10C3700000000000000000000000000000000000BD
70707+:10C3800000000000000000000000000000000000AD
70708+:10C39000000000000000000000000000000000009D
70709+:10C3A000000000000000000000000000000000008D
70710+:10C3B000000000000000000000000000000000007D
70711+:10C3C000000000000000000000000000000000006D
70712+:10C3D000000000000000000000000000000000005D
70713+:10C3E000000000000000000000000000000000004D
70714+:10C3F000000000000000000000000000000000003D
70715+:10C40000000000000000000000000000000000002C
70716+:10C41000000000000000000000000000000000001C
70717+:10C42000000000000000000000000000000000000C
70718+:10C4300000000000000000000000000000000000FC
70719+:10C4400000000000000000000000000000000000EC
70720+:10C4500000000000000000000000000000000000DC
70721+:10C4600000000000000000000000000000000000CC
70722+:10C4700000000000000000000000000000000000BC
70723+:10C4800000000000000000000000000000000000AC
70724+:10C49000000000000000000000000000000000009C
70725+:10C4A000000000000000000000000000000000008C
70726+:10C4B000000000000000000000000000000000007C
70727+:10C4C000000000000000000000000000000000006C
70728+:10C4D000000000000000000000000000000000005C
70729+:10C4E000000000000000000000000000000000004C
70730+:10C4F000000000000000000000000000000000003C
70731+:10C50000000000000000000000000000000000002B
70732+:10C51000000000000000000000000000000000001B
70733+:10C52000000000000000000000000000000000000B
70734+:10C5300000000000000000000000000000000000FB
70735+:10C5400000000000000000000000000000000000EB
70736+:10C5500000000000000000000000000000000000DB
70737+:10C5600000000000000000000000000000000000CB
70738+:10C5700000000000000000000000000000000000BB
70739+:10C5800000000000000000000000000000000000AB
70740+:10C59000000000000000000000000000000000009B
70741+:10C5A000000000000000000000000000000000008B
70742+:10C5B000000000000000000000000000000000007B
70743+:10C5C000000000000000000000000000000000006B
70744+:10C5D000000000000000000000000000000000005B
70745+:10C5E000000000000000000000000000000000004B
70746+:10C5F000000000000000000000000000000000003B
70747+:10C60000000000000000000000000000000000002A
70748+:10C61000000000000000000000000000000000001A
70749+:10C62000000000000000000000000000000000000A
70750+:10C6300000000000000000000000000000000000FA
70751+:10C6400000000000000000000000000000000000EA
70752+:10C6500000000000000000000000000000000000DA
70753+:10C6600000000000000000000000000000000000CA
70754+:10C6700000000000000000000000000000000000BA
70755+:10C6800000000000000000000000000000000000AA
70756+:10C69000000000000000000000000000000000009A
70757+:10C6A000000000000000000000000000000000008A
70758+:10C6B000000000000000000000000000000000007A
70759+:10C6C000000000000000000000000000000000006A
70760+:10C6D000000000000000000000000000000000005A
70761+:10C6E000000000000000000000000000000000004A
70762+:10C6F000000000000000000000000000000000003A
70763+:10C700000000000000000000000000000000000029
70764+:10C710000000000000000000000000000000000019
70765+:10C720000000000000000000000000000000000009
70766+:10C7300000000000000000000000000000000000F9
70767+:10C7400000000000000000000000000000000000E9
70768+:10C7500000000000000000000000000000000000D9
70769+:10C7600000000000000000000000000000000000C9
70770+:10C7700000000000000000000000000000000000B9
70771+:10C7800000000000000000000000000000000000A9
70772+:10C790000000000000000000000000000000000099
70773+:10C7A0000000000000000000000000000000000089
70774+:10C7B0000000000000000000000000000000000079
70775+:10C7C0000000000000000000000000000000000069
70776+:10C7D0000000000000000000000000000000000059
70777+:10C7E0000000000000000000000000000000000049
70778+:10C7F0000000000000000000000000000000000039
70779+:10C800000000000000000000000000000000000028
70780+:10C810000000000000000000000000000000000018
70781+:10C820000000000000000000000000000000000008
70782+:10C8300000000000000000000000000000000000F8
70783+:10C8400000000000000000000000000000000000E8
70784+:10C8500000000000000000000000000000000000D8
70785+:10C8600000000000000000000000000000000000C8
70786+:10C8700000000000000000000000000000000000B8
70787+:10C8800000000000000000000000000000000000A8
70788+:10C890000000000000000000000000000000000098
70789+:10C8A0000000000000000000000000000000000088
70790+:10C8B0000000000000000000000000000000000078
70791+:10C8C0000000000000000000000000000000000068
70792+:10C8D0000000000000000000000000000000000058
70793+:10C8E0000000000000000000000000000000000048
70794+:10C8F0000000000000000000000000000000000038
70795+:10C900000000000000000000000000000000000027
70796+:10C910000000000000000000000000000000000017
70797+:10C920000000000000000000000000000000000007
70798+:10C9300000000000000000000000000000000000F7
70799+:10C9400000000000000000000000000000000000E7
70800+:10C9500000000000000000000000000000000000D7
70801+:10C9600000000000000000000000000000000000C7
70802+:10C9700000000000000000000000000000000000B7
70803+:10C9800000000000000000000000000000000000A7
70804+:10C990000000000000000000000000000000000097
70805+:10C9A0000000000000000000000000000000000087
70806+:10C9B0000000000000000000000000000000000077
70807+:10C9C0000000000000000000000000000000000067
70808+:10C9D0000000000000000000000000000000000057
70809+:10C9E0000000000000000000000000000000000047
70810+:10C9F0000000000000000000000000000000000037
70811+:10CA00000000000000000000000000000000000026
70812+:10CA10000000000000000000000000000000000016
70813+:10CA20000000000000000000000000000000000006
70814+:10CA300000000000000000000000000000000000F6
70815+:10CA400000000000000000000000000000000000E6
70816+:10CA500000000000000000000000000000000000D6
70817+:10CA600000000000000000000000000000000000C6
70818+:10CA700000000000000000000000000000000000B6
70819+:10CA800000000000000000000000000000000000A6
70820+:10CA90000000000000000000000000000000000096
70821+:10CAA0000000000000000000000000000000000086
70822+:10CAB0000000000000000000000000000000000076
70823+:10CAC0000000000000000000000000000000000066
70824+:10CAD0000000000000000000000000000000000056
70825+:10CAE0000000000000000000000000000000000046
70826+:10CAF0000000000000000000000000000000000036
70827+:10CB00000000000000000000000000000000000025
70828+:10CB10000000000000000000000000000000000015
70829+:10CB20000000000000000000000000000000000005
70830+:10CB300000000000000000000000000000000000F5
70831+:10CB400000000000000000000000000000000000E5
70832+:10CB500000000000000000000000000000000000D5
70833+:10CB600000000000000000000000000000000000C5
70834+:10CB700000000000000000000000000000000000B5
70835+:10CB800000000000000000000000000000000000A5
70836+:10CB90000000000000000000000000000000000095
70837+:10CBA0000000000000000000000000000000000085
70838+:10CBB0000000000000000000000000000000000075
70839+:10CBC0000000000000000000000000000000000065
70840+:10CBD0000000000000000000000000000000000055
70841+:10CBE0000000000000000000000000000000000045
70842+:10CBF0000000000000000000000000000000000035
70843+:10CC00000000000000000000000000000000000024
70844+:10CC10000000000000000000000000000000000014
70845+:10CC20000000000000000000000000000000000004
70846+:10CC300000000000000000000000000000000000F4
70847+:10CC400000000000000000000000000000000000E4
70848+:10CC500000000000000000000000000000000000D4
70849+:10CC600000000000000000000000000000000000C4
70850+:10CC700000000000000000000000000000000000B4
70851+:10CC800000000000000000000000000000000000A4
70852+:10CC90000000000000000000000000000000000094
70853+:10CCA0000000000000000000000000000000000084
70854+:10CCB0000000000000000000000000000000000074
70855+:10CCC0000000000000000000000000000000000064
70856+:10CCD0000000000000000000000000000000000054
70857+:10CCE0000000000000000000000000000000000044
70858+:10CCF0000000000000000000000000000000000034
70859+:10CD00000000000000000000000000000000000023
70860+:10CD10000000000000000000000000000000000013
70861+:10CD20000000000000000000000000000000000003
70862+:10CD300000000000000000000000000000000000F3
70863+:10CD400000000000000000000000000000000000E3
70864+:10CD500000000000000000000000000000000000D3
70865+:10CD600000000000000000000000000000000000C3
70866+:10CD700000000000000000000000000000000000B3
70867+:10CD800000000000000000000000000000000000A3
70868+:10CD90000000000000000000000000000000000093
70869+:10CDA0000000000000000000000000000000000083
70870+:10CDB0000000000000000000000000000000000073
70871+:10CDC0000000000000000000000000000000000063
70872+:10CDD0000000000000000000000000000000000053
70873+:10CDE0000000000000000000000000000000000043
70874+:10CDF0000000000000000000000000000000000033
70875+:10CE00000000000000000000000000000000000022
70876+:10CE10000000000000000000000000000000000012
70877+:10CE20000000000000000000000000000000000002
70878+:10CE300000000000000000000000000000000000F2
70879+:10CE400000000000000000000000000000000000E2
70880+:10CE500000000000000000000000000000000000D2
70881+:10CE600000000000000000000000000000000000C2
70882+:10CE700000000000000000000000000000000000B2
70883+:10CE800000000000000000000000000000000000A2
70884+:10CE90000000000000000000000000000000000092
70885+:10CEA0000000000000000000000000000000000082
70886+:10CEB0000000000000000000000000000000000072
70887+:10CEC0000000000000000000000000000000000062
70888+:10CED0000000000000000000000000000000000052
70889+:10CEE0000000000000000000000000000000000042
70890+:10CEF0000000000000000000000000000000000032
70891+:10CF00000000000000000000000000000000000021
70892+:10CF10000000000000000000000000000000000011
70893+:10CF20000000000000000000000000000000000001
70894+:10CF300000000000000000000000000000000000F1
70895+:10CF400000000000000000000000000000000000E1
70896+:10CF500000000000000000000000000000000000D1
70897+:10CF600000000000000000000000000000000000C1
70898+:10CF700000000000000000000000000000000000B1
70899+:10CF800000000000000000000000000000000000A1
70900+:10CF90000000000000000000000000000000000091
70901+:10CFA0000000000000000000000000000000000081
70902+:10CFB0000000000000000000000000000000000071
70903+:10CFC0000000000000000000000000000000000061
70904+:10CFD0000000000000000000000000000000000051
70905+:10CFE0000000000000000000000000000000000041
70906+:10CFF0000000000000000000000000000000000031
70907+:10D000000000000000000000000000000000000020
70908+:10D010000000000000000000000000000000000010
70909+:10D020000000000000000000000000000000000000
70910+:10D0300000000000000000000000000000000000F0
70911+:10D0400000000000000000000000000000000000E0
70912+:10D0500000000000000000000000000000000000D0
70913+:10D0600000000000000000000000000000000000C0
70914+:10D0700000000000000000000000000000000000B0
70915+:10D0800000000000000000000000000000000000A0
70916+:10D090000000000000000000000000000000000090
70917+:10D0A0000000000000000000000000000000000080
70918+:10D0B0000000000000000000000000000000000070
70919+:10D0C0000000000000000000000000000000000060
70920+:10D0D0000000000000000000000000000000000050
70921+:10D0E0000000000000000000000000000000000040
70922+:10D0F0000000000000000000000000000000000030
70923+:10D10000000000000000000000000000000000001F
70924+:10D11000000000000000000000000000000000000F
70925+:10D1200000000000000000000000000000000000FF
70926+:10D1300000000000000000000000000000000000EF
70927+:10D1400000000000000000000000000000000000DF
70928+:10D1500000000000000000000000000000000000CF
70929+:10D1600000000000000000000000000000000000BF
70930+:10D1700000000000000000000000000000000000AF
70931+:10D18000000000000000000000000000000000009F
70932+:10D19000000000000000000000000000000000008F
70933+:10D1A000000000000000000000000000000000007F
70934+:10D1B000000000000000000000000000000000006F
70935+:10D1C000000000000000000000000000000000005F
70936+:10D1D000000000000000000000000000000000004F
70937+:10D1E000000000000000000000000000000000003F
70938+:10D1F000000000000000000000000000000000002F
70939+:10D20000000000000000000000000000000000001E
70940+:10D21000000000000000000000000000000000000E
70941+:10D2200000000000000000000000000000000000FE
70942+:10D2300000000000000000000000000000000000EE
70943+:10D2400000000000000000000000000000000000DE
70944+:10D2500000000000000000000000000000000000CE
70945+:10D2600000000000000000000000000000000000BE
70946+:10D2700000000000000000000000000000000000AE
70947+:10D28000000000000000000000000000000000009E
70948+:10D29000000000000000000000000000000000008E
70949+:10D2A000000000000000000000000000000000007E
70950+:10D2B000000000000000000000000000000000006E
70951+:10D2C000000000000000000000000000000000005E
70952+:10D2D000000000000000000000000000000000004E
70953+:10D2E000000000000000000000000000000000003E
70954+:10D2F000000000000000000000000000000000002E
70955+:10D30000000000000000000000000000000000001D
70956+:10D31000000000000000000000000000000000000D
70957+:10D3200000000000000000000000000000000000FD
70958+:10D3300000000000000000000000000000000000ED
70959+:10D3400000000000000000000000000000000000DD
70960+:10D3500000000000000000000000000000000000CD
70961+:10D3600000000000000000000000000000000000BD
70962+:10D3700000000000000000000000000000000000AD
70963+:10D38000000000000000000000000000000000009D
70964+:10D39000000000000000000000000000000000008D
70965+:10D3A000000000000000000000000000000000007D
70966+:10D3B000000000000000000000000000000000006D
70967+:10D3C000000000000000000000000000000000005D
70968+:10D3D000000000000000000000000000000000004D
70969+:10D3E000000000000000000000000000000000003D
70970+:10D3F000000000000000000000000000000000002D
70971+:10D40000000000000000000000000000000000001C
70972+:10D41000000000000000000000000000000000000C
70973+:10D4200000000000000000000000000000000000FC
70974+:10D4300000000000000000000000000000000000EC
70975+:10D4400000000000000000000000000000000000DC
70976+:10D4500000000000000000000000000000000000CC
70977+:10D4600000000000000000000000000000000000BC
70978+:10D4700000000000000000000000000000000000AC
70979+:10D48000000000000000000000000000000000009C
70980+:10D49000000000000000000000000000000000008C
70981+:10D4A000000000000000000000000000000000007C
70982+:10D4B000000000000000000000000000000000006C
70983+:10D4C000000000000000000000000000000000005C
70984+:10D4D000000000000000000000000000000000004C
70985+:10D4E000000000000000000000000000000000003C
70986+:10D4F000000000000000000000000000000000002C
70987+:10D50000000000000000000000000000000000001B
70988+:10D51000000000000000000000000000000000000B
70989+:10D5200000000000000000000000000000000000FB
70990+:10D5300000000000000000000000000000000000EB
70991+:10D5400000000000000000000000000000000000DB
70992+:10D5500000000000000000000000000000000000CB
70993+:10D5600000000000000000000000000000000000BB
70994+:10D5700000000000000000000000000000000000AB
70995+:10D58000000000000000000000000000000000009B
70996+:10D59000000000000000000000000000000000008B
70997+:10D5A000000000000000000000000000000000007B
70998+:10D5B000000000000000000000000000000000006B
70999+:10D5C000000000000000000000000000000000005B
71000+:10D5D000000000000000000000000000000000004B
71001+:10D5E000000000000000000000000000000000003B
71002+:10D5F000000000000000000000000000000000002B
71003+:10D60000000000000000000000000000000000001A
71004+:10D61000000000000000000000000000000000000A
71005+:10D6200000000000000000000000000000000000FA
71006+:10D6300000000000000000000000000000000000EA
71007+:10D6400000000000000000000000000000000000DA
71008+:10D6500000000000000000000000000000000000CA
71009+:10D6600000000000000000000000000000000000BA
71010+:10D6700000000000000000000000000000000000AA
71011+:10D68000000000000000000000000000000000009A
71012+:10D69000000000000000000000000000000000008A
71013+:10D6A000000000000000000000000000000000007A
71014+:10D6B000000000000000000000000000000000006A
71015+:10D6C000000000000000000000000000000000005A
71016+:10D6D000000000000000000000000000000000004A
71017+:10D6E000000000000000000000000000000000003A
71018+:10D6F000000000000000000000000000000000002A
71019+:10D700000000000000000000000000000000000019
71020+:10D710000000000000000000000000000000000009
71021+:10D7200000000000000000000000000000000000F9
71022+:10D7300000000000000000000000000000000000E9
71023+:10D7400000000000000000000000000000000000D9
71024+:10D7500000000000000000000000000000000000C9
71025+:10D7600000000000000000000000000000000000B9
71026+:10D7700000000000000000000000000000000000A9
71027+:10D780000000000000000000000000000000000099
71028+:10D790000000000000000000000000000000000089
71029+:10D7A0000000000000000000000000000000000079
71030+:10D7B0000000000000000000000000000000000069
71031+:10D7C0000000000000000000000000000000000059
71032+:10D7D0000000000000000000000000000000000049
71033+:10D7E0000000000000000000000000000000000039
71034+:10D7F0000000000000000000000000000000000029
71035+:10D800000000000000000000000000000000000018
71036+:10D810000000000000000000000000000000000008
71037+:10D8200000000000000000000000000000000000F8
71038+:10D8300000000000000000000000000000000000E8
71039+:10D8400000000000000000000000000000000000D8
71040+:10D8500000000000000000000000000000000000C8
71041+:10D8600000000000000000000000000000000000B8
71042+:10D8700000000000000000000000000000000000A8
71043+:10D880000000000000000000000000000000000098
71044+:10D890000000000000000000000000000000000088
71045+:10D8A0000000000000000000000000000000000078
71046+:10D8B0000000000000000000000000000000000068
71047+:10D8C0000000000000000000000000000000000058
71048+:10D8D0000000000000000000000000000000000048
71049+:10D8E0000000000000000000000000000000000038
71050+:10D8F0000000000000000000000000000000000028
71051+:10D900000000000000000000000000000000000017
71052+:10D910000000000000000000000000000000000007
71053+:10D9200000000000000000000000000000000000F7
71054+:10D9300000000000000000000000000000000000E7
71055+:10D9400000000000000000000000000000000000D7
71056+:10D9500000000000000000000000000000000000C7
71057+:10D9600000000000000000000000000000000000B7
71058+:10D9700000000000000000000000000000000000A7
71059+:10D980000000000000000000000000000000000097
71060+:10D990000000000000000000000000000000000087
71061+:10D9A0000000000000000000000000000000000077
71062+:10D9B0000000000000000000000000000000000067
71063+:10D9C0000000000000000000000000000000000057
71064+:10D9D0000000000000000000000000000000000047
71065+:10D9E0000000000000000000000000000000000037
71066+:10D9F0000000000000000000000000000000000027
71067+:10DA00000000000000000000000000000000000016
71068+:10DA10000000000000000000000000000000000006
71069+:10DA200000000000000000000000000000000000F6
71070+:10DA300000000000000000000000000000000000E6
71071+:10DA400000000000000000000000000000000000D6
71072+:10DA500000000000000000000000000000000000C6
71073+:10DA600000000000000000000000000000000000B6
71074+:10DA700000000000000000000000000000000000A6
71075+:10DA80000000000000000000000000000000000096
71076+:10DA90000000000000000000000000000000000086
71077+:10DAA0000000000000000000000000000000000076
71078+:10DAB0000000000000000000000000000000000066
71079+:10DAC0000000000000000000000000000000000056
71080+:10DAD0000000000000000000000000000000000046
71081+:10DAE0000000000000000000000000000000000036
71082+:10DAF0000000000000000000000000000000000026
71083+:10DB00000000000000000000000000000000000015
71084+:10DB10000000000000000000000000000000000005
71085+:10DB200000000000000000000000000000000000F5
71086+:10DB300000000000000000000000000000000000E5
71087+:10DB400000000000000000000000000000000000D5
71088+:10DB500000000000000000000000000000000000C5
71089+:10DB600000000000000000000000000000000000B5
71090+:10DB700000000000000000000000000000000000A5
71091+:10DB80000000000000000000000000000000000095
71092+:10DB90000000000000000000000000000000000085
71093+:10DBA0000000000000000000000000000000000075
71094+:10DBB0000000000000000000000000000000000065
71095+:10DBC0000000000000000000000000000000000055
71096+:10DBD0000000000000000000000000000000000045
71097+:10DBE0000000000000000000000000000000000035
71098+:10DBF0000000000000000000000000000000000025
71099+:10DC00000000000000000000000000000000000014
71100+:10DC10000000000000000000000000000000000004
71101+:10DC200000000000000000000000000000000000F4
71102+:10DC300000000000000000000000000000000000E4
71103+:10DC400000000000000000000000000000000000D4
71104+:10DC500000000000000000000000000000000000C4
71105+:10DC600000000000000000000000000000000000B4
71106+:10DC700000000000000000000000000000000000A4
71107+:10DC80000000000000000000000000000000000094
71108+:10DC90000000000000000000000000000000000084
71109+:10DCA0000000000000000000000000000000000074
71110+:10DCB0000000000000000000000000000000000064
71111+:10DCC0000000000000000000000000000000000054
71112+:10DCD0000000000000000000000000000000000044
71113+:10DCE0000000000000000000000000000000000034
71114+:10DCF0000000000000000000000000000000000024
71115+:10DD00000000000000000000000000000000000013
71116+:10DD10000000000000000000000000000000000003
71117+:10DD200000000000000000000000000000000000F3
71118+:10DD300000000000000000000000000000000000E3
71119+:10DD400000000000000000000000000000000000D3
71120+:10DD500000000000000000000000000000000000C3
71121+:10DD600000000000000000000000000000000000B3
71122+:10DD700000000000000000000000000000000000A3
71123+:10DD80000000000000000000000000000000000093
71124+:10DD90000000000000000000000000000000000083
71125+:10DDA0000000000000000000000000000000000073
71126+:10DDB0000000000000000000000000000000000063
71127+:10DDC0000000000000000000000000000000000053
71128+:10DDD0000000000000000000000000000000000043
71129+:10DDE0000000000000000000000000000000000033
71130+:10DDF0000000000000000000000000000000000023
71131+:10DE00000000000000000000000000000000000012
71132+:10DE10000000000000000000000000000000000002
71133+:10DE200000000000000000000000000000000000F2
71134+:10DE300000000000000000000000000000000000E2
71135+:10DE400000000000000000000000000000000000D2
71136+:10DE500000000000000000000000000000000000C2
71137+:10DE600000000000000000000000000000000000B2
71138+:10DE700000000000000000000000000000000000A2
71139+:10DE80000000000000000000000000000000000092
71140+:10DE90000000000000000000000000000000000082
71141+:10DEA0000000000000000000000000000000000072
71142+:10DEB0000000000000000000000000000000000062
71143+:10DEC0000000000000000000000000000000000052
71144+:10DED0000000000000000000000000000000000042
71145+:10DEE0000000000000000000000000000000000032
71146+:10DEF0000000000000000000000000000000000022
71147+:10DF00000000000000000000000000000000000011
71148+:10DF10000000000000000000000000000000000001
71149+:10DF200000000000000000000000000000000000F1
71150+:10DF300000000000000000000000000000000000E1
71151+:10DF400000000000000000000000000000000000D1
71152+:10DF500000000000000000000000000000000000C1
71153+:10DF600000000000000000000000000000000000B1
71154+:10DF700000000000000000000000000000000000A1
71155+:10DF80000000000000000000000000000000000091
71156+:10DF90000000000000000000000000000000000081
71157+:10DFA0000000000000000000000000000000000071
71158+:10DFB0000000000000000000000000000000000061
71159+:10DFC0000000000000000000000000000000000051
71160+:10DFD0000000000000000000000000000000000041
71161+:10DFE0000000000000000000000000000000000031
71162+:10DFF0000000000000000000000000000000000021
71163+:10E000000000000000000000000000000000000010
71164+:10E010000000000000000000000000000000000000
71165+:10E0200000000000000000000000000000000000F0
71166+:10E0300000000000000000000000000000000000E0
71167+:10E0400000000000000000000000000000000000D0
71168+:10E0500000000000000000000000000000000000C0
71169+:10E0600000000000000000000000000000000000B0
71170+:10E0700000000000000000000000000000000000A0
71171+:10E080000000000000000000000000000000000090
71172+:10E090000000000000000000000000000000000080
71173+:10E0A0000000000000000000000000000000000070
71174+:10E0B0000000000000000000000000000000000060
71175+:10E0C0000000000000000000000000000000000050
71176+:10E0D0000000000000000000000000000000000040
71177+:10E0E0000000000000000000000000000000000030
71178+:10E0F0000000000000000000000000000000000020
71179+:10E10000000000000000000000000000000000000F
71180+:10E1100000000000000000000000000000000000FF
71181+:10E1200000000000000000000000000000000000EF
71182+:10E1300000000000000000000000000000000000DF
71183+:10E1400000000000000000000000000000000000CF
71184+:10E1500000000000000000000000000000000000BF
71185+:10E1600000000000000000000000000000000000AF
71186+:10E17000000000000000000000000000000000009F
71187+:10E18000000000000000000000000000000000008F
71188+:10E19000000000000000000000000000000000007F
71189+:10E1A000000000000000000000000000000000006F
71190+:10E1B000000000000000000000000000000000005F
71191+:10E1C000000000000000000000000000000000004F
71192+:10E1D000000000000000000000000000000000003F
71193+:10E1E000000000000000000000000000000000002F
71194+:10E1F000000000000000000000000000000000809F
71195+:10E20000000000000000000000000000000000000E
71196+:10E2100000000000000000000000000000000000FE
71197+:10E220000000000A000000000000000000000000E4
71198+:10E2300010000003000000000000000D0000000DB1
71199+:10E240003C020801244295C03C030801246397FC6A
71200+:10E25000AC4000000043202B1480FFFD244200044A
71201+:10E260003C1D080037BD9FFC03A0F0213C100800B6
71202+:10E27000261032103C1C0801279C95C00E0012BECF
71203+:10E28000000000000000000D3C02800030A5FFFFF0
71204+:10E2900030C600FF344301803C0880008D0901B87E
71205+:10E2A0000520FFFE00000000AC6400002404000212
71206+:10E2B000A4650008A066000AA064000BAC67001803
71207+:10E2C0003C03100003E00008AD0301B83C0560000A
71208+:10E2D0008CA24FF80440FFFE00000000ACA44FC029
71209+:10E2E0003C0310003C040200ACA44FC403E000084F
71210+:10E2F000ACA34FF89486000C00A050212488001491
71211+:10E3000000062B0200051080004448210109182B4B
71212+:10E310001060001100000000910300002C6400094F
71213+:10E320005080000991190001000360803C0D080134
71214+:10E3300025AD9258018D58218D67000000E000083E
71215+:10E340000000000091190001011940210109302B42
71216+:10E3500054C0FFF29103000003E000080000102108
71217+:10E360000A000CCC25080001910F0001240E000AC0
71218+:10E3700015EE00400128C8232F38000A1700003D81
71219+:10E38000250D00028D580000250F0006370E0100F4
71220+:10E39000AD4E0000910C000291AB000191A400026F
71221+:10E3A00091A60003000C2E00000B3C0000A71025D6
71222+:10E3B00000041A000043C8250326C025AD580004F8
71223+:10E3C000910E000691ED000191E7000291E5000336
71224+:10E3D000000E5E00000D6400016C30250007220075
71225+:10E3E00000C41025004518252508000A0A000CCC99
71226+:10E3F000AD430008910F000125040002240800022B
71227+:10E4000055E80001012020210A000CCC00804021A9
71228+:10E41000910C0001240B0003158B00160000000076
71229+:10E420008D580000910E000225080003370D0008EA
71230+:10E43000A14E00100A000CCCAD4D00009119000156
71231+:10E44000240F0004172F000B0000000091070002AA
71232+:10E45000910400038D43000000072A0000A410254A
71233+:10E460003466000425080004AD42000C0A000CCC00
71234+:10E47000AD46000003E000082402000127BDFFE8CC
71235+:10E48000AFBF0014AFB000100E00164E0080802108
71236+:10E490003C0480083485008090A600052403FFFE1C
71237+:10E4A0000200202100C310248FBF00148FB0001081
71238+:10E4B000A0A200050A00165827BD001827BDFFE8D6
71239+:10E4C000AFB00010AFBF00140E000FD40080802149
71240+:10E4D0003C06800834C5008090A40000240200504F
71241+:10E4E000308300FF106200073C09800002002021F9
71242+:10E4F0008FBF00148FB00010AD2001800A00108F74
71243+:10E5000027BD0018240801003C07800002002021DC
71244+:10E510008FBF00148FB00010ACE801800A00108F8C
71245+:10E5200027BD001827BDFF783C058008AFBE0080DE
71246+:10E53000AFB7007CAFB3006CAFB10064AFBF008475
71247+:10E54000AFB60078AFB50074AFB40070AFB200687A
71248+:10E55000AFB0006034A600803C0580008CB201287A
71249+:10E5600090C400098CA701043C020001309100FF17
71250+:10E5700000E218240000B8210000F021106000071C
71251+:10E58000000098213C0908008D2931F02413000176
71252+:10E59000252800013C010800AC2831F0ACA0008423
71253+:10E5A00090CC0005000C5827316A0001154000721C
71254+:10E5B000AFA0005090CD00002406002031A400FF41
71255+:10E5C00010860018240E0050108E009300000000EA
71256+:10E5D0003C1008008E1000DC260F00013C010800F2
71257+:10E5E000AC2F00DC0E0016C7000000000040182110
71258+:10E5F0008FBF00848FBE00808FB7007C8FB60078FD
71259+:10E600008FB500748FB400708FB3006C8FB2006848
71260+:10E610008FB100648FB000600060102103E000083B
71261+:10E6200027BD00880000000D3C1F8000AFA0003017
71262+:10E6300097E501168FE201043C04002030B9FFFF8A
71263+:10E64000004438240007182B00033140AFA60030E7
71264+:10E650008FF5010437F80C003C1600400338802188
71265+:10E6600002B6A02434C40040128000479215000D69
71266+:10E6700032A800201500000234860080008030217E
71267+:10E6800014C0009FAFA600303C0D800835A6008066
71268+:10E6900090CC0008318B0040516000063C06800899
71269+:10E6A000240E0004122E00A8240F0012122F003294
71270+:10E6B0003C06800834C401003C0280009447011AE3
71271+:10E6C0009619000E909F00088E18000830E3FFFF97
71272+:10E6D00003F9B00432B40004AFB6005CAFA3005835
71273+:10E6E0008E1600041280002EAFB8005434C3008090
71274+:10E6F000906800083105004014A0002500000000CB
71275+:10E700008C70005002D090230640000500000000ED
71276+:10E710008C71003402D1A82306A201678EE20008A2
71277+:10E72000126000063C1280003C1508008EB531F4E2
71278+:10E7300026B600013C010800AC3631F4AE4000447E
71279+:10E74000240300018FBF00848FBE00808FB7007C40
71280+:10E750008FB600788FB500748FB400708FB3006CE3
71281+:10E760008FB200688FB100648FB00060006010212C
71282+:10E7700003E0000827BD00880E000D2800002021BE
71283+:10E780000A000D75004018210A000D9500C02021D7
71284+:10E790000E00171702C020211440FFE10000000006
71285+:10E7A0003C0B8008356400808C8A003402CA482300
71286+:10E7B0000520001D000000003C1E08008FDE310017
71287+:10E7C00027D700013C010800AC3731001260000679
71288+:10E7D000024020213C1408008E9431F42690000160
71289+:10E7E0003C010800AC3031F40E00164E3C1E80088F
71290+:10E7F00037CD008091B700250240202136EE00047D
71291+:10E800000E001658A1AE00250E000CAC02402021CF
71292+:10E810000A000DCA240300013C17080126F796C020
71293+:10E820000A000D843C1F80008C86003002C66023E5
71294+:10E830001980000C2419000C908F004F3C14080024
71295+:10E840008E94310032B500FC35ED0001268E0001BA
71296+:10E850003C010800AC2E3100A08D004FAFA0005845
71297+:10E860002419000CAFB900308C9800300316A02397
71298+:10E870001A80010B8FA300580074F82A17E0FFD309
71299+:10E88000000000001074002A8FA5005802D4B021A7
71300+:10E8900000B410233044FFFFAFA4005832A8000298
71301+:10E8A0001100002E32AB00103C15800836B00080FD
71302+:10E8B0009216000832D30040526000FB8EE200083E
71303+:10E8C0000E00164E02402021240A0018A20A000958
71304+:10E8D000921100052409FFFE024020210229902404
71305+:10E8E0000E001658A2120005240400390000282149
71306+:10E8F0000E0016F2240600180A000DCA24030001B7
71307+:10E9000092FE000C3C0A800835490080001EBB00C6
71308+:10E910008D27003836F10081024020213225F08118
71309+:10E920000E000C9B30C600FF0A000DC10000000065
71310+:10E930003AA7000130E300011460FFA402D4B02123
71311+:10E940000A000E1D00000000024020210E001734B6
71312+:10E95000020028210A000D75004018211160FF7087
71313+:10E960003C0F80083C0D800835EE00808DC40038D7
71314+:10E970008FA300548DA60004006660231D80FF68ED
71315+:10E98000000000000064C02307020001AFA400548F
71316+:10E990003C1F08008FFF31E433F9000113200015FC
71317+:10E9A0008FAC00583C07800094E3011A10600012FD
71318+:10E9B0003C0680080E00216A024020213C03080129
71319+:10E9C000906396F13064000214800145000000005D
71320+:10E9D000306C0004118000078FAC0058306600FBDB
71321+:10E9E0003C010801A02696F132B500FCAFA000580A
71322+:10E9F0008FAC00583C06800834D30080AFB40018B8
71323+:10EA0000AFB60010AFAC00143C088000950B01209D
71324+:10EA10008E6F0030966A005C8FA3005C8FBF003061
71325+:10EA20003169FFFF3144FFFF8FAE005401341021E4
71326+:10EA3000350540000064382B0045C82103E7C02598
71327+:10EA4000AFB90020AFAF0028AFB80030AFAF00249F
71328+:10EA5000AFA0002CAFAE0034926D000831B40008B6
71329+:10EA6000168000BB020020218EE200040040F8095D
71330+:10EA700027A400108FAF003031F300025660000170
71331+:10EA800032B500FE3C048008349F008093F90008F2
71332+:10EA900033380040530000138FA400248C850004F9
71333+:10EAA0008FA7005410A700D52404001432B0000131
71334+:10EAB0001200000C8FA400242414000C1234011A3C
71335+:10EAC0002A2D000D11A001022413000E240E000AAD
71336+:10EAD000522E0001241E00088FAF002425E40001FF
71337+:10EAE000AFA400248FAA00143C0B80083565008079
71338+:10EAF000008A48218CB10030ACA9003090A4004EAF
71339+:10EB00008CA700303408FFFF0088180400E3F821C8
71340+:10EB1000ACBF00348FA600308FB900548FB8005CB2
71341+:10EB200030C200081040000B033898218CAC002044
71342+:10EB3000119300D330C600FF92EE000C8FA7003473
71343+:10EB400002402021000E6B0035B400800E000C9BAB
71344+:10EB50003285F0803C028008345000808E0F0030F7
71345+:10EB600001F1302318C00097264800803C070800B8
71346+:10EB70008CE731E42404FF80010418243118007F5D
71347+:10EB80003C1F80003C19800430F10001AFE300908D
71348+:10EB900012200006031928213C030801906396F116
71349+:10EBA00030690008152000C6306A00F73C10800864
71350+:10EBB00036040080908C004F318B000115600042BC
71351+:10EBC000000000003C0608008CC6319830CE0010D2
71352+:10EBD00051C0004230F9000190AF006B55E0003F9A
71353+:10EBE00030F9000124180001A0B8006B3C1180002E
71354+:10EBF0009622007A24470064A48700123C0D800806
71355+:10EC000035A5008090B40008329000401600000442
71356+:10EC10003C03800832AE000115C0008B00000000EC
71357+:10EC2000346400808C86002010D3000A3463010015
71358+:10EC30008C67000002C7782319E000978FBF00544B
71359+:10EC4000AC93002024130001AC760000AFB3005059
71360+:10EC5000AC7F000417C0004E000000008FA90050D8
71361+:10EC60001520000B000000003C030801906396F1A2
71362+:10EC7000306A00011140002E8FAB0058306400FE56
71363+:10EC80003C010801A02496F10A000D75000018212E
71364+:10EC90000E000CAC024020210A000F1300000000FF
71365+:10ECA0000A000E200000A0210040F80924040017EB
71366+:10ECB0000A000DCA240300010040F80924040016CC
71367+:10ECC0000A000DCA240300019094004F240DFFFE9A
71368+:10ECD000028D2824A085004F30F900011320000682
71369+:10ECE0003C0480083C030801906396F1307F0010DB
71370+:10ECF00017E00051306800EF34900080240A0001D2
71371+:10ED0000024020210E00164EA60A00129203002592
71372+:10ED100024090001AFA90050346200010240202103
71373+:10ED20000E001658A20200250A000EF93C0D8008BC
71374+:10ED30001160FE83000018218FA5003030AC000464
71375+:10ED40001180FE2C8FBF00840A000DCB240300012C
71376+:10ED500027A500380E000CB6AFA000385440FF4382
71377+:10ED60008EE200048FB40038329001005200FF3F61
71378+:10ED70008EE200048FA3003C8E6E0058006E682364
71379+:10ED800005A3FF39AE6300580A000E948EE200041A
71380+:10ED90000E00164E024020213C038008346800809B
71381+:10EDA000024020210E001658A11E000903C0302188
71382+:10EDB000240400370E0016F2000028210A000F116B
71383+:10EDC0008FA900508FAB00185960FF8D3C0D800853
71384+:10EDD0000E00164E02402021920C00252405000151
71385+:10EDE000AFA5005035820004024020210E001658C5
71386+:10EDF000A20200250A000EF93C0D800812240059D9
71387+:10EE00002A2300151060004D240900162408000C68
71388+:10EE10005628FF2732B000013C0A8008914C001BA5
71389+:10EE20002406FFBD241E000E01865824A14B001BA2
71390+:10EE30000A000EA532B000013C010801A02896F19D
71391+:10EE40000A000EF93C0D80088CB500308EFE0008DB
71392+:10EE50002404001826B6000103C0F809ACB600303F
71393+:10EE60003C030801906396F13077000116E0FF81C2
71394+:10EE7000306A00018FB200300A000D753243000481
71395+:10EE80003C1080009605011A50A0FF2B34C60010DC
71396+:10EE90000A000EC892EE000C8C6200001456FF6D42
71397+:10EEA000000000008C7800048FB9005403388823D8
71398+:10EEB0000621FF638FBF00540A000F0E0000000000
71399+:10EEC0003C010801A02A96F10A000F3030F9000138
71400+:10EED0001633FF028FAF00240A000EB0241E00106C
71401+:10EEE0000E00164E024020213C0B80083568008041
71402+:10EEF00091090025240A0001AFAA0050353300040F
71403+:10EF0000024020210E001658A11300253C050801DF
71404+:10EF100090A596F130A200FD3C010801A02296F1D7
71405+:10EF20000A000E6D004018212411000E53D1FEEA94
71406+:10EF3000241E00100A000EAF241E00165629FEDC07
71407+:10EF400032B000013C0A8008914C001B2406FFBD32
71408+:10EF5000241E001001865824A14B001B0A000EA598
71409+:10EF600032B000010A000EA4241E00123C038000EF
71410+:10EF70008C6201B80440FFFE24040800AC6401B8B0
71411+:10EF800003E000080000000030A5FFFF30C6FFFFCF
71412+:10EF90003C0780008CE201B80440FFFE34EA0180A7
71413+:10EFA000AD440000ACE400203C0480089483004899
71414+:10EFB0003068FFFF11000016AF88000824AB001274
71415+:10EFC000010B482B512000133C04800034EF01005A
71416+:10EFD00095EE00208F890000240D001A31CCFFFF30
71417+:10EFE00031274000A14D000B10E000362583FFFEC5
71418+:10EFF0000103C02B170000348F9900048F88000490
71419+:10F00000A5430014350700010A001003AF87000470
71420+:10F010003C04800024030003348201808F890000B7
71421+:10F020008F870004A043000B3C088000350C018052
71422+:10F03000A585000EA585001A8F85000C30EB800099
71423+:10F04000A5890010AD850028A58600081160000F75
71424+:10F050008F85001435190100972A00163158FFFCDE
71425+:10F06000270F000401E870218DCD400031A6FFFF7D
71426+:10F0700014C000072403BFFF3C02FFFF34487FFF9A
71427+:10F0800000E83824AF8700048F8500142403BFFFF5
71428+:10F090003C04800000E3582434830180A46B0026E4
71429+:10F0A000AC69002C10A0000300054C02A465001000
71430+:10F0B000A46900263C071000AC8701B803E00008F3
71431+:10F0C000000000008F990004240AFFFE032A382460
71432+:10F0D0000A001003AF87000427BDFFE88FA20028B5
71433+:10F0E00030A5FFFF30C6FFFFAFBF0010AF87000C99
71434+:10F0F000AF820014AF8000040E000FDBAF80000071
71435+:10F100008FBF001027BD001803E00008AF80001477
71436+:10F110003C06800034C4007034C701008C8A0000B3
71437+:10F1200090E500128F84000027BDFFF030A300FFA0
71438+:10F13000000318823082400010400037246500032D
71439+:10F140000005C8800326C0218F0E4000246F0004F4
71440+:10F15000000F6880AFAE000001A660218D8B4000DB
71441+:10F16000AFAB000494E900163128FFFC01063821FA
71442+:10F170008CE64000AFA600088FA9000800003021EF
71443+:10F18000000028213C07080024E701000A0010675E
71444+:10F19000240800089059000024A500012CAC000CA4
71445+:10F1A0000079C0210018788001E770218DCD000022
71446+:10F1B0001180000600CD302603A5102114A8FFF50C
71447+:10F1C00000051A005520FFF4905900003C0480000F
71448+:10F1D000348700703C0508008CA531048CE30000E6
71449+:10F1E0002CA2002010400009006A38230005488046
71450+:10F1F0003C0B0800256B3108012B402124AA00019B
71451+:10F20000AD0700003C010800AC2A310400C0102109
71452+:10F2100003E0000827BD0010308220001040000BE2
71453+:10F2200000055880016648218D24400024680004B0
71454+:10F2300000083880AFA4000000E618218C6540006B
71455+:10F24000AFA000080A001057AFA500040000000D91
71456+:10F250000A0010588FA9000827BDFFE03C07800076
71457+:10F2600034E60100AFBF001CAFB20018AFB100140C
71458+:10F27000AFB0001094C5000E8F87000030A4FFFFD0
71459+:10F280002483000430E2400010400010AF830028C7
71460+:10F290003C09002000E940241100000D30EC800002
71461+:10F2A0008F8A0004240BBFFF00EB38243543100085
71462+:10F2B000AF87000030F220001640000B3C1900041C
71463+:10F2C000241FFFBF0A0010B7007F102430EC80001D
71464+:10F2D000158000423C0E002030F220001240FFF862
71465+:10F2E0008F8300043C19000400F9C0241300FFF5CB
71466+:10F2F000241FFFBF34620040AF82000430E20100EF
71467+:10F300001040001130F010008F83002C10600006B8
71468+:10F310003C0F80003C05002000E52024148000C044
71469+:10F320003C0800043C0F800035EE010095CD001E26
71470+:10F3300095CC001C31AAFFFF000C5C00014B482556
71471+:10F34000AF89000C30F010001200000824110001F9
71472+:10F3500030F100201620008B3C18100000F890249B
71473+:10F36000164000823C040C002411000130E801002A
71474+:10F370001500000B3C0900018F85000430A94000F6
71475+:10F38000152000073C0900013C0C1F0100EC58242B
71476+:10F390003C0A1000116A01183C1080003C09000171
71477+:10F3A00000E9302410C000173C0B10003C18080086
71478+:10F3B0008F1800243307000214E0014024030001E9
71479+:10F3C0008FBF001C8FB200188FB100148FB00010D7
71480+:10F3D0000060102103E0000827BD002000EE682433
71481+:10F3E00011A0FFBE30F220008F8F00043C11FFFF00
71482+:10F3F00036307FFF00F0382435E380000A0010A685
71483+:10F40000AF87000000EB102450400065AF8000245F
71484+:10F410008F8C002C3C0D0F0000ED18241580008807
71485+:10F42000AF83001030E8010011000086938F0010B8
71486+:10F430003C0A0200106A00833C1280003650010032
71487+:10F44000920500139789002A3626000230AF00FF8C
71488+:10F4500025EE0004000E19C03C0480008C9801B811
71489+:10F460000700FFFE34880180AD0300003C198008CE
71490+:10F47000AC830020973100483225FFFF10A0015CCB
71491+:10F48000AF8500082523001200A3F82B53E0015993
71492+:10F490008F850004348D010095AC00202402001AF1
71493+:10F4A00030E44000318BFFFFA102000B108001927D
71494+:10F4B0002563FFFE00A3502B154001908F8F0004A1
71495+:10F4C000A50300148F88000435050001AF850004F2
71496+:10F4D0003C08800035190180A729000EA729001AD1
71497+:10F4E0008F89000C30B18000A7270010AF290028B9
71498+:10F4F000A72600081220000E3C04800035020100FF
71499+:10F50000944C0016318BFFFC256400040088182100
71500+:10F510008C7F400033E6FFFF14C000053C048000F0
71501+:10F520003C0AFFFF354D7FFF00AD2824AF85000466
71502+:10F53000240EBFFF00AE402434850180A4A800261D
71503+:10F54000ACA7002C3C071000AC8701B800001821C4
71504+:10F550008FBF001C8FB200188FB100148FB0001045
71505+:10F560000060102103E0000827BD00203C020BFFD3
71506+:10F5700000E41824345FFFFF03E3C82B5320FF7B14
71507+:10F58000241100013C0608008CC6002C24C5000193
71508+:10F590003C010800AC25002C0A0010D42411000501
71509+:10F5A0008F85002410A0002FAF80001090A30000D2
71510+:10F5B000146000792419000310A0002A30E601002D
71511+:10F5C00010C000CC8F860010241F000210DF00C97D
71512+:10F5D0008F8B000C3C0708008CE7003824E4FFFF09
71513+:10F5E00014E0000201641824000018213C0D0800FA
71514+:10F5F00025AD0038006D1021904C00048F85002847
71515+:10F6000025830004000321C030A5FFFF3626000239
71516+:10F610000E000FDB000000000A00114D0000182151
71517+:10F6200000E8302414C0FF403C0F80000E00103D65
71518+:10F63000000000008F8700000A0010CAAF82000C93
71519+:10F64000938F00103C18080127189640000F90C0B7
71520+:10F6500002588021AF9000248F85002414A0FFD38E
71521+:10F66000AF8F00103C0480008C86400030C5010044
71522+:10F6700010A000BC322300043C0C08008D8C002438
71523+:10F6800024120004106000C23190000D3C04800080
71524+:10F690008C8D40003402FFFF11A201003231FFFBCC
71525+:10F6A0008C884000310A01005540000124110010EF
71526+:10F6B00030EE080011C000BE2419FFFB8F9800280F
71527+:10F6C0002F0F03EF51E000010219802430E90100FF
71528+:10F6D00011200014320800018F87002C14E000FB79
71529+:10F6E0008F8C000C3C05800034AB0100917F00132F
71530+:10F6F00033E300FF246A00042403FFFE0203802496
71531+:10F70000000A21C012000002023230253226FFFF1B
71532+:10F710000E000FDB9785002A1200FF290000182138
71533+:10F72000320800011100000D32180004240E0001FF
71534+:10F73000120E0002023230253226FFFF9785002A82
71535+:10F740000E000FDB00002021240FFFFE020F80249B
71536+:10F750001200FF1B00001821321800045300FF188C
71537+:10F760002403000102323025241200045612000145
71538+:10F770003226FFFF9785002A0E000FDB24040100CC
71539+:10F780002419FFFB021988241220FF0D0000182104
71540+:10F790000A0010E9240300011079009C00003021C8
71541+:10F7A00090AD00012402000211A200BE30EA004028
71542+:10F7B00090B90001241800011338007F30E900409F
71543+:10F7C0008CA600049785002A00C020210E000FDBC4
71544+:10F7D0003626000200004021010018218FBF001CC6
71545+:10F7E0008FB200188FB100148FB00010006010218C
71546+:10F7F00003E0000827BD0020360F010095EE000C45
71547+:10F8000031CD020015A0FEE63C0900013C1880083D
71548+:10F81000971200489789002A362600023248FFFFD7
71549+:10F82000AF8800083C0380008C7101B80620FFFE01
71550+:10F83000346A0180AD4000001100008E3C0F800052
71551+:10F84000253F0012011FC82B1320008B240E00033C
71552+:10F85000346C0100958B00202402001A30E4400033
71553+:10F860003163FFFFA142000B108000A72463FFFE5D
71554+:10F870000103682B15A000A52408FFFE34A5000194
71555+:10F88000A5430014AF8500043C0480002412BFFF90
71556+:10F8900000B2802434850180A4A9000EA4A9001A16
71557+:10F8A000A4A60008A4B00026A4A700103C071000DE
71558+:10F8B000AC8701B80A00114D000018213C038000FC
71559+:10F8C00034640100949F000E3C1908008F3900D861
71560+:10F8D0002404008033E5FFFF273100013C010800CC
71561+:10F8E000AC3100D80E000FDB240600030A00114DD6
71562+:10F8F00000001821240A000210CA00598F85002830
71563+:10F900003C0308008C6300D0240E0001106E005EE2
71564+:10F910002CCF000C24D2FFFC2E5000041600002136
71565+:10F9200000002021241800021078001B2CD9000CA4
71566+:10F9300024DFFFF82FE900041520FF330000202109
71567+:10F9400030EB020051600004000621C054C00022C8
71568+:10F9500030A5FFFF000621C030A5FFFF0A00117D82
71569+:10F96000362600023C0908008D29002431300001B0
71570+:10F970005200FEF7000018219785002A3626000263
71571+:10F980000E000FDB000020210A00114D000018219D
71572+:10F990000A00119C241200021320FFE624DFFFF866
71573+:10F9A0000000202130A5FFFF0A00117D362600024D
71574+:10F9B0000A0011AC021980245120FF828CA6000499
71575+:10F9C0003C05080190A5964110A0FF7E2408000187
71576+:10F9D0000A0011F0010018210E000FDB3226000191
71577+:10F9E0008F8600108F8500280A00124F000621C064
71578+:10F9F0008F8500043C18800024120003371001801A
71579+:10FA0000A212000B0A00112E3C08800090A30001F6
71580+:10FA1000241100011071FF70240800012409000264
71581+:10FA20005069000430E60040240800010A0011F08B
71582+:10FA30000100182150C0FFFD240800013C0C80008B
71583+:10FA4000358B01009563001094A40002307FFFFF06
71584+:10FA5000509FFF62010018210A001284240800014F
71585+:10FA60002CA803EF1100FE56240300010A001239EE
71586+:10FA700000000000240E000335EA0180A14E000BB7
71587+:10FA80000A00121C3C04800011E0FFA2000621C005
71588+:10FA900030A5FFFF0A00117D362600020A0011A5DD
71589+:10FAA000241100201140FFC63C1280003650010096
71590+:10FAB000960F001094AE000231E80FFF15C8FFC08A
71591+:10FAC000000000000A0011E690B900013C060800A1
71592+:10FAD0008CC6003824C4FFFF14C00002018418241F
71593+:10FAE000000018213C0D080025AD0038006D1021E4
71594+:10FAF0000A0011B6904300048F8F0004240EFFFE0D
71595+:10FB00000A00112C01EE28242408FFFE0A00121A14
71596+:10FB100000A8282427BDFFC8AFB00010AFBF003435
71597+:10FB20003C10600CAFBE0030AFB7002CAFB6002861
71598+:10FB3000AFB50024AFB40020AFB3001CAFB20018C3
71599+:10FB4000AFB100148E0E5000240FFF7F3C068000E2
71600+:10FB500001CF682435AC380C240B0003AE0C5000E8
71601+:10FB6000ACCB00083C010800AC2000200E001819A6
71602+:10FB7000000000003C0A0010354980513C06601628
71603+:10FB8000AE09537C8CC700003C0860148D0500A0B2
71604+:10FB90003C03FFFF00E320243C02535300051FC237
71605+:10FBA0001482000634C57C000003A08002869821E0
71606+:10FBB0008E7200043C116000025128218CBF007C31
71607+:10FBC0008CA200783C1E600037C420203C05080150
71608+:10FBD00024A59288AF820018AF9F001C0E0016DD8E
71609+:10FBE0002406000A3C190001273996403C01080010
71610+:10FBF000AC3931DC0E0020DDAF8000148FD708084F
71611+:10FC00002418FFF03C15570902F8B02412D502F56C
71612+:10FC100024040001AF80002C3C1480003697018042
71613+:10FC20003C1E080127DE9644369301008E900000AA
71614+:10FC30003205000310A0FFFD3207000110E000882C
71615+:10FC4000320600028E7100283C048000AE91002034
71616+:10FC50008E6500048E66000000A0382100C040219F
71617+:10FC60008C8301B80460FFFE3C0B0010240A0800DE
71618+:10FC700000AB4824AC8A01B8552000E0240BBFFF3C
71619+:10FC80009675000E3C1208008E52002030AC4000E9
71620+:10FC900032AFFFFF264E000125ED00043C010800B5
71621+:10FCA000AC2E0020118000E8AF8D00283C18002009
71622+:10FCB00000B8B02412C000E530B980002408BFFFAE
71623+:10FCC00000A8382434C81000AF87000030E62000B8
71624+:10FCD00010C000E92409FFBF3C03000400E328240E
71625+:10FCE00010A00002010910243502004030EA010092
71626+:10FCF00011400010AF8200048F8B002C11600007B0
71627+:10FD00003C0D002000ED6024118000043C0F000435
71628+:10FD100000EF702411C00239000000009668001E38
71629+:10FD20009678001C3115FFFF0018B40002B690252C
71630+:10FD3000AF92000C30F910001320001324150001BD
71631+:10FD400030FF002017E0000A3C04100000E41024FB
71632+:10FD50001040000D3C0A0C003C090BFF00EA18247F
71633+:10FD60003525FFFF00A3302B10C0000830ED010047
71634+:10FD70003C0C08008D8C002C24150005258B0001FF
71635+:10FD80003C010800AC2B002C30ED010015A0000B4D
71636+:10FD90003C0500018F85000430AE400055C00007CF
71637+:10FDA0003C0500013C161F0100F690243C0F10009A
71638+:10FDB000124F01CE000000003C05000100E5302498
71639+:10FDC00010C000AF3C0C10003C1F08008FFF002447
71640+:10FDD00033E90002152000712403000100601021A6
71641+:10FDE000104000083C0680003C08800035180100E7
71642+:10FDF0008F0F00243C056020ACAF00140000000011
71643+:10FE00003C0680003C194000ACD9013800000000DD
71644+:10FE10005220001332060002262B0140262C0080BF
71645+:10FE2000240EFF80016E2024018E6824000D1940ED
71646+:10FE3000318A007F0004A9403172007F3C16200007
71647+:10FE400036C20002006A482502B2382500E2882541
71648+:10FE50000122F825ACDF0830ACD1083032060002B0
71649+:10FE600010C0FF723C188000370501408CA80000CC
71650+:10FE700024100040AF08002090AF000831E300706C
71651+:10FE8000107000D428790041532000082405006038
71652+:10FE9000241100201071000E3C0A40003C09800033
71653+:10FEA000AD2A01780A001304000000001465FFFB6E
71654+:10FEB0003C0A40000E001FFA000000003C0A40000F
71655+:10FEC0003C098000AD2A01780A00130400000000FC
71656+:10FED00090A90009241F00048CA70000312800FF0E
71657+:10FEE000111F01B22503FFFA2C7200061240001404
71658+:10FEF0003C0680008CA9000494A4000A310500FF90
71659+:10FF000000095E022D6A00083086FFFF15400002DE
71660+:10FF10002567000424070003240C000910AC01FA33
71661+:10FF200028AD000A11A001DE2410000A240E0008EA
71662+:10FF300010AE0028000731C000C038213C06800008
71663+:10FF40008CD501B806A0FFFE34D20180AE47000078
71664+:10FF500034CB0140916E0008240300023C0A4000AB
71665+:10FF600031C400FF00046A0001A86025A64C000807
71666+:10FF7000A243000B9562000A3C0810003C09800077
71667+:10FF8000A64200108D670004AE470024ACC801B83B
71668+:10FF9000AD2A01780A001304000000003C0A80002A
71669+:10FFA000354401009483000E3C0208008C4200D8C6
71670+:10FFB000240400803065FFFF245500013C01080047
71671+:10FFC000AC3500D80E000FDB240600030A001370C6
71672+:10FFD000000018210009320230D900FF2418000166
71673+:10FFE0001738FFD5000731C08F910020262200016D
71674+:10FFF000AF8200200A0013C800C0382100CB2024A3
71675+:020000021000EC
71676+:10000000AF85000010800008AF860004240D87FF34
71677+:1000100000CD6024158000083C0E006000AE302446
71678+:1000200010C00005000000000E000D42000000009E
71679+:100030000A001371000000000E0016050000000009
71680+:100040000A0013710000000030B980005320FF1F28
71681+:10005000AF8500003C02002000A2F82453E0FF1B03
71682+:10006000AF8500003C07FFFF34E47FFF00A4382485
71683+:100070000A00132B34C880000A001334010910242D
71684+:1000800000EC58245160005AAF8000248F8D002C62
71685+:100090003C0E0F0000EE182415A00075AF83001071
71686+:1000A00030EF010011E00073939800103C12020041
71687+:1000B000107200703C06800034D9010093280013B0
71688+:1000C0009789002A36A60002311800FF271600047F
71689+:1000D000001619C03C0480008C8501B804A0FFFE06
71690+:1000E00034880180AD0300003C158008AC830020FB
71691+:1000F00096BF004833E5FFFF10A001BCAF850008A4
71692+:100100002523001200A3102B504001B98F85000455
71693+:10011000348D010095AC0020240B001A30E440001F
71694+:10012000318AFFFFA10B000B108001BA2543FFFEAF
71695+:1001300000A3702B15C001B88F9600048F8F0004A8
71696+:10014000A503001435E50001AF8500043C088000DC
71697+:1001500035150180A6A9000EA6A9001A8F89000CEA
71698+:1001600030BF8000A6A70010AEA90028A6A60008F0
71699+:1001700013E0000F3C0F8000350C0100958B00163A
71700+:10018000316AFFFC25440004008818218C6240007D
71701+:100190003046FFFF14C000072416BFFF3C0EFFFFD0
71702+:1001A00035CD7FFF00AD2824AF8500043C0F8000D3
71703+:1001B0002416BFFF00B6902435E50180A4B20026C6
71704+:1001C000ACA7002C3C071000ADE701B80A00137083
71705+:1001D000000018210E00165D000000003C0A4000DF
71706+:1001E0003C098000AD2A01780A00130400000000D9
71707+:1001F0008F85002410A00027AF80001090A300007E
71708+:10020000106000742409000310690101000030210E
71709+:1002100090AE0001240D000211CD014230EF0040EC
71710+:1002200090A90001241F0001113F000930E20040A5
71711+:100230008CA600049785002A00C020210E000FDB49
71712+:1002400036A60002000040210A00137001001821A8
71713+:100250005040FFF88CA600043C07080190E7964147
71714+:1002600010E0FFF4240800010A00137001001821B7
71715+:10027000939800103C1F080127FF96400018C8C043
71716+:10028000033F4021AF8800248F85002414A0FFDBAA
71717+:10029000AF9800103C0480008C86400030C50100FF
71718+:1002A00010A0008732AB00043C0C08008D8C0024A9
71719+:1002B00024160004156000033192000D241600027C
71720+:1002C0003C0480008C8E4000340DFFFF11CD0113E3
71721+:1002D00032B5FFFB8C984000330F010055E0000160
71722+:1002E0002415001030E80800110000382409FFFB35
71723+:1002F0008F9F00282FF903EF53200001024990241B
71724+:1003000030E2010010400014325F00018F87002CA2
71725+:1003100014E0010E8F8C000C3C0480003486010038
71726+:1003200090C5001330AA00FF25430004000321C03C
71727+:100330002419FFFE025990241240000202B6302513
71728+:1003400032A6FFFF0E000FDB9785002A1240FEA3A6
71729+:1003500000001821325F000113E0000D3247000455
71730+:10036000240900011249000202B6302532A6FFFF1F
71731+:100370009785002A0E000FDB000020212402FFFEDB
71732+:10038000024290241240FE950000182132470004DA
71733+:1003900050E0FE922403000102B63025241600042A
71734+:1003A0005656000132A6FFFF9785002A0E000FDB8C
71735+:1003B000240401002403FFFB0243A82412A0FE87AB
71736+:1003C000000018210A001370240300010A0014B968
71737+:1003D0000249902410A0FFAF30E5010010A00017E3
71738+:1003E0008F8600102403000210C300148F84000CB9
71739+:1003F0003C0608008CC6003824CAFFFF14C0000267
71740+:10040000008A1024000010213C0E080025CE003880
71741+:10041000004E682191AC00048F850028258B0004D4
71742+:10042000000B21C030A5FFFF36A600020E000FDB37
71743+:10043000000000000A00137000001821240F0002C1
71744+:1004400010CF0088241600013C0308008C6300D004
71745+:100450001076008D8F85002824D9FFFC2F280004FA
71746+:100460001500006300002021241F0002107F005DA2
71747+:100470002CC9000C24C3FFF82C6200041440FFE9CF
71748+:100480000000202130EA020051400004000621C093
71749+:1004900054C0000530A5FFFF000621C030A5FFFFB6
71750+:1004A0000A00150436A600020E000FDB32A600017A
71751+:1004B0008F8600108F8500280A001520000621C0B5
71752+:1004C0003C0A08008D4A0024315200015240FE438C
71753+:1004D000000018219785002A36A600020E000FDBC7
71754+:1004E000000020210A001370000018219668000CFB
71755+:1004F000311802005700FE313C0500013C1F800806
71756+:1005000097F900489789002A36A600023328FFFF92
71757+:10051000AF8800083C0380008C7501B806A0FFFE80
71758+:100520003C04800034820180AC400000110000B621
71759+:1005300024180003252A0012010A182B106000B2AB
71760+:1005400000000000966F00203C0E8000240D001A71
71761+:1005500031ECFFFF35CA018030EB4000A14D000BAC
71762+:10056000116000B02583FFFE0103902B164000AE02
71763+:100570002416FFFE34A50001A5430014AF85000436
71764+:100580002419BFFF00B94024A6E9000EA6E9001A0D
71765+:10059000A6E60008A6E80026A6E700103C07100023
71766+:1005A000AE8701B80A001370000018213C048000D7
71767+:1005B0008C8201B80440FFFE349601802415001C93
71768+:1005C000AEC70000A2D5000B3C071000AC8701B8F5
71769+:1005D0003C0A40003C098000AD2A01780A0013045F
71770+:1005E000000000005120FFA424C3FFF800002021D8
71771+:1005F00030A5FFFF0A00150436A600020E00103DCC
71772+:10060000000000008F8700000A001346AF82000C34
71773+:1006100090A30001241500011075FF0B24080001B0
71774+:10062000240600021066000430E2004024080001A5
71775+:100630000A001370010018215040FFFD240800013A
71776+:100640003C0C8000358B0100956A001094A40002D8
71777+:100650003143FFFF5083FDE1010018210A00158599
71778+:10066000240800018F8500282CB203EF1240FDDB27
71779+:10067000240300013C0308008C6300D02416000111
71780+:100680001476FF7624D9FFFC2CD8000C1300FF72DF
71781+:10069000000621C030A5FFFF0A00150436A600029F
71782+:1006A00010B00037240F000B14AFFE23000731C039
71783+:1006B000312600FF00065600000A4E0305220047BF
71784+:1006C00030C6007F0006F8C03C16080126D69640CA
71785+:1006D00003F68021A2000001A20000003C0F600090
71786+:1006E0008DF918202405000100C588040011302769
71787+:1006F0000326C024000731C000C03821ADF81820FF
71788+:100700000A0013C8A60000028F850020000731C030
71789+:1007100024A2FFFF0A0013F6AF8200200A0014B2E1
71790+:100720002415002011E0FECC3C1980003728010080
71791+:100730009518001094B6000233120FFF16D2FEC6B1
71792+:10074000000000000A00148290A900013C0B080080
71793+:100750008D6B0038256DFFFF15600002018D1024A0
71794+:10076000000010213C080800250800380048C0217E
71795+:10077000930F000425EE00040A0014C5000E21C0EA
71796+:1007800000065202241F00FF115FFDEB000731C07D
71797+:10079000000A20C03C0E080125CE9640008EA821FC
71798+:1007A000009E602100095C02240D00013C076000EE
71799+:1007B000A2AD0000AD860000A2AB00018CF21820B3
71800+:1007C00024030001014310040242B025ACF61820B6
71801+:1007D00000C038210A0013C8A6A900020A0015AA01
71802+:1007E000AF8000200A0012FFAF84002C8F85000428
71803+:1007F0003C1980002408000337380180A308000B4F
71804+:100800000A00144D3C088000A2F8000B0A00155A9B
71805+:100810002419BFFF8F9600042412FFFE0A00144B18
71806+:1008200002D228242416FFFE0A00155800B62824F8
71807+:100830003C038000346401008C85000030A2003E3F
71808+:100840001440000800000000AC6000488C870000E5
71809+:1008500030E607C010C0000500000000AC60004C8E
71810+:10086000AC60005003E0000824020001AC600054BA
71811+:10087000AC6000408C880000310438001080FFF923
71812+:10088000000000002402000103E00008AC60004406
71813+:100890003C0380008C6201B80440FFFE3467018095
71814+:1008A000ACE4000024080001ACE00004A4E500086A
71815+:1008B00024050002A0E8000A34640140A0E5000B12
71816+:1008C0009483000A14C00008A4E30010ACE00024E4
71817+:1008D0003C07800034E901803C041000AD20002872
71818+:1008E00003E00008ACE401B88C8600043C0410006E
71819+:1008F000ACE600243C07800034E90180AD200028EC
71820+:1009000003E00008ACE401B83C0680008CC201B8EA
71821+:100910000440FFFE34C7018024090002ACE400005B
71822+:10092000ACE40004A4E50008A0E9000A34C50140D5
71823+:10093000A0E9000B94A8000A3C041000A4E80010F1
71824+:10094000ACE000248CA30004ACE3002803E0000822
71825+:10095000ACC401B83C039000346200010082202541
71826+:100960003C038000AC6400208C65002004A0FFFEE6
71827+:100970000000000003E00008000000003C028000CE
71828+:10098000344300010083202503E00008AC4400202C
71829+:1009900027BDFFE03C098000AFBF0018AFB10014D5
71830+:1009A000AFB00010352801408D10000091040009FF
71831+:1009B0009107000891050008308400FF30E600FF31
71832+:1009C00000061A002C820081008330251040002A86
71833+:1009D00030A50080000460803C0D080125AD92B078
71834+:1009E000018D58218D6A00000140000800000000C0
71835+:1009F0003C038000346201409445000A14A0001EAC
71836+:100A00008F91FCC09227000530E6000414C0001A44
71837+:100A1000000000000E00164E02002021922A000560
71838+:100A200002002021354900040E001658A2290005B5
71839+:100A30009228000531040004148000020000000028
71840+:100A40000000000D922D0000240B002031AC00FFAF
71841+:100A5000158B00093C0580008CAE01B805C0FFFE77
71842+:100A600034B10180AE3000003C0F100024100005AE
71843+:100A7000A230000BACAF01B80000000D8FBF001812
71844+:100A80008FB100148FB0001003E0000827BD0020D4
71845+:100A90000200202100C028218FBF00188FB1001450
71846+:100AA0008FB00010240600010A00161D27BD00208B
71847+:100AB0000000000D0200202100C028218FBF001877
71848+:100AC0008FB100148FB00010000030210A00161DF5
71849+:100AD00027BD002014A0FFE8000000000200202134
71850+:100AE0008FBF00188FB100148FB0001000C02821F4
71851+:100AF0000A00163B27BD00203C0780008CEE01B8A1
71852+:100B000005C0FFFE34F00180241F0002A21F000B6D
71853+:100B100034F80140A60600089719000A3C0F10009F
71854+:100B2000A61900108F110004A6110012ACEF01B835
71855+:100B30000A0016998FBF001827BDFFE8AFBF00104D
71856+:100B40000E000FD4000000003C0280008FBF001098
71857+:100B500000002021AC4001800A00108F27BD001842
71858+:100B60003084FFFF30A5FFFF108000070000182130
71859+:100B7000308200011040000200042042006518216C
71860+:100B80001480FFFB0005284003E0000800601021EE
71861+:100B900010C00007000000008CA2000024C6FFFF68
71862+:100BA00024A50004AC82000014C0FFFB24840004D0
71863+:100BB00003E000080000000010A0000824A3FFFFCD
71864+:100BC000AC86000000000000000000002402FFFFCF
71865+:100BD0002463FFFF1462FFFA2484000403E000088A
71866+:100BE000000000003C03800027BDFFF83462018054
71867+:100BF000AFA20000308C00FF30AD00FF30CE00FF10
71868+:100C00003C0B80008D6401B80480FFFE00000000F2
71869+:100C10008FA900008D6801288FAA00008FA700000F
71870+:100C20008FA400002405000124020002A085000A10
71871+:100C30008FA30000359940003C051000A062000B16
71872+:100C40008FB800008FAC00008FA600008FAF0000AF
71873+:100C500027BD0008AD280000AD400004AD80002491
71874+:100C6000ACC00028A4F90008A70D0010A5EE0012E2
71875+:100C700003E00008AD6501B83C06800827BDFFE829
71876+:100C800034C50080AFBF001090A7000924020012F5
71877+:100C900030E300FF1062000B008030218CA8005070
71878+:100CA00000882023048000088FBF00108CAA003425
71879+:100CB000240400390000282100CA4823052000052B
71880+:100CC000240600128FBF00102402000103E0000878
71881+:100CD00027BD00180E0016F2000000008FBF0010A4
71882+:100CE0002402000103E0000827BD001827BDFFC84B
71883+:100CF000AFB20030AFB00028AFBF0034AFB1002CAE
71884+:100D000000A0802190A5000D30A6001010C000109A
71885+:100D1000008090213C0280088C4400048E0300086F
71886+:100D20001064000C30A7000530A6000510C0009329
71887+:100D3000240400018FBF00348FB200308FB1002C2B
71888+:100D40008FB000280080102103E0000827BD003884
71889+:100D500030A7000510E0000F30AB001210C00006F5
71890+:100D6000240400013C0980088E0800088D25000439
71891+:100D70005105009C240400388FBF00348FB200302E
71892+:100D80008FB1002C8FB000280080102103E00008F4
71893+:100D900027BD0038240A0012156AFFE6240400016A
71894+:100DA0000200202127A500100E000CB6AFA00010F5
71895+:100DB0001440007C3C19800837240080909800087B
71896+:100DC000331100081220000A8FA7001030FF010025
71897+:100DD00013E000A48FA300148C8600580066102333
71898+:100DE000044000043C0A8008AC8300588FA7001020
71899+:100DF0003C0A800835480080910900083124000829
71900+:100E00001480000224080003000040213C1F8008D9
71901+:100E100093F1001193F9001237E600808CCC005456
71902+:100E2000333800FF03087821322D00FF000F708057
71903+:100E300001AE282100AC582B1160006F00000000AB
71904+:100E400094CA005C8CC900543144FFFF0125102373
71905+:100E50000082182B14600068000000008CCB005446
71906+:100E60000165182330EC00041180006C000830800C
71907+:100E70008FA8001C0068102B1040006230ED0004A9
71908+:100E8000006610232C46008010C00002004088211C
71909+:100E9000241100800E00164E024020213C0D8008D7
71910+:100EA00035A6008024070001ACC7000C90C80008DC
71911+:100EB0000011484035A70100310C007FA0CC00088C
71912+:100EC0008E05000424AB0001ACCB0030A4D1005C43
71913+:100ED0008CCA003C9602000E01422021ACC40020C6
71914+:100EE0008CC3003C0069F821ACDF001C8E190004A3
71915+:100EF000ACF900008E180008ACF800048FB10010A7
71916+:100F0000322F000855E0004793A60020A0C0004EF5
71917+:100F100090D8004E2411FFDFA0F8000890CF000801
71918+:100F200001F17024A0CE00088E0500083C0B80085B
71919+:100F300035690080AD2500388D6A00148D2200309F
71920+:100F40002419005001422021AD24003491230000D7
71921+:100F5000307F00FF13F90036264F01000E001658AF
71922+:100F60000240202124040038000028210E0016F23F
71923+:100F70002406000A0A001757240400010E000D2859
71924+:100F8000000020218FBF00348FB200308FB1002CC1
71925+:100F90008FB00028004020210080102103E00008CD
71926+:100FA00027BD00388E0E00083C0F800835F0008009
71927+:100FB000AE0E005402402021AE0000300E00164E4E
71928+:100FC00000000000920D00250240202135AC0020D9
71929+:100FD0000E001658A20C00250E000CAC0240202179
71930+:100FE000240400382405008D0E0016F22406001299
71931+:100FF0000A0017572404000194C5005C0A001792E8
71932+:1010000030A3FFFF2407021811A0FF9E00E6102363
71933+:101010008FAE001C0A00179A01C610230A0017970A
71934+:101020002C620218A0E600080A0017C48E0500080A
71935+:101030002406FF8001E6C0243C118000AE38002861
71936+:101040008E0D000831E7007F3C0E800C00EE602121
71937+:10105000AD8D00E08E080008AF8C00380A0017D074
71938+:10106000AD8800E4AC800058908500082403FFF7A9
71939+:1010700000A33824A08700080A0017758FA7001066
71940+:101080003C05080024A560A83C04080024846FF4F3
71941+:101090003C020800244260B0240300063C01080121
71942+:1010A000AC2596C03C010801AC2496C43C01080163
71943+:1010B000AC2296C83C010801A02396CC03E00008AE
71944+:1010C0000000000003E00008240200013C02800050
71945+:1010D000308800FF344701803C0680008CC301B893
71946+:1010E0000460FFFE000000008CC501282418FF806A
71947+:1010F0003C0D800A24AF010001F8702431EC007F20
71948+:10110000ACCE0024018D2021ACE50000948B00EAD8
71949+:101110003509600024080002316AFFFFACEA0004D0
71950+:1011200024020001A4E90008A0E8000BACE00024C0
71951+:101130003C071000ACC701B8AF84003803E00008DA
71952+:10114000AF85006C938800488F8900608F820038DB
71953+:1011500030C600FF0109382330E900FF01221821C1
71954+:1011600030A500FF2468008810C000020124382147
71955+:101170000080382130E400031480000330AA00030B
71956+:101180001140000D312B000310A0000900001021B8
71957+:1011900090ED0000244E000131C200FF0045602B9D
71958+:1011A000A10D000024E700011580FFF925080001CA
71959+:1011B00003E00008000000001560FFF300000000DD
71960+:1011C00010A0FFFB000010218CF80000245900043F
71961+:1011D000332200FF0045782BAD18000024E70004FF
71962+:1011E00015E0FFF92508000403E0000800000000F6
71963+:1011F00093850048938800588F8700600004320070
71964+:101200003103007F00E5102B30C47F001040000F39
71965+:10121000006428258F8400383C0980008C8A00EC0B
71966+:10122000AD2A00A43C03800000A35825AC6B00A0AD
71967+:101230008C6C00A00580FFFE000000008C6D00ACEF
71968+:10124000AC8D00EC03E000088C6200A80A00188254
71969+:101250008F840038938800593C0280000080502120
71970+:10126000310300FEA383005930ABFFFF30CC00FFF9
71971+:1012700030E7FFFF344801803C0980008D2401B82D
71972+:101280000480FFFE8F8D006C24180016AD0D000049
71973+:101290008D2201248F8D0038AD0200048D5900206D
71974+:1012A000A5070008240201C4A119000AA118000B17
71975+:1012B000952F01208D4E00088D4700049783005C18
71976+:1012C0008D59002401CF302100C7282100A32023FD
71977+:1012D0002418FFFFA504000CA50B000EA5020010AA
71978+:1012E000A50C0012AD190018AD18002495AF00E848
71979+:1012F0003C0B10002407FFF731EEFFFFAD0E002876
71980+:101300008DAC0084AD0C002CAD2B01B88D460020B7
71981+:1013100000C7282403E00008AD4500208F8800386E
71982+:101320000080582130E7FFFF910900D63C02800081
71983+:1013300030A5FFFF312400FF00041A00006750258C
71984+:1013400030C600FF344701803C0980008D2C01B875
71985+:101350000580FFFE8F82006C240F0017ACE20000B6
71986+:101360008D390124ACF900048D780020A4EA00082E
71987+:10137000241901C4A0F8000AA0EF000B9523012056
71988+:101380008D6E00088D6D00049784005C01C35021B0
71989+:10139000014D602101841023A4E2000CA4E5000E9D
71990+:1013A000A4F90010A4E60012ACE000148D7800242B
71991+:1013B000240DFFFFACF800188D0F007CACEF001C73
71992+:1013C0008D0E00783C0F1000ACEE0020ACED002438
71993+:1013D000950A00BE240DFFF73146FFFFACE600285A
71994+:1013E000950C00809504008231837FFF0003CA00C2
71995+:1013F0003082FFFF0322C021ACF8002CAD2F01B8D2
71996+:10140000950E00828D6A002000AE3021014D282407
71997+:10141000A506008203E00008AD6500203C028000C4
71998+:10142000344501803C0480008C8301B80460FFFED9
71999+:101430008F8A0044240600199549001C3128FFFFBB
72000+:10144000000839C0ACA70000A0A6000B3C051000A6
72001+:1014500003E00008AC8501B88F87004C0080402174
72002+:1014600030C400FF3C0680008CC201B80440FFFE7F
72003+:101470008F89006C9383006834996000ACA90000E8
72004+:10148000A0A300058CE20010240F00022403FFF744
72005+:10149000A4A20006A4B900088D180020A0B8000A74
72006+:1014A000A0AF000B8CEE0000ACAE00108CED000481
72007+:1014B000ACAD00148CEC001CACAC00248CEB002018
72008+:1014C000ACAB00288CEA002C3C071000ACAA002C26
72009+:1014D0008D090024ACA90018ACC701B88D05002007
72010+:1014E00000A3202403E00008AD0400208F8600380C
72011+:1014F00027BDFFE0AFB10014AFBF0018AFB00010C0
72012+:1015000090C300D430A500FF3062002010400008D6
72013+:10151000008088218CCB00D02409FFDF256A0001E0
72014+:10152000ACCA00D090C800D401093824A0C700D4A8
72015+:1015300014A000403C0C80008F840038908700D4B9
72016+:101540002418FFBF2406FFEF30E3007FA08300D400
72017+:10155000979F005C8F8200608F8D003803E2C82364
72018+:10156000A799005CA5A000BC91AF00D401F870243D
72019+:10157000A1AE00D48F8C0038A18000D78F8A0038AC
72020+:10158000A5400082AD4000EC914500D400A658244F
72021+:10159000A14B00D48F9000348F8400609786005C4C
72022+:1015A0000204282110C0000FAF850034A38000582A
72023+:1015B0003C0780008E2C000894ED01208E2B000447
72024+:1015C000018D5021014B8021020620233086FFFF30
72025+:1015D00030C8000F3909000131310001162000091F
72026+:1015E000A3880058938600488FBF00188FB100145D
72027+:1015F0008FB0001027BD0020AF85006403E0000815
72028+:10160000AF86006000C870238FBF00189386004823
72029+:101610008FB100148FB0001034EF0C00010F28219F
72030+:1016200027BD0020ACEE0084AF85006403E0000815
72031+:10163000AF86006035900180020028210E00190F4E
72032+:10164000240600828F840038908600D430C5004084
72033+:1016500050A0FFBAA38000688F85004C3C06800034
72034+:101660008CCD01B805A0FFFE8F89006C2408608234
72035+:1016700024070002AE090000A6080008A207000B1C
72036+:101680008CA300083C0E1000AE0300108CA2000CCE
72037+:10169000AE0200148CBF0014AE1F00188CB90018E5
72038+:1016A000AE1900248CB80024AE1800288CAF002896
72039+:1016B000AE0F002CACCE01B80A001948A380006818
72040+:1016C0008F8A003827BDFFE0AFB10014AFB0001023
72041+:1016D0008F880060AFBF00189389003C954200BC22
72042+:1016E00030D100FF0109182B0080802130AC00FFB1
72043+:1016F0003047FFFF0000582114600003310600FF4F
72044+:1017000001203021010958239783005C0068202BB9
72045+:101710001480002700000000106800562419000102
72046+:101720001199006334E708803165FFFF0E0018C08F
72047+:10173000020020218F83006C3C07800034E601808A
72048+:101740003C0580008CAB01B80560FFFE240A001840
72049+:101750008F840038ACC30000A0CA000B948900BE7F
72050+:101760003C081000A4C90010ACC00030ACA801B8FF
72051+:101770009482008024430001A4830080949F008011
72052+:101780003C0608008CC6318833EC7FFF1186005E72
72053+:101790000000000002002021022028218FBF001835
72054+:1017A0008FB100148FB000100A00193427BD00203B
72055+:1017B000914400D42403FF8000838825A15100D4E4
72056+:1017C0009784005C3088FFFF51000023938C003C1D
72057+:1017D0008F8500382402EFFF008B782394AE00BC85
72058+:1017E0000168502B31E900FF01C26824A4AD00BCA0
72059+:1017F00051400039010058213C1F800037E60100AC
72060+:101800008CD800043C190001031940245500000144
72061+:1018100034E740008E0A00202403FFFB241100015E
72062+:1018200001432024AE0400201191002D34E78000F4
72063+:1018300002002021012030210E0018C03165FFFF79
72064+:101840009787005C8F890060A780005C0127802358
72065+:10185000AF900060938C003C8F8B00388FBF0018D6
72066+:101860008FB100148FB0001027BD002003E00008E6
72067+:10187000A16C00D73C0D800035AA01008D48000402
72068+:101880003C0900010109282454A0000134E740006C
72069+:101890008E0F00202418FFFB34E7800001F870242D
72070+:1018A00024190001AE0E00201599FF9F34E708802F
72071+:1018B000020020210E00188E3165FFFF020020215A
72072+:1018C000022028218FBF00188FB100148FB00010A4
72073+:1018D0000A00193427BD00200A0019F7000048212A
72074+:1018E00002002021012030210E00188E3165FFFFFB
72075+:1018F0009787005C8F890060A780005C01278023A8
72076+:101900000A001A0EAF900060948C0080241F8000A3
72077+:10191000019F3024A4860080908B0080908F0080EF
72078+:10192000316700FF0007C9C20019C027001871C045
72079+:1019300031ED007F01AE2825A08500800A0019DF67
72080+:1019400002002021938500682403000127BDFFE8E1
72081+:1019500000A330042CA20020AFB00010AFBF0014D1
72082+:1019600000C01821104000132410FFFE3C0708009F
72083+:101970008CE7319000E610243C088000350501809A
72084+:1019800014400005240600848F890038240A0004CE
72085+:101990002410FFFFA12A00FC0E00190F0000000018
72086+:1019A000020010218FBF00148FB0001003E0000868
72087+:1019B00027BD00183C0608008CC631940A001A574F
72088+:1019C00000C310248F87004427BDFFE0AFB200188A
72089+:1019D000AFB10014AFB00010AFBF001C30D000FF9B
72090+:1019E00090E6000D00A088210080902130C5007F86
72091+:1019F000A0E5000D8F8500388E2300188CA200D042
72092+:101A00001062002E240A000E0E001A4AA38A0068F3
72093+:101A10002409FFFF104900222404FFFF5200002088
72094+:101A2000000020218E2600003C0C001000CC582421
72095+:101A3000156000393C0E000800CE682455A0003F18
72096+:101A4000024020213C18000200D880241200001F10
72097+:101A50003C0A00048F8700448CE200148CE30010E1
72098+:101A60008CE500140043F82303E5C82B1320000580
72099+:101A7000024020218E24002C8CF1001010910031A6
72100+:101A80000240202124020012A38200680E001A4A9C
72101+:101A90002412FFFF105200022404FFFF0000202147
72102+:101AA0008FBF001C8FB200188FB100148FB00010D0
72103+:101AB0000080102103E0000827BD002090A800D47A
72104+:101AC000350400200A001A80A0A400D400CA4824CB
72105+:101AD0001520000B8F8B00448F8D00448DAC0010BF
72106+:101AE0001580000B024020218E2E002C51C0FFECEF
72107+:101AF00000002021024020210A001A9B2402001726
72108+:101B00008D66001050C0FFE6000020210240202119
72109+:101B10000A001A9B24020011024020212402001511
72110+:101B20000E001A4AA3820068240FFFFF104FFFDC4B
72111+:101B30002404FFFF0A001A8A8E2600000A001AC138
72112+:101B4000240200143C08000400C8382450E0FFD4EC
72113+:101B500000002021024020210A001A9B24020013C9
72114+:101B60008F85003827BDFFD8AFB3001CAFB2001877
72115+:101B7000AFB10014AFB00010AFBF002090A700D4E9
72116+:101B80008F90004C2412FFFF34E2004092060000C8
72117+:101B9000A0A200D48E0300100080982110720006CD
72118+:101BA00030D1003F2408000D0E001A4AA3880068B7
72119+:101BB000105200252404FFFF8F8A00388E09001878
72120+:101BC0008D4400D01124000702602021240C000E57
72121+:101BD0000E001A4AA38C0068240BFFFF104B001A5A
72122+:101BE0002404FFFF24040020122400048F8D0038F9
72123+:101BF00091AF00D435EE0020A1AE00D48F85005403
72124+:101C000010A00019000000001224004A8F9800382C
72125+:101C10008F92FCC0971000809651000A5230004805
72126+:101C20008F9300403C1F08008FFF318C03E5C82BC9
72127+:101C30001720001E02602021000028210E0019A993
72128+:101C400024060001000020218FBF00208FB3001C5C
72129+:101C50008FB200188FB100148FB0001000801021D7
72130+:101C600003E0000827BD00285224002A8E05001436
72131+:101C70008F840038948A008025490001A48900805F
72132+:101C8000948800803C0208008C42318831077FFF35
72133+:101C900010E2000E00000000026020210E00193446
72134+:101CA000240500010A001B0B000020212402002D46
72135+:101CB0000E001A4AA38200682403FFFF1443FFE1C9
72136+:101CC0002404FFFF0A001B0C8FBF002094990080A2
72137+:101CD000241F800024050001033FC024A498008035
72138+:101CE00090920080908E0080325100FF001181C2DE
72139+:101CF00000107827000F69C031CC007F018D582576
72140+:101D0000A08B00800E001934026020210A001B0BFA
72141+:101D1000000020212406FFFF54A6FFD68F84003840
72142+:101D2000026020210E001934240500010A001B0B5B
72143+:101D300000002021026020210A001B252402000A45
72144+:101D40002404FFFD0A001B0BAF9300608F8800384E
72145+:101D500027BDFFE8AFB00010AFBF0014910A00D458
72146+:101D60008F87004C00808021354900408CE60010B0
72147+:101D7000A10900D43C0208008C4231B030C53FFFBD
72148+:101D800000A2182B106000078F850050240DFF80E3
72149+:101D900090AE000D01AE6024318B00FF156000088D
72150+:101DA0000006C382020020212403000D8FBF00140F
72151+:101DB0008FB0001027BD00180A001A4AA3830068DC
72152+:101DC00033060003240F000254CFFFF70200202146
72153+:101DD00094A2001C8F85003824190023A4A200E8D7
72154+:101DE0008CE8000000081E02307F003F13F9003528
72155+:101DF0003C0A00838CE800188CA600D0110600086D
72156+:101E0000000000002405000E0E001A4AA385006899
72157+:101E10002407FFFF104700182404FFFF8F850038B8
72158+:101E200090A900D435240020A0A400D48F8C0044B5
72159+:101E3000918E000D31CD007FA18D000D8F83005458
72160+:101E40001060001C020020218F8400508C9800102C
72161+:101E50000303782B11E0000D241900180200202143
72162+:101E6000A39900680E001A4A2410FFFF10500002C8
72163+:101E70002404FFFF000020218FBF00148FB000104A
72164+:101E80000080102103E0000827BD00188C86001098
72165+:101E90008F9F00440200202100C31023AFE20010F6
72166+:101EA000240500010E0019A9240600010A001B9751
72167+:101EB000000020210E001934240500010A001B97A0
72168+:101EC00000002021010A5824156AFFD98F8C004494
72169+:101ED000A0A600FC0A001B84A386005A30A500FFC0
72170+:101EE0002406000124A9000100C9102B1040000C99
72171+:101EF00000004021240A000100A61823308B0001B5
72172+:101F000024C60001006A3804000420421160000267
72173+:101F100000C9182B010740251460FFF800A61823FC
72174+:101F200003E000080100102127BDFFD8AFB0001862
72175+:101F30008F90004CAFB1001CAFBF00202403FFFF07
72176+:101F40002411002FAFA30010920600002405000802
72177+:101F500026100001006620260E001BB0308400FF12
72178+:101F600000021E003C021EDC34466F410A001BD8F2
72179+:101F70000000102110A00009008018212445000154
72180+:101F800030A2FFFF2C4500080461FFFA0003204047
72181+:101F90000086202614A0FFF9008018210E001BB037
72182+:101FA000240500208FA300102629FFFF313100FFF8
72183+:101FB00000034202240700FF1627FFE20102182651
72184+:101FC00000035027AFAA0014AFAA00100000302170
72185+:101FD00027A8001027A7001400E6782391ED00033E
72186+:101FE00024CE000100C8602131C600FF2CCB0004C4
72187+:101FF0001560FFF9A18D00008FA200108FBF002097
72188+:102000008FB1001C8FB0001803E0000827BD002826
72189+:1020100027BDFFD0AFB3001CAFB00010AFBF00288A
72190+:10202000AFB50024AFB40020AFB20018AFB10014B8
72191+:102030003C0C80008D880128240FFF803C06800A1C
72192+:1020400025100100250B0080020F68243205007F57
72193+:10205000016F7024AD8E009000A62821AD8D002464
72194+:1020600090A600FC3169007F3C0A8004012A1821F7
72195+:10207000A386005A9067007C00809821AF830030CF
72196+:1020800030E20002AF88006CAF85003800A0182154
72197+:10209000144000022404003424040030A3840048C7
72198+:1020A0008C7200DC30D100FF24040004AF92006089
72199+:1020B00012240004A38000688E7400041680001EA1
72200+:1020C0003C0880009386005930C7000110E0000FE3
72201+:1020D0008F9300608CB000848CA800842404FF805F
72202+:1020E000020410240002F940310A007F03EA482567
72203+:1020F0003C0C2000012C902530CD00FE3C038000DC
72204+:10210000AC720830A38D00598F9300608FBF0028F8
72205+:102110008FB50024ACB300DC8FB400208FB3001C5B
72206+:102120008FB200188FB100148FB00010240200018C
72207+:1021300003E0000827BD00308E7F000895020120D3
72208+:102140008E67001003E2C8213326FFFF30D8000F4E
72209+:1021500033150001AF87003416A00058A39800582B
72210+:1021600035090C000309382100D81823AD03008479
72211+:10217000AF8700648E6A00043148FFFF1100007EC3
72212+:10218000A78A005C90AC00D42407FF8000EC3024C8
72213+:1021900030CB00FF1560004B9786005C938E005A91
72214+:1021A000240D000230D5FFFF11CD02A20000A021B6
72215+:1021B0008F85006002A5802B160000BC9388004824
72216+:1021C0003C11800096240120310400FF1485008812
72217+:1021D0008F8400648F9800343312000356400085CA
72218+:1021E00030A500FF8F900064310C00FF24060034FE
72219+:1021F00011860095AF90004C9204000414800118E1
72220+:102200008F8E0038A380003C8E0D00048DC800D84E
72221+:102210003C0600FF34CCFFFF01AC30240106182B34
72222+:1022200014600120AF8600548F8700609798005C8F
72223+:10223000AF8700400307402310C000C7A788005C99
72224+:102240008F91003030C3000300035823922A007C92
72225+:102250003171000302261021000A20823092000111
72226+:102260000012488000492821311FFFFF03E5C82BD9
72227+:10227000132001208F8800388F8500348F880064F8
72228+:102280001105025A3C0E3F018E0600003C0C250051
72229+:1022900000CE682411AC01638F84004C30E500FF50
72230+:1022A0000E00184A000030218F8800388F870060A8
72231+:1022B0008F8500340A001DB78F8600540A001C5613
72232+:1022C000AF87006490A400D400E48024320200FFB1
72233+:1022D000104000169386005990A6008890AE00D753
72234+:1022E00024A8008830D4003F2686FFE02CD10020AF
72235+:1022F000A38E003C1220000CAF88004C240B000180
72236+:1023000000CB20043095001916A0012B3C0680005C
72237+:1023100034CF0002008FC0241700022E3099002015
72238+:1023200017200234000000009386005930CB0001D2
72239+:102330001160000F9788005C8CBF00848CA900841A
72240+:10234000240AFF8003EA6024000C19403132007F28
72241+:10235000007238253C0D200000EDC82530D800FE65
72242+:102360003C0F8000ADF90830A39800599788005CB5
72243+:102370001500FF84000000008E630020306200041E
72244+:102380001040FF51938600592404FFFB0064802411
72245+:102390003C038000AE700020346601808C7301B86D
72246+:1023A0000660FFFE8F98006C347501003C1400013C
72247+:1023B000ACD800008C6B012424076085ACCB0004F2
72248+:1023C0008EAE000401D488245220000124076083CB
72249+:1023D00024190002A4C700083C0F1000A0D9000B6C
72250+:1023E0003C068000ACCF01B80A001C2B9386005934
72251+:1023F00030A500FF0E00184A240600018F88006CEB
72252+:102400003C05800034A90900250201889388004812
72253+:10241000304A0007304B00783C0340802407FF809F
72254+:102420000163C825014980210047F824310C00FFD1
72255+:1024300024060034ACBF0800AF90004CACB90810C3
72256+:102440005586FF6E920400048F8400388E11003090
72257+:10245000908E00D431CD001015A000108F83006045
72258+:102460002C6F000515E000E400000000909800D4F7
72259+:102470002465FFFC331200101640000830A400FF52
72260+:102480008F9F00648F99003413F90004388700018E
72261+:1024900030E20001144001C8000000000E001BC320
72262+:1024A000000000000A001DF8000000008F84006496
72263+:1024B00030C500FF0E00184A24060001939800481A
72264+:1024C000240B0034130B00A08F8500388F8600602A
72265+:1024D0009783005C306EFFFF00CE8823AF910060D1
72266+:1024E000A780005C1280FF90028018212414FFFD59
72267+:1024F0005474FFA28E6300208E6A00042403FFBF81
72268+:102500002408FFEF0155F823AE7F000490AC00D4FF
72269+:102510003189007FA0A900D48E7200208F8F0038EF
72270+:10252000A780005C364D0002AE6D0020A5E000BC27
72271+:1025300091E500D400A3C824A1F900D48F950038F8
72272+:10254000AEA000EC92B800D403085824A2AB00D48B
72273+:102550000A001CD78F8500388F910034AF8000604F
72274+:1025600002275821AF8B0034000020212403FFFFF5
72275+:10257000108301B48F8500388E0C00103C0D0800CC
72276+:102580008DAD31B09208000031843FFF008D802B6B
72277+:1025900012000023310D003F3C1908008F3931A88B
72278+:1025A0008F9F006C000479802408FF80033F202166
72279+:1025B000008FC821938500590328F8243C06008029
72280+:1025C0003C0F800034D80001001F91403331007F60
72281+:1025D0008F8600380251502535EE0940332B0078A4
72282+:1025E000333000073C0310003C02800C017890253A
72283+:1025F000020E48210143C0250222382134AE0001D9
72284+:10260000ADFF0804AF890050ADF20814AF87004455
72285+:10261000ADFF0028ACD90084ADF80830A38E005976
72286+:102620009383005A24070003106700272407000142
72287+:102630001467FFAC8F8500382411002311B1008589
72288+:1026400000000000240E000B026020210E001A4A38
72289+:10265000A38E00680040A0210A001D328F8500383B
72290+:1026600002602021240B000C0E001A4AA38B006884
72291+:10267000240AFFFF104AFFBD2404FFFF8F8E00389D
72292+:10268000A380003C8E0D00048DC800D83C0600FFDE
72293+:1026900034CCFFFF01AC30240106182B1060FEE2A1
72294+:1026A000AF86005402602021241200190E001A4A3D
72295+:1026B000A3920068240FFFFF104FFFAC2404FFFF1C
72296+:1026C0000A001C838F86005425A3FFE02C74002091
72297+:1026D0001280FFDD240E000B000328803C1108014E
72298+:1026E000263194B400B148218D2D000001A00008CE
72299+:1026F000000000008F85003400A710219385003C66
72300+:10270000AF82003402251821A383003C951F00BC32
72301+:102710000226282137F91000A51900BC5240FF926B
72302+:10272000AF850060246A0004A38A003C950900BCC0
72303+:1027300024A40004AF84006035322000A51200BC40
72304+:102740000A001D54000020218F8600602CC800055F
72305+:102750001500FF609783005C3065FFFF00C5C8234C
72306+:102760002F2F000511E00003306400FF24CDFFFC93
72307+:1027700031A400FF8F8900648F920034113200046D
72308+:10278000389F000133EC0001158001380000000083
72309+:102790008F840038908700D434E60010A08600D4DF
72310+:1027A0008F8500388F8600609783005CACA000ECBA
72311+:1027B0000A001D2F306EFFFF8CB500848CB400849E
72312+:1027C0003C04100002A7302400068940328E007FAE
72313+:1027D000022E8025020410253C08800024050001FB
72314+:1027E00002602021240600010E0019A9AD02083064
72315+:1027F0000A001CC38F8500388C8200EC1222FE7EFA
72316+:102800000260202124090005A38900680E001A4AED
72317+:102810002411FFFF1451FE782404FFFF0A001D5508
72318+:102820002403FFFF8F8F004C8F8800388DF8000045
72319+:10283000AD1800888DE70010AD0700988F87006005
72320+:102840000A001DB78F8600542406FFFF118600057D
72321+:10285000000000000E001B4C026020210A001D8FAA
72322+:102860000040A0210E001AD1026020210A001D8F15
72323+:102870000040A0218F90004C3C0208008C4231B0F7
72324+:102880008E110010322C3FFF0182282B10A0000C6B
72325+:10289000240BFF808F85005090A3000D01637024EE
72326+:1028A00031CA00FF1140000702602021001143825D
72327+:1028B000310600032418000110D8010600000000B2
72328+:1028C000026020212403000D0E001A4AA383006831
72329+:1028D000004020218F8500380A001D320080A02191
72330+:1028E0008F90004C3C0A08008D4A31B08F85005013
72331+:1028F0008E0400100000A0218CB1001430823FFF34
72332+:10290000004A602B8CB200205180FFEE0260202133
72333+:1029100090B8000D240BFF800178702431C300FFB4
72334+:102920005060FFE80260202100044382310600036A
72335+:1029300014C0FFE40260202194BF001C8F9900386E
72336+:102940008E060028A73F00E88CAF0010022F20233E
72337+:1029500014C4013A026020218F83005400C368210F
72338+:10296000022D382B14E00136240200188F8A00440F
72339+:102970008F820030024390218D4B00100163702341
72340+:10298000AD4E0010AD5200208C4C00740192282BEB
72341+:1029900014A0015F026020218F8400508E08002463
72342+:1029A0008C86002411060007026020212419001CD7
72343+:1029B0000E001A4AA3990068240FFFFF104FFFC5AD
72344+:1029C0002404FFFF8F8400448C87002424FF00012F
72345+:1029D000AC9F00241251012F8F8D00308DB10074F7
72346+:1029E0001232012C3C0B00808E0E000001CB5024D3
72347+:1029F00015400075000000008E0300142411FFFF35
72348+:102A0000107100073C0808003C0608008CC6319095
72349+:102A100000C8C0241300015202602021A380006876
72350+:102A20008E0300003C19000100792024108000135F
72351+:102A30003C1F0080007FA02416800009020028218E
72352+:102A4000026020212411001A0E001A4AA391006886
72353+:102A50002407FFFF1047FF9F2404FFFF02002821E7
72354+:102A6000026020210E001A6A240600012410FFFFD4
72355+:102A70001050FF982404FFFF241400018F8D0044A0
72356+:102A8000026020210280302195A900342405000134
72357+:102A9000253200010E0019A9A5B200340000202142
72358+:102AA0008F8500380A001D320080A0218F90004CD5
72359+:102AB0003C1408008E9431B08E07001030E53FFFC3
72360+:102AC00000B4C82B132000618F8600502412FF80B1
72361+:102AD00090C9000D0249682431A400FF5080005CB9
72362+:102AE000026020218F8C00541180000700078B8228
72363+:102AF0008F8500388F82FCC094BF0080944A000A02
72364+:102B0000515F00F78F8600403227000314E0006415
72365+:102B100000000000920E000211C000D8000000006A
72366+:102B20008E0B0024156000D902602021920400035E
72367+:102B300024190002308500FF14B90005308900FF18
72368+:102B40008F940054128000EA240D002C308900FF7D
72369+:102B5000392C00102D8400012D3200010244302553
72370+:102B6000020028210E001A6A026020212410FFFFB3
72371+:102B7000105000BF8F8500388F830054106000D341
72372+:102B8000240500013C0A08008D4A318C0143F82BD2
72373+:102B900017E000B22402002D02602021000028214D
72374+:102BA0000E0019A9240600018F85003800001821A5
72375+:102BB0000A001D320060A0210E0018750000000000
72376+:102BC0000A001DF800000000AC8000200A001E78FA
72377+:102BD0008E03001400002821026020210E0019A994
72378+:102BE000240600010A001CC38F8500380A001DB7A7
72379+:102BF0008F8800388CAA00848CAC00843C031000C1
72380+:102C00000147F824001F91403189007F024968255F
72381+:102C100001A32825ACC50830910700012405000157
72382+:102C2000026020210E0019A930E600010A001CC331
72383+:102C30008F850038938F00482403FFFD0A001D3460
72384+:102C4000AF8F00600A001D342403FFFF02602021C3
72385+:102C50002410000D0E001A4AA390006800401821AD
72386+:102C60008F8500380A001D320060A0210E00187503
72387+:102C7000000000009783005C8F86006000402021E8
72388+:102C80003070FFFF00D010232C4A00051140FE11C8
72389+:102C90008F850038ACA400EC0A001D2F306EFFFFBA
72390+:102CA00090CF000D31E300085460FFA192040003AF
72391+:102CB00002602021240200100E001A4AA38200683C
72392+:102CC0002403FFFF5443FF9A920400030A001F12DB
72393+:102CD0008F85003890A4000D308F000811E000951A
72394+:102CE0008F990054572000A6026020218E1F000CEF
72395+:102CF0008CB4002057F40005026020218E0D0008DE
72396+:102D00008CA7002411A7003A026020212402002091
72397+:102D1000A38200680E001A4A2412FFFF1052FEED33
72398+:102D20002404FFFF8F9F00442402FFF73C14800E11
72399+:102D300093EA000D2419FF803C03800001423824EF
72400+:102D4000A3E7000D8F9F00303C0908008D2931ACAE
72401+:102D50008F8C006C97F200788F870044012C302113
72402+:102D6000324D7FFF000D204000C4782131E5007F07
72403+:102D700000B4C02101F94024AC68002CA711000068
72404+:102D80008CEB0028256E0001ACEE00288CEA002CAC
72405+:102D90008E02002C01426021ACEC002C8E09002C2C
72406+:102DA000ACE900308E120014ACF2003494ED003A1D
72407+:102DB00025A40001A4E4003A97E600783C1108003D
72408+:102DC0008E3131B024C3000130707FFF1211005CDE
72409+:102DD000006030218F8F0030026020212405000127
72410+:102DE0000E001934A5E600780A001EA1000020217B
72411+:102DF0008E0900142412FFFF1132006B8F8A0038F5
72412+:102E00008E0200188D4C00D0144C00650260202109
72413+:102E10008E0B00248CAE0028116E005B2402002172
72414+:102E20000E001A4AA38200681452FFBE2404FFFF5A
72415+:102E30008F8500380A001D320080A0212402001F67
72416+:102E40000E001A4AA38200682409FFFF1049FEA160
72417+:102E50002404FFFF0A001E548F83005402602021C7
72418+:102E60000E001A4AA38200681450FF508F85003864
72419+:102E70002403FFFF0A001D320060A0218CD800242B
72420+:102E80008E0800241118FF29026020210A001F2744
72421+:102E90002402000F8E0900003C05008001259024CB
72422+:102EA0001640FF492402001A026020210E001A4A2F
72423+:102EB000A3820068240CFFFF144CFECF2404FFFF04
72424+:102EC0008F8500380A001D320080A0210E001934C1
72425+:102ED000026020218F8500380A001EE500001821BD
72426+:102EE0002403FFFD0060A0210A001D32AF860060B0
72427+:102EF000026020210E001A4AA38D00682403FFFF00
72428+:102F00001043FF588F8500380A001ECC920400033E
72429+:102F10002418001D0E001A4AA39800682403FFFF1E
72430+:102F20001443FE9D2404FFFF8F8500380A001D32E4
72431+:102F30000080A021026020210A001F3D24020024FD
72432+:102F4000240880000068C024330BFFFF000B73C20D
72433+:102F500031D000FF001088270A001F6E001133C017
72434+:102F6000240F001B0E001A4AA38F00681451FEACF8
72435+:102F70002404FFFF8F8500380A001D320080A02145
72436+:102F80000A001F3D240200278E0600288CA3002C77
72437+:102F900010C30008026020210A001F812402001FC4
72438+:102FA0000A001F812402000E026020210A001F81F6
72439+:102FB000240200258E04002C1080000D8F8F00301D
72440+:102FC0008DE800740104C02B5700000C0260202122
72441+:102FD0008CB900140086A0210334282B10A0FF52C6
72442+:102FE0008F9F0044026020210A001F8124020022DA
72443+:102FF000026020210A001F81240200230A001F8191
72444+:103000002402002627BDFFD8AFB3001CAFB10014C7
72445+:10301000AFBF0020AFB20018AFB000103C0280007C
72446+:103020008C5201408C4B01483C048000000B8C0208
72447+:10303000322300FF317300FF8C8501B804A0FFFE2E
72448+:1030400034900180AE1200008C8701442464FFF0AC
72449+:10305000240600022C830013AE070004A61100080A
72450+:10306000A206000BAE1300241060004F8FBF00209B
72451+:10307000000448803C0A0801254A9534012A402171
72452+:103080008D04000000800008000000003C030800E0
72453+:103090008C6331A831693FFF00099980007280215B
72454+:1030A000021370212405FF80264D0100264C00806C
72455+:1030B0003C02800031B1007F3198007F31CA007F2F
72456+:1030C0003C1F800A3C1980043C0F800C01C5202461
72457+:1030D00001A5302401853824014F1821AC46002475
72458+:1030E000023F402103194821AC470090AC4400281E
72459+:1030F000AF830044AF880038AF8900300E0019005C
72460+:10310000016080213C0380008C6B01B80560FFFEEC
72461+:103110008F8700448F8600383465018090E8000D69
72462+:10312000ACB20000A4B0000600082600000416039C
72463+:1031300000029027001227C21080008124C200885C
72464+:10314000241F6082A4BF0008A0A000052402000282
72465+:10315000A0A2000B8F8B0030000424003C08270045
72466+:1031600000889025ACB20010ACA00014ACA00024E4
72467+:10317000ACA00028ACA0002C8D6900382413FF807F
72468+:10318000ACA9001890E3000D02638024320500FF13
72469+:1031900010A000058FBF002090ED000D31AC007F26
72470+:1031A000A0EC000D8FBF00208FB3001C8FB2001861
72471+:1031B0008FB100148FB000103C0A10003C0E80004C
72472+:1031C00027BD002803E00008ADCA01B8265F010052
72473+:1031D0002405FF8033F8007F3C06800003E5782457
72474+:1031E0003C19800A03192021ACCF0024908E00D412
72475+:1031F00000AE682431AC00FF11800024AF84003899
72476+:10320000248E008895CD00123C0C08008D8C31A8CE
72477+:1032100031AB3FFF01924821000B5180012A402130
72478+:1032200001052024ACC400283107007F3C06800C37
72479+:1032300000E620219083000D00A31024304500FFFC
72480+:1032400010A0FFD8AF8400449098000D330F0010F9
72481+:1032500015E0FFD58FBF00200E0019000000000010
72482+:103260003C0380008C7901B80720FFFE00000000BD
72483+:10327000AE1200008C7F0144AE1F0004A6110008AE
72484+:1032800024110002A211000BAE1300243C1308010C
72485+:10329000927396F0327000015200FFC38FBF00207E
72486+:1032A0000E002146024020210A0020638FBF00202B
72487+:1032B0003C1260008E452C083C03F0033462FFFF93
72488+:1032C00000A2F824AE5F2C088E582C083C1901C0CF
72489+:1032D00003199825AE532C080A0020638FBF0020E5
72490+:1032E000264D010031AF007F3C10800A240EFF8084
72491+:1032F00001F0282101AE60243C0B8000AD6C00245D
72492+:103300001660FFA8AF85003824110003A0B100FCAF
72493+:103310000A0020638FBF002026480100310A007F89
72494+:103320003C0B800A2409FF80014B30210109202435
72495+:103330003C078000ACE400240A002062AF8600381D
72496+:10334000944E0012320C3FFF31CD3FFF15ACFF7D94
72497+:10335000241F608290D900D42418FF800319782498
72498+:1033600031EA00FF1140FF7700000000240700044D
72499+:10337000A0C700FC8F870044241160842406000D40
72500+:10338000A4B10008A0A600050A00204D24020002F6
72501+:103390003C040001248496DC24030014240200FE73
72502+:1033A0003C010800AC2431EC3C010800AC2331E8BE
72503+:1033B0003C010801A42296F83C040801248496F8F4
72504+:1033C0000000182100643021A0C300042463000120
72505+:1033D0002C6500FF54A0FFFC006430213C0708006E
72506+:1033E00024E7010003E00008AF87007800A058211F
72507+:1033F000008048210000102114A00012000050217C
72508+:103400000A002142000000003C010801A42096F8B7
72509+:103410003C05080194A596F88F8200783C0C0801C1
72510+:10342000258C96F800E2182100AC2021014B302BAE
72511+:10343000A089000400001021A460000810C0003919
72512+:10344000010048218F8600780009384000E94021BA
72513+:103450000008388000E6282190A8000B90B9000AE7
72514+:103460000008204000881021000218800066C0215A
72515+:10347000A319000A8F85007800E5782191EE000AF3
72516+:1034800091E6000B000E684001AE6021000C208028
72517+:1034900000851021A046000B3C030801906396F2C2
72518+:1034A000106000222462FFFF8F8300383C01080176
72519+:1034B000A02296F2906C00FF118000040000000032
72520+:1034C000906E00FF25CDFFFFA06D00FF3C190801A5
72521+:1034D000973996F8272300013078FFFF2F0F00FF60
72522+:1034E00011E0FFC9254A00013C010801A42396F818
72523+:1034F0003C05080194A596F88F8200783C0C0801E1
72524+:10350000258C96F800E2182100AC2021014B302BCD
72525+:10351000A089000400001021A460000814C0FFC9A5
72526+:103520000100482103E000080000000003E000085B
72527+:103530002402000227BDFFE0248501002407FF804C
72528+:10354000AFB00010AFBF0018AFB1001400A718242F
72529+:103550003C10800030A4007F3C06800A00862821B1
72530+:103560008E110024AE03002490A200FF1440000836
72531+:10357000AF850038A0A000098FBF0018AE1100244D
72532+:103580008FB100148FB0001003E0000827BD0020A9
72533+:1035900090A900FD90A800FF312400FF0E0020F448
72534+:1035A000310500FF8F8500388FBF0018A0A00009EB
72535+:1035B000AE1100248FB100148FB0001003E000089A
72536+:1035C00027BD002027BDFFD0AFB20020AFB1001C47
72537+:1035D000AFB00018AFBF002CAFB40028AFB30024C9
72538+:1035E0003C0980009533011635320C00952F011AE5
72539+:1035F0003271FFFF023280218E08000431EEFFFF9E
72540+:10360000248B0100010E6821240CFF8025A5FFFFFB
72541+:10361000016C50243166007F3C07800AAD2A0024EB
72542+:1036200000C73021AF850074AF8800703C010801ED
72543+:10363000A02096F190C300090200D02100809821BB
72544+:10364000306300FF2862000510400048AF86003854
72545+:10365000286400021480008E24140001240D00054B
72546+:103660003C010801A02D96D590CC00FD3C0108013D
72547+:10367000A02096D63C010801A02096D790CB000A46
72548+:10368000240AFF80318500FF014B4824312700FFC9
72549+:1036900010E0000C000058213C12800836510080D8
72550+:1036A0008E2F00308CD0005C01F0702305C0018E9D
72551+:1036B0008F87007090D4000A3284007FA0C4000A73
72552+:1036C0008F8600383C118008363000808E0F003025
72553+:1036D0008F87007000EF702319C000EE000000001B
72554+:1036E00090D4000924120002328400FF1092024795
72555+:1036F000000000008CC2005800E2F82327F9FFFF09
72556+:103700001B2001300000000090C5000924080004BF
72557+:1037100030A300FF10680057240A00013C01080193
72558+:10372000A02A96D590C900FF252700013C01080179
72559+:10373000A02796D43C030801906396D52406000583
72560+:103740001066006A2C780005130000C40000902168
72561+:103750000003F8803C0408012484958003E4C82118
72562+:103760008F25000000A0000800000000241800FFC2
72563+:103770001078005C0000000090CC000A90CA00099C
72564+:103780003C080801910896F13187008000EA48253D
72565+:103790003C010801A02996DC90C500FD3C140801FD
72566+:1037A000929496F2311100013C010801A02596DDAA
72567+:1037B00090DF00FE3C010801A03F96DE90D200FFA2
72568+:1037C0003C010801A03296DF8CD900543C0108016D
72569+:1037D000AC3996E08CD000583C010801AC3096E43E
72570+:1037E0008CC3005C3C010801AC3496EC3C01080140
72571+:1037F000AC2396E8162000088FBF002C8FB4002859
72572+:103800008FB300248FB200208FB1001C8FB000183E
72573+:1038100003E0000827BD00303C1180009624010E13
72574+:103820000E000FD43094FFFF3C0B08018D6B96F413
72575+:103830000260382102802821AE2B01803C13080150
72576+:103840008E7396D401602021240600830E00102F71
72577+:10385000AFB300108FBF002C8FB400288FB30024AB
72578+:103860008FB200208FB1001C8FB0001803E0000859
72579+:1038700027BD00303C1808008F1831FC270F0001CD
72580+:103880003C010800AC2F31FC0A0021D700000000E9
72581+:103890001474FFB900000000A0C000FF3C05080040
72582+:1038A0008CA531E43C0308008C6331E03C02080045
72583+:1038B0008C4232048F99003834A80001241F000282
72584+:1038C0003C010801AC2396F43C010801A02896F0C5
72585+:1038D0003C010801A02296F3A33F00090A002190B1
72586+:1038E0008F8600380E002146000000000A0021D714
72587+:1038F0008F8600383C1F080193FF96D424190001DD
72588+:1039000013F902298F8700703C100801921096D895
72589+:103910003C06080190C696D610C000050200A02102
72590+:103920003C040801908496D9109001E48F870078B8
72591+:10393000001088408F9F0078023048210009C8801D
72592+:10394000033F702195D80008270F0001A5CF00087C
72593+:103950003C040801908496D93C05080190A596D6B0
72594+:103960000E0020F4000000008F8700780230202134
72595+:103970000004308000C720218C8500048F820074F1
72596+:1039800000A2402305020006AC8200048C8A0000DD
72597+:103990008F830070014310235C400001AC83000062
72598+:1039A0008F86003890CB00FF2D6C00025580002DD3
72599+:1039B000241400010230F821001F40800107282153
72600+:1039C00090B9000B8CAE00040019C0400319782197
72601+:1039D000000F1880006710218C4D000001AE882375
72602+:1039E0002630FFFF5E00001F241400018C440004F9
72603+:1039F0008CAA0000008A482319200019240E000414
72604+:103A00003C010801A02E96D590AD000B8CAB0004B4
72605+:103A1000000D8840022D80210010108000471021E9
72606+:103A20008C44000401646023058202009443000872
72607+:103A300090DF00FE90B9000B33E500FF54B900049D
72608+:103A40000107A021A0D400FE8F8700780107A021E4
72609+:103A50009284000B0E0020F4240500018F860038AC
72610+:103A600024140001125400962E500001160000424A
72611+:103A70003C08FFFF241900021659FF3F0000000018
72612+:103A8000A0C000FF8F860038A0D200090A0021D70D
72613+:103A90008F86003890C700092404000230E300FF3D
72614+:103AA0001064016F24090004106901528F880074AA
72615+:103AB0008CCE0054010E682325B10001062001754B
72616+:103AC000241800043C010801A03896D53C010801E7
72617+:103AD000A02096D490D400FD90D200FF2E4F00027B
72618+:103AE00015E0FF14328400FF000438408F8900780D
72619+:103AF00090DF00FF00E41021000220800089C8212F
72620+:103B00002FE500029324000B14A0FF0A24070002F3
72621+:103B100000041840006480210010588001692821A9
72622+:103B20008CAC0004010C50230540FF020000000093
72623+:103B30003C030801906396D614600005246F0001D1
72624+:103B40003C010801A02496D93C010801A02796D782
72625+:103B50003C010801A02F96D690CE00FF24E700017B
72626+:103B600031CD00FF01A7882B1220FFE990A4000BA4
72627+:103B70000A0021C6000000003C0508018CA596D46F
72628+:103B80003C12000400A8F82413F2000624020005E9
72629+:103B90003C090801912996D5152000022402000352
72630+:103BA000240200053C010801A02296F190C700FF05
72631+:103BB00014E0012024020002A0C200090A0021D75B
72632+:103BC0008F86003890CC00FF1180FEDA240A0001B5
72633+:103BD0008F8C00748F890078240F00030180682186
72634+:103BE0001160001E240E0002000540400105A021C6
72635+:103BF00000142080008990218E51000401918023BF
72636+:103C00000600FECC000000003C020801904296D65F
72637+:103C100014400005245800013C010801A02A96D751
72638+:103C20003C010801A02596D93C010801A03896D690
72639+:103C300090DF00FF010510210002C88033E500FF7E
72640+:103C4000254A00010329202100AA402B1500FEB9B6
72641+:103C50009085000B1560FFE50005404000054040E1
72642+:103C600001051821000310803C010801A02A96D408
72643+:103C70003C010801A02596D8004918218C64000455
72644+:103C800000E4F82327F9FFFF1F20FFE900000000F0
72645+:103C90008C63000000E358230560013A01A38823E8
72646+:103CA00010E301170184C0231B00FEA200000000E6
72647+:103CB0003C010801A02E96D50A002305240B000123
72648+:103CC000240E0004A0CE00093C0D08008DAD31F893
72649+:103CD0008F86003825A200013C010800AC2231F893
72650+:103CE0000A0021D7000000008CD9005C00F9C02335
72651+:103CF0001F00FE7B000000008CDF005C10FFFF65F2
72652+:103D00008F8400748CC3005C008340232502000173
72653+:103D10001C40FF60000000008CC9005C248700018B
72654+:103D200000E9282B10A0FE943C0D80008DAB01040F
72655+:103D30003C0C0001016C50241140FE8F2402001045
72656+:103D40003C010801A02296F10A0021D700000000E2
72657+:103D50008F9100748F86003826220001ACC2005C6F
72658+:103D60000A002292241400018F8700382404FF8067
72659+:103D70000000882190E9000A241400010124302564
72660+:103D8000A0E6000A3C05080190A596D63C0408016F
72661+:103D9000908496D90E0020F4000000008F86003831
72662+:103DA0008F85007890C800FD310700FF0007404074
72663+:103DB0000107F821001FC0800305C8219323000BD1
72664+:103DC000A0C300FD8F8500788F8600380305602131
72665+:103DD000918F000B000F704001CF6821000D808093
72666+:103DE000020510218C4B0000ACCB00548D840004E4
72667+:103DF0008F83007400645023194000022482000164
72668+:103E00002462000101074821ACC2005C0009308037
72669+:103E100000C5402100E02021240500010E0020F40F
72670+:103E20009110000B8F86003890C500FF10A0FF0C8A
72671+:103E3000001070408F85007801D06821000D10803F
72672+:103E4000004558218D6400008F8C0074018450233C
72673+:103E50002547000104E0FF02263100013C03080170
72674+:103E6000906396D62E2F0002247800013C010801B1
72675+:103E7000A03896D63C010801A03496D711E0FEF890
72676+:103E8000020038210A002365000740408F84003873
72677+:103E90008F8300748C85005800A340230502FE9A8E
72678+:103EA000AC8300580A00223B000000003C070801D8
72679+:103EB00090E796F2240200FF10E200BE8F860038E1
72680+:103EC0003C110801963196FA3C030801246396F8E8
72681+:103ED000262500013230FFFF30ABFFFF02036021D7
72682+:103EE0002D6A00FF1540008D918700043C010801F8
72683+:103EF000A42096FA8F88003800074840012728211F
72684+:103F0000911800FF000530802405000127140001EE
72685+:103F1000A11400FF3C120801925296F28F8800789B
72686+:103F20008F8E0070264F000100C820213C0108013F
72687+:103F3000A02F96F2AC8E00008F8D0074A48500082F
72688+:103F4000AC8D00043C030801906396D414600077A4
72689+:103F5000000090213C010801A02596D4A087000B09
72690+:103F60008F8C007800CC5021A147000A8F82003846
72691+:103F7000A04700FD8F840038A08700FE8F860038A0
72692+:103F80008F9F0070ACDF00548F990074ACD900583B
72693+:103F90008F8D00780127C02100185880016DA02165
72694+:103FA000928F000A000F704001CF18210003888013
72695+:103FB000022D8021A207000B8F8600780166602108
72696+:103FC000918A000B000A1040004A2021000428803A
72697+:103FD00000A64021A107000A3C07800834E90080C0
72698+:103FE0008D2200308F860038ACC2005C0A0022921D
72699+:103FF0002414000190CA00FF1540FEAD8F880074A4
72700+:10400000A0C400090A0021D78F860038A0C000FD97
72701+:104010008F98003824060001A30000FE3C0108012F
72702+:10402000A02696D53C010801A02096D40A0021C6FE
72703+:104030000000000090CB00FF3C040801908496F340
72704+:10404000316C00FF0184502B1540000F2402000347
72705+:1040500024020004A0C200090A0021D78F8600387C
72706+:1040600090C3000A2410FF8002035824316C00FF23
72707+:104070001180FDC1000000003C010801A02096D580
72708+:104080000A0021C600000000A0C200090A0021D7D2
72709+:104090008F86003890D4000A2412FF8002544824EE
72710+:1040A000312800FF1500FFF4240200083C0108013C
72711+:1040B000A02296F10A0021D70000000000108840DD
72712+:1040C0008F8B0070023018210003688001A7202127
72713+:1040D000AC8B00008F8A0074240C0001A48C0008B3
72714+:1040E000AC8A00043C05080190A596D62402000184
72715+:1040F00010A2FE1E24A5FFFF0A0022519084000B8F
72716+:104100000184A0231A80FD8B000000003C010801FF
72717+:10411000A02E96D50A002305240B00013C010801BE
72718+:10412000A42596FA0A0023B78F880038240B0001D3
72719+:10413000106B00228F9800388F85003890BF00FFE9
72720+:1041400033F900FF1079002B000000003C1F08012C
72721+:1041500093FF96D8001FC840033FC0210018A080DD
72722+:104160000288782191EE000AA08E000A8F8D0078D7
72723+:104170003C030801906396D800CD88210A0023DD16
72724+:10418000A223000B263000010600003101A4902379
72725+:104190000640002B240200033C010801A02F96D505
72726+:1041A0000A002305240B00018F8900380A00223BF6
72727+:1041B000AD2700540A00229124120001931400FD3F
72728+:1041C000A094000B8F8800388F8F0078910E00FE2E
72729+:1041D00000CF6821A1AE000A8F910038A22700FD10
72730+:1041E0008F8300708F900038AE0300540A0023DEE6
72731+:1041F0008F8D007890B000FEA090000A8F8B003861
72732+:104200008F8C0078916A00FD00CC1021A04A000B31
72733+:104210008F840038A08700FE8F8600748F85003859
72734+:10422000ACA600580A0023DE8F8D007894B80008F1
72735+:10423000ACA40004030378210A002285A4AF00087F
72736+:104240003C010801A02296D50A0021C6000000000A
72737+:1042500090CF0009240D000431EE00FF11CDFD8543
72738+:10426000240200013C010801A02296D50A0021C6C3
72739+:1042700000000000080033440800334408003420E4
72740+:10428000080033F4080033D8080033280800332826
72741+:10429000080033280800334C8008010080080080A3
72742+:1042A000800800005F865437E4AC62CC50103A4579
72743+:1042B00036621985BF14C0E81BC27A1E84F4B55655
72744+:1042C000094EA6FE7DDA01E7C04D748108005A74DC
72745+:1042D00008005AB808005A5C08005A5C08005A5C8A
72746+:1042E00008005A5C08005A7408005A5C08005A5CBE
72747+:1042F00008005AC008005A5C080059D408005A5CEB
72748+:1043000008005A5C08005AC008005A5C08005A5C51
72749+:1043100008005A5C08005A5C08005A5C08005A5CA5
72750+:1043200008005A5C08005A5C08005A5C08005A5C95
72751+:1043300008005A9408005A5C08005A9408005A5C15
72752+:1043400008005A5C08005A5C08005A9808005A9401
72753+:1043500008005A5C08005A5C08005A5C08005A5C65
72754+:1043600008005A5C08005A5C08005A5C08005A5C55
72755+:1043700008005A5C08005A5C08005A5C08005A5C45
72756+:1043800008005A5C08005A5C08005A5C08005A5C35
72757+:1043900008005A5C08005A5C08005A5C08005A5C25
72758+:1043A00008005A9808005A9808005A5C08005A9861
72759+:1043B00008005A5C08005A5C08005A5C08005A5C05
72760+:1043C00008005A5C08005A5C08005A5C08005A5CF5
72761+:1043D00008005A5C08005A5C08005A5C08005A5CE5
72762+:1043E00008005A5C08005A5C08005A5C08005A5CD5
72763+:1043F00008005A5C08005A5C08005A5C08005A5CC5
72764+:1044000008005A5C08005A5C08005A5C08005A5CB4
72765+:1044100008005A5C08005A5C08005A5C08005A5CA4
72766+:1044200008005A5C08005A5C08005A5C08005A5C94
72767+:1044300008005A5C08005A5C08005A5C08005A5C84
72768+:1044400008005A5C08005A5C08005A5C08005A5C74
72769+:1044500008005A5C08005A5C08005A5C08005A5C64
72770+:1044600008005A5C08005A5C08005A5C08005A5C54
72771+:1044700008005A5C08005A5C08005A5C08005A5C44
72772+:1044800008005A5C08005A5C08005A5C08005A5C34
72773+:1044900008005A5C08005A5C08005A5C08005A5C24
72774+:1044A00008005A5C08005A5C08005A5C08005A5C14
72775+:1044B00008005A5C08005A5C08005A5C08005A5C04
72776+:1044C00008005A5C08005A5C08005A5C08005ADC74
72777+:1044D0000800782C08007A900800783808007628C0
72778+:1044E00008007838080078C4080078380800762872
72779+:1044F0000800762808007628080076280800762824
72780+:104500000800762808007628080076280800762813
72781+:1045100008007628080078580800784808007628AF
72782+:1045200008007628080076280800762808007628F3
72783+:1045300008007628080076280800762808007628E3
72784+:1045400008007628080076280800762808007848B1
72785+:10455000080082FC08008188080082C40800818865
72786+:104560000800829408008070080081880800818813
72787+:1045700008008188080081880800818808008188F7
72788+:1045800008008188080081880800818808008188E7
72789+:104590000800818808008188080081B008008D34F7
72790+:1045A00008008E9008008E70080088D808008D4C96
72791+:1045B0000A00012400000000000000000000000DBF
72792+:1045C000747061362E322E31620000000602010145
72793+:1045D00000000000000000000000000000000000DB
72794+:1045E00000000000000000000000000000000000CB
72795+:1045F00000000000000000000000000000000000BB
72796+:1046000000000000000000000000000000000000AA
72797+:10461000000000000000000000000000000000009A
72798+:10462000000000000000000000000000000000008A
72799+:10463000000000000000000000000000000000007A
72800+:104640000000000010000003000000000000000D4A
72801+:104650000000000D3C020800244217203C03080023
72802+:1046600024632A10AC4000000043202B1480FFFD7F
72803+:10467000244200043C1D080037BD2FFC03A0F0219C
72804+:104680003C100800261004903C1C0800279C1720B2
72805+:104690000E000262000000000000000D2402FF80F6
72806+:1046A00027BDFFE000821024AFB00010AF42002011
72807+:1046B000AFBF0018AFB10014936500043084007FD1
72808+:1046C000034418213C0200080062182130A5002094
72809+:1046D000036080213C080111277B000814A0000220
72810+:1046E0002466005C2466005892020004974301048B
72811+:1046F000920400043047000F3063FFFF3084004015
72812+:10470000006728231080000900004821920200055C
72813+:1047100030420004104000050000000010A000031B
72814+:104720000000000024A5FFFC2409000492020005FB
72815+:1047300030420004104000120000000010A00010E1
72816+:10474000000000009602000200A72021010440257D
72817+:104750002442FFFEA7421016920300042402FF80A9
72818+:1047600000431024304200FF104000033C020400CC
72819+:104770000A000174010240258CC20000AF421018EB
72820+:104780008F4201780440FFFE2402000AA742014044
72821+:1047900096020002240400093042000700021023A0
72822+:1047A00030420007A7420142960200022442FFFE67
72823+:1047B000A7420144A740014697420104A74201488D
72824+:1047C0008F420108304200205040000124040001C3
72825+:1047D00092020004304200101440000234830010A2
72826+:1047E00000801821A743014A0000000000000000DB
72827+:1047F0000000000000000000AF48100000000000B2
72828+:104800000000000000000000000000008F421000C7
72829+:104810000441FFFE3102FFFF1040000700000000CE
72830+:1048200092020004304200401440000300000000E7
72831+:104830008F421018ACC20000960200063042FFFF03
72832+:10484000244200020002104300021040036288214B
72833+:10485000962200001120000D3044FFFF00A7102118
72834+:104860008F8300388F45101C0002108200021080D8
72835+:1048700000431021AC45000030A6FFFF0E00058D5F
72836+:1048800000052C0200402021A62200009203000413
72837+:104890002402FF8000431024304200FF1040001F1C
72838+:1048A0000000000092020005304200021040001B90
72839+:1048B000000000009742100C2442FFFEA742101691
72840+:1048C000000000003C02040034420030AF421000FF
72841+:1048D00000000000000000000000000000000000D8
72842+:1048E0008F4210000441FFFE000000009742100CB0
72843+:1048F0008F45101C3042FFFF24420030000210821E
72844+:1049000000021080005B1021AC45000030A6FFFFC4
72845+:104910000E00058D00052C02A62200009604000260
72846+:10492000248400080E0001E93084FFFF974401044D
72847+:104930000E0001F73084FFFF8FBF00188FB1001405
72848+:104940008FB000103C02100027BD002003E00008DB
72849+:10495000AF4201783084FFFF308200078F8500244A
72850+:1049600010400002248300073064FFF800A41021E7
72851+:1049700030421FFF03421821247B4000AF850028EE
72852+:10498000AF82002403E00008AF4200843084FFFFC0
72853+:104990003082000F8F85002C8F860034104000027B
72854+:1049A0002483000F3064FFF000A410210046182B70
72855+:1049B000AF8500300046202314600002AF82002C37
72856+:1049C000AF84002C8F82002C340480000342182115
72857+:1049D00000641821AF83003803E00008AF42008074
72858+:1049E0008F820014104000088F8200048F82FFDC49
72859+:1049F000144000058F8200043C02FFBF3442FFFFD9
72860+:104A0000008220248F82000430430006240200022A
72861+:104A10001062000F3C0201012C62000350400005AF
72862+:104A2000240200041060000F3C0200010A00023062
72863+:104A30000000000010620005240200061462000C51
72864+:104A40003C0201110A000229008210253C020011DB
72865+:104A500000821025AF421000240200010A0002303B
72866+:104A6000AF82000C00821025AF421000AF80000C16
72867+:104A700000000000000000000000000003E000084B
72868+:104A8000000000008F82000C1040000400000000B5
72869+:104A90008F4210000441FFFE0000000003E0000808
72870+:104AA000000000008F8200102443F800000231C291
72871+:104AB00024C2FFF02C6303011060000300021042C7
72872+:104AC0000A000257AC8200008F85001800C5102B29
72873+:104AD0001440000B0000182100C5102324470001DA
72874+:104AE0008F82001C00A210212442FFFF0046102BE1
72875+:104AF000544000042402FFFF0A000257AC87000064
72876+:104B00002402FFFF0A000260AC8200008C820000D9
72877+:104B10000002194000621821000318800062182169
72878+:104B2000000318803C0208002442175C0062182130
72879+:104B300003E000080060102127BDFFD8AFBF0020B0
72880+:104B4000AFB1001CAFB000183C0460088C8250006C
72881+:104B50002403FF7F3C066000004310243442380CDD
72882+:104B6000AC8250008CC24C1C3C1A80000002160221
72883+:104B70003042000F10400007AF82001C8CC34C1C59
72884+:104B80003C02001F3442FC0000621824000319C2DA
72885+:104B9000AF8300188F420008275B400034420001B9
72886+:104BA000AF420008AF8000243C02601CAF40008090
72887+:104BB000AF4000848C4500088CC308083402800094
72888+:104BC000034220212402FFF0006218243C020080EE
72889+:104BD0003C010800AC2204203C025709AF84003895
72890+:104BE00014620004AF850034240200010A0002921E
72891+:104BF000AF820014AF8000148F42000038420001E1
72892+:104C0000304200011440FFFC8F8200141040001657
72893+:104C10000000000097420104104000058F8300004F
72894+:104C2000146000072462FFFF0A0002A72C62000A3A
72895+:104C30002C620010504000048F83000024620001A9
72896+:104C4000AF8200008F8300002C62000A1440000332
72897+:104C50002C6200070A0002AEAF80FFDC10400002A9
72898+:104C600024020001AF82FFDC8F4301088F44010062
72899+:104C700030622000AF83000410400008AF840010B1
72900+:104C80003C0208008C42042C244200013C01080034
72901+:104C9000AC22042C0A00058A3C0240003065020068
72902+:104CA00014A0000324020F001482026024020D00ED
72903+:104CB00097420104104002C83C02400030624000AC
72904+:104CC000144000AD8F8200388C4400088F42017878
72905+:104CD0000440FFFE24020800AF42017824020008CD
72906+:104CE000A7420140A7400142974201048F8400047B
72907+:104CF0003051FFFF30820001104000070220802168
72908+:104D00002623FFFE240200023070FFFFA742014667
72909+:104D10000A0002DBA7430148A74001463C02080005
72910+:104D20008C42043C1440000D8F8300103082002020
72911+:104D30001440000224030009240300010060202124
72912+:104D40008F830010240209005062000134840004A3
72913+:104D5000A744014A0A0002F60000000024020F00E6
72914+:104D60001462000530820020144000062403000D68
72915+:104D70000A0002F524030005144000022403000980
72916+:104D800024030001A743014A3C0208008C4204208E
72917+:104D90003C0400480E00020C004420250E000235A1
72918+:104DA000000000008F82000C1040003E0000000058
72919+:104DB0008F4210003C0300200043102410400039B3
72920+:104DC0008F820004304200021040003600000000D4
72921+:104DD000974210141440003300000000974210085E
72922+:104DE0008F8800383042FFFF2442000600021882FC
72923+:104DF0000003388000E83021304300018CC40000FB
72924+:104E000010600004304200030000000D0A00033768
72925+:104E100000E81021544000103084FFFF3C05FFFFE4
72926+:104E200000852024008518260003182B0004102B71
72927+:104E300000431024104000050000000000000000A6
72928+:104E40000000000D00000000240002228CC20000BF
72929+:104E50000A000336004520253883FFFF0003182B86
72930+:104E60000004102B00431024104000050000000037
72931+:104E7000000000000000000D000000002400022BD4
72932+:104E80008CC200003444FFFF00E81021AC44000055
72933+:104E90003C0208008C420430244200013C0108001E
72934+:104EA000AC2204308F6200008F840038AF8200088B
72935+:104EB0008C8300003402FFFF1462000F00001021F9
72936+:104EC0003C0508008CA504543C0408008C84045064
72937+:104ED00000B0282100B0302B008220210086202144
72938+:104EE0003C010800AC2504543C010800AC240450EB
72939+:104EF0000A000580240400088C8200003042010072
72940+:104F00001040000F000010213C0508008CA5044C47
72941+:104F10003C0408008C84044800B0282100B0302BE9
72942+:104F200000822021008620213C010800AC25044C91
72943+:104F30003C010800AC2404480A0005802404000851
72944+:104F40003C0508008CA504443C0408008C84044003
72945+:104F500000B0282100B0302B0082202100862021C3
72946+:104F60003C010800AC2504443C010800AC2404408A
72947+:104F70000A000580240400088F6200088F62000088
72948+:104F800000021602304300F02402003010620005D7
72949+:104F900024020040106200E08F8200200A00058891
72950+:104FA0002442000114A000050000000000000000E1
72951+:104FB0000000000D00000000240002568F4201781E
72952+:104FC0000440FFFE000000000E00023D27A4001078
72953+:104FD0001440000500408021000000000000000D8A
72954+:104FE000000000002400025D8E0200001040000559
72955+:104FF00000000000000000000000000D00000000A4
72956+:10500000240002608F62000C0443000324020001AC
72957+:105010000A00042EAE000000AE0200008F820038AD
72958+:105020008C480008A20000078F65000C8F64000404
72959+:1050300030A3FFFF0004240200852023308200FFFC
72960+:105040000043102124420005000230832CC200815D
72961+:10505000A605000A14400005A20400040000000098
72962+:105060000000000D00000000240002788F85003849
72963+:105070000E0005AB260400148F6200048F43010864
72964+:10508000A60200083C02100000621824106000080C
72965+:105090000000000097420104920300072442FFEC45
72966+:1050A000346300023045FFFF0A0003C3A203000778
72967+:1050B000974201042442FFF03045FFFF96060008A6
72968+:1050C0002CC200135440000592030007920200070F
72969+:1050D00034420001A20200079203000724020001EB
72970+:1050E00010620005240200031062000B8F8200385A
72971+:1050F0000A0003E030C6FFFF8F8200383C04FFFF48
72972+:105100008C43000C0064182400651825AC43000C87
72973+:105110000A0003E030C6FFFF3C04FFFF8C43001091
72974+:105120000064182400651825AC43001030C6FFFF4A
72975+:1051300024C2000200021083A20200058F830038FF
72976+:10514000304200FF00021080004328218CA800009C
72977+:105150008CA2000024030004000217021443001272
72978+:1051600000000000974201043C03FFFF01031824E4
72979+:105170003042FFFF004610232442FFFE006240251C
72980+:10518000ACA8000092030005306200FF000210800E
72981+:1051900000501021904200143042000F00431021B3
72982+:1051A0000A000415A20200068CA400049742010420
72983+:1051B0009603000A3088FFFF3042FFFF00461023AD
72984+:1051C0002442FFD60002140001024025ACA80004CE
72985+:1051D000920200079204000524630028000318834C
72986+:1051E0000064182134420004A2030006A202000752
72987+:1051F0008F8200042403FFFB34420002004310248A
72988+:10520000AF820004920300068F87003800031880E5
72989+:10521000007010218C4400203C02FFF63442FFFF56
72990+:105220000082402400671821AE04000CAC68000C1A
72991+:10523000920500063C03FF7F8E02000C00052880CB
72992+:1052400000B020213463FFFF01033024948800263E
72993+:1052500000A7282100431024AE02000CAC860020D9
72994+:10526000AC880024ACA8001024020010A742014022
72995+:1052700024020002A7400142A7400144A742014680
72996+:10528000974201043C0400082442FFFEA742014863
72997+:10529000240200010E00020CA742014A9603000AF4
72998+:1052A0009202000400431021244200023042000711
72999+:1052B00000021023304200070E000235AE0200103B
73000+:1052C0008F6200003C0308008C6304442404001037
73001+:1052D000AF820008974201043042FFFF2442FFFEE4
73002+:1052E00000403821000237C33C0208008C420440D1
73003+:1052F000006718210067282B004610210045102167
73004+:105300003C010800AC2304443C010800AC220440EA
73005+:105310000A0005150000000014A0000500000000B0
73006+:10532000000000000000000D000000002400030A3F
73007+:105330008F4201780440FFFE000000000E00023D95
73008+:1053400027A4001414400005004080210000000044
73009+:105350000000000D00000000240003118E02000078
73010+:105360005440000692020007000000000000000DFB
73011+:10537000000000002400031C9202000730420004D9
73012+:10538000104000058F8200042403FFFB344200021A
73013+:1053900000431024AF8200048F620004044300081D
73014+:1053A00092020007920200068E03000CAE0000007D
73015+:1053B0000002108000501021AC4300209202000730
73016+:1053C00030420004544000099602000A920200058F
73017+:1053D0003C03000100021080005010218C46001890
73018+:1053E00000C33021AC4600189602000A9206000461
73019+:1053F000277100080220202100C2302124C60005A8
73020+:10540000260500140E0005AB00063082920400064B
73021+:105410008F6500043C027FFF000420800091202162
73022+:105420008C8300043442FFFF00A228240065182169
73023+:10543000AC8300049202000792040005920300046A
73024+:10544000304200041040001496070008308400FF2A
73025+:1054500000042080009120218C86000497420104E2
73026+:105460009605000A306300FF3042FFFF0043102121
73027+:105470000045102130E3FFFF004310232442FFD8F2
73028+:1054800030C6FFFF0002140000C23025AC860004C5
73029+:105490000A0004C992030007308500FF0005288038
73030+:1054A00000B128218CA4000097420104306300FF62
73031+:1054B0003042FFFF00431021004710233C03FFFF51
73032+:1054C000008320243042FFFF00822025ACA400008E
73033+:1054D0009203000724020001106200060000000091
73034+:1054E0002402000310620011000000000A0004EC16
73035+:1054F0008E03001097420104920300049605000AEF
73036+:105500008E24000C00431021004510212442FFF29C
73037+:105510003C03FFFF008320243042FFFF0082202550
73038+:10552000AE24000C0A0004EC8E0300109742010424
73039+:10553000920300049605000A8E24001000431021F7
73040+:10554000004510212442FFEE3C03FFFF008320248E
73041+:105550003042FFFF00822025AE2400108E03001091
73042+:105560002402000AA7420140A74301429603000A11
73043+:10557000920200043C04004000431021A742014471
73044+:10558000A740014697420104A742014824020001B6
73045+:105590000E00020CA742014A0E0002350000000076
73046+:1055A0008F6200009203000400002021AF820008F7
73047+:1055B000974201049606000A3042FFFF006218215C
73048+:1055C000006028213C0308008C6304443C0208006E
73049+:1055D0008C42044000651821004410210065382BDE
73050+:1055E000004710213C010800AC2304443C010800A2
73051+:1055F000AC22044092040004008620212484000A86
73052+:105600003084FFFF0E0001E9000000009744010410
73053+:105610003084FFFF0E0001F7000000003C02100084
73054+:10562000AF4201780A0005878F820020148200278C
73055+:105630003062000697420104104000673C024000BF
73056+:105640003062400010400005000000000000000033
73057+:105650000000000D00000000240004208F420178AB
73058+:105660000440FFFE24020800AF4201782402000833
73059+:10567000A7420140A74001428F82000497430104E2
73060+:1056800030420001104000073070FFFF2603FFFE8C
73061+:1056900024020002A7420146A74301480A00053F31
73062+:1056A0002402000DA74001462402000DA742014A32
73063+:1056B0008F62000024040008AF8200080E0001E998
73064+:1056C000000000000A0005190200202110400042DD
73065+:1056D0003C02400093620000304300F024020010BE
73066+:1056E0001062000524020070106200358F820020D5
73067+:1056F0000A000588244200018F62000097430104DC
73068+:105700003050FFFF3071FFFF8F4201780440FFFEF1
73069+:105710003202000700021023304200072403000A6F
73070+:105720002604FFFEA7430140A7420142A7440144CB
73071+:10573000A7400146A75101488F420108304200208E
73072+:10574000144000022403000924030001A743014A76
73073+:105750000E00020C3C0400400E0002350000000068
73074+:105760003C0708008CE70444021110212442FFFE8C
73075+:105770003C0608008CC604400040182100E3382194
73076+:10578000000010218F65000000E3402B00C2302193
73077+:105790002604000800C830213084FFFFAF850008D0
73078+:1057A0003C010800AC2704443C010800AC2604403E
73079+:1057B0000E0001E9000000000A0005190220202166
73080+:1057C0000E00013B000000008F82002024420001F7
73081+:1057D000AF8200203C024000AF4201380A00029232
73082+:1057E000000000003084FFFF30C6FFFF00052C00E2
73083+:1057F00000A628253882FFFF004510210045282BF0
73084+:105800000045102100021C023042FFFF004310211E
73085+:1058100000021C023042FFFF004310213842FFFF0C
73086+:1058200003E000083042FFFF3084FFFF30A5FFFF98
73087+:1058300000001821108000070000000030820001E5
73088+:105840001040000200042042006518210A0005A152
73089+:105850000005284003E000080060102110C0000689
73090+:1058600024C6FFFF8CA2000024A50004AC82000027
73091+:105870000A0005AB2484000403E0000800000000D7
73092+:1058800010A0000824A3FFFFAC8600000000000069
73093+:10589000000000002402FFFF2463FFFF1462FFFAF0
73094+:1058A0002484000403E00008000000000000000160
73095+:1058B0000A00002A00000000000000000000000DA7
73096+:1058C000747870362E322E3162000000060201001C
73097+:1058D00000000000000001360000EA600000000047
73098+:1058E00000000000000000000000000000000000B8
73099+:1058F00000000000000000000000000000000000A8
73100+:105900000000000000000000000000000000000097
73101+:105910000000001600000000000000000000000071
73102+:105920000000000000000000000000000000000077
73103+:105930000000000000000000000000000000000067
73104+:1059400000000000000000000000138800000000BC
73105+:10595000000005DC00000000000000001000000353
73106+:10596000000000000000000D0000000D3C020800D7
73107+:1059700024423D683C0308002463401CAC40000006
73108+:105980000043202B1480FFFD244200043C1D08002E
73109+:1059900037BD7FFC03A0F0213C100800261000A8B2
73110+:1059A0003C1C0800279C3D680E00044E00000000CF
73111+:1059B0000000000D27BDFFB4AFA10000AFA200049E
73112+:1059C000AFA30008AFA4000CAFA50010AFA6001451
73113+:1059D000AFA70018AFA8001CAFA90020AFAA0024F1
73114+:1059E000AFAB0028AFAC002CAFAD0030AFAE003491
73115+:1059F000AFAF0038AFB8003CAFB90040AFBC004417
73116+:105A0000AFBF00480E000591000000008FBF0048A6
73117+:105A10008FBC00448FB900408FB8003C8FAF003876
73118+:105A20008FAE00348FAD00308FAC002C8FAB0028D0
73119+:105A30008FAA00248FA900208FA8001C8FA7001810
73120+:105A40008FA600148FA500108FA4000C8FA3000850
73121+:105A50008FA200048FA1000027BD004C3C1B6004F6
73122+:105A60008F7A5030377B502803400008AF7A00000F
73123+:105A70008F86003C3C0390003C0280000086282575
73124+:105A800000A32025AC4400203C0380008C6700204C
73125+:105A900004E0FFFE0000000003E00008000000003A
73126+:105AA0000A000070240400018F85003C3C04800043
73127+:105AB0003483000100A3102503E00008AC8200201D
73128+:105AC00003E00008000010213084FFFF30A5FFFF35
73129+:105AD00010800007000018213082000110400002F1
73130+:105AE00000042042006518211480FFFB00052840B7
73131+:105AF00003E000080060102110C000070000000053
73132+:105B00008CA2000024C6FFFF24A50004AC82000084
73133+:105B100014C0FFFB2484000403E000080000000020
73134+:105B200010A0000824A3FFFFAC86000000000000C6
73135+:105B3000000000002402FFFF2463FFFF1462FFFA4D
73136+:105B40002484000403E000080000000090AA003153
73137+:105B50008FAB00108CAC00403C0300FF8D6800044C
73138+:105B6000AD6C00208CAD004400E060213462FFFF8A
73139+:105B7000AD6D00248CA700483C09FF000109C0243A
73140+:105B8000AD6700288CAE004C0182C824031978252B
73141+:105B9000AD6F0004AD6E002C8CAD0038314A00FFB3
73142+:105BA000AD6D001C94A900323128FFFFAD680010D4
73143+:105BB00090A70030A5600002A1600004A16700006A
73144+:105BC00090A30032306200FF0002198210600005CD
73145+:105BD000240500011065000E0000000003E000082D
73146+:105BE000A16A00018CD80028354A0080AD780018E1
73147+:105BF0008CCF0014AD6F00148CCE0030AD6E000859
73148+:105C00008CC4002CA16A000103E00008AD64000C04
73149+:105C10008CCD001CAD6D00188CC90014AD6900144A
73150+:105C20008CC80024AD6800088CC70020AD67000C4C
73151+:105C30008CC200148C8300700043C82B1320000713
73152+:105C4000000000008CC20014144CFFE400000000AF
73153+:105C5000354A008003E00008A16A00018C820070D0
73154+:105C60000A0000E6000000009089003027BDFFF820
73155+:105C70008FA8001CA3A900008FA300003C0DFF808B
73156+:105C800035A2FFFF8CAC002C00625824AFAB0000A3
73157+:105C9000A100000400C05821A7A000028D06000446
73158+:105CA00000A048210167C8218FA500000080502175
73159+:105CB0003C18FF7F032C20263C0E00FF2C8C00019B
73160+:105CC000370FFFFF35CDFFFF3C02FF0000AFC824B8
73161+:105CD00000EDC02400C27824000C1DC003236825F9
73162+:105CE00001F87025AD0D0000AD0E00048D240024D8
73163+:105CF000AFAD0000AD0400088D2C00202404FFFF90
73164+:105D0000AD0C000C9547003230E6FFFFAD060010E9
73165+:105D10009145004830A200FF000219C25060000106
73166+:105D20008D240034AD0400148D4700388FAA00186C
73167+:105D300027BD0008AD0B0028AD0A0024AD07001CEC
73168+:105D4000AD00002CAD00001803E00008AD000020FD
73169+:105D500027BDFFE0AFB20018AFB10014AFB0001024
73170+:105D6000AFBF001C9098003000C088213C0D00FFA0
73171+:105D7000330F007FA0CF0000908E003135ACFFFFC5
73172+:105D80003C0AFF00A0CE000194A6001EA220000441
73173+:105D90008CAB00148E29000400A08021016C282403
73174+:105DA000012A40240080902101052025A62600021A
73175+:105DB000AE24000426050020262400080E000092D0
73176+:105DC00024060002924700302605002826240014ED
73177+:105DD00000071E000003160324060004044000030D
73178+:105DE0002403FFFF965900323323FFFF0E00009279
73179+:105DF000AE230010262400248FBF001C8FB2001891
73180+:105E00008FB100148FB00010240500030000302172
73181+:105E10000A00009C27BD002027BDFFD8AFB1001CA1
73182+:105E2000AFB00018AFBF002090A9003024020001DD
73183+:105E300000E050213123003F00A040218FB00040FE
73184+:105E40000080882100C04821106200148FA700380C
73185+:105E5000240B000500A0202100C02821106B001396
73186+:105E6000020030210E000128000000009225007C75
73187+:105E700030A400021080000326030030AE00003082
73188+:105E8000260300348FBF00208FB1001C8FB0001894
73189+:105E90000060102103E0000827BD00280E0000A7C5
73190+:105EA000AFB000100A00016F000000008FA3003C9B
73191+:105EB000010020210120282101403021AFA3001042
73192+:105EC0000E0000EEAFB000140A00016F00000000E9
73193+:105ED0003C06800034C20E008C4400108F850044C4
73194+:105EE000ACA400208C43001803E00008ACA30024FD
73195+:105EF0003C06800034C20E008C4400148F850044A0
73196+:105F0000ACA400208C43001C03E00008ACA30024D8
73197+:105F10009382000C1040001B2483000F2404FFF028
73198+:105F20000064382410E00019978B00109784000E4D
73199+:105F30009389000D3C0A601C0A0001AC01644023F7
73200+:105F400001037021006428231126000231C2FFFFE3
73201+:105F500030A2FFFF0047302B50C0000E00E4482164
73202+:105F60008D4D000C31A3FFFF00036400000C2C03D7
73203+:105F700004A1FFF30000302130637FFF0A0001A479
73204+:105F80002406000103E00008000000009784000ED2
73205+:105F900000E448213123FFFF3168FFFF0068382B00
73206+:105FA00054E0FFF8A783000E938A000D114000050E
73207+:105FB000240F0001006BC023A380000D03E0000844
73208+:105FC000A798000E006BC023A38F000D03E000080C
73209+:105FD000A798000E03E000080000000027BDFFE8BE
73210+:105FE000AFB000103C10800036030140308BFFFF43
73211+:105FF00093AA002BAFBF0014A46B000436040E005C
73212+:106000009488001630C600FF8FA90030A4680006EF
73213+:10601000AC650008A0660012A46A001AAC670020F4
73214+:106020008FA5002CA4690018012020210E000198E2
73215+:10603000AC6500143C021000AE0201788FBF001462
73216+:106040008FB0001003E0000827BD00188F85000006
73217+:106050002484000727BDFFF83084FFF83C06800049
73218+:1060600094CB008A316AFFFFAFAA00008FA900001D
73219+:10607000012540232507FFFF30E31FFF0064102B9D
73220+:106080001440FFF700056882000D288034CC4000E2
73221+:1060900000AC102103E0000827BD00088F8200003B
73222+:1060A0002486000730C5FFF800A2182130641FFFC6
73223+:1060B00003E00008AF8400008F87003C8F84004419
73224+:1060C00027BDFFB0AFB70044AFB40038AFB1002C6C
73225+:1060D000AFBF0048AFB60040AFB5003CAFB300342F
73226+:1060E000AFB20030AFB000283C0B80008C8600249B
73227+:1060F000AD6700808C8A002035670E00356901008D
73228+:10610000ACEA00108C8800248D2500040000B82122
73229+:10611000ACE800188CE3001000A688230000A02142
73230+:10612000ACE300148CE20018ACE2001C122000FE6C
73231+:1061300000E0B021936C0008118000F40000000022
73232+:10614000976F001031EEFFFF022E682B15A000EFB5
73233+:1061500000000000977200103250FFFFAED0000028
73234+:106160003C0380008C740000329300081260FFFD35
73235+:106170000000000096D800088EC700043305FFFF1A
73236+:1061800030B5000112A000E4000000000000000D86
73237+:1061900030BFA0402419004013F9011B30B4A00007
73238+:1061A000128000DF000000009373000812600008F6
73239+:1061B00000000000976D001031ACFFFF00EC202BB9
73240+:1061C0001080000330AE004011C000D50000000078
73241+:1061D000A7850040AF87003893630008022028217C
73242+:1061E000AFB10020146000F527B40020AF60000CB0
73243+:1061F000978F004031F14000162000022403001662
73244+:106200002403000E24054007A363000AAF650014B1
73245+:10621000938A00428F70001431550001001512401E
73246+:1062200002024825AF690014979F00408F78001440
73247+:1062300033F9001003194025AF680014979200400D
73248+:106240003247000810E0016E000000008F67001464
73249+:106250003C1210003C11800000F27825AF6F001452
73250+:1062600036230E00946E000A3C0D81002406000EB9
73251+:1062700031CCFFFF018D2025AF640004A36600022E
73252+:106280009373000A3406FFFC266B0004A36B000A1C
73253+:1062900097980040330820001100015F00000000C3
73254+:1062A0003C05800034A90E00979900409538000CF9
73255+:1062B00097870040001940423312C00031030003A9
73256+:1062C00000127B0330F11000006F6825001172038B
73257+:1062D00001AE6025000C20C0A76400129793004017
73258+:1062E000936A000A001359823175003C02AA1021FA
73259+:1062F0002450003CA3700009953F000C33F93FFF88
73260+:10630000A779001097700012936900090130F821F5
73261+:1063100027E5000230B900070019C0233308000741
73262+:10632000A368000B9371000997720012976F001019
73263+:10633000322700FF8F910038978D004000F218211E
73264+:10634000006F702101C6602131A6004010C0000519
73265+:106350003185FFFF00B1102B3C1280001040001768
73266+:10636000000098210225A82B56A0013E8FA50020F1
73267+:106370003C048000348A0E008D5300143C068000DB
73268+:10638000AD5300108D4B001CAD4B0018AD45000007
73269+:106390008CCD000031AC00081180FFFD34CE0E0022
73270+:1063A00095C3000800A0882100009021A783004029
73271+:1063B0008DC6000424130001AF860038976F0010CB
73272+:1063C00031F5FFFF8E9F000003F1282310A0011F6D
73273+:1063D000AE85000093620008144000DD000000005C
73274+:1063E0000E0001E7240400108F900048004028218F
73275+:1063F0003C023200320600FF000654000142F8253C
73276+:1064000026090001AF890048ACBF0000937900095C
73277+:1064100097780012936F000A332800FF3303FFFFC1
73278+:106420000103382100076C0031EE00FF01AE60254A
73279+:10643000ACAC00048F840048978B0040316A200088
73280+:106440001140010AACA4000897640012308BFFFFD2
73281+:1064500006400108ACAB000C978E004031C5000827
73282+:1064600014A0000226280006262800023C1F8000F7
73283+:1064700037E70E0094F900148CE5001C8F670004C8
73284+:10648000937800023324FFFF330300FFAFA3001013
73285+:106490008F6F0014AFA800180E0001CBAFAF00142F
73286+:1064A000240400100E0001FB000000008E9200008A
73287+:1064B00016400005000000008F7800142403FFBF81
73288+:1064C0000303A024AF7400148F67000C00F5C821EB
73289+:1064D000AF79000C9375000816A0000800000000BA
73290+:1064E00012600006000000008F6800143C0AEFFFF5
73291+:1064F0003549FFFE0109F824AF7F0014A37300089B
73292+:106500008FA500200A00034F02202021AED10000F9
73293+:106510000A00022D3C03800014E0FF1E30BFA040A3
73294+:106520000E0001900000A0212E9100010237B0253D
73295+:1065300012C000188FBF00488F87003C24170F003F
73296+:1065400010F700D43C0680008CD901780720FFFEAC
73297+:10655000241F0F0010FF00F634CA0E008D560014E1
73298+:1065600034C7014024080240ACF600048D49001CE9
73299+:106570003C141000ACE90008A0E00012A4E0001AEE
73300+:10658000ACE00020A4E00018ACE80014ACD4017822
73301+:106590008FBF00488FB700448FB600408FB5003CD6
73302+:1065A0008FB400388FB300348FB200308FB1002C1D
73303+:1065B0008FB0002803E0000827BD00508F910038FD
73304+:1065C000978800403C1280000220A821310700403B
73305+:1065D00014E0FF7C00009821977900108F9200381A
73306+:1065E0003338FFFF131200A8000020210080A021F3
73307+:1065F000108000F300A088211620FECE00000000CD
73308+:106600000A00031F2E9100013C0380008C62017878
73309+:106610000440FFFE240808008F860000AC68017863
73310+:106620003C038000946D008A31ACFFFF0186582343
73311+:10663000256AFFFF31441FFF2C8900081520FFF950
73312+:10664000000000008F8F0048347040008F83003CB2
73313+:1066500000E0A021240E0F0025E70001AF870048CD
73314+:1066600000D03021023488233C08800031F500FF3F
73315+:10667000106E0005240700019398004233130001B7
73316+:106680000013924036470001001524003C0A010027
73317+:10669000008A4825ACC900008F82004830BF003610
73318+:1066A00030B90008ACC200041320009900FF9825FF
73319+:1066B00035120E009650000A8F8700003C0F8100B3
73320+:1066C0003203FFFF24ED000835060140006F60250E
73321+:1066D0003C0E100031AB1FFF269200062405000E71
73322+:1066E000ACCC0020026E9825A4C5001AAF8B000028
73323+:1066F000A4D20018162000083C1080008F89003CAE
73324+:1067000024020F00512200022417000136730040BA
73325+:106710000E0001883C10800036060E008CCB001461
73326+:10672000360A014002402021AD4B00048CC5001CFC
73327+:10673000AD450008A1550012AD5300140E0001989C
73328+:106740003C151000AE1501780A000352000000004D
73329+:10675000936F0009976E0012936D000B31E500FFF7
73330+:1067600000AE202131AC00FF008C80212602000AFF
73331+:106770003050FFFF0E0001E7020020218F86004805
73332+:106780003C0341003C05800024CB0001AF8B004856
73333+:10679000936A00099769001230C600FF315F00FF5D
73334+:1067A0003128FFFF03E8382124F900020006C40065
73335+:1067B0000319782501E37025AC4E00008F6D000CA5
73336+:1067C00034A40E00948B001401B26025AC4C00047C
73337+:1067D0008C85001C8F670004936A00023164FFFF00
73338+:1067E000314900FFAFA900108F680014AFB1001845
73339+:1067F0000E0001CBAFA800140A0002FD0200202108
73340+:10680000AF600004A36000029798004033082000A6
73341+:106810001500FEA300003021A760001297840040FD
73342+:10682000936B000A3C10800030931F0000135183CB
73343+:10683000014BA82126A20028A362000936090E00F8
73344+:10684000953F000C0A000295A77F00108F7000147E
73345+:10685000360900400E000188AF6900140A0002C921
73346+:10686000000000000A00034F000020210641FEFA4C
73347+:10687000ACA0000C8CAC000C3C0D8000018D902570
73348+:106880000A0002EAACB2000C000090210A0002C526
73349+:1068900024130001128000073C028000344B0E00DC
73350+:1068A0009566000830D300401260004900000000E7
73351+:1068B0003C0680008CD001780600FFFE34C50E0037
73352+:1068C00094B500103C03050034CC014032B8FFFF02
73353+:1068D00003039025AD92000C8CAF0014240D200012
73354+:1068E0003C041000AD8F00048CAE001CAD8E00087F
73355+:1068F000A1800012A580001AAD800020A58000189C
73356+:10690000AD8D0014ACC401780A0003263C0680005B
73357+:106910008F9F0000351801402692000227F90008D9
73358+:1069200033281FFFA71200180A000391AF88000048
73359+:106930003C02800034450140ACA0000C1280001BDA
73360+:1069400034530E0034510E008E370010ACB70004E3
73361+:106950008E2400183C0B8000ACA400083570014068
73362+:1069600024040040A20000128FBF0048A600001AB5
73363+:106970008FB70044AE0000208FB60040A60000187C
73364+:106980008FB5003CAE0400148FB400388FB30034D0
73365+:106990008FB200308FB1002C8FB000283C02100065
73366+:1069A00027BD005003E00008AD6201788E66001438
73367+:1069B000ACA600048E64001C0A00042A3C0B800074
73368+:1069C0000E0001902E9100010A0003200237B0252D
73369+:1069D000000000000000000D00000000240003691A
73370+:1069E0000A0004013C06800027BDFFD8AFBF00208D
73371+:1069F0003C0980003C1F20FFAFB200183C0760003C
73372+:106A000035320E002402001037F9FFFDACE23008E9
73373+:106A1000AFB3001CAFB10014AFB00010AE5900000E
73374+:106A20000000000000000000000000000000000066
73375+:106A3000000000003C1800FF3713FFFDAE530000BC
73376+:106A40003C0B60048D7050002411FF7F3C0E00024F
73377+:106A50000211782435EC380C35CD0109ACED4C1819
73378+:106A6000240A0009AD6C50008CE80438AD2A0008F7
73379+:106A7000AD2000148CE54C1C3106FFFF38C42F718B
73380+:106A800000051E023062000F2486C0B310400007CC
73381+:106A9000AF8200088CE54C1C3C09001F3528FC0027
73382+:106AA00000A81824000321C2AF8400048CF1080858
73383+:106AB0003C0F57092412F0000232702435F0001008
73384+:106AC00001D0602601CF68262DAA00012D8B000180
73385+:106AD000014B382550E00009A380000C3C1F601CCE
73386+:106AE0008FF8000824190001A399000C33137C00CF
73387+:106AF000A7930010A780000EA380000DAF80004870
73388+:106B000014C00003AF8000003C066000ACC0442C01
73389+:106B10000E0005B93C1080000E000F1A361101005E
73390+:106B20003C12080026523DD03C13080026733E500C
73391+:106B30008E03000038640001308200011440FFFC25
73392+:106B40003C0B800A8E2600002407FF8024C90240E7
73393+:106B5000312A007F014B402101272824AE06002066
73394+:106B6000AF880044AE0500243C048000AF86003CA2
73395+:106B70008C8C01780580FFFE24180800922F0008F5
73396+:106B8000AC980178A38F0042938E004231CD000172
73397+:106B900011A0000F24050D0024DFF8002FF90301D8
73398+:106BA0001320001C000629C224A4FFF00004104298
73399+:106BB000000231400E00020200D2D8213C02400007
73400+:106BC0003C068000ACC201380A0004A000000000AE
73401+:106BD00010C50023240D0F0010CD00273C1F800896
73402+:106BE00037F9008093380000240E0050330F00FF67
73403+:106BF00015EEFFF33C0240000E000A3600000000D4
73404+:106C00003C0240003C068000ACC201380A0004A0EF
73405+:106C1000000000008F83000400A3402B1500000B30
73406+:106C20008F8B0008006B50212547FFFF00E5482BA4
73407+:106C30001520000600A36023000C19400E0002027C
73408+:106C40000073D8210A0004C43C0240000000000D7B
73409+:106C50000E000202000000000A0004C43C024000D2
73410+:106C60003C1B0800277B3F500E0002020000000082
73411+:106C70000A0004C43C0240003C1B0800277B3F7014
73412+:106C80000E000202000000000A0004C43C024000A2
73413+:106C90003C0660043C09080025290104ACC9502CBD
73414+:106CA0008CC850003C0580003C0200023507008083
73415+:106CB000ACC750003C040800248415A43C03080021
73416+:106CC0002463155CACA50008ACA2000C3C010800D4
73417+:106CD000AC243D603C010800AC233D6403E00008A7
73418+:106CE0002402000100A030213C1C0800279C3D68C4
73419+:106CF0003C0C04003C0B0002008B3826008C402624
73420+:106D00002CE200010007502B2D050001000A4880ED
73421+:106D10003C03080024633D60004520250123182121
73422+:106D20001080000300001021AC6600002402000166
73423+:106D300003E00008000000003C1C0800279C3D68A0
73424+:106D40003C0B04003C0A0002008A3026008B3826E7
73425+:106D50002CC200010006482B2CE5000100094080F0
73426+:106D60003C03080024633D600045202501031821F1
73427+:106D700010800005000010213C0C0800258C155CDB
73428+:106D8000AC6C00002402000103E0000800000000D9
73429+:106D90003C0900023C08040000883026008938269F
73430+:106DA0002CC30001008028212CE400010083102561
73431+:106DB0001040000B000030213C1C0800279C3D685F
73432+:106DC0003C0A80008D4E00082406000101CA682597
73433+:106DD000AD4D00088D4C000C01855825AD4B000CC5
73434+:106DE00003E0000800C010213C1C0800279C3D68FF
73435+:106DF0003C0580008CA6000C000420272402000122
73436+:106E000000C4182403E00008ACA3000C3C020002FC
73437+:106E10001082000B3C0560003C0704001087000353
73438+:106E20000000000003E00008000000008CA908D06A
73439+:106E3000240AFFFD012A402403E00008ACA808D082
73440+:106E40008CA408D02406FFFE0086182403E0000866
73441+:106E5000ACA308D03C05601A34A600108CC3008097
73442+:106E600027BDFFF88CC50084AFA3000093A40000E9
73443+:106E70002402000110820003AFA5000403E0000813
73444+:106E800027BD000893A7000114E0001497AC00028E
73445+:106E900097B800023C0F8000330EFFFC01CF682141
73446+:106EA000ADA50000A3A000003C0660008CC708D080
73447+:106EB0002408FFFE3C04601A00E82824ACC508D072
73448+:106EC0008FA300048FA200003499001027BD000892
73449+:106ED000AF22008003E00008AF2300843C0B800059
73450+:106EE000318AFFFC014B48218D2800000A00057DF6
73451+:106EF000AFA8000427BDFFE8AFBF00103C1C08008E
73452+:106F0000279C3D683C0580008CA4000C8CA20004EA
73453+:106F10003C0300020044282410A0000A00A3182407
73454+:106F20003C0604003C0400021460000900A6102482
73455+:106F30001440000F3C0404000000000D3C1C08003D
73456+:106F4000279C3D688FBF001003E0000827BD001894
73457+:106F50003C0208008C423D600040F809000000003F
73458+:106F60003C1C0800279C3D680A0005A68FBF001046
73459+:106F70003C0208008C423D640040F809000000001B
73460+:106F80000A0005AC00000000000411C003E0000886
73461+:106F9000244202403C04080024843FB42405001A23
73462+:106FA0000A00009C0000302127BDFFE0AFB00010B8
73463+:106FB0003C108000AFBF0018AFB1001436110100C3
73464+:106FC000922200090E0005B63044007F8E3F00007B
73465+:106FD0008F89003C3C0F008003E26021258800403F
73466+:106FE0000049F821240DFF80310E00783198007897
73467+:106FF00035F9000135F100020319382501D1482582
73468+:10700000010D302403ED5824018D2824240A00406A
73469+:1070100024040080240300C0AE0B0024AE0008103E
73470+:10702000AE0A0814AE040818AE03081CAE05080426
73471+:10703000AE070820AE060808AE0908243609090084
73472+:107040009539000C3605098033ED007F3338FFFF9A
73473+:10705000001889C0AE110800AE0F0828952C000C4E
73474+:107060008FBF00188FB10014318BFFFF000B51C090
73475+:10707000AE0A002C8CA400508FB000108CA3003CF2
73476+:107080008D2700048CA8001C8CA600383C0E800ABA
73477+:1070900001AE102127BD0020AF820044AF84005014
73478+:1070A000AF830054AF87004CAF88005C03E000085A
73479+:1070B000AF8600603C09080091293FD924A800024E
73480+:1070C0003C05110000093C0000E8302500C51825EA
73481+:1070D00024820008AC83000003E00008AC800004B8
73482+:1070E0003C098000352309009128010B906A0011AA
73483+:1070F0002402002800804821314700FF00A07021B1
73484+:1071000000C068213108004010E20002340C86DD26
73485+:10711000240C08003C0A800035420A9A944700007B
73486+:10712000354B0A9C35460AA030F9FFFFAD39000007
73487+:107130008D780000354B0A8024040001AD3800042E
73488+:107140008CCF0000AD2F00089165001930A300031B
73489+:107150001064009028640002148000AF240500022F
73490+:107160001065009E240F0003106F00B435450AA47B
73491+:10717000240A0800118A0048000000005100003D68
73492+:107180003C0B80003C0480003483090090670012AF
73493+:1071900030E200FF004D7821000FC8802724000155
73494+:1071A0003C0A8000354F090091E50019354C0980F3
73495+:1071B0008D87002830A300FF0003150000475825E5
73496+:1071C0000004C4003C19600001793025370806FF2F
73497+:1071D000AD260000AD2800048DEA002C25280028EB
73498+:1071E000AD2A00088DEC0030AD2C000C8DE500348C
73499+:1071F000AD2500108DE400383C05800034AC093C1E
73500+:10720000AD2400148DE3001CAD2300188DE7002091
73501+:10721000AD27001C8DE20024AD2200208DF900284E
73502+:1072200034A20100AD3900248D830000AD0E0004AE
73503+:1072300034B90900AD0300008C47000C250200148E
73504+:10724000AD070008932B00123C04080090843FD83F
73505+:10725000AD000010317800FF030D302100064F0013
73506+:1072600000047C00012F702535CDFFFC03E00008F1
73507+:10727000AD0D000C35780900930600123C0508009E
73508+:1072800094A53FC830C800FF010D5021000A60805E
73509+:107290000A00063C018520211500005B000000006B
73510+:1072A0003C08080095083FCE3C06080094C63FC83D
73511+:1072B000010610213C0B800035790900933800113C
73512+:1072C000932A001935660A80330800FF94CF002AFC
73513+:1072D00000086082314500FF978A0058000C1E00AC
73514+:1072E000000524003047FFFF006410250047C0253B
73515+:1072F00001EA30213C0B4000030B402500066400EE
73516+:10730000AD280000AD2C0004932500183C030006B6
73517+:107310002528001400053E0000E31025AD220008DA
73518+:107320008F24002C3C05800034AC093CAD24000CBB
73519+:107330008F38001C34A20100254F0001AD38001029
73520+:107340008D830000AD0E000431EB7FFFAD03000024
73521+:107350008C47000C34B90900A78B0058AD07000812
73522+:10736000932B00123C04080090843FD8250200149F
73523+:10737000317800FF030D302100064F0000047C002F
73524+:10738000012F702535CDFFFCAD00001003E0000893
73525+:10739000AD0D000C3C02080094423FD23C050800B1
73526+:1073A00094A53FC835440AA43C07080094E73FC4AD
73527+:1073B000948B00000045C8210327C023000B1C004C
73528+:1073C0002706FFF200665025AD2A000CAD20001004
73529+:1073D000AD2C00140A00063025290018354F0AA4E8
73530+:1073E00095E50000956400280005140000043C00A9
73531+:1073F0003459810000EC5825AD39000CAD2B00103C
73532+:107400000A000630252900143C0C0800958C3FCE5C
73533+:107410000A000681258200015460FF56240A0800F4
73534+:1074200035580AA49706000000061C00006C502581
73535+:10743000AD2A000C0A000630252900103C03080084
73536+:1074400094633FD23C07080094E73FC83C0F080014
73537+:1074500095EF3FC494A4000095790028006710219F
73538+:10746000004F582300041C00001934002578FFEE5B
73539+:1074700000D87825346A8100AD2A000CAD2F0010A9
73540+:10748000AD200014AD2C00180A0006302529001C80
73541+:1074900003E00008240207D027BDFFE0AFB20018C8
73542+:1074A000AFB10014AFB00010AFBF001C0E00007CE5
73543+:1074B000008088218F8800548F87004C3C0580080D
73544+:1074C00034B20080011128213C1080002402008089
73545+:1074D000240300C000A72023AE0208183C06800841
73546+:1074E000AE03081C18800004AF850054ACC500042E
73547+:1074F0008CC90004AF89004C1220000936040980B1
73548+:107500000E0006F800000000924C00278E0B00745D
73549+:1075100001825004014B3021AE46000C3604098034
73550+:107520008C8E001C8F8F005C01CF682319A0000493
73551+:107530008FBF001C8C90001CAF90005C8FBF001CA4
73552+:107540008FB200188FB100148FB000100A00007EB7
73553+:1075500027BD00208F8600508F8300548F82004CFF
73554+:107560003C05800834A40080AC860050AC83003C0D
73555+:1075700003E00008ACA200043C0308008C63005444
73556+:1075800027BDFFF8308400FF2462000130A500FF12
73557+:107590003C010800AC22005430C600FF3C078000CC
73558+:1075A0008CE801780500FFFE3C0C7FFFA3A40003DC
73559+:1075B0008FAA0000358BFFFF014B4824000627C02F
73560+:1075C00001244025AFA8000034E201009043000AE6
73561+:1075D000A3A000023C1980FFA3A300018FAF00000D
73562+:1075E00030AE007F3738FFFF01F86024000E6E00D8
73563+:1075F0003C0A002034E50140018D58253549200022
73564+:107600002406FF803C04100027BD0008ACAB000C32
73565+:10761000ACA90014A4A00018A0A6001203E0000862
73566+:10762000ACE40178308800FF30A700FF3C03800005
73567+:107630008C6201780440FFFE3C0C8000358A0A0011
73568+:107640008D4B00203584014035850980AC8B0004CA
73569+:107650008D4900240007302B00061540AC89000836
73570+:10766000A088001090A3004CA083002D03E0000828
73571+:10767000A480001827BDFFE8308400FFAFBF0010D2
73572+:107680000E00075D30A500FF8F8300548FBF0010F0
73573+:107690003C06800034C50140344700402404FF907C
73574+:1076A0003C02100027BD0018ACA3000CA0A40012DF
73575+:1076B000ACA7001403E00008ACC2017827BDFFE0CE
73576+:1076C0003C088008AFBF001CAFB20018AFB1001477
73577+:1076D000AFB00010351000808E0600183C07800007
73578+:1076E000309200FF00C72025AE0400180E00007C79
73579+:1076F00030B100FF92030005346200080E00007EE6
73580+:10770000A2020005024020210E000771022028215C
73581+:10771000024020218FBF001C8FB200188FB10014CF
73582+:107720008FB0001024050005240600010A0007326E
73583+:1077300027BD00203C05800034A309809066000826
73584+:1077400030C200081040000F3C0A01013549080A08
73585+:10775000AC8900008CA80074AC8800043C070800C9
73586+:1077600090E73FD830E5001050A00008AC8000083A
73587+:107770003C0D800835AC00808D8B0058AC8B000828
73588+:107780002484000C03E00008008010210A0007B5E3
73589+:107790002484000C27BDFFE83C098000AFB0001036
73590+:1077A000AFBF00143526098090C8000924020006E6
73591+:1077B00000A05821310300FF3527090000808021F7
73592+:1077C000240500041062007B2408000294CF005CB2
73593+:1077D0003C0E020431EDFFFF01AE6025AE0C00004F
73594+:1077E00090CA00083144002010800008000000000A
73595+:1077F00090C2004E3C1F010337F90300305800FFD0
73596+:107800000319302524050008AE06000490F9001184
73597+:1078100090E6001290E40011333800FF00187082E7
73598+:1078200030CF00FF01CF5021014B6821308900FF8C
73599+:1078300031AAFFFF39230028000A60801460002C61
73600+:10784000020C482390E400123C198000372F0100FD
73601+:10785000308C00FF018B1821000310800045F821B7
73602+:10786000001F8400360706FFAD270004373F0900DC
73603+:1078700093EC001193EE0012372609800005C082B8
73604+:107880008DE4000C8CC5003431CD00FF01AB10211C
73605+:107890000058182100A4F8230008840000033F00CA
73606+:1078A00000F0302533F9FFFF318F00FC00D970253F
73607+:1078B0000158202101E9682100045080ADAE000C80
73608+:1078C0000E00007C012A80213C088008240B000463
73609+:1078D000350500800E00007EA0AB000902001021DB
73610+:1078E0008FBF00148FB0001003E0000827BD001800
73611+:1078F00090EC001190E300193C18080097183FCE57
73612+:10790000318200FF0002F882307000FF001FCE00BD
73613+:1079100000103C000327302500D870253C0F4000A4
73614+:1079200001CF68253C198000AD2D0000373F0900CC
73615+:1079300093EC001193EE0012372F010037260980D7
73616+:107940000005C0828DE4000C8CC5003431CD00FFF1
73617+:1079500001AB10210058182100A4F823000884006E
73618+:1079600000033F0000F0302533F9FFFF318F00FCAA
73619+:1079700000D970250158202101E9682100045080B8
73620+:10798000ADAE000C0E00007C012A80213C0880086E
73621+:10799000240B0004350500800E00007EA0AB00091A
73622+:1079A000020010218FBF00148FB0001003E0000808
73623+:1079B00027BD00180A0007C72408001227BDFFD002
73624+:1079C0003C038000AFB60028AFB50024AFB4002060
73625+:1079D000AFB10014AFBF002CAFB3001CAFB20018A2
73626+:1079E000AFB000103467010090E6000B309400FF48
73627+:1079F00030B500FF30C200300000B02110400099C7
73628+:107A000000008821346409809088000800082E0056
73629+:107A100000051E03046000C0240400048F86005487
73630+:107A20003C010800A0243FD83C0C8000AD800048F9
73631+:107A30003C048000348E010091CD000B31A5002064
73632+:107A400010A000073C078000349309809272000860
73633+:107A50000012860000107E0305E000C43C1F800871
73634+:107A600034EC0100918A000B34EB09809169000825
73635+:107A7000314400400004402B3123000800C8982303
73636+:107A80001460000224120003000090213C108000CA
73637+:107A900036180A8036040900970E002C90830011D6
73638+:107AA0009089001293050018307F00FF312800FFF5
73639+:107AB000024810210002C880930D0018033F78216E
73640+:107AC00001F1302130B100FF00D11821A78E0058FC
73641+:107AD0003C010800A4263FCE3C010800A4233FD06F
73642+:107AE00015A00002000000000000000D920B010B29
73643+:107AF0003065FFFF3C010800A4233FD2316A0040FB
73644+:107B00003C010800A4203FC83C010800A4203FC459
73645+:107B10001140000224A4000A24A4000B3091FFFFAE
73646+:107B20000E0001E7022020219206010B3C0C080008
73647+:107B3000958C3FD2004020210006698231A70001C8
73648+:107B40000E00060101872821004020210260282123
73649+:107B50000E00060C024030210E0007A1004020213B
73650+:107B600016C00069004020219212010B32560040DD
73651+:107B700012C000053C0500FF8C93000034AEFFFFEF
73652+:107B8000026E8024AC9000000E0001FB0220202138
73653+:107B90003C0F080091EF3FD831F10003122000168E
73654+:107BA0003C1380088F8200543C09800835280080EF
73655+:107BB000245F0001AD1F003C3C0580088CB9000427
73656+:107BC00003E02021033FC0231B000002AF9F0054AD
73657+:107BD0008CA400040E0006F8ACA400043C0780004E
73658+:107BE0008CEB00743C04800834830080004B5021EF
73659+:107BF000AC6A000C3C1380083670008002802021A3
73660+:107C000002A02821A200006B0E00075D3C1480003A
73661+:107C10008F920054368C0140AD92000C8F86004844
73662+:107C20003C151000344D000624D60001AF960048E4
73663+:107C30008FBF002CA18600128FB60028AD8D0014D6
73664+:107C40008FB3001CAE9501788FB200188FB5002459
73665+:107C50008FB400208FB100148FB0001003E0000833
73666+:107C600027BD003034640980908F0008000F760033
73667+:107C7000000E6E0305A00033347F090093F8001B4B
73668+:107C8000241900103C010800A0393FD8331300022A
73669+:107C90001260FF678F8600548F8200601446FF6574
73670+:107CA0003C0480000E00007C000000003C048008C2
73671+:107CB0003485008090A8000924060016310300FFD7
73672+:107CC0001066000D0000000090AB00093C070800A2
73673+:107CD00090E73FD824090008316400FF34EA00012E
73674+:107CE0003C010800A02A3FD81089002F240C000A6C
73675+:107CF000108C00282402000C0E00007E0000000002
73676+:107D00000A0008608F8600540E0007B9024028213F
73677+:107D10000A0008AE004020213C0B8008356A008034
73678+:107D20008D4600548CE9000C1120FF3DAF860054B5
73679+:107D3000240700143C010800A0273FD80A00085F70
73680+:107D40003C0C800090910008241200023C010800C5
73681+:107D5000A0323FD8323000201200000B2416000160
73682+:107D60008F8600540A0008602411000837F800804C
73683+:107D70008F020038AFE200048FF90004AF19003C15
73684+:107D80000A00086C3C0780008F8600540A000860D7
73685+:107D900024110004A0A200090E00007E00000000D3
73686+:107DA0000A0008608F860054240200140A00093A71
73687+:107DB000A0A2000927BDFFE8AFB000103C10800072
73688+:107DC000AFBF001436020100904400090E00075DA9
73689+:107DD000240500013C0480089099000E3483008043
73690+:107DE000909F000F906F00269089000A33F800FFE3
73691+:107DF00000196E000018740031EC00FF01AE502530
73692+:107E0000000C5A00014B3825312800FF3603014091
73693+:107E10003445600000E830252402FF813C04100056
73694+:107E2000AC66000C8FBF0014AC650014A062001299
73695+:107E3000AE0401788FB0001003E0000827BD0018E1
73696+:107E400027BDFFE8308400FFAFBF00100E00075DC4
73697+:107E500030A500FF3C05800034A4014034470040B9
73698+:107E60002406FF92AC870014A08600128F83005472
73699+:107E70008FBF00103C02100027BD0018AC83000C1F
73700+:107E800003E00008ACA2017827BDFFD8AFB0001016
73701+:107E9000308400FF30B000FF3C058000AFB100141B
73702+:107EA000AFBF0020AFB3001CAFB20018000410C277
73703+:107EB00034A60100320300023051000114600007B3
73704+:107EC00090D200093C098008353300809268000593
73705+:107ED0003107000810E0000C308A00100240202119
73706+:107EE0000E00078302202821240200018FBF0020FA
73707+:107EF0008FB3001C8FB200188FB100148FB0001028
73708+:107F000003E0000827BD00281540003434A50A000E
73709+:107F10008CB800248CAF0008130F004B00003821F0
73710+:107F20003C0D800835B30080926C00682406000286
73711+:107F3000318B00FF116600843C06800034C20100D2
73712+:107F40009263004C90590009307F00FF53F9000400
73713+:107F50003213007C10E00069000000003213007C46
73714+:107F60005660005C0240202116200009320D0001FD
73715+:107F70003C0C800035840100358B0A008D6500249F
73716+:107F80008C86000414A6FFD900001021320D0001D8
73717+:107F900011A0000E024020213C1880003710010083
73718+:107FA0008E0F000C8F8E005011EE000800000000B4
73719+:107FB0000E000843022028218E19000C3C1F800867
73720+:107FC00037F00080AE190050024020210E000771EA
73721+:107FD000022028210A00098F240200013C05080024
73722+:107FE0008CA5006424A400013C010800AC240064BA
73723+:107FF0001600000D00000000022028210E0007716D
73724+:1080000002402021926E0068240C000231CD00FF56
73725+:1080100011AC0022024020210E00094100000000A6
73726+:108020000A00098F240200010E00007024040001E0
73727+:10803000926B0025020B30250E00007EA266002503
73728+:108040000A0009D3022028218E6200188CDF000468
73729+:108050008CB9002400021E0217F9FFB13065007FC1
73730+:108060009268004C264400013093007F1265004066
73731+:10807000310300FF1464FFAB3C0D8008264700016C
73732+:1080800030F1007F30E200FF1225000B24070001D1
73733+:10809000004090210A00099C2411000124050004DD
73734+:1080A0000E000732240600010E0009410000000006
73735+:1080B0000A00098F240200012405FF8002452024C4
73736+:1080C00000859026324200FF004090210A00099C62
73737+:1080D000241100010E00084302202821320700303D
73738+:1080E00010E0FFA132100082024020210E00078321
73739+:1080F000022028210A00098F240200018E6900183D
73740+:108100000240202102202821012640250E0009647A
73741+:10811000AE6800189264004C240500032406000198
73742+:108120000E000732308400FF0E00007024040001AE
73743+:1081300092710025021150250E00007EA26A0025D2
73744+:108140000A00098F240200018E6F00183C1880007D
73745+:108150000240202101F87025022028210E0007711D
73746+:10816000AE6E00189264004C0A000A1B240500043D
73747+:10817000324A0080394900801469FF6A3C0D80084A
73748+:108180000A0009F42647000127BDFFC0AFB0001860
73749+:108190003C108000AFBF0038AFB70034AFB600303E
73750+:1081A000AFB5002CAFB40028AFB30024AFB20020AD
73751+:1081B0000E0005BEAFB1001C360201009045000B59
73752+:1081C0000E00097690440008144000E78FBF003885
73753+:1081D0003C08800835070080A0E0006B3606098067
73754+:1081E00090C50000240300503C17080026F73F907C
73755+:1081F00030A400FF3C13080026733FA01083000347
73756+:108200003C1080000000B82100009821241F0010BD
73757+:108210003611010036120A00361509808E580024E6
73758+:108220008E3400048EAF00208F8C00543C01080077
73759+:10823000A03F3FD836190A80972B002C8EF60000FD
73760+:10824000932A00180298702301EC68233C0108006F
73761+:10825000AC2E3FB43C010800AC2D3FB83C010800F7
73762+:10826000AC2C3FDCA78B005802C0F809315400FF4A
73763+:1082700030490002152000E930420001504000C49E
73764+:108280009227000992A90008312800081500000271
73765+:10829000241500030000A8213C0A80003543090092
73766+:1082A00035440A008C8D00249072001190700012E9
73767+:1082B000907F0011325900FF321100FF02B11021EE
73768+:1082C0000002C08033EF00FF0319B021028F70213C
73769+:1082D00002D4602125CB00103C010800A4363FCE1B
73770+:1082E0003C010800AC2D3FE03C010800A42C3FD02D
73771+:1082F0003C010800A42B3FCC3556010035540980C1
73772+:1083000035510E008F8700548F89005C8E850020C8
73773+:1083100024080006012730233C010800AC283FD484
73774+:1083200000A7282304C000B50000902104A000B3DA
73775+:1083300000C5502B114000B5000000003C010800B2
73776+:10834000AC263FB88E6200000040F8090000000033
73777+:108350003046000214C0007400408021304B000100
73778+:10836000556000118E6200043C0D08008DAD3FBCCD
73779+:108370003C0EC0003C04800001AE6025AE2C000025
73780+:108380008C980000330F000811E0FFFD0000000092
73781+:10839000963F000824120001A79F00408E39000478
73782+:1083A000AF9900388E6200040040F8090000000018
73783+:1083B0000202802532030002146000B300000000B6
73784+:1083C0003C09080095293FC43C06080094C63FD0EC
73785+:1083D0003C0A0800954A3FC63C0708008CE73FBCB2
73786+:1083E000012670213C0308008C633FE03C08080034
73787+:1083F00095083FDA01CA20218ED9000C00E9282116
73788+:10840000249F000200A878210067C02133E4FFFF09
73789+:10841000AF9900503C010800AC383FE03C01080037
73790+:10842000A42F3FC83C010800A42E3FD20E0001E754
73791+:10843000000000008F8D0048004020213C01080012
73792+:10844000A02D3FD98E62000825AC0001AF8C0048FA
73793+:108450000040F809000000008F85005402A0302180
73794+:108460000E00060C004020210E0007A10040202134
73795+:108470008E6B000C0160F809004020213C0A0800C6
73796+:10848000954A3FD23C06080094C63FC601464821A3
73797+:10849000252800020E0001FB3104FFFF3C05080007
73798+:1084A0008CA53FB43C0708008CE73FBC00A7202305
73799+:1084B0003C010800AC243FB414800006000000001A
73800+:1084C0003C0208008C423FD4344B00403C01080081
73801+:1084D000AC2B3FD4124000438F8E00448E2D0010F1
73802+:1084E0008F920044AE4D00208E2C0018AE4C00241C
73803+:1084F0003C04080094843FC80E0006FA0000000007
73804+:108500008F9F00548E6700103C010800AC3F3FDC99
73805+:1085100000E0F809000000003C1908008F393FB462
73806+:108520001720FF798F870054979300583C11800ED5
73807+:10853000321601000E000729A633002C16C0004594
73808+:10854000320300105460004C8EE5000432080040F5
73809+:108550005500001D8EF000088EE4000C0080F80924
73810+:10856000000000008FBF00388FB700348FB6003096
73811+:108570008FB5002C8FB400288FB300248FB2002059
73812+:108580008FB1001C8FB0001803E0000827BD004029
73813+:108590008F86003C36110E0000072E0000A6202515
73814+:1085A000AE0400808E4300208E500024AFA3001044
73815+:1085B000AE2300148FB20010AE320010AE30001C9B
73816+:1085C0000A000A75AE3000180200F8090000000029
73817+:1085D0008EE4000C0080F809000000000A000B2E59
73818+:1085E0008FBF003824180001240F0001A5C000200F
73819+:1085F000A5D800220A000B10ADCF00243C010800D2
73820+:10860000AC203FB80A000AA68E6200003C010800B8
73821+:10861000AC253FB80A000AA68E6200009224000929
73822+:108620000E000771000028218FBF00388FB700347B
73823+:108630008FB600308FB5002C8FB400288FB3002484
73824+:108640008FB200208FB1001C8FB0001803E000082B
73825+:1086500027BD00403C1480009295010900002821AC
73826+:108660000E00084332A400FF320300105060FFB830
73827+:10867000320800408EE5000400A0F8090000000068
73828+:108680000A000B28320800405240FFA89793005878
73829+:108690008E3400148F930044AE7400208E35001C7D
73830+:1086A000AE7500240A000B1F979300588F820014A8
73831+:1086B0000004218003E00008008210213C078008AC
73832+:1086C00034E200809043006900804021106000097E
73833+:1086D0003C0401003C0708008CE73FDC8F8300303E
73834+:1086E00000E32023048000089389001C14E30003A6
73835+:1086F0000100202103E00008008010213C0401005B
73836+:1087000003E00008008010211120000B00673823CF
73837+:108710003C0D800035AC0980918B007C316A0002F1
73838+:10872000114000202409003400E9702B15C0FFF12E
73839+:108730000100202100E938232403FFFC00A3C82402
73840+:1087400000E3C02400F9782B15E0FFEA030820219C
73841+:1087500030C400030004102314C000143049000387
73842+:108760000000302100A9782101E6702100EE682B7D
73843+:1087700011A0FFE03C0401002D3800010006C82BC9
73844+:10878000010548210319382414E0FFDA2524FFFCF1
73845+:108790002402FFFC00A218240068202103E0000846
73846+:1087A000008010210A000B9E240900303C0C800040
73847+:1087B0003586098090CB007C316A00041540FFE9C2
73848+:1087C000240600040A000BAD000030213C03080021
73849+:1087D0008C63005C8F82001827BDFFE0AFBF0018DC
73850+:1087E000AFB1001410620005AFB00010000329C043
73851+:1087F00024A40280AF840014AF8300183C108000D2
73852+:1088000036020A0094450032361101000E000B7F3B
73853+:1088100030A43FFF8E240000241FFF803C11008005
73854+:108820000082C021031F60243309007F000CC9406F
73855+:1088300003294025330E0078362F00033C0D10002D
73856+:10884000010D502501CF5825AE0C002836080980AF
73857+:10885000AE0C080CAE0B082CAE0A08309103006970
73858+:108860003C06800C0126382110600006AF870034DA
73859+:108870008D09003C8D03006C0123382318E0008231
73860+:10888000000000003C0B8008356A00803C1080002E
73861+:10889000A1400069360609808CC200383C06800081
73862+:1088A00034C50A0090A8003C310C00201180001A49
73863+:1088B000AF820030240D00013C0E800035D10A004B
73864+:1088C000A38D001CAF8000248E2400248F850024FB
73865+:1088D000240D0008AF800020AF8000283C01080074
73866+:1088E000A42D3FC63C010800A4203FDA0E000B83F4
73867+:1088F000000030219228003C8FBF00188FB1001477
73868+:108900008FB0001000086142AF82002C27BD00200C
73869+:1089100003E000083182000190B80032240E00010B
73870+:10892000330F00FF000F2182108E00412419000236
73871+:108930001099006434C40AC03C03800034640A0007
73872+:108940008C8F002415E0001E34660900909F0030D3
73873+:108950002418000533F9003F1338004E24030001AA
73874+:108960008F860020A383001CAF860028AF860024DA
73875+:108970003C0E800035D10A008E2400248F8500240F
73876+:10898000240D00083C010800A42D3FC63C0108004E
73877+:10899000A4203FDA0E000B83000000009228003C68
73878+:1089A0008FBF00188FB100148FB000100008614213
73879+:1089B000AF82002C27BD002003E0000831820001B7
73880+:1089C0008C8A00088C8B00248CD000643C0E8000C4
73881+:1089D00035D10A00014B2823AF900024A380001C4E
73882+:1089E000AF8500288E2400248F8600208F850024E8
73883+:1089F000240D00083C010800A42D3FC63C010800DE
73884+:108A0000A4203FDA0E000B83000000009228003CF7
73885+:108A10008FBF00188FB100148FB0001000086142A2
73886+:108A2000AF82002C27BD002003E000083182000146
73887+:108A300090A200303051003F5224002834C50AC0B3
73888+:108A40008CB000241600002234CB09008CA600480C
73889+:108A50003C0A7FFF3545FFFF00C510243C0E800017
73890+:108A6000AF82002035C509008F8800208CAD0060E2
73891+:108A7000010D602B15800002010020218CA40060F4
73892+:108A80000A000C22AF8400208D02006C0A000BFC4F
73893+:108A90003C0680008C8200488F8600203C097FFFC6
73894+:108AA0003527FFFF004788243C0480082403000189
73895+:108AB000AF910028AC80006CA383001C0A000C302E
73896+:108AC000AF8600248C9F00140A000C22AF9F002068
73897+:108AD0008D6200680A000C6C3C0E800034C4098072
73898+:108AE0008C8900708CA300140123382B10E0000443
73899+:108AF000000000008C8200700A000C6C3C0E8000AC
73900+:108B00008CA200140A000C6C3C0E80008F8500249F
73901+:108B100027BDFFE0AFBF0018AFB1001414A00008DC
73902+:108B2000AFB000103C04800034870A0090E60030AB
73903+:108B30002402000530C3003F106200B934840900EC
73904+:108B40008F91002000A080213C048000348E0A0018
73905+:108B50008DCD00043C0608008CC63FB831A73FFF0E
73906+:108B600000E6602B5580000100E03021938F001C4F
73907+:108B700011E0007800D0282B349F098093F9007C05
73908+:108B800033380002130000792403003400C3102B93
73909+:108B9000144000D90000000000C3302300D0282B6F
73910+:108BA0003C010800A4233FC414A0006E0200182159
73911+:108BB0003C0408008C843FB40064402B5500000145
73912+:108BC000006020213C05800034A90A00912A003C65
73913+:108BD0003C010800AC243FBC31430020146000037A
73914+:108BE0000000482134AB0E008D6900188F88002CDE
73915+:108BF0000128202B1080005F000000003C050800C9
73916+:108C00008CA53FBC00A96821010D602B1180005C80
73917+:108C100000B0702B0109382300E028213C01080036
73918+:108C2000AC273FBC12000003240AFFFC10B0008DEB
73919+:108C30003224000300AA18243C010800A4203FDAD3
73920+:108C40003C010800AC233FBC006028218F84002435
73921+:108C5000120400063C0B80088D6C006C0200202181
73922+:108C6000AF91002025900001AD70006C8F8D002821
73923+:108C700000858823AF91002401A52023AF8400281C
73924+:108C80001220000224070018240700103C18800856
73925+:108C90003706008090CF00683C010800A0273FD82D
73926+:108CA0002407000131EE00FF11C70047000000005B
73927+:108CB00014800018000028213C06800034D109806F
73928+:108CC00034CD010091A600098E2C001824C40001A7
73929+:108CD000000C86023205007F308B007F1165007F1B
73930+:108CE0002407FF803C19800837290080A124004C0C
73931+:108CF0003C0808008D083FD4241800023C010800FD
73932+:108D0000A0384019350F00083C010800AC2F3FD4B3
73933+:108D1000240500103C02800034440A009083003C8B
73934+:108D2000307F002013E0000500A02021240A00016C
73935+:108D30003C010800AC2A3FBC34A400018FBF0018DE
73936+:108D40008FB100148FB000100080102103E00008E4
73937+:108D500027BD00203C010800A4203FC410A0FF94C0
73938+:108D6000020018210A000CC000C018210A000CB72C
73939+:108D7000240300303C0508008CA53FBC00B0702BDC
73940+:108D800011C0FFA8000000003C19080097393FC43B
73941+:108D90000325C0210307782B11E000072CAA00044B
73942+:108DA0003C0360008C625404305F003F17E0FFE337
73943+:108DB000240400422CAA00041140FF9A240400421B
73944+:108DC0000A000D248FBF00181528FFB9000000000D
73945+:108DD0008CCA00183C1F800024020002015F182585
73946+:108DE000ACC3001837F90A00A0C200689329003C00
73947+:108DF0002404000400A01021312800203C010800B8
73948+:108E0000A0244019110000022405001024020001D2
73949+:108E10003C010800AC223FB40A000D1A3C0280005D
73950+:108E20008F8800288C8900600109282B14A000027B
73951+:108E3000010088218C9100603C048000348B0E007E
73952+:108E40008D640018240A000102202821022030210C
73953+:108E5000A38A001C0E000B83022080210A000CA6AE
73954+:108E6000AF82002C00045823122000073164000355
73955+:108E70003C0E800035C7098090ED007C31AC0004C9
73956+:108E800015800019248F00043C010800A4243FDA57
73957+:108E90003C1F080097FF3FDA03E5C82100D9C02B2B
73958+:108EA0001300FF6B8F8400242CA6000514C0FFA3C1
73959+:108EB0002404004230A200031440000200A2182340
73960+:108EC00024A3FFFC3C010800AC233FBC3C0108008C
73961+:108ED000A4203FDA0A000CE70060282100C77024B4
73962+:108EE0000A000D0D01C720263C010800A42F3FDA1F
73963+:108EF0000A000D78000000003C010800AC203FBCD7
73964+:108F00000A000D23240400428F8300283C058000C2
73965+:108F100034AA0A00146000060000102191470030B6
73966+:108F20002406000530E400FF108600030000000066
73967+:108F300003E0000800000000914B0048316900FF89
73968+:108F4000000941C21500FFFA3C0680083C040800F5
73969+:108F500094843FC43C0308008C633FDC3C19080048
73970+:108F60008F393FBC3C0F080095EF3FDA0064C02109
73971+:108F70008CCD00040319702101CF602134AB0E00A9
73972+:108F8000018D282318A0001D00000000914F004C07
73973+:108F90008F8C0034956D001031EE00FF8D89000438
73974+:108FA00001AE30238D8A000030CEFFFF000E290075
73975+:108FB0000125C82100003821014720210325182B55
73976+:108FC0000083C021AD990004AD980000918F000A84
73977+:108FD00001CF6821A18D000A956500128F8A0034A7
73978+:108FE000A5450008954B003825690001A5490038C2
73979+:108FF0009148000D35070008A147000D03E0000867
73980+:109000000000000027BDFFD8AFB000189388001CF7
73981+:109010008FB000143C0A80003C197FFF8F8700242A
73982+:109020003738FFFFAFBF0020AFB1001C355F0A002B
73983+:109030000218182493EB003C00087FC03C02BFFFDD
73984+:10904000006F60252CF000013449FFFF3C1F080031
73985+:109050008FFF3FDC8F9900303C18080097183FD2F3
73986+:1090600001897824001047803C07EFFF3C05F0FFA2
73987+:1090700001E818253C1180003169002034E2FFFF2F
73988+:1090800034ADFFFF362E098027A50010240600020C
73989+:1090900003F96023270B0002354A0E0000621824F2
73990+:1090A0000080802115200002000040218D48001C16
73991+:1090B000A7AB0012058000392407000030E800FF4C
73992+:1090C00000083F00006758253C028008AFAB001441
73993+:1090D000344F008091EA00683C08080091083FD9AD
73994+:1090E0003C09DFFF352CFFFF000AF82B3C0208008B
73995+:1090F00094423FCCA3A80011016CC024001FCF40B4
73996+:10910000031918258FA70010AFA300143C0C08000A
73997+:10911000918C3FDBA7A200168FAB001400ED482412
73998+:109120003C0F01003C0A0FFF012FC82531980003B6
73999+:10913000355FFFFF016D40243C027000033F38247F
74000+:1091400000181E0000E2482501037825AFAF001487
74001+:10915000AFA9001091CC007C0E000092A3AC0015CA
74002+:10916000362D0A0091A6003C30C400201080000675
74003+:10917000260200083C11080096313FC8262EFFFF4A
74004+:109180003C010800A42E3FC88FBF00208FB1001CF7
74005+:109190008FB0001803E0000827BD00288F8B002C3B
74006+:1091A000010B502B5540FFC5240700010A000E0497
74007+:1091B00030E800FF9383001C3C02800027BDFFD8ED
74008+:1091C00034480A0000805021AFBF002034460AC056
74009+:1091D000010028211060000E3444098091070030FE
74010+:1091E000240B00058F89002030EC003F118B000B11
74011+:1091F00000003821AFA900103C0B80088D69006C7D
74012+:10920000AFAA00180E00015AAFA90014A380001CD9
74013+:109210008FBF002003E0000827BD00288D1F0048F5
74014+:109220003C1808008F183FBC8F9900283C027FFF34
74015+:109230008D0800443443FFFFAFA900103C0B8008A9
74016+:109240008D69006C03E370240319782101CF682332
74017+:1092500001A83821AFAA00180E00015AAFA90014C6
74018+:109260000A000E58A380001C3C05800034A60A00AA
74019+:1092700090C7003C3C06080094C63FDA3C02080058
74020+:109280008C423FD430E30020000624001060001E12
74021+:10929000004438253C0880083505008090A300680C
74022+:1092A00000004821240800010000282124040001B6
74023+:1092B0003C0680008CCD017805A0FFFE34CF014034
74024+:1092C000ADE800083C0208008C423FDCA5E5000444
74025+:1092D000A5E40006ADE2000C3C04080090843FD9F0
74026+:1092E0003C03800834790080A1E40012ADE700144B
74027+:1092F000A5E900189338004C3C0E1000A1F8002D91
74028+:1093000003E00008ACCE017834A90E008D28001CC3
74029+:109310003C0C08008D8C3FBC952B0016952A001440
74030+:10932000018648213164FFFF0A000E803145FFFFAE
74031+:109330003C04800034830A009065003C30A2002089
74032+:109340001040001934870E00000040210000382131
74033+:10935000000020213C0680008CC901780520FFFE1A
74034+:1093600034CA014034CF010091EB0009AD48000838
74035+:109370003C0E08008DCE3FDC240DFF91240C0040F4
74036+:109380003C081000A5440004A5470006AD4E000CA3
74037+:10939000A14D0012AD4C0014A5400018A14B002DAA
74038+:1093A00003E00008ACC801788CE8001894E60012CD
74039+:1093B00094E4001030C7FFFF0A000EA93084FFFFBD
74040+:1093C0003C04800034830A009065003C30A20020F9
74041+:1093D0001040002727BDFFF82409000100003821B4
74042+:1093E000240800013C0680008CCA01780540FFFE7D
74043+:1093F0003C0280FF34C40100908D00093C0C080041
74044+:10940000918C4019A3AD00038FAB00003185007F24
74045+:109410003459FFFF01665025AFAA00009083000A6F
74046+:10942000A3A0000200057E00A3A300018FB80000E6
74047+:1094300034CB0140240C30000319702401CF68257F
74048+:10944000AD6D000C27BD0008AD6C0014A5600018C0
74049+:10945000AD690008A56700042409FF80A56800061F
74050+:109460003C081000A169001203E00008ACC80178B4
74051+:1094700034870E008CE9001894E6001294E4001082
74052+:1094800030C8FFFF0A000ECD3087FFFF27BDFFE089
74053+:10949000AFB100143C118000AFB00010AFBF001896
74054+:1094A00036380A00970F0032363001000E000B7F6D
74055+:1094B00031E43FFF8E0E0000240DFF803C042000AD
74056+:1094C00001C25821016D6024000C4940316A007FBF
74057+:1094D000012A4025010438253C048008AE270830C5
74058+:1094E0003486008090C500682403000230A200FF8B
74059+:1094F000104300048F9F00208F990024AC9F0068C8
74060+:10950000AC9900648FBF00188FB100148FB00010A9
74061+:1095100003E0000827BD00203C0A0800254A3A80E5
74062+:109520003C09080025293B103C08080025082F1C91
74063+:109530003C07080024E73BDC3C06080024C639044D
74064+:109540003C05080024A536583C0408002484325CFD
74065+:109550003C030800246339B83C0208002442375415
74066+:109560003C010800AC2A3F983C010800AC293F941C
74067+:109570003C010800AC283F903C010800AC273F9C10
74068+:109580003C010800AC263FAC3C010800AC253FA4E0
74069+:109590003C010800AC243FA03C010800AC233FB0D4
74070+:1095A0003C010800AC223FA803E0000800000000D6
74071+:1095B00080000940800009008008010080080080C8
74072+:1095C00080080000800E00008008008080080000F5
74073+:1095D00080000A8080000A00800009808000090065
74074+:00000001FF
74075diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
74076index 2d0cbbd..a6d6149 100644
74077--- a/fs/Kconfig.binfmt
74078+++ b/fs/Kconfig.binfmt
74079@@ -103,7 +103,7 @@ config HAVE_AOUT
74080
74081 config BINFMT_AOUT
74082 tristate "Kernel support for a.out and ECOFF binaries"
74083- depends on HAVE_AOUT
74084+ depends on HAVE_AOUT && BROKEN
74085 ---help---
74086 A.out (Assembler.OUTput) is a set of formats for libraries and
74087 executables used in the earliest versions of UNIX. Linux used
74088diff --git a/fs/afs/inode.c b/fs/afs/inode.c
74089index e06f5a2..81d07ac 100644
74090--- a/fs/afs/inode.c
74091+++ b/fs/afs/inode.c
74092@@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
74093 struct afs_vnode *vnode;
74094 struct super_block *sb;
74095 struct inode *inode;
74096- static atomic_t afs_autocell_ino;
74097+ static atomic_unchecked_t afs_autocell_ino;
74098
74099 _enter("{%x:%u},%*.*s,",
74100 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
74101@@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
74102 data.fid.unique = 0;
74103 data.fid.vnode = 0;
74104
74105- inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
74106+ inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
74107 afs_iget5_autocell_test, afs_iget5_set,
74108 &data);
74109 if (!inode) {
74110diff --git a/fs/aio.c b/fs/aio.c
74111index 480440f..623fd88 100644
74112--- a/fs/aio.c
74113+++ b/fs/aio.c
74114@@ -441,7 +441,7 @@ static int aio_setup_ring(struct kioctx *ctx)
74115 size += sizeof(struct io_event) * nr_events;
74116
74117 nr_pages = PFN_UP(size);
74118- if (nr_pages < 0)
74119+ if (nr_pages <= 0)
74120 return -EINVAL;
74121
74122 file = aio_private_file(ctx, nr_pages);
74123diff --git a/fs/attr.c b/fs/attr.c
74124index 6530ced..4a827e2 100644
74125--- a/fs/attr.c
74126+++ b/fs/attr.c
74127@@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
74128 unsigned long limit;
74129
74130 limit = rlimit(RLIMIT_FSIZE);
74131+ gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
74132 if (limit != RLIM_INFINITY && offset > limit)
74133 goto out_sig;
74134 if (offset > inode->i_sb->s_maxbytes)
74135diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
74136index 35b755e..f4b9e0a 100644
74137--- a/fs/autofs4/waitq.c
74138+++ b/fs/autofs4/waitq.c
74139@@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
74140 {
74141 unsigned long sigpipe, flags;
74142 mm_segment_t fs;
74143- const char *data = (const char *)addr;
74144+ const char __user *data = (const char __force_user *)addr;
74145 ssize_t wr = 0;
74146
74147 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
74148@@ -340,6 +340,10 @@ static int validate_request(struct autofs_wait_queue **wait,
74149 return 1;
74150 }
74151
74152+#ifdef CONFIG_GRKERNSEC_HIDESYM
74153+static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
74154+#endif
74155+
74156 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
74157 enum autofs_notify notify)
74158 {
74159@@ -385,7 +389,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
74160
74161 /* If this is a direct mount request create a dummy name */
74162 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
74163+#ifdef CONFIG_GRKERNSEC_HIDESYM
74164+ /* this name does get written to userland via autofs4_write() */
74165+ qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
74166+#else
74167 qstr.len = sprintf(name, "%p", dentry);
74168+#endif
74169 else {
74170 qstr.len = autofs4_getpath(sbi, dentry, &name);
74171 if (!qstr.len) {
74172diff --git a/fs/befs/endian.h b/fs/befs/endian.h
74173index 2722387..56059b5 100644
74174--- a/fs/befs/endian.h
74175+++ b/fs/befs/endian.h
74176@@ -11,7 +11,7 @@
74177
74178 #include <asm/byteorder.h>
74179
74180-static inline u64
74181+static inline u64 __intentional_overflow(-1)
74182 fs64_to_cpu(const struct super_block *sb, fs64 n)
74183 {
74184 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
74185@@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
74186 return (__force fs64)cpu_to_be64(n);
74187 }
74188
74189-static inline u32
74190+static inline u32 __intentional_overflow(-1)
74191 fs32_to_cpu(const struct super_block *sb, fs32 n)
74192 {
74193 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
74194@@ -47,7 +47,7 @@ cpu_to_fs32(const struct super_block *sb, u32 n)
74195 return (__force fs32)cpu_to_be32(n);
74196 }
74197
74198-static inline u16
74199+static inline u16 __intentional_overflow(-1)
74200 fs16_to_cpu(const struct super_block *sb, fs16 n)
74201 {
74202 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
74203diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
74204index 4c55668..eeae150 100644
74205--- a/fs/binfmt_aout.c
74206+++ b/fs/binfmt_aout.c
74207@@ -16,6 +16,7 @@
74208 #include <linux/string.h>
74209 #include <linux/fs.h>
74210 #include <linux/file.h>
74211+#include <linux/security.h>
74212 #include <linux/stat.h>
74213 #include <linux/fcntl.h>
74214 #include <linux/ptrace.h>
74215@@ -58,6 +59,8 @@ static int aout_core_dump(struct coredump_params *cprm)
74216 #endif
74217 # define START_STACK(u) ((void __user *)u.start_stack)
74218
74219+ memset(&dump, 0, sizeof(dump));
74220+
74221 fs = get_fs();
74222 set_fs(KERNEL_DS);
74223 has_dumped = 1;
74224@@ -68,10 +71,12 @@ static int aout_core_dump(struct coredump_params *cprm)
74225
74226 /* If the size of the dump file exceeds the rlimit, then see what would happen
74227 if we wrote the stack, but not the data area. */
74228+ gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
74229 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
74230 dump.u_dsize = 0;
74231
74232 /* Make sure we have enough room to write the stack and data areas. */
74233+ gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
74234 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
74235 dump.u_ssize = 0;
74236
74237@@ -232,6 +237,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
74238 rlim = rlimit(RLIMIT_DATA);
74239 if (rlim >= RLIM_INFINITY)
74240 rlim = ~0;
74241+
74242+ gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
74243 if (ex.a_data + ex.a_bss > rlim)
74244 return -ENOMEM;
74245
74246@@ -261,6 +268,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
74247
74248 install_exec_creds(bprm);
74249
74250+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
74251+ current->mm->pax_flags = 0UL;
74252+#endif
74253+
74254+#ifdef CONFIG_PAX_PAGEEXEC
74255+ if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
74256+ current->mm->pax_flags |= MF_PAX_PAGEEXEC;
74257+
74258+#ifdef CONFIG_PAX_EMUTRAMP
74259+ if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
74260+ current->mm->pax_flags |= MF_PAX_EMUTRAMP;
74261+#endif
74262+
74263+#ifdef CONFIG_PAX_MPROTECT
74264+ if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
74265+ current->mm->pax_flags |= MF_PAX_MPROTECT;
74266+#endif
74267+
74268+ }
74269+#endif
74270+
74271 if (N_MAGIC(ex) == OMAGIC) {
74272 unsigned long text_addr, map_size;
74273 loff_t pos;
74274@@ -312,7 +340,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
74275 return error;
74276
74277 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
74278- PROT_READ | PROT_WRITE | PROT_EXEC,
74279+ PROT_READ | PROT_WRITE,
74280 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
74281 fd_offset + ex.a_text);
74282 if (error != N_DATADDR(ex))
74283diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
74284index 6b65996..17bd3c4 100644
74285--- a/fs/binfmt_elf.c
74286+++ b/fs/binfmt_elf.c
74287@@ -35,6 +35,7 @@
74288 #include <linux/utsname.h>
74289 #include <linux/coredump.h>
74290 #include <linux/sched.h>
74291+#include <linux/xattr.h>
74292 #include <asm/uaccess.h>
74293 #include <asm/param.h>
74294 #include <asm/page.h>
74295@@ -66,6 +67,14 @@ static int elf_core_dump(struct coredump_params *cprm);
74296 #define elf_core_dump NULL
74297 #endif
74298
74299+#ifdef CONFIG_PAX_MPROTECT
74300+static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
74301+#endif
74302+
74303+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
74304+static void elf_handle_mmap(struct file *file);
74305+#endif
74306+
74307 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
74308 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
74309 #else
74310@@ -85,6 +94,15 @@ static struct linux_binfmt elf_format = {
74311 .load_binary = load_elf_binary,
74312 .load_shlib = load_elf_library,
74313 .core_dump = elf_core_dump,
74314+
74315+#ifdef CONFIG_PAX_MPROTECT
74316+ .handle_mprotect= elf_handle_mprotect,
74317+#endif
74318+
74319+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
74320+ .handle_mmap = elf_handle_mmap,
74321+#endif
74322+
74323 .min_coredump = ELF_EXEC_PAGESIZE,
74324 };
74325
74326@@ -92,6 +110,8 @@ static struct linux_binfmt elf_format = {
74327
74328 static int set_brk(unsigned long start, unsigned long end)
74329 {
74330+ unsigned long e = end;
74331+
74332 start = ELF_PAGEALIGN(start);
74333 end = ELF_PAGEALIGN(end);
74334 if (end > start) {
74335@@ -100,7 +120,7 @@ static int set_brk(unsigned long start, unsigned long end)
74336 if (BAD_ADDR(addr))
74337 return addr;
74338 }
74339- current->mm->start_brk = current->mm->brk = end;
74340+ current->mm->start_brk = current->mm->brk = e;
74341 return 0;
74342 }
74343
74344@@ -161,12 +181,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
74345 elf_addr_t __user *u_rand_bytes;
74346 const char *k_platform = ELF_PLATFORM;
74347 const char *k_base_platform = ELF_BASE_PLATFORM;
74348- unsigned char k_rand_bytes[16];
74349+ u32 k_rand_bytes[4];
74350 int items;
74351 elf_addr_t *elf_info;
74352 int ei_index = 0;
74353 const struct cred *cred = current_cred();
74354 struct vm_area_struct *vma;
74355+ unsigned long saved_auxv[AT_VECTOR_SIZE];
74356
74357 /*
74358 * In some cases (e.g. Hyper-Threading), we want to avoid L1
74359@@ -208,8 +229,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
74360 * Generate 16 random bytes for userspace PRNG seeding.
74361 */
74362 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
74363- u_rand_bytes = (elf_addr_t __user *)
74364- STACK_ALLOC(p, sizeof(k_rand_bytes));
74365+ prandom_seed(k_rand_bytes[0] ^ prandom_u32());
74366+ prandom_seed(k_rand_bytes[1] ^ prandom_u32());
74367+ prandom_seed(k_rand_bytes[2] ^ prandom_u32());
74368+ prandom_seed(k_rand_bytes[3] ^ prandom_u32());
74369+ p = STACK_ROUND(p, sizeof(k_rand_bytes));
74370+ u_rand_bytes = (elf_addr_t __user *) p;
74371 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
74372 return -EFAULT;
74373
74374@@ -324,9 +349,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
74375 return -EFAULT;
74376 current->mm->env_end = p;
74377
74378+ memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
74379+
74380 /* Put the elf_info on the stack in the right place. */
74381 sp = (elf_addr_t __user *)envp + 1;
74382- if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
74383+ if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
74384 return -EFAULT;
74385 return 0;
74386 }
74387@@ -515,14 +542,14 @@ static inline int arch_check_elf(struct elfhdr *ehdr, bool has_interp,
74388 an ELF header */
74389
74390 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74391- struct file *interpreter, unsigned long *interp_map_addr,
74392+ struct file *interpreter,
74393 unsigned long no_base, struct elf_phdr *interp_elf_phdata)
74394 {
74395 struct elf_phdr *eppnt;
74396- unsigned long load_addr = 0;
74397+ unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
74398 int load_addr_set = 0;
74399 unsigned long last_bss = 0, elf_bss = 0;
74400- unsigned long error = ~0UL;
74401+ unsigned long error = -EINVAL;
74402 unsigned long total_size;
74403 int i;
74404
74405@@ -542,6 +569,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74406 goto out;
74407 }
74408
74409+#ifdef CONFIG_PAX_SEGMEXEC
74410+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
74411+ pax_task_size = SEGMEXEC_TASK_SIZE;
74412+#endif
74413+
74414 eppnt = interp_elf_phdata;
74415 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
74416 if (eppnt->p_type == PT_LOAD) {
74417@@ -565,8 +597,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74418 map_addr = elf_map(interpreter, load_addr + vaddr,
74419 eppnt, elf_prot, elf_type, total_size);
74420 total_size = 0;
74421- if (!*interp_map_addr)
74422- *interp_map_addr = map_addr;
74423 error = map_addr;
74424 if (BAD_ADDR(map_addr))
74425 goto out;
74426@@ -585,8 +615,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74427 k = load_addr + eppnt->p_vaddr;
74428 if (BAD_ADDR(k) ||
74429 eppnt->p_filesz > eppnt->p_memsz ||
74430- eppnt->p_memsz > TASK_SIZE ||
74431- TASK_SIZE - eppnt->p_memsz < k) {
74432+ eppnt->p_memsz > pax_task_size ||
74433+ pax_task_size - eppnt->p_memsz < k) {
74434 error = -ENOMEM;
74435 goto out;
74436 }
74437@@ -625,9 +655,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74438 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
74439
74440 /* Map the last of the bss segment */
74441- error = vm_brk(elf_bss, last_bss - elf_bss);
74442- if (BAD_ADDR(error))
74443- goto out;
74444+ if (last_bss > elf_bss) {
74445+ error = vm_brk(elf_bss, last_bss - elf_bss);
74446+ if (BAD_ADDR(error))
74447+ goto out;
74448+ }
74449 }
74450
74451 error = load_addr;
74452@@ -635,6 +667,336 @@ out:
74453 return error;
74454 }
74455
74456+#ifdef CONFIG_PAX_PT_PAX_FLAGS
74457+#ifdef CONFIG_PAX_SOFTMODE
74458+static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
74459+{
74460+ unsigned long pax_flags = 0UL;
74461+
74462+#ifdef CONFIG_PAX_PAGEEXEC
74463+ if (elf_phdata->p_flags & PF_PAGEEXEC)
74464+ pax_flags |= MF_PAX_PAGEEXEC;
74465+#endif
74466+
74467+#ifdef CONFIG_PAX_SEGMEXEC
74468+ if (elf_phdata->p_flags & PF_SEGMEXEC)
74469+ pax_flags |= MF_PAX_SEGMEXEC;
74470+#endif
74471+
74472+#ifdef CONFIG_PAX_EMUTRAMP
74473+ if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
74474+ pax_flags |= MF_PAX_EMUTRAMP;
74475+#endif
74476+
74477+#ifdef CONFIG_PAX_MPROTECT
74478+ if (elf_phdata->p_flags & PF_MPROTECT)
74479+ pax_flags |= MF_PAX_MPROTECT;
74480+#endif
74481+
74482+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
74483+ if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
74484+ pax_flags |= MF_PAX_RANDMMAP;
74485+#endif
74486+
74487+ return pax_flags;
74488+}
74489+#endif
74490+
74491+static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
74492+{
74493+ unsigned long pax_flags = 0UL;
74494+
74495+#ifdef CONFIG_PAX_PAGEEXEC
74496+ if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
74497+ pax_flags |= MF_PAX_PAGEEXEC;
74498+#endif
74499+
74500+#ifdef CONFIG_PAX_SEGMEXEC
74501+ if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
74502+ pax_flags |= MF_PAX_SEGMEXEC;
74503+#endif
74504+
74505+#ifdef CONFIG_PAX_EMUTRAMP
74506+ if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
74507+ pax_flags |= MF_PAX_EMUTRAMP;
74508+#endif
74509+
74510+#ifdef CONFIG_PAX_MPROTECT
74511+ if (!(elf_phdata->p_flags & PF_NOMPROTECT))
74512+ pax_flags |= MF_PAX_MPROTECT;
74513+#endif
74514+
74515+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
74516+ if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
74517+ pax_flags |= MF_PAX_RANDMMAP;
74518+#endif
74519+
74520+ return pax_flags;
74521+}
74522+#endif
74523+
74524+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
74525+#ifdef CONFIG_PAX_SOFTMODE
74526+static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
74527+{
74528+ unsigned long pax_flags = 0UL;
74529+
74530+#ifdef CONFIG_PAX_PAGEEXEC
74531+ if (pax_flags_softmode & MF_PAX_PAGEEXEC)
74532+ pax_flags |= MF_PAX_PAGEEXEC;
74533+#endif
74534+
74535+#ifdef CONFIG_PAX_SEGMEXEC
74536+ if (pax_flags_softmode & MF_PAX_SEGMEXEC)
74537+ pax_flags |= MF_PAX_SEGMEXEC;
74538+#endif
74539+
74540+#ifdef CONFIG_PAX_EMUTRAMP
74541+ if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
74542+ pax_flags |= MF_PAX_EMUTRAMP;
74543+#endif
74544+
74545+#ifdef CONFIG_PAX_MPROTECT
74546+ if (pax_flags_softmode & MF_PAX_MPROTECT)
74547+ pax_flags |= MF_PAX_MPROTECT;
74548+#endif
74549+
74550+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
74551+ if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
74552+ pax_flags |= MF_PAX_RANDMMAP;
74553+#endif
74554+
74555+ return pax_flags;
74556+}
74557+#endif
74558+
74559+static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
74560+{
74561+ unsigned long pax_flags = 0UL;
74562+
74563+#ifdef CONFIG_PAX_PAGEEXEC
74564+ if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
74565+ pax_flags |= MF_PAX_PAGEEXEC;
74566+#endif
74567+
74568+#ifdef CONFIG_PAX_SEGMEXEC
74569+ if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
74570+ pax_flags |= MF_PAX_SEGMEXEC;
74571+#endif
74572+
74573+#ifdef CONFIG_PAX_EMUTRAMP
74574+ if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
74575+ pax_flags |= MF_PAX_EMUTRAMP;
74576+#endif
74577+
74578+#ifdef CONFIG_PAX_MPROTECT
74579+ if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
74580+ pax_flags |= MF_PAX_MPROTECT;
74581+#endif
74582+
74583+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
74584+ if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
74585+ pax_flags |= MF_PAX_RANDMMAP;
74586+#endif
74587+
74588+ return pax_flags;
74589+}
74590+#endif
74591+
74592+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
74593+static unsigned long pax_parse_defaults(void)
74594+{
74595+ unsigned long pax_flags = 0UL;
74596+
74597+#ifdef CONFIG_PAX_SOFTMODE
74598+ if (pax_softmode)
74599+ return pax_flags;
74600+#endif
74601+
74602+#ifdef CONFIG_PAX_PAGEEXEC
74603+ pax_flags |= MF_PAX_PAGEEXEC;
74604+#endif
74605+
74606+#ifdef CONFIG_PAX_SEGMEXEC
74607+ pax_flags |= MF_PAX_SEGMEXEC;
74608+#endif
74609+
74610+#ifdef CONFIG_PAX_MPROTECT
74611+ pax_flags |= MF_PAX_MPROTECT;
74612+#endif
74613+
74614+#ifdef CONFIG_PAX_RANDMMAP
74615+ if (randomize_va_space)
74616+ pax_flags |= MF_PAX_RANDMMAP;
74617+#endif
74618+
74619+ return pax_flags;
74620+}
74621+
74622+static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
74623+{
74624+ unsigned long pax_flags = PAX_PARSE_FLAGS_FALLBACK;
74625+
74626+#ifdef CONFIG_PAX_EI_PAX
74627+
74628+#ifdef CONFIG_PAX_SOFTMODE
74629+ if (pax_softmode)
74630+ return pax_flags;
74631+#endif
74632+
74633+ pax_flags = 0UL;
74634+
74635+#ifdef CONFIG_PAX_PAGEEXEC
74636+ if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
74637+ pax_flags |= MF_PAX_PAGEEXEC;
74638+#endif
74639+
74640+#ifdef CONFIG_PAX_SEGMEXEC
74641+ if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
74642+ pax_flags |= MF_PAX_SEGMEXEC;
74643+#endif
74644+
74645+#ifdef CONFIG_PAX_EMUTRAMP
74646+ if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
74647+ pax_flags |= MF_PAX_EMUTRAMP;
74648+#endif
74649+
74650+#ifdef CONFIG_PAX_MPROTECT
74651+ if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
74652+ pax_flags |= MF_PAX_MPROTECT;
74653+#endif
74654+
74655+#ifdef CONFIG_PAX_ASLR
74656+ if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
74657+ pax_flags |= MF_PAX_RANDMMAP;
74658+#endif
74659+
74660+#endif
74661+
74662+ return pax_flags;
74663+
74664+}
74665+
74666+static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
74667+{
74668+
74669+#ifdef CONFIG_PAX_PT_PAX_FLAGS
74670+ unsigned long i;
74671+
74672+ for (i = 0UL; i < elf_ex->e_phnum; i++)
74673+ if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
74674+ if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
74675+ ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
74676+ ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
74677+ ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
74678+ ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
74679+ return PAX_PARSE_FLAGS_FALLBACK;
74680+
74681+#ifdef CONFIG_PAX_SOFTMODE
74682+ if (pax_softmode)
74683+ return pax_parse_pt_pax_softmode(&elf_phdata[i]);
74684+ else
74685+#endif
74686+
74687+ return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
74688+ break;
74689+ }
74690+#endif
74691+
74692+ return PAX_PARSE_FLAGS_FALLBACK;
74693+}
74694+
74695+static unsigned long pax_parse_xattr_pax(struct file * const file)
74696+{
74697+
74698+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
74699+ ssize_t xattr_size, i;
74700+ unsigned char xattr_value[sizeof("pemrs") - 1];
74701+ unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
74702+
74703+ xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
74704+ if (xattr_size < 0 || xattr_size > sizeof xattr_value)
74705+ return PAX_PARSE_FLAGS_FALLBACK;
74706+
74707+ for (i = 0; i < xattr_size; i++)
74708+ switch (xattr_value[i]) {
74709+ default:
74710+ return PAX_PARSE_FLAGS_FALLBACK;
74711+
74712+#define parse_flag(option1, option2, flag) \
74713+ case option1: \
74714+ if (pax_flags_hardmode & MF_PAX_##flag) \
74715+ return PAX_PARSE_FLAGS_FALLBACK;\
74716+ pax_flags_hardmode |= MF_PAX_##flag; \
74717+ break; \
74718+ case option2: \
74719+ if (pax_flags_softmode & MF_PAX_##flag) \
74720+ return PAX_PARSE_FLAGS_FALLBACK;\
74721+ pax_flags_softmode |= MF_PAX_##flag; \
74722+ break;
74723+
74724+ parse_flag('p', 'P', PAGEEXEC);
74725+ parse_flag('e', 'E', EMUTRAMP);
74726+ parse_flag('m', 'M', MPROTECT);
74727+ parse_flag('r', 'R', RANDMMAP);
74728+ parse_flag('s', 'S', SEGMEXEC);
74729+
74730+#undef parse_flag
74731+ }
74732+
74733+ if (pax_flags_hardmode & pax_flags_softmode)
74734+ return PAX_PARSE_FLAGS_FALLBACK;
74735+
74736+#ifdef CONFIG_PAX_SOFTMODE
74737+ if (pax_softmode)
74738+ return pax_parse_xattr_pax_softmode(pax_flags_softmode);
74739+ else
74740+#endif
74741+
74742+ return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
74743+#else
74744+ return PAX_PARSE_FLAGS_FALLBACK;
74745+#endif
74746+
74747+}
74748+
74749+static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
74750+{
74751+ unsigned long pax_flags, ei_pax_flags, pt_pax_flags, xattr_pax_flags;
74752+
74753+ pax_flags = pax_parse_defaults();
74754+ ei_pax_flags = pax_parse_ei_pax(elf_ex);
74755+ pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
74756+ xattr_pax_flags = pax_parse_xattr_pax(file);
74757+
74758+ if (pt_pax_flags != PAX_PARSE_FLAGS_FALLBACK &&
74759+ xattr_pax_flags != PAX_PARSE_FLAGS_FALLBACK &&
74760+ pt_pax_flags != xattr_pax_flags)
74761+ return -EINVAL;
74762+ if (xattr_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
74763+ pax_flags = xattr_pax_flags;
74764+ else if (pt_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
74765+ pax_flags = pt_pax_flags;
74766+ else if (ei_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
74767+ pax_flags = ei_pax_flags;
74768+
74769+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
74770+ if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
74771+ if ((__supported_pte_mask & _PAGE_NX))
74772+ pax_flags &= ~MF_PAX_SEGMEXEC;
74773+ else
74774+ pax_flags &= ~MF_PAX_PAGEEXEC;
74775+ }
74776+#endif
74777+
74778+ if (0 > pax_check_flags(&pax_flags))
74779+ return -EINVAL;
74780+
74781+ current->mm->pax_flags = pax_flags;
74782+ return 0;
74783+}
74784+#endif
74785+
74786 /*
74787 * These are the functions used to load ELF style executables and shared
74788 * libraries. There is no binary dependent code anywhere else.
74789@@ -648,6 +1010,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
74790 {
74791 unsigned long random_variable = 0;
74792
74793+#ifdef CONFIG_PAX_RANDUSTACK
74794+ if (current->mm->pax_flags & MF_PAX_RANDMMAP)
74795+ return stack_top - current->mm->delta_stack;
74796+#endif
74797+
74798 if ((current->flags & PF_RANDOMIZE) &&
74799 !(current->personality & ADDR_NO_RANDOMIZE)) {
74800 random_variable = (unsigned long) get_random_int();
74801@@ -667,7 +1034,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
74802 unsigned long load_addr = 0, load_bias = 0;
74803 int load_addr_set = 0;
74804 char * elf_interpreter = NULL;
74805- unsigned long error;
74806+ unsigned long error = 0;
74807 struct elf_phdr *elf_ppnt, *elf_phdata, *interp_elf_phdata = NULL;
74808 unsigned long elf_bss, elf_brk;
74809 int retval, i;
74810@@ -682,6 +1049,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
74811 struct elfhdr interp_elf_ex;
74812 } *loc;
74813 struct arch_elf_state arch_state = INIT_ARCH_ELF_STATE;
74814+ unsigned long pax_task_size;
74815
74816 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
74817 if (!loc) {
74818@@ -840,6 +1208,77 @@ static int load_elf_binary(struct linux_binprm *bprm)
74819 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
74820 may depend on the personality. */
74821 SET_PERSONALITY2(loc->elf_ex, &arch_state);
74822+
74823+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
74824+ current->mm->pax_flags = 0UL;
74825+#endif
74826+
74827+#ifdef CONFIG_PAX_DLRESOLVE
74828+ current->mm->call_dl_resolve = 0UL;
74829+#endif
74830+
74831+#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
74832+ current->mm->call_syscall = 0UL;
74833+#endif
74834+
74835+#ifdef CONFIG_PAX_ASLR
74836+ current->mm->delta_mmap = 0UL;
74837+ current->mm->delta_stack = 0UL;
74838+#endif
74839+
74840+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
74841+ if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
74842+ retval = -EINVAL;
74843+ goto out_free_dentry;
74844+ }
74845+#endif
74846+
74847+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
74848+ pax_set_initial_flags(bprm);
74849+#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
74850+ if (pax_set_initial_flags_func)
74851+ (pax_set_initial_flags_func)(bprm);
74852+#endif
74853+
74854+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
74855+ if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
74856+ current->mm->context.user_cs_limit = PAGE_SIZE;
74857+ current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
74858+ }
74859+#endif
74860+
74861+#ifdef CONFIG_PAX_SEGMEXEC
74862+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
74863+ current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
74864+ current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
74865+ pax_task_size = SEGMEXEC_TASK_SIZE;
74866+ current->mm->def_flags |= VM_NOHUGEPAGE;
74867+ } else
74868+#endif
74869+
74870+ pax_task_size = TASK_SIZE;
74871+
74872+#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
74873+ if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
74874+ set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
74875+ put_cpu();
74876+ }
74877+#endif
74878+
74879+#ifdef CONFIG_PAX_ASLR
74880+ if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
74881+ current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
74882+ current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
74883+ }
74884+#endif
74885+
74886+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
74887+ if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
74888+ executable_stack = EXSTACK_DISABLE_X;
74889+ current->personality &= ~READ_IMPLIES_EXEC;
74890+ } else
74891+#endif
74892+
74893 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
74894 current->personality |= READ_IMPLIES_EXEC;
74895
74896@@ -915,8 +1354,21 @@ static int load_elf_binary(struct linux_binprm *bprm)
74897 if (current->flags & PF_RANDOMIZE)
74898 load_bias += arch_mmap_rnd();
74899 load_bias = ELF_PAGESTART(load_bias);
74900- total_size = total_mapping_size(elf_phdata,
74901- loc->elf_ex.e_phnum);
74902+
74903+#ifdef CONFIG_PAX_RANDMMAP
74904+ /* PaX: randomize base address at the default exe base if requested */
74905+ if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
74906+#ifdef CONFIG_SPARC64
74907+ load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
74908+#else
74909+ load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
74910+#endif
74911+ load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
74912+ elf_flags |= MAP_FIXED;
74913+ }
74914+#endif
74915+
74916+ total_size = total_mapping_size(elf_phdata, loc->elf_ex.e_phnum);
74917 if (!total_size) {
74918 retval = -EINVAL;
74919 goto out_free_dentry;
74920@@ -952,9 +1404,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
74921 * allowed task size. Note that p_filesz must always be
74922 * <= p_memsz so it is only necessary to check p_memsz.
74923 */
74924- if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
74925- elf_ppnt->p_memsz > TASK_SIZE ||
74926- TASK_SIZE - elf_ppnt->p_memsz < k) {
74927+ if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
74928+ elf_ppnt->p_memsz > pax_task_size ||
74929+ pax_task_size - elf_ppnt->p_memsz < k) {
74930 /* set_brk can never work. Avoid overflows. */
74931 retval = -EINVAL;
74932 goto out_free_dentry;
74933@@ -990,16 +1442,43 @@ static int load_elf_binary(struct linux_binprm *bprm)
74934 if (retval)
74935 goto out_free_dentry;
74936 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
74937- retval = -EFAULT; /* Nobody gets to see this, but.. */
74938- goto out_free_dentry;
74939+ /*
74940+ * This bss-zeroing can fail if the ELF
74941+ * file specifies odd protections. So
74942+ * we don't check the return value
74943+ */
74944 }
74945
74946+#ifdef CONFIG_PAX_RANDMMAP
74947+ if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
74948+ unsigned long start, size, flags;
74949+ vm_flags_t vm_flags;
74950+
74951+ start = ELF_PAGEALIGN(elf_brk);
74952+ size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
74953+ flags = MAP_FIXED | MAP_PRIVATE;
74954+ vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
74955+
74956+ down_write(&current->mm->mmap_sem);
74957+ start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
74958+ retval = -ENOMEM;
74959+ if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
74960+// if (current->personality & ADDR_NO_RANDOMIZE)
74961+// vm_flags |= VM_READ | VM_MAYREAD;
74962+ start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
74963+ retval = IS_ERR_VALUE(start) ? start : 0;
74964+ }
74965+ up_write(&current->mm->mmap_sem);
74966+ if (retval == 0)
74967+ retval = set_brk(start + size, start + size + PAGE_SIZE);
74968+ if (retval < 0)
74969+ goto out_free_dentry;
74970+ }
74971+#endif
74972+
74973 if (elf_interpreter) {
74974- unsigned long interp_map_addr = 0;
74975-
74976 elf_entry = load_elf_interp(&loc->interp_elf_ex,
74977 interpreter,
74978- &interp_map_addr,
74979 load_bias, interp_elf_phdata);
74980 if (!IS_ERR((void *)elf_entry)) {
74981 /*
74982@@ -1050,6 +1529,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
74983 current->mm->end_data = end_data;
74984 current->mm->start_stack = bprm->p;
74985
74986+#ifndef CONFIG_PAX_RANDMMAP
74987 if ((current->flags & PF_RANDOMIZE) && (randomize_va_space > 1)) {
74988 current->mm->brk = current->mm->start_brk =
74989 arch_randomize_brk(current->mm);
74990@@ -1057,6 +1537,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
74991 current->brk_randomized = 1;
74992 #endif
74993 }
74994+#endif
74995
74996 if (current->personality & MMAP_PAGE_ZERO) {
74997 /* Why this, you ask??? Well SVr4 maps page 0 as read-only,
74998@@ -1225,7 +1706,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
74999 * Decide what to dump of a segment, part, all or none.
75000 */
75001 static unsigned long vma_dump_size(struct vm_area_struct *vma,
75002- unsigned long mm_flags)
75003+ unsigned long mm_flags, long signr)
75004 {
75005 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
75006
75007@@ -1263,7 +1744,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
75008 if (vma->vm_file == NULL)
75009 return 0;
75010
75011- if (FILTER(MAPPED_PRIVATE))
75012+ if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
75013 goto whole;
75014
75015 /*
75016@@ -1363,7 +1844,7 @@ static void fill_elf_header(struct elfhdr *elf, int segs,
75017 return;
75018 }
75019
75020-static void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, loff_t offset)
75021+static void fill_elf_note_phdr(struct elf_phdr *phdr, size_t sz, loff_t offset)
75022 {
75023 phdr->p_type = PT_NOTE;
75024 phdr->p_offset = offset;
75025@@ -1470,9 +1951,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
75026 {
75027 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
75028 int i = 0;
75029- do
75030+ do {
75031 i += 2;
75032- while (auxv[i - 2] != AT_NULL);
75033+ } while (auxv[i - 2] != AT_NULL);
75034 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
75035 }
75036
75037@@ -1481,7 +1962,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
75038 {
75039 mm_segment_t old_fs = get_fs();
75040 set_fs(KERNEL_DS);
75041- copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
75042+ copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
75043 set_fs(old_fs);
75044 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
75045 }
75046@@ -2201,7 +2682,7 @@ static int elf_core_dump(struct coredump_params *cprm)
75047 vma = next_vma(vma, gate_vma)) {
75048 unsigned long dump_size;
75049
75050- dump_size = vma_dump_size(vma, cprm->mm_flags);
75051+ dump_size = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
75052 vma_filesz[i++] = dump_size;
75053 vma_data_size += dump_size;
75054 }
75055@@ -2309,6 +2790,167 @@ out:
75056
75057 #endif /* CONFIG_ELF_CORE */
75058
75059+#ifdef CONFIG_PAX_MPROTECT
75060+/* PaX: non-PIC ELF libraries need relocations on their executable segments
75061+ * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
75062+ * we'll remove VM_MAYWRITE for good on RELRO segments.
75063+ *
75064+ * The checks favour ld-linux.so behaviour which operates on a per ELF segment
75065+ * basis because we want to allow the common case and not the special ones.
75066+ */
75067+static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
75068+{
75069+ struct elfhdr elf_h;
75070+ struct elf_phdr elf_p;
75071+ unsigned long i;
75072+ unsigned long oldflags;
75073+ bool is_textrel_rw, is_textrel_rx, is_relro;
75074+
75075+ if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
75076+ return;
75077+
75078+ oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
75079+ newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
75080+
75081+#ifdef CONFIG_PAX_ELFRELOCS
75082+ /* possible TEXTREL */
75083+ is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
75084+ is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
75085+#else
75086+ is_textrel_rw = false;
75087+ is_textrel_rx = false;
75088+#endif
75089+
75090+ /* possible RELRO */
75091+ is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
75092+
75093+ if (!is_textrel_rw && !is_textrel_rx && !is_relro)
75094+ return;
75095+
75096+ if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
75097+ memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
75098+
75099+#ifdef CONFIG_PAX_ETEXECRELOCS
75100+ ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
75101+#else
75102+ ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
75103+#endif
75104+
75105+ (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
75106+ !elf_check_arch(&elf_h) ||
75107+ elf_h.e_phentsize != sizeof(struct elf_phdr) ||
75108+ elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
75109+ return;
75110+
75111+ for (i = 0UL; i < elf_h.e_phnum; i++) {
75112+ if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
75113+ return;
75114+ switch (elf_p.p_type) {
75115+ case PT_DYNAMIC:
75116+ if (!is_textrel_rw && !is_textrel_rx)
75117+ continue;
75118+ i = 0UL;
75119+ while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
75120+ elf_dyn dyn;
75121+
75122+ if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
75123+ break;
75124+ if (dyn.d_tag == DT_NULL)
75125+ break;
75126+ if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
75127+ gr_log_textrel(vma, is_textrel_rw);
75128+ if (is_textrel_rw)
75129+ vma->vm_flags |= VM_MAYWRITE;
75130+ else
75131+ /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
75132+ vma->vm_flags &= ~VM_MAYWRITE;
75133+ break;
75134+ }
75135+ i++;
75136+ }
75137+ is_textrel_rw = false;
75138+ is_textrel_rx = false;
75139+ continue;
75140+
75141+ case PT_GNU_RELRO:
75142+ if (!is_relro)
75143+ continue;
75144+ if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
75145+ vma->vm_flags &= ~VM_MAYWRITE;
75146+ is_relro = false;
75147+ continue;
75148+
75149+#ifdef CONFIG_PAX_PT_PAX_FLAGS
75150+ case PT_PAX_FLAGS: {
75151+ const char *msg_mprotect = "", *msg_emutramp = "";
75152+ char *buffer_lib, *buffer_exe;
75153+
75154+ if (elf_p.p_flags & PF_NOMPROTECT)
75155+ msg_mprotect = "MPROTECT disabled";
75156+
75157+#ifdef CONFIG_PAX_EMUTRAMP
75158+ if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
75159+ msg_emutramp = "EMUTRAMP enabled";
75160+#endif
75161+
75162+ if (!msg_mprotect[0] && !msg_emutramp[0])
75163+ continue;
75164+
75165+ if (!printk_ratelimit())
75166+ continue;
75167+
75168+ buffer_lib = (char *)__get_free_page(GFP_KERNEL);
75169+ buffer_exe = (char *)__get_free_page(GFP_KERNEL);
75170+ if (buffer_lib && buffer_exe) {
75171+ char *path_lib, *path_exe;
75172+
75173+ path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
75174+ path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
75175+
75176+ pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
75177+ (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
75178+
75179+ }
75180+ free_page((unsigned long)buffer_exe);
75181+ free_page((unsigned long)buffer_lib);
75182+ continue;
75183+ }
75184+#endif
75185+
75186+ }
75187+ }
75188+}
75189+#endif
75190+
75191+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
75192+
75193+extern int grsec_enable_log_rwxmaps;
75194+
75195+static void elf_handle_mmap(struct file *file)
75196+{
75197+ struct elfhdr elf_h;
75198+ struct elf_phdr elf_p;
75199+ unsigned long i;
75200+
75201+ if (!grsec_enable_log_rwxmaps)
75202+ return;
75203+
75204+ if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
75205+ memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
75206+ (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
75207+ elf_h.e_phentsize != sizeof(struct elf_phdr) ||
75208+ elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
75209+ return;
75210+
75211+ for (i = 0UL; i < elf_h.e_phnum; i++) {
75212+ if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
75213+ return;
75214+ if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
75215+ gr_log_ptgnustack(file);
75216+ }
75217+}
75218+#endif
75219+
75220 static int __init init_elf_binfmt(void)
75221 {
75222 register_binfmt(&elf_format);
75223diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
75224index d3634bf..10fc244 100644
75225--- a/fs/binfmt_elf_fdpic.c
75226+++ b/fs/binfmt_elf_fdpic.c
75227@@ -1296,7 +1296,7 @@ static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs)
75228 return;
75229 }
75230
75231-static inline void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, loff_t offset)
75232+static inline void fill_elf_note_phdr(struct elf_phdr *phdr, size_t sz, loff_t offset)
75233 {
75234 phdr->p_type = PT_NOTE;
75235 phdr->p_offset = offset;
75236@@ -1667,7 +1667,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
75237
75238 /* Write notes phdr entry */
75239 {
75240- int sz = 0;
75241+ size_t sz = 0;
75242
75243 for (i = 0; i < numnote; i++)
75244 sz += notesize(notes + i);
75245diff --git a/fs/block_dev.c b/fs/block_dev.c
75246index 1170f8c..2a8acc1 100644
75247--- a/fs/block_dev.c
75248+++ b/fs/block_dev.c
75249@@ -738,7 +738,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
75250 else if (bdev->bd_contains == bdev)
75251 return true; /* is a whole device which isn't held */
75252
75253- else if (whole->bd_holder == bd_may_claim)
75254+ else if (whole->bd_holder == (void *)bd_may_claim)
75255 return true; /* is a partition of a device that is being partitioned */
75256 else if (whole->bd_holder != NULL)
75257 return false; /* is a partition of a held device */
75258diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
75259index 54114b4..580cfc9 100644
75260--- a/fs/btrfs/ctree.c
75261+++ b/fs/btrfs/ctree.c
75262@@ -1180,9 +1180,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
75263 free_extent_buffer(buf);
75264 add_root_to_dirty_list(root);
75265 } else {
75266- if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
75267- parent_start = parent->start;
75268- else
75269+ if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
75270+ if (parent)
75271+ parent_start = parent->start;
75272+ else
75273+ parent_start = 0;
75274+ } else
75275 parent_start = 0;
75276
75277 WARN_ON(trans->transid != btrfs_header_generation(parent));
75278diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
75279index a2ae427..53c2e98 100644
75280--- a/fs/btrfs/delayed-inode.c
75281+++ b/fs/btrfs/delayed-inode.c
75282@@ -462,7 +462,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
75283
75284 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
75285 {
75286- int seq = atomic_inc_return(&delayed_root->items_seq);
75287+ int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
75288 if ((atomic_dec_return(&delayed_root->items) <
75289 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
75290 waitqueue_active(&delayed_root->wait))
75291@@ -1412,7 +1412,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
75292
75293 static int could_end_wait(struct btrfs_delayed_root *delayed_root, int seq)
75294 {
75295- int val = atomic_read(&delayed_root->items_seq);
75296+ int val = atomic_read_unchecked(&delayed_root->items_seq);
75297
75298 if (val < seq || val >= seq + BTRFS_DELAYED_BATCH)
75299 return 1;
75300@@ -1437,7 +1437,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
75301 int seq;
75302 int ret;
75303
75304- seq = atomic_read(&delayed_root->items_seq);
75305+ seq = atomic_read_unchecked(&delayed_root->items_seq);
75306
75307 ret = btrfs_wq_run_delayed_node(delayed_root, fs_info, 0);
75308 if (ret)
75309diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
75310index f70119f..ab5894d 100644
75311--- a/fs/btrfs/delayed-inode.h
75312+++ b/fs/btrfs/delayed-inode.h
75313@@ -43,7 +43,7 @@ struct btrfs_delayed_root {
75314 */
75315 struct list_head prepare_list;
75316 atomic_t items; /* for delayed items */
75317- atomic_t items_seq; /* for delayed items */
75318+ atomic_unchecked_t items_seq; /* for delayed items */
75319 int nodes; /* for delayed nodes */
75320 wait_queue_head_t wait;
75321 };
75322@@ -90,7 +90,7 @@ static inline void btrfs_init_delayed_root(
75323 struct btrfs_delayed_root *delayed_root)
75324 {
75325 atomic_set(&delayed_root->items, 0);
75326- atomic_set(&delayed_root->items_seq, 0);
75327+ atomic_set_unchecked(&delayed_root->items_seq, 0);
75328 delayed_root->nodes = 0;
75329 spin_lock_init(&delayed_root->lock);
75330 init_waitqueue_head(&delayed_root->wait);
75331diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
75332index cd7ef34..1e31ae3 100644
75333--- a/fs/btrfs/super.c
75334+++ b/fs/btrfs/super.c
75335@@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
75336 function, line, errstr);
75337 return;
75338 }
75339- ACCESS_ONCE(trans->transaction->aborted) = errno;
75340+ ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
75341 /* Wake up anybody who may be waiting on this transaction */
75342 wake_up(&root->fs_info->transaction_wait);
75343 wake_up(&root->fs_info->transaction_blocked_wait);
75344diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
75345index 603b0cc..8e3f600 100644
75346--- a/fs/btrfs/sysfs.c
75347+++ b/fs/btrfs/sysfs.c
75348@@ -481,7 +481,7 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
75349 for (set = 0; set < FEAT_MAX; set++) {
75350 int i;
75351 struct attribute *attrs[2];
75352- struct attribute_group agroup = {
75353+ attribute_group_no_const agroup = {
75354 .name = "features",
75355 .attrs = attrs,
75356 };
75357diff --git a/fs/btrfs/tests/free-space-tests.c b/fs/btrfs/tests/free-space-tests.c
75358index 2299bfd..4098e72 100644
75359--- a/fs/btrfs/tests/free-space-tests.c
75360+++ b/fs/btrfs/tests/free-space-tests.c
75361@@ -463,7 +463,9 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache)
75362 * extent entry.
75363 */
75364 use_bitmap_op = cache->free_space_ctl->op->use_bitmap;
75365- cache->free_space_ctl->op->use_bitmap = test_use_bitmap;
75366+ pax_open_kernel();
75367+ *(void **)&cache->free_space_ctl->op->use_bitmap = test_use_bitmap;
75368+ pax_close_kernel();
75369
75370 /*
75371 * Extent entry covering free space range [128Mb - 256Kb, 128Mb - 128Kb[
75372@@ -870,7 +872,9 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache)
75373 if (ret)
75374 return ret;
75375
75376- cache->free_space_ctl->op->use_bitmap = use_bitmap_op;
75377+ pax_open_kernel();
75378+ *(void **)&cache->free_space_ctl->op->use_bitmap = use_bitmap_op;
75379+ pax_close_kernel();
75380 __btrfs_remove_free_space_cache(cache->free_space_ctl);
75381
75382 return 0;
75383diff --git a/fs/btrfs/tree-log.h b/fs/btrfs/tree-log.h
75384index 6916a78..4598936 100644
75385--- a/fs/btrfs/tree-log.h
75386+++ b/fs/btrfs/tree-log.h
75387@@ -45,7 +45,7 @@ static inline void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx)
75388 static inline void btrfs_set_log_full_commit(struct btrfs_fs_info *fs_info,
75389 struct btrfs_trans_handle *trans)
75390 {
75391- ACCESS_ONCE(fs_info->last_trans_log_full_commit) = trans->transid;
75392+ ACCESS_ONCE_RW(fs_info->last_trans_log_full_commit) = trans->transid;
75393 }
75394
75395 static inline int btrfs_need_log_full_commit(struct btrfs_fs_info *fs_info,
75396diff --git a/fs/buffer.c b/fs/buffer.c
75397index 1cf7a53..b49f8c0 100644
75398--- a/fs/buffer.c
75399+++ b/fs/buffer.c
75400@@ -3440,7 +3440,7 @@ void __init buffer_init(void)
75401 bh_cachep = kmem_cache_create("buffer_head",
75402 sizeof(struct buffer_head), 0,
75403 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
75404- SLAB_MEM_SPREAD),
75405+ SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
75406 NULL);
75407
75408 /*
75409diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
75410index 6af790f..ec4c1e6 100644
75411--- a/fs/cachefiles/bind.c
75412+++ b/fs/cachefiles/bind.c
75413@@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
75414 args);
75415
75416 /* start by checking things over */
75417- ASSERT(cache->fstop_percent >= 0 &&
75418- cache->fstop_percent < cache->fcull_percent &&
75419+ ASSERT(cache->fstop_percent < cache->fcull_percent &&
75420 cache->fcull_percent < cache->frun_percent &&
75421 cache->frun_percent < 100);
75422
75423- ASSERT(cache->bstop_percent >= 0 &&
75424- cache->bstop_percent < cache->bcull_percent &&
75425+ ASSERT(cache->bstop_percent < cache->bcull_percent &&
75426 cache->bcull_percent < cache->brun_percent &&
75427 cache->brun_percent < 100);
75428
75429diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
75430index f601def..b2cf704 100644
75431--- a/fs/cachefiles/daemon.c
75432+++ b/fs/cachefiles/daemon.c
75433@@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
75434 if (n > buflen)
75435 return -EMSGSIZE;
75436
75437- if (copy_to_user(_buffer, buffer, n) != 0)
75438+ if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
75439 return -EFAULT;
75440
75441 return n;
75442@@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
75443 if (test_bit(CACHEFILES_DEAD, &cache->flags))
75444 return -EIO;
75445
75446- if (datalen < 0 || datalen > PAGE_SIZE - 1)
75447+ if (datalen > PAGE_SIZE - 1)
75448 return -EOPNOTSUPP;
75449
75450 /* drag the command string into the kernel so we can parse it */
75451@@ -385,7 +385,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
75452 if (args[0] != '%' || args[1] != '\0')
75453 return -EINVAL;
75454
75455- if (fstop < 0 || fstop >= cache->fcull_percent)
75456+ if (fstop >= cache->fcull_percent)
75457 return cachefiles_daemon_range_error(cache, args);
75458
75459 cache->fstop_percent = fstop;
75460@@ -457,7 +457,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
75461 if (args[0] != '%' || args[1] != '\0')
75462 return -EINVAL;
75463
75464- if (bstop < 0 || bstop >= cache->bcull_percent)
75465+ if (bstop >= cache->bcull_percent)
75466 return cachefiles_daemon_range_error(cache, args);
75467
75468 cache->bstop_percent = bstop;
75469diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
75470index aecd085..3584e2f 100644
75471--- a/fs/cachefiles/internal.h
75472+++ b/fs/cachefiles/internal.h
75473@@ -65,7 +65,7 @@ struct cachefiles_cache {
75474 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
75475 struct rb_root active_nodes; /* active nodes (can't be culled) */
75476 rwlock_t active_lock; /* lock for active_nodes */
75477- atomic_t gravecounter; /* graveyard uniquifier */
75478+ atomic_unchecked_t gravecounter; /* graveyard uniquifier */
75479 unsigned frun_percent; /* when to stop culling (% files) */
75480 unsigned fcull_percent; /* when to start culling (% files) */
75481 unsigned fstop_percent; /* when to stop allocating (% files) */
75482@@ -177,19 +177,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
75483 * proc.c
75484 */
75485 #ifdef CONFIG_CACHEFILES_HISTOGRAM
75486-extern atomic_t cachefiles_lookup_histogram[HZ];
75487-extern atomic_t cachefiles_mkdir_histogram[HZ];
75488-extern atomic_t cachefiles_create_histogram[HZ];
75489+extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
75490+extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
75491+extern atomic_unchecked_t cachefiles_create_histogram[HZ];
75492
75493 extern int __init cachefiles_proc_init(void);
75494 extern void cachefiles_proc_cleanup(void);
75495 static inline
75496-void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
75497+void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
75498 {
75499 unsigned long jif = jiffies - start_jif;
75500 if (jif >= HZ)
75501 jif = HZ - 1;
75502- atomic_inc(&histogram[jif]);
75503+ atomic_inc_unchecked(&histogram[jif]);
75504 }
75505
75506 #else
75507diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
75508index fc1056f..501a546 100644
75509--- a/fs/cachefiles/namei.c
75510+++ b/fs/cachefiles/namei.c
75511@@ -312,7 +312,7 @@ try_again:
75512 /* first step is to make up a grave dentry in the graveyard */
75513 sprintf(nbuffer, "%08x%08x",
75514 (uint32_t) get_seconds(),
75515- (uint32_t) atomic_inc_return(&cache->gravecounter));
75516+ (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
75517
75518 /* do the multiway lock magic */
75519 trap = lock_rename(cache->graveyard, dir);
75520diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
75521index eccd339..4c1d995 100644
75522--- a/fs/cachefiles/proc.c
75523+++ b/fs/cachefiles/proc.c
75524@@ -14,9 +14,9 @@
75525 #include <linux/seq_file.h>
75526 #include "internal.h"
75527
75528-atomic_t cachefiles_lookup_histogram[HZ];
75529-atomic_t cachefiles_mkdir_histogram[HZ];
75530-atomic_t cachefiles_create_histogram[HZ];
75531+atomic_unchecked_t cachefiles_lookup_histogram[HZ];
75532+atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
75533+atomic_unchecked_t cachefiles_create_histogram[HZ];
75534
75535 /*
75536 * display the latency histogram
75537@@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
75538 return 0;
75539 default:
75540 index = (unsigned long) v - 3;
75541- x = atomic_read(&cachefiles_lookup_histogram[index]);
75542- y = atomic_read(&cachefiles_mkdir_histogram[index]);
75543- z = atomic_read(&cachefiles_create_histogram[index]);
75544+ x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
75545+ y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
75546+ z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
75547 if (x == 0 && y == 0 && z == 0)
75548 return 0;
75549
75550diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
75551index 9314b4e..4a1f602 100644
75552--- a/fs/ceph/dir.c
75553+++ b/fs/ceph/dir.c
75554@@ -214,10 +214,18 @@ static int __dcache_readdir(struct file *file, struct dir_context *ctx,
75555 spin_unlock(&dentry->d_lock);
75556
75557 if (emit_dentry) {
75558+ char d_name[DNAME_INLINE_LEN];
75559+ const unsigned char *name;
75560+
75561 dout(" %llu (%llu) dentry %p %pd %p\n", di->offset, ctx->pos,
75562 dentry, dentry, d_inode(dentry));
75563 ctx->pos = di->offset;
75564- if (!dir_emit(ctx, dentry->d_name.name,
75565+ name = dentry->d_name.name;
75566+ if (name == dentry->d_iname) {
75567+ memcpy(d_name, name, dentry->d_name.len);
75568+ name = d_name;
75569+ }
75570+ if (!dir_emit(ctx, name,
75571 dentry->d_name.len,
75572 ceph_translate_ino(dentry->d_sb,
75573 d_inode(dentry)->i_ino),
75574@@ -259,7 +267,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
75575 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
75576 struct ceph_mds_client *mdsc = fsc->mdsc;
75577 unsigned frag = fpos_frag(ctx->pos);
75578- int off = fpos_off(ctx->pos);
75579+ unsigned int off = fpos_off(ctx->pos);
75580 int err;
75581 u32 ftype;
75582 struct ceph_mds_reply_info_parsed *rinfo;
75583diff --git a/fs/ceph/super.c b/fs/ceph/super.c
75584index 7b6bfcb..f8d5416 100644
75585--- a/fs/ceph/super.c
75586+++ b/fs/ceph/super.c
75587@@ -906,7 +906,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
75588 /*
75589 * construct our own bdi so we can control readahead, etc.
75590 */
75591-static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
75592+static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
75593
75594 static int ceph_register_bdi(struct super_block *sb,
75595 struct ceph_fs_client *fsc)
75596@@ -923,7 +923,7 @@ static int ceph_register_bdi(struct super_block *sb,
75597 VM_MAX_READAHEAD * 1024 / PAGE_CACHE_SIZE;
75598
75599 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
75600- atomic_long_inc_return(&bdi_seq));
75601+ atomic_long_inc_return_unchecked(&bdi_seq));
75602 if (!err)
75603 sb->s_bdi = &fsc->backing_dev_info;
75604 return err;
75605diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
75606index 7febcf2..62a5721 100644
75607--- a/fs/cifs/cifs_debug.c
75608+++ b/fs/cifs/cifs_debug.c
75609@@ -269,8 +269,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
75610
75611 if (strtobool(&c, &bv) == 0) {
75612 #ifdef CONFIG_CIFS_STATS2
75613- atomic_set(&totBufAllocCount, 0);
75614- atomic_set(&totSmBufAllocCount, 0);
75615+ atomic_set_unchecked(&totBufAllocCount, 0);
75616+ atomic_set_unchecked(&totSmBufAllocCount, 0);
75617 #endif /* CONFIG_CIFS_STATS2 */
75618 spin_lock(&cifs_tcp_ses_lock);
75619 list_for_each(tmp1, &cifs_tcp_ses_list) {
75620@@ -283,7 +283,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
75621 tcon = list_entry(tmp3,
75622 struct cifs_tcon,
75623 tcon_list);
75624- atomic_set(&tcon->num_smbs_sent, 0);
75625+ atomic_set_unchecked(&tcon->num_smbs_sent, 0);
75626 if (server->ops->clear_stats)
75627 server->ops->clear_stats(tcon);
75628 }
75629@@ -315,8 +315,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
75630 smBufAllocCount.counter, cifs_min_small);
75631 #ifdef CONFIG_CIFS_STATS2
75632 seq_printf(m, "Total Large %d Small %d Allocations\n",
75633- atomic_read(&totBufAllocCount),
75634- atomic_read(&totSmBufAllocCount));
75635+ atomic_read_unchecked(&totBufAllocCount),
75636+ atomic_read_unchecked(&totSmBufAllocCount));
75637 #endif /* CONFIG_CIFS_STATS2 */
75638
75639 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
75640@@ -345,7 +345,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
75641 if (tcon->need_reconnect)
75642 seq_puts(m, "\tDISCONNECTED ");
75643 seq_printf(m, "\nSMBs: %d",
75644- atomic_read(&tcon->num_smbs_sent));
75645+ atomic_read_unchecked(&tcon->num_smbs_sent));
75646 if (server->ops->print_stats)
75647 server->ops->print_stats(m, tcon);
75648 }
75649diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
75650index 6a1119e..b2f2160 100644
75651--- a/fs/cifs/cifsfs.c
75652+++ b/fs/cifs/cifsfs.c
75653@@ -1082,7 +1082,7 @@ cifs_init_request_bufs(void)
75654 */
75655 cifs_req_cachep = kmem_cache_create("cifs_request",
75656 CIFSMaxBufSize + max_hdr_size, 0,
75657- SLAB_HWCACHE_ALIGN, NULL);
75658+ SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
75659 if (cifs_req_cachep == NULL)
75660 return -ENOMEM;
75661
75662@@ -1109,7 +1109,7 @@ cifs_init_request_bufs(void)
75663 efficient to alloc 1 per page off the slab compared to 17K (5page)
75664 alloc of large cifs buffers even when page debugging is on */
75665 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
75666- MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
75667+ MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
75668 NULL);
75669 if (cifs_sm_req_cachep == NULL) {
75670 mempool_destroy(cifs_req_poolp);
75671@@ -1194,8 +1194,8 @@ init_cifs(void)
75672 atomic_set(&bufAllocCount, 0);
75673 atomic_set(&smBufAllocCount, 0);
75674 #ifdef CONFIG_CIFS_STATS2
75675- atomic_set(&totBufAllocCount, 0);
75676- atomic_set(&totSmBufAllocCount, 0);
75677+ atomic_set_unchecked(&totBufAllocCount, 0);
75678+ atomic_set_unchecked(&totSmBufAllocCount, 0);
75679 #endif /* CONFIG_CIFS_STATS2 */
75680
75681 atomic_set(&midCount, 0);
75682diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
75683index b406a32..243eb1c 100644
75684--- a/fs/cifs/cifsglob.h
75685+++ b/fs/cifs/cifsglob.h
75686@@ -832,35 +832,35 @@ struct cifs_tcon {
75687 __u16 Flags; /* optional support bits */
75688 enum statusEnum tidStatus;
75689 #ifdef CONFIG_CIFS_STATS
75690- atomic_t num_smbs_sent;
75691+ atomic_unchecked_t num_smbs_sent;
75692 union {
75693 struct {
75694- atomic_t num_writes;
75695- atomic_t num_reads;
75696- atomic_t num_flushes;
75697- atomic_t num_oplock_brks;
75698- atomic_t num_opens;
75699- atomic_t num_closes;
75700- atomic_t num_deletes;
75701- atomic_t num_mkdirs;
75702- atomic_t num_posixopens;
75703- atomic_t num_posixmkdirs;
75704- atomic_t num_rmdirs;
75705- atomic_t num_renames;
75706- atomic_t num_t2renames;
75707- atomic_t num_ffirst;
75708- atomic_t num_fnext;
75709- atomic_t num_fclose;
75710- atomic_t num_hardlinks;
75711- atomic_t num_symlinks;
75712- atomic_t num_locks;
75713- atomic_t num_acl_get;
75714- atomic_t num_acl_set;
75715+ atomic_unchecked_t num_writes;
75716+ atomic_unchecked_t num_reads;
75717+ atomic_unchecked_t num_flushes;
75718+ atomic_unchecked_t num_oplock_brks;
75719+ atomic_unchecked_t num_opens;
75720+ atomic_unchecked_t num_closes;
75721+ atomic_unchecked_t num_deletes;
75722+ atomic_unchecked_t num_mkdirs;
75723+ atomic_unchecked_t num_posixopens;
75724+ atomic_unchecked_t num_posixmkdirs;
75725+ atomic_unchecked_t num_rmdirs;
75726+ atomic_unchecked_t num_renames;
75727+ atomic_unchecked_t num_t2renames;
75728+ atomic_unchecked_t num_ffirst;
75729+ atomic_unchecked_t num_fnext;
75730+ atomic_unchecked_t num_fclose;
75731+ atomic_unchecked_t num_hardlinks;
75732+ atomic_unchecked_t num_symlinks;
75733+ atomic_unchecked_t num_locks;
75734+ atomic_unchecked_t num_acl_get;
75735+ atomic_unchecked_t num_acl_set;
75736 } cifs_stats;
75737 #ifdef CONFIG_CIFS_SMB2
75738 struct {
75739- atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
75740- atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
75741+ atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
75742+ atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
75743 } smb2_stats;
75744 #endif /* CONFIG_CIFS_SMB2 */
75745 } stats;
75746@@ -1207,7 +1207,7 @@ convert_delimiter(char *path, char delim)
75747 }
75748
75749 #ifdef CONFIG_CIFS_STATS
75750-#define cifs_stats_inc atomic_inc
75751+#define cifs_stats_inc atomic_inc_unchecked
75752
75753 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
75754 unsigned int bytes)
75755@@ -1574,8 +1574,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
75756 /* Various Debug counters */
75757 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
75758 #ifdef CONFIG_CIFS_STATS2
75759-GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
75760-GLOBAL_EXTERN atomic_t totSmBufAllocCount;
75761+GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
75762+GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
75763 #endif
75764 GLOBAL_EXTERN atomic_t smBufAllocCount;
75765 GLOBAL_EXTERN atomic_t midCount;
75766diff --git a/fs/cifs/file.c b/fs/cifs/file.c
75767index 3f50cee..7741620 100644
75768--- a/fs/cifs/file.c
75769+++ b/fs/cifs/file.c
75770@@ -2054,10 +2054,14 @@ static int cifs_writepages(struct address_space *mapping,
75771 index = mapping->writeback_index; /* Start from prev offset */
75772 end = -1;
75773 } else {
75774- index = wbc->range_start >> PAGE_CACHE_SHIFT;
75775- end = wbc->range_end >> PAGE_CACHE_SHIFT;
75776- if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
75777+ if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) {
75778 range_whole = true;
75779+ index = 0;
75780+ end = ULONG_MAX;
75781+ } else {
75782+ index = wbc->range_start >> PAGE_CACHE_SHIFT;
75783+ end = wbc->range_end >> PAGE_CACHE_SHIFT;
75784+ }
75785 scanned = true;
75786 }
75787 server = cifs_sb_master_tcon(cifs_sb)->ses->server;
75788diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
75789index 8442b8b..ea6986f 100644
75790--- a/fs/cifs/misc.c
75791+++ b/fs/cifs/misc.c
75792@@ -170,7 +170,7 @@ cifs_buf_get(void)
75793 memset(ret_buf, 0, buf_size + 3);
75794 atomic_inc(&bufAllocCount);
75795 #ifdef CONFIG_CIFS_STATS2
75796- atomic_inc(&totBufAllocCount);
75797+ atomic_inc_unchecked(&totBufAllocCount);
75798 #endif /* CONFIG_CIFS_STATS2 */
75799 }
75800
75801@@ -205,7 +205,7 @@ cifs_small_buf_get(void)
75802 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
75803 atomic_inc(&smBufAllocCount);
75804 #ifdef CONFIG_CIFS_STATS2
75805- atomic_inc(&totSmBufAllocCount);
75806+ atomic_inc_unchecked(&totSmBufAllocCount);
75807 #endif /* CONFIG_CIFS_STATS2 */
75808
75809 }
75810diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
75811index fc537c2..47d654c 100644
75812--- a/fs/cifs/smb1ops.c
75813+++ b/fs/cifs/smb1ops.c
75814@@ -622,27 +622,27 @@ static void
75815 cifs_clear_stats(struct cifs_tcon *tcon)
75816 {
75817 #ifdef CONFIG_CIFS_STATS
75818- atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
75819- atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
75820- atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
75821- atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
75822- atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
75823- atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
75824- atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
75825- atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
75826- atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
75827- atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
75828- atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
75829- atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
75830- atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
75831- atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
75832- atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
75833- atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
75834- atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
75835- atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
75836- atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
75837- atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
75838- atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
75839+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
75840+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
75841+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
75842+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
75843+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
75844+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
75845+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
75846+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
75847+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
75848+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
75849+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
75850+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
75851+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
75852+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
75853+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
75854+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
75855+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
75856+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
75857+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
75858+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
75859+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
75860 #endif
75861 }
75862
75863@@ -651,36 +651,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
75864 {
75865 #ifdef CONFIG_CIFS_STATS
75866 seq_printf(m, " Oplocks breaks: %d",
75867- atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
75868+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
75869 seq_printf(m, "\nReads: %d Bytes: %llu",
75870- atomic_read(&tcon->stats.cifs_stats.num_reads),
75871+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
75872 (long long)(tcon->bytes_read));
75873 seq_printf(m, "\nWrites: %d Bytes: %llu",
75874- atomic_read(&tcon->stats.cifs_stats.num_writes),
75875+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
75876 (long long)(tcon->bytes_written));
75877 seq_printf(m, "\nFlushes: %d",
75878- atomic_read(&tcon->stats.cifs_stats.num_flushes));
75879+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
75880 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
75881- atomic_read(&tcon->stats.cifs_stats.num_locks),
75882- atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
75883- atomic_read(&tcon->stats.cifs_stats.num_symlinks));
75884+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
75885+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
75886+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
75887 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
75888- atomic_read(&tcon->stats.cifs_stats.num_opens),
75889- atomic_read(&tcon->stats.cifs_stats.num_closes),
75890- atomic_read(&tcon->stats.cifs_stats.num_deletes));
75891+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
75892+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
75893+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
75894 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
75895- atomic_read(&tcon->stats.cifs_stats.num_posixopens),
75896- atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
75897+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
75898+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
75899 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
75900- atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
75901- atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
75902+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
75903+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
75904 seq_printf(m, "\nRenames: %d T2 Renames %d",
75905- atomic_read(&tcon->stats.cifs_stats.num_renames),
75906- atomic_read(&tcon->stats.cifs_stats.num_t2renames));
75907+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
75908+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
75909 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
75910- atomic_read(&tcon->stats.cifs_stats.num_ffirst),
75911- atomic_read(&tcon->stats.cifs_stats.num_fnext),
75912- atomic_read(&tcon->stats.cifs_stats.num_fclose));
75913+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
75914+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
75915+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
75916 #endif
75917 }
75918
75919diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
75920index 18da19f..38a3a79 100644
75921--- a/fs/cifs/smb2ops.c
75922+++ b/fs/cifs/smb2ops.c
75923@@ -422,8 +422,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
75924 #ifdef CONFIG_CIFS_STATS
75925 int i;
75926 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
75927- atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
75928- atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
75929+ atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
75930+ atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
75931 }
75932 #endif
75933 }
75934@@ -463,65 +463,65 @@ static void
75935 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
75936 {
75937 #ifdef CONFIG_CIFS_STATS
75938- atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
75939- atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
75940+ atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
75941+ atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
75942 seq_printf(m, "\nNegotiates: %d sent %d failed",
75943- atomic_read(&sent[SMB2_NEGOTIATE_HE]),
75944- atomic_read(&failed[SMB2_NEGOTIATE_HE]));
75945+ atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
75946+ atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
75947 seq_printf(m, "\nSessionSetups: %d sent %d failed",
75948- atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
75949- atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
75950+ atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
75951+ atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
75952 seq_printf(m, "\nLogoffs: %d sent %d failed",
75953- atomic_read(&sent[SMB2_LOGOFF_HE]),
75954- atomic_read(&failed[SMB2_LOGOFF_HE]));
75955+ atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
75956+ atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
75957 seq_printf(m, "\nTreeConnects: %d sent %d failed",
75958- atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
75959- atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
75960+ atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
75961+ atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
75962 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
75963- atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
75964- atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
75965+ atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
75966+ atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
75967 seq_printf(m, "\nCreates: %d sent %d failed",
75968- atomic_read(&sent[SMB2_CREATE_HE]),
75969- atomic_read(&failed[SMB2_CREATE_HE]));
75970+ atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
75971+ atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
75972 seq_printf(m, "\nCloses: %d sent %d failed",
75973- atomic_read(&sent[SMB2_CLOSE_HE]),
75974- atomic_read(&failed[SMB2_CLOSE_HE]));
75975+ atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
75976+ atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
75977 seq_printf(m, "\nFlushes: %d sent %d failed",
75978- atomic_read(&sent[SMB2_FLUSH_HE]),
75979- atomic_read(&failed[SMB2_FLUSH_HE]));
75980+ atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
75981+ atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
75982 seq_printf(m, "\nReads: %d sent %d failed",
75983- atomic_read(&sent[SMB2_READ_HE]),
75984- atomic_read(&failed[SMB2_READ_HE]));
75985+ atomic_read_unchecked(&sent[SMB2_READ_HE]),
75986+ atomic_read_unchecked(&failed[SMB2_READ_HE]));
75987 seq_printf(m, "\nWrites: %d sent %d failed",
75988- atomic_read(&sent[SMB2_WRITE_HE]),
75989- atomic_read(&failed[SMB2_WRITE_HE]));
75990+ atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
75991+ atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
75992 seq_printf(m, "\nLocks: %d sent %d failed",
75993- atomic_read(&sent[SMB2_LOCK_HE]),
75994- atomic_read(&failed[SMB2_LOCK_HE]));
75995+ atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
75996+ atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
75997 seq_printf(m, "\nIOCTLs: %d sent %d failed",
75998- atomic_read(&sent[SMB2_IOCTL_HE]),
75999- atomic_read(&failed[SMB2_IOCTL_HE]));
76000+ atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
76001+ atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
76002 seq_printf(m, "\nCancels: %d sent %d failed",
76003- atomic_read(&sent[SMB2_CANCEL_HE]),
76004- atomic_read(&failed[SMB2_CANCEL_HE]));
76005+ atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
76006+ atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
76007 seq_printf(m, "\nEchos: %d sent %d failed",
76008- atomic_read(&sent[SMB2_ECHO_HE]),
76009- atomic_read(&failed[SMB2_ECHO_HE]));
76010+ atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
76011+ atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
76012 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
76013- atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
76014- atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
76015+ atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
76016+ atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
76017 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
76018- atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
76019- atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
76020+ atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
76021+ atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
76022 seq_printf(m, "\nQueryInfos: %d sent %d failed",
76023- atomic_read(&sent[SMB2_QUERY_INFO_HE]),
76024- atomic_read(&failed[SMB2_QUERY_INFO_HE]));
76025+ atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
76026+ atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
76027 seq_printf(m, "\nSetInfos: %d sent %d failed",
76028- atomic_read(&sent[SMB2_SET_INFO_HE]),
76029- atomic_read(&failed[SMB2_SET_INFO_HE]));
76030+ atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
76031+ atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
76032 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
76033- atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
76034- atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
76035+ atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
76036+ atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
76037 #endif
76038 }
76039
76040diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
76041index 60dd831..42f911c 100644
76042--- a/fs/cifs/smb2pdu.c
76043+++ b/fs/cifs/smb2pdu.c
76044@@ -2252,8 +2252,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
76045 default:
76046 cifs_dbg(VFS, "info level %u isn't supported\n",
76047 srch_inf->info_level);
76048- rc = -EINVAL;
76049- goto qdir_exit;
76050+ return -EINVAL;
76051 }
76052
76053 req->FileIndex = cpu_to_le32(index);
76054diff --git a/fs/coda/cache.c b/fs/coda/cache.c
76055index 5bb630a..043dc70 100644
76056--- a/fs/coda/cache.c
76057+++ b/fs/coda/cache.c
76058@@ -24,7 +24,7 @@
76059 #include "coda_linux.h"
76060 #include "coda_cache.h"
76061
76062-static atomic_t permission_epoch = ATOMIC_INIT(0);
76063+static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
76064
76065 /* replace or extend an acl cache hit */
76066 void coda_cache_enter(struct inode *inode, int mask)
76067@@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
76068 struct coda_inode_info *cii = ITOC(inode);
76069
76070 spin_lock(&cii->c_lock);
76071- cii->c_cached_epoch = atomic_read(&permission_epoch);
76072+ cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
76073 if (!uid_eq(cii->c_uid, current_fsuid())) {
76074 cii->c_uid = current_fsuid();
76075 cii->c_cached_perm = mask;
76076@@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
76077 {
76078 struct coda_inode_info *cii = ITOC(inode);
76079 spin_lock(&cii->c_lock);
76080- cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
76081+ cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
76082 spin_unlock(&cii->c_lock);
76083 }
76084
76085 /* remove all acl caches */
76086 void coda_cache_clear_all(struct super_block *sb)
76087 {
76088- atomic_inc(&permission_epoch);
76089+ atomic_inc_unchecked(&permission_epoch);
76090 }
76091
76092
76093@@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
76094 spin_lock(&cii->c_lock);
76095 hit = (mask & cii->c_cached_perm) == mask &&
76096 uid_eq(cii->c_uid, current_fsuid()) &&
76097- cii->c_cached_epoch == atomic_read(&permission_epoch);
76098+ cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
76099 spin_unlock(&cii->c_lock);
76100
76101 return hit;
76102diff --git a/fs/compat.c b/fs/compat.c
76103index 6fd272d..dd34ba2 100644
76104--- a/fs/compat.c
76105+++ b/fs/compat.c
76106@@ -54,7 +54,7 @@
76107 #include <asm/ioctls.h>
76108 #include "internal.h"
76109
76110-int compat_log = 1;
76111+int compat_log = 0;
76112
76113 int compat_printk(const char *fmt, ...)
76114 {
76115@@ -512,7 +512,7 @@ COMPAT_SYSCALL_DEFINE2(io_setup, unsigned, nr_reqs, u32 __user *, ctx32p)
76116
76117 set_fs(KERNEL_DS);
76118 /* The __user pointer cast is valid because of the set_fs() */
76119- ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
76120+ ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
76121 set_fs(oldfs);
76122 /* truncating is ok because it's a user address */
76123 if (!ret)
76124@@ -562,7 +562,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
76125 goto out;
76126
76127 ret = -EINVAL;
76128- if (nr_segs > UIO_MAXIOV || nr_segs < 0)
76129+ if (nr_segs > UIO_MAXIOV)
76130 goto out;
76131 if (nr_segs > fast_segs) {
76132 ret = -ENOMEM;
76133@@ -844,6 +844,7 @@ struct compat_old_linux_dirent {
76134 struct compat_readdir_callback {
76135 struct dir_context ctx;
76136 struct compat_old_linux_dirent __user *dirent;
76137+ struct file * file;
76138 int result;
76139 };
76140
76141@@ -863,6 +864,10 @@ static int compat_fillonedir(struct dir_context *ctx, const char *name,
76142 buf->result = -EOVERFLOW;
76143 return -EOVERFLOW;
76144 }
76145+
76146+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
76147+ return 0;
76148+
76149 buf->result++;
76150 dirent = buf->dirent;
76151 if (!access_ok(VERIFY_WRITE, dirent,
76152@@ -894,6 +899,7 @@ COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
76153 if (!f.file)
76154 return -EBADF;
76155
76156+ buf.file = f.file;
76157 error = iterate_dir(f.file, &buf.ctx);
76158 if (buf.result)
76159 error = buf.result;
76160@@ -913,6 +919,7 @@ struct compat_getdents_callback {
76161 struct dir_context ctx;
76162 struct compat_linux_dirent __user *current_dir;
76163 struct compat_linux_dirent __user *previous;
76164+ struct file * file;
76165 int count;
76166 int error;
76167 };
76168@@ -935,6 +942,10 @@ static int compat_filldir(struct dir_context *ctx, const char *name, int namlen,
76169 buf->error = -EOVERFLOW;
76170 return -EOVERFLOW;
76171 }
76172+
76173+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
76174+ return 0;
76175+
76176 dirent = buf->previous;
76177 if (dirent) {
76178 if (__put_user(offset, &dirent->d_off))
76179@@ -980,6 +991,7 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd,
76180 if (!f.file)
76181 return -EBADF;
76182
76183+ buf.file = f.file;
76184 error = iterate_dir(f.file, &buf.ctx);
76185 if (error >= 0)
76186 error = buf.error;
76187@@ -1000,6 +1012,7 @@ struct compat_getdents_callback64 {
76188 struct dir_context ctx;
76189 struct linux_dirent64 __user *current_dir;
76190 struct linux_dirent64 __user *previous;
76191+ struct file * file;
76192 int count;
76193 int error;
76194 };
76195@@ -1018,6 +1031,10 @@ static int compat_filldir64(struct dir_context *ctx, const char *name,
76196 buf->error = -EINVAL; /* only used if we fail.. */
76197 if (reclen > buf->count)
76198 return -EINVAL;
76199+
76200+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
76201+ return 0;
76202+
76203 dirent = buf->previous;
76204
76205 if (dirent) {
76206@@ -1067,6 +1084,7 @@ COMPAT_SYSCALL_DEFINE3(getdents64, unsigned int, fd,
76207 if (!f.file)
76208 return -EBADF;
76209
76210+ buf.file = f.file;
76211 error = iterate_dir(f.file, &buf.ctx);
76212 if (error >= 0)
76213 error = buf.error;
76214diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
76215index 4d24d17..4f8c09e 100644
76216--- a/fs/compat_binfmt_elf.c
76217+++ b/fs/compat_binfmt_elf.c
76218@@ -30,11 +30,13 @@
76219 #undef elf_phdr
76220 #undef elf_shdr
76221 #undef elf_note
76222+#undef elf_dyn
76223 #undef elf_addr_t
76224 #define elfhdr elf32_hdr
76225 #define elf_phdr elf32_phdr
76226 #define elf_shdr elf32_shdr
76227 #define elf_note elf32_note
76228+#define elf_dyn Elf32_Dyn
76229 #define elf_addr_t Elf32_Addr
76230
76231 /*
76232diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
76233index 48851f6..6c79d32 100644
76234--- a/fs/compat_ioctl.c
76235+++ b/fs/compat_ioctl.c
76236@@ -622,7 +622,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
76237 return -EFAULT;
76238 if (__get_user(udata, &ss32->iomem_base))
76239 return -EFAULT;
76240- ss.iomem_base = compat_ptr(udata);
76241+ ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
76242 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
76243 __get_user(ss.port_high, &ss32->port_high))
76244 return -EFAULT;
76245@@ -704,8 +704,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
76246 for (i = 0; i < nmsgs; i++) {
76247 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
76248 return -EFAULT;
76249- if (get_user(datap, &umsgs[i].buf) ||
76250- put_user(compat_ptr(datap), &tmsgs[i].buf))
76251+ if (get_user(datap, (compat_caddr_t __user *)&umsgs[i].buf) ||
76252+ put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
76253 return -EFAULT;
76254 }
76255 return sys_ioctl(fd, cmd, (unsigned long)tdata);
76256@@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
76257 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
76258 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
76259 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
76260- copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
76261+ copy_in_user(p->l_pad, p32->l_pad, 4*sizeof(u32)))
76262 return -EFAULT;
76263
76264 return ioctl_preallocate(file, p);
76265@@ -1621,8 +1621,8 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,
76266 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
76267 {
76268 unsigned int a, b;
76269- a = *(unsigned int *)p;
76270- b = *(unsigned int *)q;
76271+ a = *(const unsigned int *)p;
76272+ b = *(const unsigned int *)q;
76273 if (a > b)
76274 return 1;
76275 if (a < b)
76276diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
76277index c81ce7f..f3de5fd 100644
76278--- a/fs/configfs/dir.c
76279+++ b/fs/configfs/dir.c
76280@@ -1540,7 +1540,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
76281 }
76282 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
76283 struct configfs_dirent *next;
76284- const char *name;
76285+ const unsigned char * name;
76286+ char d_name[sizeof(next->s_dentry->d_iname)];
76287 int len;
76288 struct inode *inode = NULL;
76289
76290@@ -1549,7 +1550,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
76291 continue;
76292
76293 name = configfs_get_name(next);
76294- len = strlen(name);
76295+ if (next->s_dentry && name == next->s_dentry->d_iname) {
76296+ len = next->s_dentry->d_name.len;
76297+ memcpy(d_name, name, len);
76298+ name = d_name;
76299+ } else
76300+ len = strlen(name);
76301
76302 /*
76303 * We'll have a dentry and an inode for
76304diff --git a/fs/coredump.c b/fs/coredump.c
76305index a8f7564..3dde349 100644
76306--- a/fs/coredump.c
76307+++ b/fs/coredump.c
76308@@ -457,8 +457,8 @@ static void wait_for_dump_helpers(struct file *file)
76309 struct pipe_inode_info *pipe = file->private_data;
76310
76311 pipe_lock(pipe);
76312- pipe->readers++;
76313- pipe->writers--;
76314+ atomic_inc(&pipe->readers);
76315+ atomic_dec(&pipe->writers);
76316 wake_up_interruptible_sync(&pipe->wait);
76317 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
76318 pipe_unlock(pipe);
76319@@ -467,11 +467,11 @@ static void wait_for_dump_helpers(struct file *file)
76320 * We actually want wait_event_freezable() but then we need
76321 * to clear TIF_SIGPENDING and improve dump_interrupted().
76322 */
76323- wait_event_interruptible(pipe->wait, pipe->readers == 1);
76324+ wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
76325
76326 pipe_lock(pipe);
76327- pipe->readers--;
76328- pipe->writers++;
76329+ atomic_dec(&pipe->readers);
76330+ atomic_inc(&pipe->writers);
76331 pipe_unlock(pipe);
76332 }
76333
76334@@ -518,7 +518,9 @@ void do_coredump(const siginfo_t *siginfo)
76335 /* require nonrelative corefile path and be extra careful */
76336 bool need_suid_safe = false;
76337 bool core_dumped = false;
76338- static atomic_t core_dump_count = ATOMIC_INIT(0);
76339+ static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
76340+ long signr = siginfo->si_signo;
76341+ int dumpable;
76342 struct coredump_params cprm = {
76343 .siginfo = siginfo,
76344 .regs = signal_pt_regs(),
76345@@ -531,12 +533,17 @@ void do_coredump(const siginfo_t *siginfo)
76346 .mm_flags = mm->flags,
76347 };
76348
76349- audit_core_dumps(siginfo->si_signo);
76350+ audit_core_dumps(signr);
76351+
76352+ dumpable = __get_dumpable(cprm.mm_flags);
76353+
76354+ if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
76355+ gr_handle_brute_attach(dumpable);
76356
76357 binfmt = mm->binfmt;
76358 if (!binfmt || !binfmt->core_dump)
76359 goto fail;
76360- if (!__get_dumpable(cprm.mm_flags))
76361+ if (!dumpable)
76362 goto fail;
76363
76364 cred = prepare_creds();
76365@@ -554,7 +561,7 @@ void do_coredump(const siginfo_t *siginfo)
76366 need_suid_safe = true;
76367 }
76368
76369- retval = coredump_wait(siginfo->si_signo, &core_state);
76370+ retval = coredump_wait(signr, &core_state);
76371 if (retval < 0)
76372 goto fail_creds;
76373
76374@@ -597,7 +604,7 @@ void do_coredump(const siginfo_t *siginfo)
76375 }
76376 cprm.limit = RLIM_INFINITY;
76377
76378- dump_count = atomic_inc_return(&core_dump_count);
76379+ dump_count = atomic_inc_return_unchecked(&core_dump_count);
76380 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
76381 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
76382 task_tgid_vnr(current), current->comm);
76383@@ -629,6 +636,8 @@ void do_coredump(const siginfo_t *siginfo)
76384 } else {
76385 struct inode *inode;
76386
76387+ gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
76388+
76389 if (cprm.limit < binfmt->min_coredump)
76390 goto fail_unlock;
76391
76392@@ -718,7 +727,7 @@ close_fail:
76393 filp_close(cprm.file, NULL);
76394 fail_dropcount:
76395 if (ispipe)
76396- atomic_dec(&core_dump_count);
76397+ atomic_dec_unchecked(&core_dump_count);
76398 fail_unlock:
76399 kfree(cn.corename);
76400 coredump_finish(mm, core_dumped);
76401@@ -739,6 +748,8 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr)
76402 struct file *file = cprm->file;
76403 loff_t pos = file->f_pos;
76404 ssize_t n;
76405+
76406+ gr_learn_resource(current, RLIMIT_CORE, cprm->written + nr, 1);
76407 if (cprm->written + nr > cprm->limit)
76408 return 0;
76409 while (nr) {
76410diff --git a/fs/dcache.c b/fs/dcache.c
76411index e3b44ca..e0d94f1 100644
76412--- a/fs/dcache.c
76413+++ b/fs/dcache.c
76414@@ -545,7 +545,7 @@ static void __dentry_kill(struct dentry *dentry)
76415 * dentry_iput drops the locks, at which point nobody (except
76416 * transient RCU lookups) can reach this dentry.
76417 */
76418- BUG_ON(dentry->d_lockref.count > 0);
76419+ BUG_ON(__lockref_read(&dentry->d_lockref) > 0);
76420 this_cpu_dec(nr_dentry);
76421 if (dentry->d_op && dentry->d_op->d_release)
76422 dentry->d_op->d_release(dentry);
76423@@ -598,7 +598,7 @@ static inline struct dentry *lock_parent(struct dentry *dentry)
76424 struct dentry *parent = dentry->d_parent;
76425 if (IS_ROOT(dentry))
76426 return NULL;
76427- if (unlikely(dentry->d_lockref.count < 0))
76428+ if (unlikely(__lockref_read(&dentry->d_lockref) < 0))
76429 return NULL;
76430 if (likely(spin_trylock(&parent->d_lock)))
76431 return parent;
76432@@ -660,8 +660,8 @@ static inline bool fast_dput(struct dentry *dentry)
76433 */
76434 if (unlikely(ret < 0)) {
76435 spin_lock(&dentry->d_lock);
76436- if (dentry->d_lockref.count > 1) {
76437- dentry->d_lockref.count--;
76438+ if (__lockref_read(&dentry->d_lockref) > 1) {
76439+ __lockref_dec(&dentry->d_lockref);
76440 spin_unlock(&dentry->d_lock);
76441 return 1;
76442 }
76443@@ -716,7 +716,7 @@ static inline bool fast_dput(struct dentry *dentry)
76444 * else could have killed it and marked it dead. Either way, we
76445 * don't need to do anything else.
76446 */
76447- if (dentry->d_lockref.count) {
76448+ if (__lockref_read(&dentry->d_lockref)) {
76449 spin_unlock(&dentry->d_lock);
76450 return 1;
76451 }
76452@@ -726,7 +726,7 @@ static inline bool fast_dput(struct dentry *dentry)
76453 * lock, and we just tested that it was zero, so we can just
76454 * set it to 1.
76455 */
76456- dentry->d_lockref.count = 1;
76457+ __lockref_set(&dentry->d_lockref, 1);
76458 return 0;
76459 }
76460
76461@@ -788,7 +788,7 @@ repeat:
76462 dentry->d_flags |= DCACHE_REFERENCED;
76463 dentry_lru_add(dentry);
76464
76465- dentry->d_lockref.count--;
76466+ __lockref_dec(&dentry->d_lockref);
76467 spin_unlock(&dentry->d_lock);
76468 return;
76469
76470@@ -803,7 +803,7 @@ EXPORT_SYMBOL(dput);
76471 /* This must be called with d_lock held */
76472 static inline void __dget_dlock(struct dentry *dentry)
76473 {
76474- dentry->d_lockref.count++;
76475+ __lockref_inc(&dentry->d_lockref);
76476 }
76477
76478 static inline void __dget(struct dentry *dentry)
76479@@ -844,8 +844,8 @@ repeat:
76480 goto repeat;
76481 }
76482 rcu_read_unlock();
76483- BUG_ON(!ret->d_lockref.count);
76484- ret->d_lockref.count++;
76485+ BUG_ON(!__lockref_read(&ret->d_lockref));
76486+ __lockref_inc(&ret->d_lockref);
76487 spin_unlock(&ret->d_lock);
76488 return ret;
76489 }
76490@@ -923,9 +923,9 @@ restart:
76491 spin_lock(&inode->i_lock);
76492 hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
76493 spin_lock(&dentry->d_lock);
76494- if (!dentry->d_lockref.count) {
76495+ if (!__lockref_read(&dentry->d_lockref)) {
76496 struct dentry *parent = lock_parent(dentry);
76497- if (likely(!dentry->d_lockref.count)) {
76498+ if (likely(!__lockref_read(&dentry->d_lockref))) {
76499 __dentry_kill(dentry);
76500 dput(parent);
76501 goto restart;
76502@@ -960,7 +960,7 @@ static void shrink_dentry_list(struct list_head *list)
76503 * We found an inuse dentry which was not removed from
76504 * the LRU because of laziness during lookup. Do not free it.
76505 */
76506- if (dentry->d_lockref.count > 0) {
76507+ if (__lockref_read(&dentry->d_lockref) > 0) {
76508 spin_unlock(&dentry->d_lock);
76509 if (parent)
76510 spin_unlock(&parent->d_lock);
76511@@ -998,8 +998,8 @@ static void shrink_dentry_list(struct list_head *list)
76512 dentry = parent;
76513 while (dentry && !lockref_put_or_lock(&dentry->d_lockref)) {
76514 parent = lock_parent(dentry);
76515- if (dentry->d_lockref.count != 1) {
76516- dentry->d_lockref.count--;
76517+ if (__lockref_read(&dentry->d_lockref) != 1) {
76518+ __lockref_inc(&dentry->d_lockref);
76519 spin_unlock(&dentry->d_lock);
76520 if (parent)
76521 spin_unlock(&parent->d_lock);
76522@@ -1039,7 +1039,7 @@ static enum lru_status dentry_lru_isolate(struct list_head *item,
76523 * counts, just remove them from the LRU. Otherwise give them
76524 * another pass through the LRU.
76525 */
76526- if (dentry->d_lockref.count) {
76527+ if (__lockref_read(&dentry->d_lockref)) {
76528 d_lru_isolate(lru, dentry);
76529 spin_unlock(&dentry->d_lock);
76530 return LRU_REMOVED;
76531@@ -1373,7 +1373,7 @@ static enum d_walk_ret select_collect(void *_data, struct dentry *dentry)
76532 } else {
76533 if (dentry->d_flags & DCACHE_LRU_LIST)
76534 d_lru_del(dentry);
76535- if (!dentry->d_lockref.count) {
76536+ if (!__lockref_read(&dentry->d_lockref)) {
76537 d_shrink_add(dentry, &data->dispose);
76538 data->found++;
76539 }
76540@@ -1421,7 +1421,7 @@ static enum d_walk_ret umount_check(void *_data, struct dentry *dentry)
76541 return D_WALK_CONTINUE;
76542
76543 /* root with refcount 1 is fine */
76544- if (dentry == _data && dentry->d_lockref.count == 1)
76545+ if (dentry == _data && __lockref_read(&dentry->d_lockref) == 1)
76546 return D_WALK_CONTINUE;
76547
76548 printk(KERN_ERR "BUG: Dentry %p{i=%lx,n=%pd} "
76549@@ -1430,7 +1430,7 @@ static enum d_walk_ret umount_check(void *_data, struct dentry *dentry)
76550 dentry->d_inode ?
76551 dentry->d_inode->i_ino : 0UL,
76552 dentry,
76553- dentry->d_lockref.count,
76554+ __lockref_read(&dentry->d_lockref),
76555 dentry->d_sb->s_type->name,
76556 dentry->d_sb->s_id);
76557 WARN_ON(1);
76558@@ -1571,7 +1571,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
76559 dentry->d_iname[DNAME_INLINE_LEN-1] = 0;
76560 if (name->len > DNAME_INLINE_LEN-1) {
76561 size_t size = offsetof(struct external_name, name[1]);
76562- struct external_name *p = kmalloc(size + name->len, GFP_KERNEL);
76563+ struct external_name *p = kmalloc(round_up(size + name->len, sizeof(unsigned long)), GFP_KERNEL);
76564 if (!p) {
76565 kmem_cache_free(dentry_cache, dentry);
76566 return NULL;
76567@@ -1594,7 +1594,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
76568 smp_wmb();
76569 dentry->d_name.name = dname;
76570
76571- dentry->d_lockref.count = 1;
76572+ __lockref_set(&dentry->d_lockref, 1);
76573 dentry->d_flags = 0;
76574 spin_lock_init(&dentry->d_lock);
76575 seqcount_init(&dentry->d_seq);
76576@@ -1603,6 +1603,9 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
76577 dentry->d_sb = sb;
76578 dentry->d_op = NULL;
76579 dentry->d_fsdata = NULL;
76580+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
76581+ atomic_set(&dentry->chroot_refcnt, 0);
76582+#endif
76583 INIT_HLIST_BL_NODE(&dentry->d_hash);
76584 INIT_LIST_HEAD(&dentry->d_lru);
76585 INIT_LIST_HEAD(&dentry->d_subdirs);
76586@@ -2327,7 +2330,7 @@ struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name)
76587 goto next;
76588 }
76589
76590- dentry->d_lockref.count++;
76591+ __lockref_inc(&dentry->d_lockref);
76592 found = dentry;
76593 spin_unlock(&dentry->d_lock);
76594 break;
76595@@ -2395,7 +2398,7 @@ again:
76596 spin_lock(&dentry->d_lock);
76597 inode = dentry->d_inode;
76598 isdir = S_ISDIR(inode->i_mode);
76599- if (dentry->d_lockref.count == 1) {
76600+ if (__lockref_read(&dentry->d_lockref) == 1) {
76601 if (!spin_trylock(&inode->i_lock)) {
76602 spin_unlock(&dentry->d_lock);
76603 cpu_relax();
76604@@ -3344,7 +3347,7 @@ static enum d_walk_ret d_genocide_kill(void *data, struct dentry *dentry)
76605
76606 if (!(dentry->d_flags & DCACHE_GENOCIDE)) {
76607 dentry->d_flags |= DCACHE_GENOCIDE;
76608- dentry->d_lockref.count--;
76609+ __lockref_dec(&dentry->d_lockref);
76610 }
76611 }
76612 return D_WALK_CONTINUE;
76613@@ -3452,7 +3455,8 @@ void __init vfs_caches_init_early(void)
76614 void __init vfs_caches_init(void)
76615 {
76616 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
76617- SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
76618+ SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
76619+ SLAB_NO_SANITIZE, NULL);
76620
76621 dcache_init();
76622 inode_init();
76623diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
76624index c711be8..23b8df9 100644
76625--- a/fs/debugfs/inode.c
76626+++ b/fs/debugfs/inode.c
76627@@ -402,6 +402,10 @@ EXPORT_SYMBOL_GPL(debugfs_create_file_size);
76628 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
76629 * returned.
76630 */
76631+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
76632+extern int grsec_enable_sysfs_restrict;
76633+#endif
76634+
76635 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
76636 {
76637 struct dentry *dentry = start_creating(name, parent);
76638@@ -414,7 +418,12 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
76639 if (unlikely(!inode))
76640 return failed_creating(dentry);
76641
76642- inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
76643+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
76644+ if (grsec_enable_sysfs_restrict)
76645+ inode->i_mode = S_IFDIR | S_IRWXU;
76646+ else
76647+#endif
76648+ inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
76649 inode->i_op = &simple_dir_inode_operations;
76650 inode->i_fop = &simple_dir_operations;
76651
76652diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
76653index 754fd6c..ed6acbe 100644
76654--- a/fs/dlm/lowcomms.c
76655+++ b/fs/dlm/lowcomms.c
76656@@ -538,7 +538,7 @@ static void close_connection(struct connection *con, bool and_other)
76657 /* We only send shutdown messages to nodes that are not part of the cluster */
76658 static void sctp_send_shutdown(sctp_assoc_t associd)
76659 {
76660- static char outcmsg[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))];
76661+ char outcmsg[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))];
76662 struct msghdr outmessage;
76663 struct cmsghdr *cmsg;
76664 struct sctp_sndrcvinfo *sinfo;
76665diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
76666index 3c4db11..a43976f 100644
76667--- a/fs/ecryptfs/inode.c
76668+++ b/fs/ecryptfs/inode.c
76669@@ -662,7 +662,7 @@ static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz)
76670 old_fs = get_fs();
76671 set_fs(get_ds());
76672 rc = d_inode(lower_dentry)->i_op->readlink(lower_dentry,
76673- (char __user *)lower_buf,
76674+ (char __force_user *)lower_buf,
76675 PATH_MAX);
76676 set_fs(old_fs);
76677 if (rc < 0)
76678diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
76679index e4141f2..d8263e8 100644
76680--- a/fs/ecryptfs/miscdev.c
76681+++ b/fs/ecryptfs/miscdev.c
76682@@ -304,7 +304,7 @@ check_list:
76683 goto out_unlock_msg_ctx;
76684 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
76685 if (msg_ctx->msg) {
76686- if (copy_to_user(&buf[i], packet_length, packet_length_size))
76687+ if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
76688 goto out_unlock_msg_ctx;
76689 i += packet_length_size;
76690 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
76691diff --git a/fs/exec.c b/fs/exec.c
76692index 1977c2a..b6b953a 100644
76693--- a/fs/exec.c
76694+++ b/fs/exec.c
76695@@ -56,8 +56,20 @@
76696 #include <linux/pipe_fs_i.h>
76697 #include <linux/oom.h>
76698 #include <linux/compat.h>
76699+#include <linux/random.h>
76700+#include <linux/seq_file.h>
76701+#include <linux/coredump.h>
76702+#include <linux/mman.h>
76703+
76704+#ifdef CONFIG_PAX_REFCOUNT
76705+#include <linux/kallsyms.h>
76706+#include <linux/kdebug.h>
76707+#endif
76708+
76709+#include <trace/events/fs.h>
76710
76711 #include <asm/uaccess.h>
76712+#include <asm/sections.h>
76713 #include <asm/mmu_context.h>
76714 #include <asm/tlb.h>
76715
76716@@ -66,19 +78,34 @@
76717
76718 #include <trace/events/sched.h>
76719
76720+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
76721+void __weak pax_set_initial_flags(struct linux_binprm *bprm)
76722+{
76723+ 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");
76724+}
76725+#endif
76726+
76727+#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
76728+void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
76729+EXPORT_SYMBOL(pax_set_initial_flags_func);
76730+#endif
76731+
76732 int suid_dumpable = 0;
76733
76734 static LIST_HEAD(formats);
76735 static DEFINE_RWLOCK(binfmt_lock);
76736
76737+extern int gr_process_kernel_exec_ban(void);
76738+extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
76739+
76740 void __register_binfmt(struct linux_binfmt * fmt, int insert)
76741 {
76742 BUG_ON(!fmt);
76743 if (WARN_ON(!fmt->load_binary))
76744 return;
76745 write_lock(&binfmt_lock);
76746- insert ? list_add(&fmt->lh, &formats) :
76747- list_add_tail(&fmt->lh, &formats);
76748+ insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
76749+ pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
76750 write_unlock(&binfmt_lock);
76751 }
76752
76753@@ -87,7 +114,7 @@ EXPORT_SYMBOL(__register_binfmt);
76754 void unregister_binfmt(struct linux_binfmt * fmt)
76755 {
76756 write_lock(&binfmt_lock);
76757- list_del(&fmt->lh);
76758+ pax_list_del((struct list_head *)&fmt->lh);
76759 write_unlock(&binfmt_lock);
76760 }
76761
76762@@ -183,18 +210,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
76763 int write)
76764 {
76765 struct page *page;
76766- int ret;
76767
76768-#ifdef CONFIG_STACK_GROWSUP
76769- if (write) {
76770- ret = expand_downwards(bprm->vma, pos);
76771- if (ret < 0)
76772- return NULL;
76773- }
76774-#endif
76775- ret = get_user_pages(current, bprm->mm, pos,
76776- 1, write, 1, &page, NULL);
76777- if (ret <= 0)
76778+ if (0 > expand_downwards(bprm->vma, pos))
76779+ return NULL;
76780+ if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
76781 return NULL;
76782
76783 if (write) {
76784@@ -210,6 +229,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
76785 if (size <= ARG_MAX)
76786 return page;
76787
76788+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76789+ // only allow 512KB for argv+env on suid/sgid binaries
76790+ // to prevent easy ASLR exhaustion
76791+ if (((!uid_eq(bprm->cred->euid, current_euid())) ||
76792+ (!gid_eq(bprm->cred->egid, current_egid()))) &&
76793+ (size > (512 * 1024))) {
76794+ put_page(page);
76795+ return NULL;
76796+ }
76797+#endif
76798+
76799 /*
76800 * Limit to 1/4-th the stack size for the argv+env strings.
76801 * This ensures that:
76802@@ -269,6 +299,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
76803 vma->vm_end = STACK_TOP_MAX;
76804 vma->vm_start = vma->vm_end - PAGE_SIZE;
76805 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
76806+
76807+#ifdef CONFIG_PAX_SEGMEXEC
76808+ vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
76809+#endif
76810+
76811 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
76812 INIT_LIST_HEAD(&vma->anon_vma_chain);
76813
76814@@ -280,6 +315,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
76815 arch_bprm_mm_init(mm, vma);
76816 up_write(&mm->mmap_sem);
76817 bprm->p = vma->vm_end - sizeof(void *);
76818+
76819+#ifdef CONFIG_PAX_RANDUSTACK
76820+ if (randomize_va_space)
76821+ bprm->p ^= prandom_u32() & ~PAGE_MASK;
76822+#endif
76823+
76824 return 0;
76825 err:
76826 up_write(&mm->mmap_sem);
76827@@ -396,7 +437,7 @@ struct user_arg_ptr {
76828 } ptr;
76829 };
76830
76831-static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
76832+const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
76833 {
76834 const char __user *native;
76835
76836@@ -405,14 +446,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
76837 compat_uptr_t compat;
76838
76839 if (get_user(compat, argv.ptr.compat + nr))
76840- return ERR_PTR(-EFAULT);
76841+ return (const char __force_user *)ERR_PTR(-EFAULT);
76842
76843 return compat_ptr(compat);
76844 }
76845 #endif
76846
76847 if (get_user(native, argv.ptr.native + nr))
76848- return ERR_PTR(-EFAULT);
76849+ return (const char __force_user *)ERR_PTR(-EFAULT);
76850
76851 return native;
76852 }
76853@@ -431,7 +472,7 @@ static int count(struct user_arg_ptr argv, int max)
76854 if (!p)
76855 break;
76856
76857- if (IS_ERR(p))
76858+ if (IS_ERR((const char __force_kernel *)p))
76859 return -EFAULT;
76860
76861 if (i >= max)
76862@@ -466,7 +507,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
76863
76864 ret = -EFAULT;
76865 str = get_user_arg_ptr(argv, argc);
76866- if (IS_ERR(str))
76867+ if (IS_ERR((const char __force_kernel *)str))
76868 goto out;
76869
76870 len = strnlen_user(str, MAX_ARG_STRLEN);
76871@@ -548,7 +589,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
76872 int r;
76873 mm_segment_t oldfs = get_fs();
76874 struct user_arg_ptr argv = {
76875- .ptr.native = (const char __user *const __user *)__argv,
76876+ .ptr.native = (const char __user * const __force_user *)__argv,
76877 };
76878
76879 set_fs(KERNEL_DS);
76880@@ -583,7 +624,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
76881 unsigned long new_end = old_end - shift;
76882 struct mmu_gather tlb;
76883
76884- BUG_ON(new_start > new_end);
76885+ if (new_start >= new_end || new_start < mmap_min_addr)
76886+ return -ENOMEM;
76887
76888 /*
76889 * ensure there are no vmas between where we want to go
76890@@ -592,6 +634,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
76891 if (vma != find_vma(mm, new_start))
76892 return -EFAULT;
76893
76894+#ifdef CONFIG_PAX_SEGMEXEC
76895+ BUG_ON(pax_find_mirror_vma(vma));
76896+#endif
76897+
76898 /*
76899 * cover the whole range: [new_start, old_end)
76900 */
76901@@ -675,10 +721,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
76902 stack_top = arch_align_stack(stack_top);
76903 stack_top = PAGE_ALIGN(stack_top);
76904
76905- if (unlikely(stack_top < mmap_min_addr) ||
76906- unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
76907- return -ENOMEM;
76908-
76909 stack_shift = vma->vm_end - stack_top;
76910
76911 bprm->p -= stack_shift;
76912@@ -690,8 +732,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
76913 bprm->exec -= stack_shift;
76914
76915 down_write(&mm->mmap_sem);
76916+
76917+ /* Move stack pages down in memory. */
76918+ if (stack_shift) {
76919+ ret = shift_arg_pages(vma, stack_shift);
76920+ if (ret)
76921+ goto out_unlock;
76922+ }
76923+
76924 vm_flags = VM_STACK_FLAGS;
76925
76926+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
76927+ if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
76928+ vm_flags &= ~VM_EXEC;
76929+
76930+#ifdef CONFIG_PAX_MPROTECT
76931+ if (mm->pax_flags & MF_PAX_MPROTECT)
76932+ vm_flags &= ~VM_MAYEXEC;
76933+#endif
76934+
76935+ }
76936+#endif
76937+
76938 /*
76939 * Adjust stack execute permissions; explicitly enable for
76940 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
76941@@ -710,13 +772,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
76942 goto out_unlock;
76943 BUG_ON(prev != vma);
76944
76945- /* Move stack pages down in memory. */
76946- if (stack_shift) {
76947- ret = shift_arg_pages(vma, stack_shift);
76948- if (ret)
76949- goto out_unlock;
76950- }
76951-
76952 /* mprotect_fixup is overkill to remove the temporary stack flags */
76953 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
76954
76955@@ -740,6 +795,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
76956 #endif
76957 current->mm->start_stack = bprm->p;
76958 ret = expand_stack(vma, stack_base);
76959+
76960+#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
76961+ if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
76962+ unsigned long size;
76963+ vm_flags_t vm_flags;
76964+
76965+ size = STACK_TOP - vma->vm_end;
76966+ vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
76967+
76968+ ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
76969+
76970+#ifdef CONFIG_X86
76971+ if (!ret) {
76972+ size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
76973+ ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
76974+ }
76975+#endif
76976+
76977+ }
76978+#endif
76979+
76980 if (ret)
76981 ret = -EFAULT;
76982
76983@@ -784,8 +860,10 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
76984 if (err)
76985 goto exit;
76986
76987- if (name->name[0] != '\0')
76988+ if (name->name[0] != '\0') {
76989 fsnotify_open(file);
76990+ trace_open_exec(name->name);
76991+ }
76992
76993 out:
76994 return file;
76995@@ -818,7 +896,7 @@ int kernel_read(struct file *file, loff_t offset,
76996 old_fs = get_fs();
76997 set_fs(get_ds());
76998 /* The cast to a user pointer is valid due to the set_fs() */
76999- result = vfs_read(file, (void __user *)addr, count, &pos);
77000+ result = vfs_read(file, (void __force_user *)addr, count, &pos);
77001 set_fs(old_fs);
77002 return result;
77003 }
77004@@ -863,6 +941,7 @@ static int exec_mmap(struct mm_struct *mm)
77005 tsk->mm = mm;
77006 tsk->active_mm = mm;
77007 activate_mm(active_mm, mm);
77008+ populate_stack();
77009 tsk->mm->vmacache_seqnum = 0;
77010 vmacache_flush(tsk);
77011 task_unlock(tsk);
77012@@ -1271,7 +1350,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm)
77013 }
77014 rcu_read_unlock();
77015
77016- if (p->fs->users > n_fs)
77017+ if (atomic_read(&p->fs->users) > n_fs)
77018 bprm->unsafe |= LSM_UNSAFE_SHARE;
77019 else
77020 p->fs->in_exec = 1;
77021@@ -1472,6 +1551,31 @@ static int exec_binprm(struct linux_binprm *bprm)
77022 return ret;
77023 }
77024
77025+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77026+static DEFINE_PER_CPU(u64, exec_counter);
77027+static int __init init_exec_counters(void)
77028+{
77029+ unsigned int cpu;
77030+
77031+ for_each_possible_cpu(cpu) {
77032+ per_cpu(exec_counter, cpu) = (u64)cpu;
77033+ }
77034+
77035+ return 0;
77036+}
77037+early_initcall(init_exec_counters);
77038+static inline void increment_exec_counter(void)
77039+{
77040+ BUILD_BUG_ON(NR_CPUS > (1 << 16));
77041+ current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
77042+}
77043+#else
77044+static inline void increment_exec_counter(void) {}
77045+#endif
77046+
77047+extern void gr_handle_exec_args(struct linux_binprm *bprm,
77048+ struct user_arg_ptr argv);
77049+
77050 /*
77051 * sys_execve() executes a new program.
77052 */
77053@@ -1480,6 +1584,11 @@ static int do_execveat_common(int fd, struct filename *filename,
77054 struct user_arg_ptr envp,
77055 int flags)
77056 {
77057+#ifdef CONFIG_GRKERNSEC
77058+ struct file *old_exec_file;
77059+ struct acl_subject_label *old_acl;
77060+ struct rlimit old_rlim[RLIM_NLIMITS];
77061+#endif
77062 char *pathbuf = NULL;
77063 struct linux_binprm *bprm;
77064 struct file *file;
77065@@ -1489,6 +1598,8 @@ static int do_execveat_common(int fd, struct filename *filename,
77066 if (IS_ERR(filename))
77067 return PTR_ERR(filename);
77068
77069+ gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
77070+
77071 /*
77072 * We move the actual failure in case of RLIMIT_NPROC excess from
77073 * set*uid() to execve() because too many poorly written programs
77074@@ -1526,6 +1637,11 @@ static int do_execveat_common(int fd, struct filename *filename,
77075 if (IS_ERR(file))
77076 goto out_unmark;
77077
77078+ if (gr_ptrace_readexec(file, bprm->unsafe)) {
77079+ retval = -EPERM;
77080+ goto out_unmark;
77081+ }
77082+
77083 sched_exec();
77084
77085 bprm->file = file;
77086@@ -1552,6 +1668,11 @@ static int do_execveat_common(int fd, struct filename *filename,
77087 }
77088 bprm->interp = bprm->filename;
77089
77090+ if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
77091+ retval = -EACCES;
77092+ goto out_unmark;
77093+ }
77094+
77095 retval = bprm_mm_init(bprm);
77096 if (retval)
77097 goto out_unmark;
77098@@ -1568,24 +1689,70 @@ static int do_execveat_common(int fd, struct filename *filename,
77099 if (retval < 0)
77100 goto out;
77101
77102+#ifdef CONFIG_GRKERNSEC
77103+ old_acl = current->acl;
77104+ memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
77105+ old_exec_file = current->exec_file;
77106+ get_file(file);
77107+ current->exec_file = file;
77108+#endif
77109+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77110+ /* limit suid stack to 8MB
77111+ * we saved the old limits above and will restore them if this exec fails
77112+ */
77113+ if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
77114+ (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
77115+ current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
77116+#endif
77117+
77118+ if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
77119+ retval = -EPERM;
77120+ goto out_fail;
77121+ }
77122+
77123+ if (!gr_tpe_allow(file)) {
77124+ retval = -EACCES;
77125+ goto out_fail;
77126+ }
77127+
77128+ if (gr_check_crash_exec(file)) {
77129+ retval = -EACCES;
77130+ goto out_fail;
77131+ }
77132+
77133+ retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
77134+ bprm->unsafe);
77135+ if (retval < 0)
77136+ goto out_fail;
77137+
77138 retval = copy_strings_kernel(1, &bprm->filename, bprm);
77139 if (retval < 0)
77140- goto out;
77141+ goto out_fail;
77142
77143 bprm->exec = bprm->p;
77144 retval = copy_strings(bprm->envc, envp, bprm);
77145 if (retval < 0)
77146- goto out;
77147+ goto out_fail;
77148
77149 retval = copy_strings(bprm->argc, argv, bprm);
77150 if (retval < 0)
77151- goto out;
77152+ goto out_fail;
77153+
77154+ gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
77155+
77156+ gr_handle_exec_args(bprm, argv);
77157
77158 retval = exec_binprm(bprm);
77159 if (retval < 0)
77160- goto out;
77161+ goto out_fail;
77162+#ifdef CONFIG_GRKERNSEC
77163+ if (old_exec_file)
77164+ fput(old_exec_file);
77165+#endif
77166
77167 /* execve succeeded */
77168+
77169+ increment_exec_counter();
77170 current->fs->in_exec = 0;
77171 current->in_execve = 0;
77172 acct_update_integrals(current);
77173@@ -1597,6 +1764,14 @@ static int do_execveat_common(int fd, struct filename *filename,
77174 put_files_struct(displaced);
77175 return retval;
77176
77177+out_fail:
77178+#ifdef CONFIG_GRKERNSEC
77179+ current->acl = old_acl;
77180+ memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
77181+ fput(current->exec_file);
77182+ current->exec_file = old_exec_file;
77183+#endif
77184+
77185 out:
77186 if (bprm->mm) {
77187 acct_arg_size(bprm, 0);
77188@@ -1743,3 +1918,324 @@ COMPAT_SYSCALL_DEFINE5(execveat, int, fd,
77189 argv, envp, flags);
77190 }
77191 #endif
77192+
77193+int pax_check_flags(unsigned long *flags)
77194+{
77195+ int retval = 0;
77196+
77197+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
77198+ if (*flags & MF_PAX_SEGMEXEC)
77199+ {
77200+ *flags &= ~MF_PAX_SEGMEXEC;
77201+ retval = -EINVAL;
77202+ }
77203+#endif
77204+
77205+ if ((*flags & MF_PAX_PAGEEXEC)
77206+
77207+#ifdef CONFIG_PAX_PAGEEXEC
77208+ && (*flags & MF_PAX_SEGMEXEC)
77209+#endif
77210+
77211+ )
77212+ {
77213+ *flags &= ~MF_PAX_PAGEEXEC;
77214+ retval = -EINVAL;
77215+ }
77216+
77217+ if ((*flags & MF_PAX_MPROTECT)
77218+
77219+#ifdef CONFIG_PAX_MPROTECT
77220+ && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
77221+#endif
77222+
77223+ )
77224+ {
77225+ *flags &= ~MF_PAX_MPROTECT;
77226+ retval = -EINVAL;
77227+ }
77228+
77229+ if ((*flags & MF_PAX_EMUTRAMP)
77230+
77231+#ifdef CONFIG_PAX_EMUTRAMP
77232+ && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
77233+#endif
77234+
77235+ )
77236+ {
77237+ *flags &= ~MF_PAX_EMUTRAMP;
77238+ retval = -EINVAL;
77239+ }
77240+
77241+ return retval;
77242+}
77243+
77244+EXPORT_SYMBOL(pax_check_flags);
77245+
77246+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
77247+char *pax_get_path(const struct path *path, char *buf, int buflen)
77248+{
77249+ char *pathname = d_path(path, buf, buflen);
77250+
77251+ if (IS_ERR(pathname))
77252+ goto toolong;
77253+
77254+ pathname = mangle_path(buf, pathname, "\t\n\\");
77255+ if (!pathname)
77256+ goto toolong;
77257+
77258+ *pathname = 0;
77259+ return buf;
77260+
77261+toolong:
77262+ return "<path too long>";
77263+}
77264+EXPORT_SYMBOL(pax_get_path);
77265+
77266+void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
77267+{
77268+ struct task_struct *tsk = current;
77269+ struct mm_struct *mm = current->mm;
77270+ char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
77271+ char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
77272+ char *path_exec = NULL;
77273+ char *path_fault = NULL;
77274+ unsigned long start = 0UL, end = 0UL, offset = 0UL;
77275+ siginfo_t info = { };
77276+
77277+ if (buffer_exec && buffer_fault) {
77278+ struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
77279+
77280+ down_read(&mm->mmap_sem);
77281+ vma = mm->mmap;
77282+ while (vma && (!vma_exec || !vma_fault)) {
77283+ if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
77284+ vma_exec = vma;
77285+ if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
77286+ vma_fault = vma;
77287+ vma = vma->vm_next;
77288+ }
77289+ if (vma_exec)
77290+ path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
77291+ if (vma_fault) {
77292+ start = vma_fault->vm_start;
77293+ end = vma_fault->vm_end;
77294+ offset = vma_fault->vm_pgoff << PAGE_SHIFT;
77295+ if (vma_fault->vm_file)
77296+ path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
77297+ else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
77298+ path_fault = "<heap>";
77299+ else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
77300+ path_fault = "<stack>";
77301+ else
77302+ path_fault = "<anonymous mapping>";
77303+ }
77304+ up_read(&mm->mmap_sem);
77305+ }
77306+ if (tsk->signal->curr_ip)
77307+ printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
77308+ else
77309+ printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
77310+ 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),
77311+ from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
77312+ free_page((unsigned long)buffer_exec);
77313+ free_page((unsigned long)buffer_fault);
77314+ pax_report_insns(regs, pc, sp);
77315+ info.si_signo = SIGKILL;
77316+ info.si_errno = 0;
77317+ info.si_code = SI_KERNEL;
77318+ info.si_pid = 0;
77319+ info.si_uid = 0;
77320+ do_coredump(&info);
77321+}
77322+#endif
77323+
77324+#ifdef CONFIG_PAX_REFCOUNT
77325+void pax_report_refcount_overflow(struct pt_regs *regs)
77326+{
77327+ if (current->signal->curr_ip)
77328+ printk(KERN_EMERG "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
77329+ &current->signal->curr_ip, current->comm, task_pid_nr(current),
77330+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
77331+ else
77332+ printk(KERN_EMERG "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
77333+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
77334+ print_symbol(KERN_EMERG "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
77335+ preempt_disable();
77336+ show_regs(regs);
77337+ preempt_enable();
77338+ force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
77339+}
77340+#endif
77341+
77342+#ifdef CONFIG_PAX_USERCOPY
77343+/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
77344+static noinline int check_stack_object(const void *obj, unsigned long len)
77345+{
77346+ const void * const stack = task_stack_page(current);
77347+ const void * const stackend = stack + THREAD_SIZE;
77348+
77349+#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
77350+ const void *frame = NULL;
77351+ const void *oldframe;
77352+#endif
77353+
77354+ if (obj + len < obj)
77355+ return -1;
77356+
77357+ if (obj + len <= stack || stackend <= obj)
77358+ return 0;
77359+
77360+ if (obj < stack || stackend < obj + len)
77361+ return -1;
77362+
77363+#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
77364+ oldframe = __builtin_frame_address(1);
77365+ if (oldframe)
77366+ frame = __builtin_frame_address(2);
77367+ /*
77368+ low ----------------------------------------------> high
77369+ [saved bp][saved ip][args][local vars][saved bp][saved ip]
77370+ ^----------------^
77371+ allow copies only within here
77372+ */
77373+ while (stack <= frame && frame < stackend) {
77374+ /* if obj + len extends past the last frame, this
77375+ check won't pass and the next frame will be 0,
77376+ causing us to bail out and correctly report
77377+ the copy as invalid
77378+ */
77379+ if (obj + len <= frame)
77380+ return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
77381+ oldframe = frame;
77382+ frame = *(const void * const *)frame;
77383+ }
77384+ return -1;
77385+#else
77386+ return 1;
77387+#endif
77388+}
77389+
77390+static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
77391+{
77392+ if (current->signal->curr_ip)
77393+ printk(KERN_EMERG "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
77394+ &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
77395+ else
77396+ printk(KERN_EMERG "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
77397+ to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
77398+ dump_stack();
77399+ gr_handle_kernel_exploit();
77400+ do_group_exit(SIGKILL);
77401+}
77402+#endif
77403+
77404+#ifdef CONFIG_PAX_USERCOPY
77405+
77406+static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
77407+{
77408+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
77409+ unsigned long textlow = ktla_ktva((unsigned long)_stext);
77410+#ifdef CONFIG_MODULES
77411+ unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
77412+#else
77413+ unsigned long texthigh = ktla_ktva((unsigned long)_etext);
77414+#endif
77415+
77416+#else
77417+ unsigned long textlow = (unsigned long)_stext;
77418+ unsigned long texthigh = (unsigned long)_etext;
77419+
77420+#ifdef CONFIG_X86_64
77421+ /* check against linear mapping as well */
77422+ if (high > (unsigned long)__va(__pa(textlow)) &&
77423+ low < (unsigned long)__va(__pa(texthigh)))
77424+ return true;
77425+#endif
77426+
77427+#endif
77428+
77429+ if (high <= textlow || low >= texthigh)
77430+ return false;
77431+ else
77432+ return true;
77433+}
77434+#endif
77435+
77436+void __check_object_size(const void *ptr, unsigned long n, bool to_user, bool const_size)
77437+{
77438+#ifdef CONFIG_PAX_USERCOPY
77439+ const char *type;
77440+#endif
77441+
77442+#if !defined(CONFIG_STACK_GROWSUP) && !defined(CONFIG_X86_64)
77443+ unsigned long stackstart = (unsigned long)task_stack_page(current);
77444+ unsigned long currentsp = (unsigned long)&stackstart;
77445+ if (unlikely((currentsp < stackstart + 512 ||
77446+ currentsp >= stackstart + THREAD_SIZE) && !in_interrupt()))
77447+ BUG();
77448+#endif
77449+
77450+#ifndef CONFIG_PAX_USERCOPY_DEBUG
77451+ if (const_size)
77452+ return;
77453+#endif
77454+
77455+#ifdef CONFIG_PAX_USERCOPY
77456+ if (!n)
77457+ return;
77458+
77459+ type = check_heap_object(ptr, n);
77460+ if (!type) {
77461+ int ret = check_stack_object(ptr, n);
77462+ if (ret == 1 || ret == 2)
77463+ return;
77464+ if (ret == 0) {
77465+ if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
77466+ type = "<kernel text>";
77467+ else
77468+ return;
77469+ } else
77470+ type = "<process stack>";
77471+ }
77472+
77473+ pax_report_usercopy(ptr, n, to_user, type);
77474+#endif
77475+
77476+}
77477+EXPORT_SYMBOL(__check_object_size);
77478+
77479+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
77480+void __used pax_track_stack(void)
77481+{
77482+ unsigned long sp = (unsigned long)&sp;
77483+ if (sp < current_thread_info()->lowest_stack &&
77484+ sp >= (unsigned long)task_stack_page(current) + 2 * sizeof(unsigned long))
77485+ current_thread_info()->lowest_stack = sp;
77486+ if (unlikely((sp & ~(THREAD_SIZE - 1)) < (THREAD_SIZE/16)))
77487+ BUG();
77488+}
77489+EXPORT_SYMBOL(pax_track_stack);
77490+#endif
77491+
77492+#ifdef CONFIG_PAX_SIZE_OVERFLOW
77493+
77494+#ifdef CONFIG_PAX_SIZE_OVERFLOW_DISABLE_KILL
77495+static DEFINE_RATELIMIT_STATE(size_overflow_ratelimit, 15 * HZ, 3);
77496+#endif
77497+
77498+void __nocapture(1, 3, 4) __used report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
77499+{
77500+#ifdef CONFIG_PAX_SIZE_OVERFLOW_DISABLE_KILL
77501+ if (__ratelimit(&size_overflow_ratelimit)) {
77502+ printk(KERN_EMERG "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
77503+ dump_stack();
77504+ }
77505+#else
77506+ printk(KERN_EMERG "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
77507+ dump_stack();
77508+ do_group_exit(SIGKILL);
77509+#endif
77510+}
77511+EXPORT_SYMBOL(report_size_overflow);
77512+#endif
77513diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
77514index 9f9992b..8b59411 100644
77515--- a/fs/ext2/balloc.c
77516+++ b/fs/ext2/balloc.c
77517@@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
77518
77519 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
77520 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
77521- if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
77522+ if (free_blocks < root_blocks + 1 &&
77523 !uid_eq(sbi->s_resuid, current_fsuid()) &&
77524 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
77525- !in_group_p (sbi->s_resgid))) {
77526+ !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
77527 return 0;
77528 }
77529 return 1;
77530diff --git a/fs/ext2/super.c b/fs/ext2/super.c
77531index 900e19c..f7dc2b8 100644
77532--- a/fs/ext2/super.c
77533+++ b/fs/ext2/super.c
77534@@ -267,10 +267,8 @@ static int ext2_show_options(struct seq_file *seq, struct dentry *root)
77535 #ifdef CONFIG_EXT2_FS_XATTR
77536 if (test_opt(sb, XATTR_USER))
77537 seq_puts(seq, ",user_xattr");
77538- if (!test_opt(sb, XATTR_USER) &&
77539- (def_mount_opts & EXT2_DEFM_XATTR_USER)) {
77540+ if (!test_opt(sb, XATTR_USER))
77541 seq_puts(seq, ",nouser_xattr");
77542- }
77543 #endif
77544
77545 #ifdef CONFIG_EXT2_FS_POSIX_ACL
77546@@ -856,8 +854,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
77547 if (def_mount_opts & EXT2_DEFM_UID16)
77548 set_opt(sbi->s_mount_opt, NO_UID32);
77549 #ifdef CONFIG_EXT2_FS_XATTR
77550- if (def_mount_opts & EXT2_DEFM_XATTR_USER)
77551- set_opt(sbi->s_mount_opt, XATTR_USER);
77552+ /* always enable user xattrs */
77553+ set_opt(sbi->s_mount_opt, XATTR_USER);
77554 #endif
77555 #ifdef CONFIG_EXT2_FS_POSIX_ACL
77556 if (def_mount_opts & EXT2_DEFM_ACL)
77557diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
77558index 0b6bfd3..93a2964 100644
77559--- a/fs/ext2/xattr.c
77560+++ b/fs/ext2/xattr.c
77561@@ -247,7 +247,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
77562 struct buffer_head *bh = NULL;
77563 struct ext2_xattr_entry *entry;
77564 char *end;
77565- size_t rest = buffer_size;
77566+ size_t rest = buffer_size, total_size = 0;
77567 int error;
77568
77569 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
77570@@ -305,9 +305,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
77571 buffer += size;
77572 }
77573 rest -= size;
77574+ total_size += size;
77575 }
77576 }
77577- error = buffer_size - rest; /* total size */
77578+ error = total_size;
77579
77580 cleanup:
77581 brelse(bh);
77582diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
77583index 158b5d4..2432610 100644
77584--- a/fs/ext3/balloc.c
77585+++ b/fs/ext3/balloc.c
77586@@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
77587
77588 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
77589 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
77590- if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
77591+ if (free_blocks < root_blocks + 1 &&
77592 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
77593 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
77594- !in_group_p (sbi->s_resgid))) {
77595+ !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
77596 return 0;
77597 }
77598 return 1;
77599diff --git a/fs/ext3/super.c b/fs/ext3/super.c
77600index 5ed0044..656e3d2 100644
77601--- a/fs/ext3/super.c
77602+++ b/fs/ext3/super.c
77603@@ -655,10 +655,8 @@ static int ext3_show_options(struct seq_file *seq, struct dentry *root)
77604 #ifdef CONFIG_EXT3_FS_XATTR
77605 if (test_opt(sb, XATTR_USER))
77606 seq_puts(seq, ",user_xattr");
77607- if (!test_opt(sb, XATTR_USER) &&
77608- (def_mount_opts & EXT3_DEFM_XATTR_USER)) {
77609+ if (!test_opt(sb, XATTR_USER))
77610 seq_puts(seq, ",nouser_xattr");
77611- }
77612 #endif
77613 #ifdef CONFIG_EXT3_FS_POSIX_ACL
77614 if (test_opt(sb, POSIX_ACL))
77615@@ -1760,8 +1758,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
77616 if (def_mount_opts & EXT3_DEFM_UID16)
77617 set_opt(sbi->s_mount_opt, NO_UID32);
77618 #ifdef CONFIG_EXT3_FS_XATTR
77619- if (def_mount_opts & EXT3_DEFM_XATTR_USER)
77620- set_opt(sbi->s_mount_opt, XATTR_USER);
77621+ /* always enable user xattrs */
77622+ set_opt(sbi->s_mount_opt, XATTR_USER);
77623 #endif
77624 #ifdef CONFIG_EXT3_FS_POSIX_ACL
77625 if (def_mount_opts & EXT3_DEFM_ACL)
77626diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
77627index 7cf3650..e3f4a51 100644
77628--- a/fs/ext3/xattr.c
77629+++ b/fs/ext3/xattr.c
77630@@ -330,7 +330,7 @@ static int
77631 ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
77632 char *buffer, size_t buffer_size)
77633 {
77634- size_t rest = buffer_size;
77635+ size_t rest = buffer_size, total_size = 0;
77636
77637 for (; !IS_LAST_ENTRY(entry); entry = EXT3_XATTR_NEXT(entry)) {
77638 const struct xattr_handler *handler =
77639@@ -347,9 +347,10 @@ ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
77640 buffer += size;
77641 }
77642 rest -= size;
77643+ total_size += size;
77644 }
77645 }
77646- return buffer_size - rest;
77647+ return total_size;
77648 }
77649
77650 static int
77651diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
77652index cd6ea29..1cd2a97 100644
77653--- a/fs/ext4/balloc.c
77654+++ b/fs/ext4/balloc.c
77655@@ -556,8 +556,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
77656 /* Hm, nope. Are (enough) root reserved clusters available? */
77657 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
77658 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
77659- capable(CAP_SYS_RESOURCE) ||
77660- (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
77661+ (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
77662+ capable_nolog(CAP_SYS_RESOURCE)) {
77663
77664 if (free_clusters >= (nclusters + dirty_clusters +
77665 resv_clusters))
77666diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
77667index f5e9f04..91296b9 100644
77668--- a/fs/ext4/ext4.h
77669+++ b/fs/ext4/ext4.h
77670@@ -1305,19 +1305,19 @@ struct ext4_sb_info {
77671 unsigned long s_mb_last_start;
77672
77673 /* stats for buddy allocator */
77674- atomic_t s_bal_reqs; /* number of reqs with len > 1 */
77675- atomic_t s_bal_success; /* we found long enough chunks */
77676- atomic_t s_bal_allocated; /* in blocks */
77677- atomic_t s_bal_ex_scanned; /* total extents scanned */
77678- atomic_t s_bal_goals; /* goal hits */
77679- atomic_t s_bal_breaks; /* too long searches */
77680- atomic_t s_bal_2orders; /* 2^order hits */
77681+ atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
77682+ atomic_unchecked_t s_bal_success; /* we found long enough chunks */
77683+ atomic_unchecked_t s_bal_allocated; /* in blocks */
77684+ atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
77685+ atomic_unchecked_t s_bal_goals; /* goal hits */
77686+ atomic_unchecked_t s_bal_breaks; /* too long searches */
77687+ atomic_unchecked_t s_bal_2orders; /* 2^order hits */
77688 spinlock_t s_bal_lock;
77689 unsigned long s_mb_buddies_generated;
77690 unsigned long long s_mb_generation_time;
77691- atomic_t s_mb_lost_chunks;
77692- atomic_t s_mb_preallocated;
77693- atomic_t s_mb_discarded;
77694+ atomic_unchecked_t s_mb_lost_chunks;
77695+ atomic_unchecked_t s_mb_preallocated;
77696+ atomic_unchecked_t s_mb_discarded;
77697 atomic_t s_lock_busy;
77698
77699 /* locality groups */
77700diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
77701index 34b610e..ecc47cb 100644
77702--- a/fs/ext4/mballoc.c
77703+++ b/fs/ext4/mballoc.c
77704@@ -1905,7 +1905,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
77705 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
77706
77707 if (EXT4_SB(sb)->s_mb_stats)
77708- atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
77709+ atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
77710
77711 break;
77712 }
77713@@ -2228,7 +2228,7 @@ repeat:
77714 ac->ac_status = AC_STATUS_CONTINUE;
77715 ac->ac_flags |= EXT4_MB_HINT_FIRST;
77716 cr = 3;
77717- atomic_inc(&sbi->s_mb_lost_chunks);
77718+ atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
77719 goto repeat;
77720 }
77721 }
77722@@ -2732,25 +2732,25 @@ int ext4_mb_release(struct super_block *sb)
77723 if (sbi->s_mb_stats) {
77724 ext4_msg(sb, KERN_INFO,
77725 "mballoc: %u blocks %u reqs (%u success)",
77726- atomic_read(&sbi->s_bal_allocated),
77727- atomic_read(&sbi->s_bal_reqs),
77728- atomic_read(&sbi->s_bal_success));
77729+ atomic_read_unchecked(&sbi->s_bal_allocated),
77730+ atomic_read_unchecked(&sbi->s_bal_reqs),
77731+ atomic_read_unchecked(&sbi->s_bal_success));
77732 ext4_msg(sb, KERN_INFO,
77733 "mballoc: %u extents scanned, %u goal hits, "
77734 "%u 2^N hits, %u breaks, %u lost",
77735- atomic_read(&sbi->s_bal_ex_scanned),
77736- atomic_read(&sbi->s_bal_goals),
77737- atomic_read(&sbi->s_bal_2orders),
77738- atomic_read(&sbi->s_bal_breaks),
77739- atomic_read(&sbi->s_mb_lost_chunks));
77740+ atomic_read_unchecked(&sbi->s_bal_ex_scanned),
77741+ atomic_read_unchecked(&sbi->s_bal_goals),
77742+ atomic_read_unchecked(&sbi->s_bal_2orders),
77743+ atomic_read_unchecked(&sbi->s_bal_breaks),
77744+ atomic_read_unchecked(&sbi->s_mb_lost_chunks));
77745 ext4_msg(sb, KERN_INFO,
77746 "mballoc: %lu generated and it took %Lu",
77747 sbi->s_mb_buddies_generated,
77748 sbi->s_mb_generation_time);
77749 ext4_msg(sb, KERN_INFO,
77750 "mballoc: %u preallocated, %u discarded",
77751- atomic_read(&sbi->s_mb_preallocated),
77752- atomic_read(&sbi->s_mb_discarded));
77753+ atomic_read_unchecked(&sbi->s_mb_preallocated),
77754+ atomic_read_unchecked(&sbi->s_mb_discarded));
77755 }
77756
77757 free_percpu(sbi->s_locality_groups);
77758@@ -3206,16 +3206,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
77759 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
77760
77761 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
77762- atomic_inc(&sbi->s_bal_reqs);
77763- atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
77764+ atomic_inc_unchecked(&sbi->s_bal_reqs);
77765+ atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
77766 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
77767- atomic_inc(&sbi->s_bal_success);
77768- atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
77769+ atomic_inc_unchecked(&sbi->s_bal_success);
77770+ atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
77771 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
77772 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
77773- atomic_inc(&sbi->s_bal_goals);
77774+ atomic_inc_unchecked(&sbi->s_bal_goals);
77775 if (ac->ac_found > sbi->s_mb_max_to_scan)
77776- atomic_inc(&sbi->s_bal_breaks);
77777+ atomic_inc_unchecked(&sbi->s_bal_breaks);
77778 }
77779
77780 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
77781@@ -3642,7 +3642,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
77782 trace_ext4_mb_new_inode_pa(ac, pa);
77783
77784 ext4_mb_use_inode_pa(ac, pa);
77785- atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
77786+ atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
77787
77788 ei = EXT4_I(ac->ac_inode);
77789 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
77790@@ -3702,7 +3702,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
77791 trace_ext4_mb_new_group_pa(ac, pa);
77792
77793 ext4_mb_use_group_pa(ac, pa);
77794- atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
77795+ atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
77796
77797 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
77798 lg = ac->ac_lg;
77799@@ -3791,7 +3791,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
77800 * from the bitmap and continue.
77801 */
77802 }
77803- atomic_add(free, &sbi->s_mb_discarded);
77804+ atomic_add_unchecked(free, &sbi->s_mb_discarded);
77805
77806 return err;
77807 }
77808@@ -3809,7 +3809,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
77809 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
77810 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
77811 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
77812- atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
77813+ atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
77814 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
77815
77816 return 0;
77817diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
77818index 8313ca3..8a37d08 100644
77819--- a/fs/ext4/mmp.c
77820+++ b/fs/ext4/mmp.c
77821@@ -111,7 +111,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
77822 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
77823 const char *function, unsigned int line, const char *msg)
77824 {
77825- __ext4_warning(sb, function, line, msg);
77826+ __ext4_warning(sb, function, line, "%s", msg);
77827 __ext4_warning(sb, function, line,
77828 "MMP failure info: last update time: %llu, last update "
77829 "node: %s, last update device: %s\n",
77830diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
77831index cf0c472..ddf284d 100644
77832--- a/fs/ext4/resize.c
77833+++ b/fs/ext4/resize.c
77834@@ -413,7 +413,7 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
77835
77836 ext4_debug("mark blocks [%llu/%u] used\n", block, count);
77837 for (count2 = count; count > 0; count -= count2, block += count2) {
77838- ext4_fsblk_t start;
77839+ ext4_fsblk_t start, diff;
77840 struct buffer_head *bh;
77841 ext4_group_t group;
77842 int err;
77843@@ -422,10 +422,6 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
77844 start = ext4_group_first_block_no(sb, group);
77845 group -= flex_gd->groups[0].group;
77846
77847- count2 = EXT4_BLOCKS_PER_GROUP(sb) - (block - start);
77848- if (count2 > count)
77849- count2 = count;
77850-
77851 if (flex_gd->bg_flags[group] & EXT4_BG_BLOCK_UNINIT) {
77852 BUG_ON(flex_gd->count > 1);
77853 continue;
77854@@ -443,9 +439,15 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
77855 err = ext4_journal_get_write_access(handle, bh);
77856 if (err)
77857 return err;
77858+
77859+ diff = block - start;
77860+ count2 = EXT4_BLOCKS_PER_GROUP(sb) - diff;
77861+ if (count2 > count)
77862+ count2 = count;
77863+
77864 ext4_debug("mark block bitmap %#04llx (+%llu/%u)\n", block,
77865- block - start, count2);
77866- ext4_set_bits(bh->b_data, block - start, count2);
77867+ diff, count2);
77868+ ext4_set_bits(bh->b_data, diff, count2);
77869
77870 err = ext4_handle_dirty_metadata(handle, NULL, bh);
77871 if (unlikely(err))
77872diff --git a/fs/ext4/super.c b/fs/ext4/super.c
77873index a5e8c74..a7711a8 100644
77874--- a/fs/ext4/super.c
77875+++ b/fs/ext4/super.c
77876@@ -1274,7 +1274,7 @@ static ext4_fsblk_t get_sb_block(void **data)
77877 }
77878
77879 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
77880-static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
77881+static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
77882 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
77883
77884 #ifdef CONFIG_QUOTA
77885@@ -2484,7 +2484,7 @@ struct ext4_attr {
77886 int offset;
77887 int deprecated_val;
77888 } u;
77889-};
77890+} __do_const;
77891
77892 static int parse_strtoull(const char *buf,
77893 unsigned long long max, unsigned long long *value)
77894diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
77895index 16e28c0..728c282 100644
77896--- a/fs/ext4/xattr.c
77897+++ b/fs/ext4/xattr.c
77898@@ -398,7 +398,7 @@ static int
77899 ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
77900 char *buffer, size_t buffer_size)
77901 {
77902- size_t rest = buffer_size;
77903+ size_t rest = buffer_size, total_size = 0;
77904
77905 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
77906 const struct xattr_handler *handler =
77907@@ -415,9 +415,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
77908 buffer += size;
77909 }
77910 rest -= size;
77911+ total_size += size;
77912 }
77913 }
77914- return buffer_size - rest;
77915+ return total_size;
77916 }
77917
77918 static int
77919diff --git a/fs/fcntl.c b/fs/fcntl.c
77920index ee85cd4..9dd0d20 100644
77921--- a/fs/fcntl.c
77922+++ b/fs/fcntl.c
77923@@ -102,6 +102,10 @@ void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
77924 int force)
77925 {
77926 security_file_set_fowner(filp);
77927+ if (gr_handle_chroot_fowner(pid, type))
77928+ return;
77929+ if (gr_check_protected_task_fowner(pid, type))
77930+ return;
77931 f_modown(filp, pid, type, force);
77932 }
77933 EXPORT_SYMBOL(__f_setown);
77934diff --git a/fs/fhandle.c b/fs/fhandle.c
77935index d59712d..2281df9 100644
77936--- a/fs/fhandle.c
77937+++ b/fs/fhandle.c
77938@@ -8,6 +8,7 @@
77939 #include <linux/fs_struct.h>
77940 #include <linux/fsnotify.h>
77941 #include <linux/personality.h>
77942+#include <linux/grsecurity.h>
77943 #include <asm/uaccess.h>
77944 #include "internal.h"
77945 #include "mount.h"
77946@@ -67,8 +68,7 @@ static long do_sys_name_to_handle(struct path *path,
77947 } else
77948 retval = 0;
77949 /* copy the mount id */
77950- if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
77951- sizeof(*mnt_id)) ||
77952+ if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
77953 copy_to_user(ufh, handle,
77954 sizeof(struct file_handle) + handle_bytes))
77955 retval = -EFAULT;
77956@@ -175,7 +175,7 @@ static int handle_to_path(int mountdirfd, struct file_handle __user *ufh,
77957 * the directory. Ideally we would like CAP_DAC_SEARCH.
77958 * But we don't have that
77959 */
77960- if (!capable(CAP_DAC_READ_SEARCH)) {
77961+ if (!capable(CAP_DAC_READ_SEARCH) || !gr_chroot_fhandle()) {
77962 retval = -EPERM;
77963 goto out_err;
77964 }
77965diff --git a/fs/file.c b/fs/file.c
77966index 6c672ad..bf787b0 100644
77967--- a/fs/file.c
77968+++ b/fs/file.c
77969@@ -16,6 +16,7 @@
77970 #include <linux/slab.h>
77971 #include <linux/vmalloc.h>
77972 #include <linux/file.h>
77973+#include <linux/security.h>
77974 #include <linux/fdtable.h>
77975 #include <linux/bitops.h>
77976 #include <linux/interrupt.h>
77977@@ -139,7 +140,7 @@ out:
77978 * Return <0 error code on error; 1 on successful completion.
77979 * The files->file_lock should be held on entry, and will be held on exit.
77980 */
77981-static int expand_fdtable(struct files_struct *files, int nr)
77982+static int expand_fdtable(struct files_struct *files, unsigned int nr)
77983 __releases(files->file_lock)
77984 __acquires(files->file_lock)
77985 {
77986@@ -184,7 +185,7 @@ static int expand_fdtable(struct files_struct *files, int nr)
77987 * expanded and execution may have blocked.
77988 * The files->file_lock should be held on entry, and will be held on exit.
77989 */
77990-static int expand_files(struct files_struct *files, int nr)
77991+static int expand_files(struct files_struct *files, unsigned int nr)
77992 __releases(files->file_lock)
77993 __acquires(files->file_lock)
77994 {
77995@@ -834,6 +835,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
77996 if (!file)
77997 return __close_fd(files, fd);
77998
77999+ gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
78000 if (fd >= rlimit(RLIMIT_NOFILE))
78001 return -EBADF;
78002
78003@@ -860,6 +862,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
78004 if (unlikely(oldfd == newfd))
78005 return -EINVAL;
78006
78007+ gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
78008 if (newfd >= rlimit(RLIMIT_NOFILE))
78009 return -EBADF;
78010
78011@@ -915,6 +918,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
78012 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
78013 {
78014 int err;
78015+ gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
78016 if (from >= rlimit(RLIMIT_NOFILE))
78017 return -EINVAL;
78018 err = alloc_fd(from, flags);
78019diff --git a/fs/filesystems.c b/fs/filesystems.c
78020index 5797d45..7d7d79a 100644
78021--- a/fs/filesystems.c
78022+++ b/fs/filesystems.c
78023@@ -275,7 +275,11 @@ struct file_system_type *get_fs_type(const char *name)
78024 int len = dot ? dot - name : strlen(name);
78025
78026 fs = __get_fs_type(name, len);
78027+#ifdef CONFIG_GRKERNSEC_MODHARDEN
78028+ if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
78029+#else
78030 if (!fs && (request_module("fs-%.*s", len, name) == 0))
78031+#endif
78032 fs = __get_fs_type(name, len);
78033
78034 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
78035diff --git a/fs/fs_struct.c b/fs/fs_struct.c
78036index 7dca743..1ff87ae 100644
78037--- a/fs/fs_struct.c
78038+++ b/fs/fs_struct.c
78039@@ -4,6 +4,7 @@
78040 #include <linux/path.h>
78041 #include <linux/slab.h>
78042 #include <linux/fs_struct.h>
78043+#include <linux/grsecurity.h>
78044 #include "internal.h"
78045
78046 /*
78047@@ -15,14 +16,18 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
78048 struct path old_root;
78049
78050 path_get(path);
78051+ gr_inc_chroot_refcnts(path->dentry, path->mnt);
78052 spin_lock(&fs->lock);
78053 write_seqcount_begin(&fs->seq);
78054 old_root = fs->root;
78055 fs->root = *path;
78056+ gr_set_chroot_entries(current, path);
78057 write_seqcount_end(&fs->seq);
78058 spin_unlock(&fs->lock);
78059- if (old_root.dentry)
78060+ if (old_root.dentry) {
78061+ gr_dec_chroot_refcnts(old_root.dentry, old_root.mnt);
78062 path_put(&old_root);
78063+ }
78064 }
78065
78066 /*
78067@@ -67,6 +72,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
78068 int hits = 0;
78069 spin_lock(&fs->lock);
78070 write_seqcount_begin(&fs->seq);
78071+ /* this root replacement is only done by pivot_root,
78072+ leave grsec's chroot tagging alone for this task
78073+ so that a pivoted root isn't treated as a chroot
78074+ */
78075 hits += replace_path(&fs->root, old_root, new_root);
78076 hits += replace_path(&fs->pwd, old_root, new_root);
78077 write_seqcount_end(&fs->seq);
78078@@ -85,6 +94,7 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
78079
78080 void free_fs_struct(struct fs_struct *fs)
78081 {
78082+ gr_dec_chroot_refcnts(fs->root.dentry, fs->root.mnt);
78083 path_put(&fs->root);
78084 path_put(&fs->pwd);
78085 kmem_cache_free(fs_cachep, fs);
78086@@ -99,7 +109,8 @@ void exit_fs(struct task_struct *tsk)
78087 task_lock(tsk);
78088 spin_lock(&fs->lock);
78089 tsk->fs = NULL;
78090- kill = !--fs->users;
78091+ gr_clear_chroot_entries(tsk);
78092+ kill = !atomic_dec_return(&fs->users);
78093 spin_unlock(&fs->lock);
78094 task_unlock(tsk);
78095 if (kill)
78096@@ -112,7 +123,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
78097 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
78098 /* We don't need to lock fs - think why ;-) */
78099 if (fs) {
78100- fs->users = 1;
78101+ atomic_set(&fs->users, 1);
78102 fs->in_exec = 0;
78103 spin_lock_init(&fs->lock);
78104 seqcount_init(&fs->seq);
78105@@ -121,9 +132,13 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
78106 spin_lock(&old->lock);
78107 fs->root = old->root;
78108 path_get(&fs->root);
78109+ /* instead of calling gr_set_chroot_entries here,
78110+ we call it from every caller of this function
78111+ */
78112 fs->pwd = old->pwd;
78113 path_get(&fs->pwd);
78114 spin_unlock(&old->lock);
78115+ gr_inc_chroot_refcnts(fs->root.dentry, fs->root.mnt);
78116 }
78117 return fs;
78118 }
78119@@ -139,8 +154,9 @@ int unshare_fs_struct(void)
78120
78121 task_lock(current);
78122 spin_lock(&fs->lock);
78123- kill = !--fs->users;
78124+ kill = !atomic_dec_return(&fs->users);
78125 current->fs = new_fs;
78126+ gr_set_chroot_entries(current, &new_fs->root);
78127 spin_unlock(&fs->lock);
78128 task_unlock(current);
78129
78130@@ -153,13 +169,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
78131
78132 int current_umask(void)
78133 {
78134- return current->fs->umask;
78135+ return current->fs->umask | gr_acl_umask();
78136 }
78137 EXPORT_SYMBOL(current_umask);
78138
78139 /* to be mentioned only in INIT_TASK */
78140 struct fs_struct init_fs = {
78141- .users = 1,
78142+ .users = ATOMIC_INIT(1),
78143 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
78144 .seq = SEQCNT_ZERO(init_fs.seq),
78145 .umask = 0022,
78146diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
78147index d403c69..30be0a9 100644
78148--- a/fs/fscache/cookie.c
78149+++ b/fs/fscache/cookie.c
78150@@ -19,7 +19,7 @@
78151
78152 struct kmem_cache *fscache_cookie_jar;
78153
78154-static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
78155+static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
78156
78157 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
78158 static int fscache_alloc_object(struct fscache_cache *cache,
78159@@ -69,11 +69,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
78160 parent ? (char *) parent->def->name : "<no-parent>",
78161 def->name, netfs_data, enable);
78162
78163- fscache_stat(&fscache_n_acquires);
78164+ fscache_stat_unchecked(&fscache_n_acquires);
78165
78166 /* if there's no parent cookie, then we don't create one here either */
78167 if (!parent) {
78168- fscache_stat(&fscache_n_acquires_null);
78169+ fscache_stat_unchecked(&fscache_n_acquires_null);
78170 _leave(" [no parent]");
78171 return NULL;
78172 }
78173@@ -88,7 +88,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
78174 /* allocate and initialise a cookie */
78175 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
78176 if (!cookie) {
78177- fscache_stat(&fscache_n_acquires_oom);
78178+ fscache_stat_unchecked(&fscache_n_acquires_oom);
78179 _leave(" [ENOMEM]");
78180 return NULL;
78181 }
78182@@ -115,13 +115,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
78183
78184 switch (cookie->def->type) {
78185 case FSCACHE_COOKIE_TYPE_INDEX:
78186- fscache_stat(&fscache_n_cookie_index);
78187+ fscache_stat_unchecked(&fscache_n_cookie_index);
78188 break;
78189 case FSCACHE_COOKIE_TYPE_DATAFILE:
78190- fscache_stat(&fscache_n_cookie_data);
78191+ fscache_stat_unchecked(&fscache_n_cookie_data);
78192 break;
78193 default:
78194- fscache_stat(&fscache_n_cookie_special);
78195+ fscache_stat_unchecked(&fscache_n_cookie_special);
78196 break;
78197 }
78198
78199@@ -135,7 +135,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
78200 } else {
78201 atomic_dec(&parent->n_children);
78202 __fscache_cookie_put(cookie);
78203- fscache_stat(&fscache_n_acquires_nobufs);
78204+ fscache_stat_unchecked(&fscache_n_acquires_nobufs);
78205 _leave(" = NULL");
78206 return NULL;
78207 }
78208@@ -144,7 +144,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
78209 }
78210 }
78211
78212- fscache_stat(&fscache_n_acquires_ok);
78213+ fscache_stat_unchecked(&fscache_n_acquires_ok);
78214 _leave(" = %p", cookie);
78215 return cookie;
78216 }
78217@@ -213,7 +213,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
78218 cache = fscache_select_cache_for_object(cookie->parent);
78219 if (!cache) {
78220 up_read(&fscache_addremove_sem);
78221- fscache_stat(&fscache_n_acquires_no_cache);
78222+ fscache_stat_unchecked(&fscache_n_acquires_no_cache);
78223 _leave(" = -ENOMEDIUM [no cache]");
78224 return -ENOMEDIUM;
78225 }
78226@@ -297,14 +297,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
78227 object = cache->ops->alloc_object(cache, cookie);
78228 fscache_stat_d(&fscache_n_cop_alloc_object);
78229 if (IS_ERR(object)) {
78230- fscache_stat(&fscache_n_object_no_alloc);
78231+ fscache_stat_unchecked(&fscache_n_object_no_alloc);
78232 ret = PTR_ERR(object);
78233 goto error;
78234 }
78235
78236- fscache_stat(&fscache_n_object_alloc);
78237+ fscache_stat_unchecked(&fscache_n_object_alloc);
78238
78239- object->debug_id = atomic_inc_return(&fscache_object_debug_id);
78240+ object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
78241
78242 _debug("ALLOC OBJ%x: %s {%lx}",
78243 object->debug_id, cookie->def->name, object->events);
78244@@ -419,7 +419,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
78245
78246 _enter("{%s}", cookie->def->name);
78247
78248- fscache_stat(&fscache_n_invalidates);
78249+ fscache_stat_unchecked(&fscache_n_invalidates);
78250
78251 /* Only permit invalidation of data files. Invalidating an index will
78252 * require the caller to release all its attachments to the tree rooted
78253@@ -477,10 +477,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
78254 {
78255 struct fscache_object *object;
78256
78257- fscache_stat(&fscache_n_updates);
78258+ fscache_stat_unchecked(&fscache_n_updates);
78259
78260 if (!cookie) {
78261- fscache_stat(&fscache_n_updates_null);
78262+ fscache_stat_unchecked(&fscache_n_updates_null);
78263 _leave(" [no cookie]");
78264 return;
78265 }
78266@@ -581,12 +581,12 @@ EXPORT_SYMBOL(__fscache_disable_cookie);
78267 */
78268 void __fscache_relinquish_cookie(struct fscache_cookie *cookie, bool retire)
78269 {
78270- fscache_stat(&fscache_n_relinquishes);
78271+ fscache_stat_unchecked(&fscache_n_relinquishes);
78272 if (retire)
78273- fscache_stat(&fscache_n_relinquishes_retire);
78274+ fscache_stat_unchecked(&fscache_n_relinquishes_retire);
78275
78276 if (!cookie) {
78277- fscache_stat(&fscache_n_relinquishes_null);
78278+ fscache_stat_unchecked(&fscache_n_relinquishes_null);
78279 _leave(" [no cookie]");
78280 return;
78281 }
78282@@ -687,7 +687,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
78283 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
78284 goto inconsistent;
78285
78286- op->debug_id = atomic_inc_return(&fscache_op_debug_id);
78287+ op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
78288
78289 __fscache_use_cookie(cookie);
78290 if (fscache_submit_op(object, op) < 0)
78291diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
78292index 97ec451..f722cee 100644
78293--- a/fs/fscache/internal.h
78294+++ b/fs/fscache/internal.h
78295@@ -136,8 +136,8 @@ extern void fscache_operation_gc(struct work_struct *);
78296 extern int fscache_wait_for_deferred_lookup(struct fscache_cookie *);
78297 extern int fscache_wait_for_operation_activation(struct fscache_object *,
78298 struct fscache_operation *,
78299- atomic_t *,
78300- atomic_t *);
78301+ atomic_unchecked_t *,
78302+ atomic_unchecked_t *);
78303 extern void fscache_invalidate_writes(struct fscache_cookie *);
78304
78305 /*
78306@@ -155,102 +155,102 @@ extern void fscache_proc_cleanup(void);
78307 * stats.c
78308 */
78309 #ifdef CONFIG_FSCACHE_STATS
78310-extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
78311-extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
78312+extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
78313+extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
78314
78315-extern atomic_t fscache_n_op_pend;
78316-extern atomic_t fscache_n_op_run;
78317-extern atomic_t fscache_n_op_enqueue;
78318-extern atomic_t fscache_n_op_deferred_release;
78319-extern atomic_t fscache_n_op_initialised;
78320-extern atomic_t fscache_n_op_release;
78321-extern atomic_t fscache_n_op_gc;
78322-extern atomic_t fscache_n_op_cancelled;
78323-extern atomic_t fscache_n_op_rejected;
78324+extern atomic_unchecked_t fscache_n_op_pend;
78325+extern atomic_unchecked_t fscache_n_op_run;
78326+extern atomic_unchecked_t fscache_n_op_enqueue;
78327+extern atomic_unchecked_t fscache_n_op_deferred_release;
78328+extern atomic_unchecked_t fscache_n_op_initialised;
78329+extern atomic_unchecked_t fscache_n_op_release;
78330+extern atomic_unchecked_t fscache_n_op_gc;
78331+extern atomic_unchecked_t fscache_n_op_cancelled;
78332+extern atomic_unchecked_t fscache_n_op_rejected;
78333
78334-extern atomic_t fscache_n_attr_changed;
78335-extern atomic_t fscache_n_attr_changed_ok;
78336-extern atomic_t fscache_n_attr_changed_nobufs;
78337-extern atomic_t fscache_n_attr_changed_nomem;
78338-extern atomic_t fscache_n_attr_changed_calls;
78339+extern atomic_unchecked_t fscache_n_attr_changed;
78340+extern atomic_unchecked_t fscache_n_attr_changed_ok;
78341+extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
78342+extern atomic_unchecked_t fscache_n_attr_changed_nomem;
78343+extern atomic_unchecked_t fscache_n_attr_changed_calls;
78344
78345-extern atomic_t fscache_n_allocs;
78346-extern atomic_t fscache_n_allocs_ok;
78347-extern atomic_t fscache_n_allocs_wait;
78348-extern atomic_t fscache_n_allocs_nobufs;
78349-extern atomic_t fscache_n_allocs_intr;
78350-extern atomic_t fscache_n_allocs_object_dead;
78351-extern atomic_t fscache_n_alloc_ops;
78352-extern atomic_t fscache_n_alloc_op_waits;
78353+extern atomic_unchecked_t fscache_n_allocs;
78354+extern atomic_unchecked_t fscache_n_allocs_ok;
78355+extern atomic_unchecked_t fscache_n_allocs_wait;
78356+extern atomic_unchecked_t fscache_n_allocs_nobufs;
78357+extern atomic_unchecked_t fscache_n_allocs_intr;
78358+extern atomic_unchecked_t fscache_n_allocs_object_dead;
78359+extern atomic_unchecked_t fscache_n_alloc_ops;
78360+extern atomic_unchecked_t fscache_n_alloc_op_waits;
78361
78362-extern atomic_t fscache_n_retrievals;
78363-extern atomic_t fscache_n_retrievals_ok;
78364-extern atomic_t fscache_n_retrievals_wait;
78365-extern atomic_t fscache_n_retrievals_nodata;
78366-extern atomic_t fscache_n_retrievals_nobufs;
78367-extern atomic_t fscache_n_retrievals_intr;
78368-extern atomic_t fscache_n_retrievals_nomem;
78369-extern atomic_t fscache_n_retrievals_object_dead;
78370-extern atomic_t fscache_n_retrieval_ops;
78371-extern atomic_t fscache_n_retrieval_op_waits;
78372+extern atomic_unchecked_t fscache_n_retrievals;
78373+extern atomic_unchecked_t fscache_n_retrievals_ok;
78374+extern atomic_unchecked_t fscache_n_retrievals_wait;
78375+extern atomic_unchecked_t fscache_n_retrievals_nodata;
78376+extern atomic_unchecked_t fscache_n_retrievals_nobufs;
78377+extern atomic_unchecked_t fscache_n_retrievals_intr;
78378+extern atomic_unchecked_t fscache_n_retrievals_nomem;
78379+extern atomic_unchecked_t fscache_n_retrievals_object_dead;
78380+extern atomic_unchecked_t fscache_n_retrieval_ops;
78381+extern atomic_unchecked_t fscache_n_retrieval_op_waits;
78382
78383-extern atomic_t fscache_n_stores;
78384-extern atomic_t fscache_n_stores_ok;
78385-extern atomic_t fscache_n_stores_again;
78386-extern atomic_t fscache_n_stores_nobufs;
78387-extern atomic_t fscache_n_stores_oom;
78388-extern atomic_t fscache_n_store_ops;
78389-extern atomic_t fscache_n_store_calls;
78390-extern atomic_t fscache_n_store_pages;
78391-extern atomic_t fscache_n_store_radix_deletes;
78392-extern atomic_t fscache_n_store_pages_over_limit;
78393+extern atomic_unchecked_t fscache_n_stores;
78394+extern atomic_unchecked_t fscache_n_stores_ok;
78395+extern atomic_unchecked_t fscache_n_stores_again;
78396+extern atomic_unchecked_t fscache_n_stores_nobufs;
78397+extern atomic_unchecked_t fscache_n_stores_oom;
78398+extern atomic_unchecked_t fscache_n_store_ops;
78399+extern atomic_unchecked_t fscache_n_store_calls;
78400+extern atomic_unchecked_t fscache_n_store_pages;
78401+extern atomic_unchecked_t fscache_n_store_radix_deletes;
78402+extern atomic_unchecked_t fscache_n_store_pages_over_limit;
78403
78404-extern atomic_t fscache_n_store_vmscan_not_storing;
78405-extern atomic_t fscache_n_store_vmscan_gone;
78406-extern atomic_t fscache_n_store_vmscan_busy;
78407-extern atomic_t fscache_n_store_vmscan_cancelled;
78408-extern atomic_t fscache_n_store_vmscan_wait;
78409+extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
78410+extern atomic_unchecked_t fscache_n_store_vmscan_gone;
78411+extern atomic_unchecked_t fscache_n_store_vmscan_busy;
78412+extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
78413+extern atomic_unchecked_t fscache_n_store_vmscan_wait;
78414
78415-extern atomic_t fscache_n_marks;
78416-extern atomic_t fscache_n_uncaches;
78417+extern atomic_unchecked_t fscache_n_marks;
78418+extern atomic_unchecked_t fscache_n_uncaches;
78419
78420-extern atomic_t fscache_n_acquires;
78421-extern atomic_t fscache_n_acquires_null;
78422-extern atomic_t fscache_n_acquires_no_cache;
78423-extern atomic_t fscache_n_acquires_ok;
78424-extern atomic_t fscache_n_acquires_nobufs;
78425-extern atomic_t fscache_n_acquires_oom;
78426+extern atomic_unchecked_t fscache_n_acquires;
78427+extern atomic_unchecked_t fscache_n_acquires_null;
78428+extern atomic_unchecked_t fscache_n_acquires_no_cache;
78429+extern atomic_unchecked_t fscache_n_acquires_ok;
78430+extern atomic_unchecked_t fscache_n_acquires_nobufs;
78431+extern atomic_unchecked_t fscache_n_acquires_oom;
78432
78433-extern atomic_t fscache_n_invalidates;
78434-extern atomic_t fscache_n_invalidates_run;
78435+extern atomic_unchecked_t fscache_n_invalidates;
78436+extern atomic_unchecked_t fscache_n_invalidates_run;
78437
78438-extern atomic_t fscache_n_updates;
78439-extern atomic_t fscache_n_updates_null;
78440-extern atomic_t fscache_n_updates_run;
78441+extern atomic_unchecked_t fscache_n_updates;
78442+extern atomic_unchecked_t fscache_n_updates_null;
78443+extern atomic_unchecked_t fscache_n_updates_run;
78444
78445-extern atomic_t fscache_n_relinquishes;
78446-extern atomic_t fscache_n_relinquishes_null;
78447-extern atomic_t fscache_n_relinquishes_waitcrt;
78448-extern atomic_t fscache_n_relinquishes_retire;
78449+extern atomic_unchecked_t fscache_n_relinquishes;
78450+extern atomic_unchecked_t fscache_n_relinquishes_null;
78451+extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
78452+extern atomic_unchecked_t fscache_n_relinquishes_retire;
78453
78454-extern atomic_t fscache_n_cookie_index;
78455-extern atomic_t fscache_n_cookie_data;
78456-extern atomic_t fscache_n_cookie_special;
78457+extern atomic_unchecked_t fscache_n_cookie_index;
78458+extern atomic_unchecked_t fscache_n_cookie_data;
78459+extern atomic_unchecked_t fscache_n_cookie_special;
78460
78461-extern atomic_t fscache_n_object_alloc;
78462-extern atomic_t fscache_n_object_no_alloc;
78463-extern atomic_t fscache_n_object_lookups;
78464-extern atomic_t fscache_n_object_lookups_negative;
78465-extern atomic_t fscache_n_object_lookups_positive;
78466-extern atomic_t fscache_n_object_lookups_timed_out;
78467-extern atomic_t fscache_n_object_created;
78468-extern atomic_t fscache_n_object_avail;
78469-extern atomic_t fscache_n_object_dead;
78470+extern atomic_unchecked_t fscache_n_object_alloc;
78471+extern atomic_unchecked_t fscache_n_object_no_alloc;
78472+extern atomic_unchecked_t fscache_n_object_lookups;
78473+extern atomic_unchecked_t fscache_n_object_lookups_negative;
78474+extern atomic_unchecked_t fscache_n_object_lookups_positive;
78475+extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
78476+extern atomic_unchecked_t fscache_n_object_created;
78477+extern atomic_unchecked_t fscache_n_object_avail;
78478+extern atomic_unchecked_t fscache_n_object_dead;
78479
78480-extern atomic_t fscache_n_checkaux_none;
78481-extern atomic_t fscache_n_checkaux_okay;
78482-extern atomic_t fscache_n_checkaux_update;
78483-extern atomic_t fscache_n_checkaux_obsolete;
78484+extern atomic_unchecked_t fscache_n_checkaux_none;
78485+extern atomic_unchecked_t fscache_n_checkaux_okay;
78486+extern atomic_unchecked_t fscache_n_checkaux_update;
78487+extern atomic_unchecked_t fscache_n_checkaux_obsolete;
78488
78489 extern atomic_t fscache_n_cop_alloc_object;
78490 extern atomic_t fscache_n_cop_lookup_object;
78491@@ -280,6 +280,11 @@ static inline void fscache_stat(atomic_t *stat)
78492 atomic_inc(stat);
78493 }
78494
78495+static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
78496+{
78497+ atomic_inc_unchecked(stat);
78498+}
78499+
78500 static inline void fscache_stat_d(atomic_t *stat)
78501 {
78502 atomic_dec(stat);
78503@@ -292,6 +297,7 @@ extern const struct file_operations fscache_stats_fops;
78504
78505 #define __fscache_stat(stat) (NULL)
78506 #define fscache_stat(stat) do {} while (0)
78507+#define fscache_stat_unchecked(stat) do {} while (0)
78508 #define fscache_stat_d(stat) do {} while (0)
78509 #endif
78510
78511diff --git a/fs/fscache/object.c b/fs/fscache/object.c
78512index 9e792e3..6b2affb 100644
78513--- a/fs/fscache/object.c
78514+++ b/fs/fscache/object.c
78515@@ -465,7 +465,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
78516 _debug("LOOKUP \"%s\" in \"%s\"",
78517 cookie->def->name, object->cache->tag->name);
78518
78519- fscache_stat(&fscache_n_object_lookups);
78520+ fscache_stat_unchecked(&fscache_n_object_lookups);
78521 fscache_stat(&fscache_n_cop_lookup_object);
78522 ret = object->cache->ops->lookup_object(object);
78523 fscache_stat_d(&fscache_n_cop_lookup_object);
78524@@ -475,7 +475,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
78525 if (ret == -ETIMEDOUT) {
78526 /* probably stuck behind another object, so move this one to
78527 * the back of the queue */
78528- fscache_stat(&fscache_n_object_lookups_timed_out);
78529+ fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
78530 _leave(" [timeout]");
78531 return NO_TRANSIT;
78532 }
78533@@ -503,7 +503,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
78534 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
78535
78536 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
78537- fscache_stat(&fscache_n_object_lookups_negative);
78538+ fscache_stat_unchecked(&fscache_n_object_lookups_negative);
78539
78540 /* Allow write requests to begin stacking up and read requests to begin
78541 * returning ENODATA.
78542@@ -538,7 +538,7 @@ void fscache_obtained_object(struct fscache_object *object)
78543 /* if we were still looking up, then we must have a positive lookup
78544 * result, in which case there may be data available */
78545 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
78546- fscache_stat(&fscache_n_object_lookups_positive);
78547+ fscache_stat_unchecked(&fscache_n_object_lookups_positive);
78548
78549 /* We do (presumably) have data */
78550 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
78551@@ -550,7 +550,7 @@ void fscache_obtained_object(struct fscache_object *object)
78552 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
78553 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
78554 } else {
78555- fscache_stat(&fscache_n_object_created);
78556+ fscache_stat_unchecked(&fscache_n_object_created);
78557 }
78558
78559 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
78560@@ -586,7 +586,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
78561 fscache_stat_d(&fscache_n_cop_lookup_complete);
78562
78563 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
78564- fscache_stat(&fscache_n_object_avail);
78565+ fscache_stat_unchecked(&fscache_n_object_avail);
78566
78567 _leave("");
78568 return transit_to(JUMPSTART_DEPS);
78569@@ -735,7 +735,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
78570
78571 /* this just shifts the object release to the work processor */
78572 fscache_put_object(object);
78573- fscache_stat(&fscache_n_object_dead);
78574+ fscache_stat_unchecked(&fscache_n_object_dead);
78575
78576 _leave("");
78577 return transit_to(OBJECT_DEAD);
78578@@ -900,7 +900,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
78579 enum fscache_checkaux result;
78580
78581 if (!object->cookie->def->check_aux) {
78582- fscache_stat(&fscache_n_checkaux_none);
78583+ fscache_stat_unchecked(&fscache_n_checkaux_none);
78584 return FSCACHE_CHECKAUX_OKAY;
78585 }
78586
78587@@ -909,17 +909,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
78588 switch (result) {
78589 /* entry okay as is */
78590 case FSCACHE_CHECKAUX_OKAY:
78591- fscache_stat(&fscache_n_checkaux_okay);
78592+ fscache_stat_unchecked(&fscache_n_checkaux_okay);
78593 break;
78594
78595 /* entry requires update */
78596 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
78597- fscache_stat(&fscache_n_checkaux_update);
78598+ fscache_stat_unchecked(&fscache_n_checkaux_update);
78599 break;
78600
78601 /* entry requires deletion */
78602 case FSCACHE_CHECKAUX_OBSOLETE:
78603- fscache_stat(&fscache_n_checkaux_obsolete);
78604+ fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
78605 break;
78606
78607 default:
78608@@ -1007,7 +1007,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
78609 {
78610 const struct fscache_state *s;
78611
78612- fscache_stat(&fscache_n_invalidates_run);
78613+ fscache_stat_unchecked(&fscache_n_invalidates_run);
78614 fscache_stat(&fscache_n_cop_invalidate_object);
78615 s = _fscache_invalidate_object(object, event);
78616 fscache_stat_d(&fscache_n_cop_invalidate_object);
78617@@ -1022,7 +1022,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
78618 {
78619 _enter("{OBJ%x},%d", object->debug_id, event);
78620
78621- fscache_stat(&fscache_n_updates_run);
78622+ fscache_stat_unchecked(&fscache_n_updates_run);
78623 fscache_stat(&fscache_n_cop_update_object);
78624 object->cache->ops->update_object(object);
78625 fscache_stat_d(&fscache_n_cop_update_object);
78626diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
78627index de67745..6a3a9b6 100644
78628--- a/fs/fscache/operation.c
78629+++ b/fs/fscache/operation.c
78630@@ -17,7 +17,7 @@
78631 #include <linux/slab.h>
78632 #include "internal.h"
78633
78634-atomic_t fscache_op_debug_id;
78635+atomic_unchecked_t fscache_op_debug_id;
78636 EXPORT_SYMBOL(fscache_op_debug_id);
78637
78638 static void fscache_operation_dummy_cancel(struct fscache_operation *op)
78639@@ -40,12 +40,12 @@ void fscache_operation_init(struct fscache_operation *op,
78640 INIT_WORK(&op->work, fscache_op_work_func);
78641 atomic_set(&op->usage, 1);
78642 op->state = FSCACHE_OP_ST_INITIALISED;
78643- op->debug_id = atomic_inc_return(&fscache_op_debug_id);
78644+ op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
78645 op->processor = processor;
78646 op->cancel = cancel ?: fscache_operation_dummy_cancel;
78647 op->release = release;
78648 INIT_LIST_HEAD(&op->pend_link);
78649- fscache_stat(&fscache_n_op_initialised);
78650+ fscache_stat_unchecked(&fscache_n_op_initialised);
78651 }
78652 EXPORT_SYMBOL(fscache_operation_init);
78653
78654@@ -68,7 +68,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
78655 ASSERTCMP(atomic_read(&op->usage), >, 0);
78656 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
78657
78658- fscache_stat(&fscache_n_op_enqueue);
78659+ fscache_stat_unchecked(&fscache_n_op_enqueue);
78660 switch (op->flags & FSCACHE_OP_TYPE) {
78661 case FSCACHE_OP_ASYNC:
78662 _debug("queue async");
78663@@ -101,7 +101,7 @@ static void fscache_run_op(struct fscache_object *object,
78664 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
78665 if (op->processor)
78666 fscache_enqueue_operation(op);
78667- fscache_stat(&fscache_n_op_run);
78668+ fscache_stat_unchecked(&fscache_n_op_run);
78669 }
78670
78671 /*
78672@@ -169,7 +169,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
78673 op->state = FSCACHE_OP_ST_PENDING;
78674 flags = READ_ONCE(object->flags);
78675 if (unlikely(!(flags & BIT(FSCACHE_OBJECT_IS_LIVE)))) {
78676- fscache_stat(&fscache_n_op_rejected);
78677+ fscache_stat_unchecked(&fscache_n_op_rejected);
78678 op->cancel(op);
78679 op->state = FSCACHE_OP_ST_CANCELLED;
78680 ret = -ENOBUFS;
78681@@ -185,11 +185,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
78682 if (object->n_in_progress > 0) {
78683 atomic_inc(&op->usage);
78684 list_add_tail(&op->pend_link, &object->pending_ops);
78685- fscache_stat(&fscache_n_op_pend);
78686+ fscache_stat_unchecked(&fscache_n_op_pend);
78687 } else if (!list_empty(&object->pending_ops)) {
78688 atomic_inc(&op->usage);
78689 list_add_tail(&op->pend_link, &object->pending_ops);
78690- fscache_stat(&fscache_n_op_pend);
78691+ fscache_stat_unchecked(&fscache_n_op_pend);
78692 fscache_start_operations(object);
78693 } else {
78694 ASSERTCMP(object->n_in_progress, ==, 0);
78695@@ -205,7 +205,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
78696 object->n_exclusive++; /* reads and writes must wait */
78697 atomic_inc(&op->usage);
78698 list_add_tail(&op->pend_link, &object->pending_ops);
78699- fscache_stat(&fscache_n_op_pend);
78700+ fscache_stat_unchecked(&fscache_n_op_pend);
78701 ret = 0;
78702 } else if (flags & BIT(FSCACHE_OBJECT_KILLED_BY_CACHE)) {
78703 op->cancel(op);
78704@@ -254,7 +254,7 @@ int fscache_submit_op(struct fscache_object *object,
78705 op->state = FSCACHE_OP_ST_PENDING;
78706 flags = READ_ONCE(object->flags);
78707 if (unlikely(!(flags & BIT(FSCACHE_OBJECT_IS_LIVE)))) {
78708- fscache_stat(&fscache_n_op_rejected);
78709+ fscache_stat_unchecked(&fscache_n_op_rejected);
78710 op->cancel(op);
78711 op->state = FSCACHE_OP_ST_CANCELLED;
78712 ret = -ENOBUFS;
78713@@ -269,11 +269,11 @@ int fscache_submit_op(struct fscache_object *object,
78714 if (object->n_exclusive > 0) {
78715 atomic_inc(&op->usage);
78716 list_add_tail(&op->pend_link, &object->pending_ops);
78717- fscache_stat(&fscache_n_op_pend);
78718+ fscache_stat_unchecked(&fscache_n_op_pend);
78719 } else if (!list_empty(&object->pending_ops)) {
78720 atomic_inc(&op->usage);
78721 list_add_tail(&op->pend_link, &object->pending_ops);
78722- fscache_stat(&fscache_n_op_pend);
78723+ fscache_stat_unchecked(&fscache_n_op_pend);
78724 fscache_start_operations(object);
78725 } else {
78726 ASSERTCMP(object->n_exclusive, ==, 0);
78727@@ -285,7 +285,7 @@ int fscache_submit_op(struct fscache_object *object,
78728 object->n_ops++;
78729 atomic_inc(&op->usage);
78730 list_add_tail(&op->pend_link, &object->pending_ops);
78731- fscache_stat(&fscache_n_op_pend);
78732+ fscache_stat_unchecked(&fscache_n_op_pend);
78733 ret = 0;
78734 } else if (flags & BIT(FSCACHE_OBJECT_KILLED_BY_CACHE)) {
78735 op->cancel(op);
78736@@ -369,7 +369,7 @@ int fscache_cancel_op(struct fscache_operation *op,
78737 list_del_init(&op->pend_link);
78738 put = true;
78739
78740- fscache_stat(&fscache_n_op_cancelled);
78741+ fscache_stat_unchecked(&fscache_n_op_cancelled);
78742 op->cancel(op);
78743 op->state = FSCACHE_OP_ST_CANCELLED;
78744 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
78745@@ -385,7 +385,7 @@ int fscache_cancel_op(struct fscache_operation *op,
78746 if (object->n_in_progress == 0)
78747 fscache_start_operations(object);
78748
78749- fscache_stat(&fscache_n_op_cancelled);
78750+ fscache_stat_unchecked(&fscache_n_op_cancelled);
78751 op->cancel(op);
78752 op->state = FSCACHE_OP_ST_CANCELLED;
78753 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
78754@@ -416,7 +416,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
78755 while (!list_empty(&object->pending_ops)) {
78756 op = list_entry(object->pending_ops.next,
78757 struct fscache_operation, pend_link);
78758- fscache_stat(&fscache_n_op_cancelled);
78759+ fscache_stat_unchecked(&fscache_n_op_cancelled);
78760 list_del_init(&op->pend_link);
78761
78762 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
78763@@ -493,7 +493,7 @@ void fscache_put_operation(struct fscache_operation *op)
78764 op->state != FSCACHE_OP_ST_COMPLETE,
78765 op->state, ==, FSCACHE_OP_ST_CANCELLED);
78766
78767- fscache_stat(&fscache_n_op_release);
78768+ fscache_stat_unchecked(&fscache_n_op_release);
78769
78770 if (op->release) {
78771 op->release(op);
78772@@ -513,7 +513,7 @@ void fscache_put_operation(struct fscache_operation *op)
78773 * lock, and defer it otherwise */
78774 if (!spin_trylock(&object->lock)) {
78775 _debug("defer put");
78776- fscache_stat(&fscache_n_op_deferred_release);
78777+ fscache_stat_unchecked(&fscache_n_op_deferred_release);
78778
78779 cache = object->cache;
78780 spin_lock(&cache->op_gc_list_lock);
78781@@ -567,7 +567,7 @@ void fscache_operation_gc(struct work_struct *work)
78782
78783 _debug("GC DEFERRED REL OBJ%x OP%x",
78784 object->debug_id, op->debug_id);
78785- fscache_stat(&fscache_n_op_gc);
78786+ fscache_stat_unchecked(&fscache_n_op_gc);
78787
78788 ASSERTCMP(atomic_read(&op->usage), ==, 0);
78789 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
78790diff --git a/fs/fscache/page.c b/fs/fscache/page.c
78791index 483bbc6..ba36737 100644
78792--- a/fs/fscache/page.c
78793+++ b/fs/fscache/page.c
78794@@ -74,7 +74,7 @@ try_again:
78795 val = radix_tree_lookup(&cookie->stores, page->index);
78796 if (!val) {
78797 rcu_read_unlock();
78798- fscache_stat(&fscache_n_store_vmscan_not_storing);
78799+ fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
78800 __fscache_uncache_page(cookie, page);
78801 return true;
78802 }
78803@@ -104,11 +104,11 @@ try_again:
78804 spin_unlock(&cookie->stores_lock);
78805
78806 if (xpage) {
78807- fscache_stat(&fscache_n_store_vmscan_cancelled);
78808- fscache_stat(&fscache_n_store_radix_deletes);
78809+ fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
78810+ fscache_stat_unchecked(&fscache_n_store_radix_deletes);
78811 ASSERTCMP(xpage, ==, page);
78812 } else {
78813- fscache_stat(&fscache_n_store_vmscan_gone);
78814+ fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
78815 }
78816
78817 wake_up_bit(&cookie->flags, 0);
78818@@ -123,11 +123,11 @@ page_busy:
78819 * sleeping on memory allocation, so we may need to impose a timeout
78820 * too. */
78821 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
78822- fscache_stat(&fscache_n_store_vmscan_busy);
78823+ fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
78824 return false;
78825 }
78826
78827- fscache_stat(&fscache_n_store_vmscan_wait);
78828+ fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
78829 if (!release_page_wait_timeout(cookie, page))
78830 _debug("fscache writeout timeout page: %p{%lx}",
78831 page, page->index);
78832@@ -156,7 +156,7 @@ static void fscache_end_page_write(struct fscache_object *object,
78833 FSCACHE_COOKIE_STORING_TAG);
78834 if (!radix_tree_tag_get(&cookie->stores, page->index,
78835 FSCACHE_COOKIE_PENDING_TAG)) {
78836- fscache_stat(&fscache_n_store_radix_deletes);
78837+ fscache_stat_unchecked(&fscache_n_store_radix_deletes);
78838 xpage = radix_tree_delete(&cookie->stores, page->index);
78839 }
78840 spin_unlock(&cookie->stores_lock);
78841@@ -177,7 +177,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
78842
78843 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
78844
78845- fscache_stat(&fscache_n_attr_changed_calls);
78846+ fscache_stat_unchecked(&fscache_n_attr_changed_calls);
78847
78848 if (fscache_object_is_active(object)) {
78849 fscache_stat(&fscache_n_cop_attr_changed);
78850@@ -204,11 +204,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
78851
78852 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
78853
78854- fscache_stat(&fscache_n_attr_changed);
78855+ fscache_stat_unchecked(&fscache_n_attr_changed);
78856
78857 op = kzalloc(sizeof(*op), GFP_KERNEL);
78858 if (!op) {
78859- fscache_stat(&fscache_n_attr_changed_nomem);
78860+ fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
78861 _leave(" = -ENOMEM");
78862 return -ENOMEM;
78863 }
78864@@ -230,7 +230,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
78865 if (fscache_submit_exclusive_op(object, op) < 0)
78866 goto nobufs_dec;
78867 spin_unlock(&cookie->lock);
78868- fscache_stat(&fscache_n_attr_changed_ok);
78869+ fscache_stat_unchecked(&fscache_n_attr_changed_ok);
78870 fscache_put_operation(op);
78871 _leave(" = 0");
78872 return 0;
78873@@ -242,7 +242,7 @@ nobufs:
78874 fscache_put_operation(op);
78875 if (wake_cookie)
78876 __fscache_wake_unused_cookie(cookie);
78877- fscache_stat(&fscache_n_attr_changed_nobufs);
78878+ fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
78879 _leave(" = %d", -ENOBUFS);
78880 return -ENOBUFS;
78881 }
78882@@ -293,7 +293,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
78883 /* allocate a retrieval operation and attempt to submit it */
78884 op = kzalloc(sizeof(*op), GFP_NOIO);
78885 if (!op) {
78886- fscache_stat(&fscache_n_retrievals_nomem);
78887+ fscache_stat_unchecked(&fscache_n_retrievals_nomem);
78888 return NULL;
78889 }
78890
78891@@ -332,12 +332,12 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
78892 return 0;
78893 }
78894
78895- fscache_stat(&fscache_n_retrievals_wait);
78896+ fscache_stat_unchecked(&fscache_n_retrievals_wait);
78897
78898 jif = jiffies;
78899 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
78900 TASK_INTERRUPTIBLE) != 0) {
78901- fscache_stat(&fscache_n_retrievals_intr);
78902+ fscache_stat_unchecked(&fscache_n_retrievals_intr);
78903 _leave(" = -ERESTARTSYS");
78904 return -ERESTARTSYS;
78905 }
78906@@ -355,8 +355,8 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
78907 */
78908 int fscache_wait_for_operation_activation(struct fscache_object *object,
78909 struct fscache_operation *op,
78910- atomic_t *stat_op_waits,
78911- atomic_t *stat_object_dead)
78912+ atomic_unchecked_t *stat_op_waits,
78913+ atomic_unchecked_t *stat_object_dead)
78914 {
78915 int ret;
78916
78917@@ -365,7 +365,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
78918
78919 _debug(">>> WT");
78920 if (stat_op_waits)
78921- fscache_stat(stat_op_waits);
78922+ fscache_stat_unchecked(stat_op_waits);
78923 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
78924 TASK_INTERRUPTIBLE) != 0) {
78925 ret = fscache_cancel_op(op, false);
78926@@ -382,7 +382,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
78927 check_if_dead:
78928 if (op->state == FSCACHE_OP_ST_CANCELLED) {
78929 if (stat_object_dead)
78930- fscache_stat(stat_object_dead);
78931+ fscache_stat_unchecked(stat_object_dead);
78932 _leave(" = -ENOBUFS [cancelled]");
78933 return -ENOBUFS;
78934 }
78935@@ -391,7 +391,7 @@ check_if_dead:
78936 enum fscache_operation_state state = op->state;
78937 fscache_cancel_op(op, true);
78938 if (stat_object_dead)
78939- fscache_stat(stat_object_dead);
78940+ fscache_stat_unchecked(stat_object_dead);
78941 _leave(" = -ENOBUFS [obj dead %d]", state);
78942 return -ENOBUFS;
78943 }
78944@@ -420,7 +420,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
78945
78946 _enter("%p,%p,,,", cookie, page);
78947
78948- fscache_stat(&fscache_n_retrievals);
78949+ fscache_stat_unchecked(&fscache_n_retrievals);
78950
78951 if (hlist_empty(&cookie->backing_objects))
78952 goto nobufs;
78953@@ -462,7 +462,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
78954 goto nobufs_unlock_dec;
78955 spin_unlock(&cookie->lock);
78956
78957- fscache_stat(&fscache_n_retrieval_ops);
78958+ fscache_stat_unchecked(&fscache_n_retrieval_ops);
78959
78960 /* we wait for the operation to become active, and then process it
78961 * *here*, in this thread, and not in the thread pool */
78962@@ -488,15 +488,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
78963
78964 error:
78965 if (ret == -ENOMEM)
78966- fscache_stat(&fscache_n_retrievals_nomem);
78967+ fscache_stat_unchecked(&fscache_n_retrievals_nomem);
78968 else if (ret == -ERESTARTSYS)
78969- fscache_stat(&fscache_n_retrievals_intr);
78970+ fscache_stat_unchecked(&fscache_n_retrievals_intr);
78971 else if (ret == -ENODATA)
78972- fscache_stat(&fscache_n_retrievals_nodata);
78973+ fscache_stat_unchecked(&fscache_n_retrievals_nodata);
78974 else if (ret < 0)
78975- fscache_stat(&fscache_n_retrievals_nobufs);
78976+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
78977 else
78978- fscache_stat(&fscache_n_retrievals_ok);
78979+ fscache_stat_unchecked(&fscache_n_retrievals_ok);
78980
78981 fscache_put_retrieval(op);
78982 _leave(" = %d", ret);
78983@@ -511,7 +511,7 @@ nobufs_unlock:
78984 __fscache_wake_unused_cookie(cookie);
78985 fscache_put_retrieval(op);
78986 nobufs:
78987- fscache_stat(&fscache_n_retrievals_nobufs);
78988+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
78989 _leave(" = -ENOBUFS");
78990 return -ENOBUFS;
78991 }
78992@@ -550,7 +550,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
78993
78994 _enter("%p,,%d,,,", cookie, *nr_pages);
78995
78996- fscache_stat(&fscache_n_retrievals);
78997+ fscache_stat_unchecked(&fscache_n_retrievals);
78998
78999 if (hlist_empty(&cookie->backing_objects))
79000 goto nobufs;
79001@@ -588,7 +588,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
79002 goto nobufs_unlock_dec;
79003 spin_unlock(&cookie->lock);
79004
79005- fscache_stat(&fscache_n_retrieval_ops);
79006+ fscache_stat_unchecked(&fscache_n_retrieval_ops);
79007
79008 /* we wait for the operation to become active, and then process it
79009 * *here*, in this thread, and not in the thread pool */
79010@@ -614,15 +614,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
79011
79012 error:
79013 if (ret == -ENOMEM)
79014- fscache_stat(&fscache_n_retrievals_nomem);
79015+ fscache_stat_unchecked(&fscache_n_retrievals_nomem);
79016 else if (ret == -ERESTARTSYS)
79017- fscache_stat(&fscache_n_retrievals_intr);
79018+ fscache_stat_unchecked(&fscache_n_retrievals_intr);
79019 else if (ret == -ENODATA)
79020- fscache_stat(&fscache_n_retrievals_nodata);
79021+ fscache_stat_unchecked(&fscache_n_retrievals_nodata);
79022 else if (ret < 0)
79023- fscache_stat(&fscache_n_retrievals_nobufs);
79024+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
79025 else
79026- fscache_stat(&fscache_n_retrievals_ok);
79027+ fscache_stat_unchecked(&fscache_n_retrievals_ok);
79028
79029 fscache_put_retrieval(op);
79030 _leave(" = %d", ret);
79031@@ -637,7 +637,7 @@ nobufs_unlock:
79032 if (wake_cookie)
79033 __fscache_wake_unused_cookie(cookie);
79034 nobufs:
79035- fscache_stat(&fscache_n_retrievals_nobufs);
79036+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
79037 _leave(" = -ENOBUFS");
79038 return -ENOBUFS;
79039 }
79040@@ -662,7 +662,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
79041
79042 _enter("%p,%p,,,", cookie, page);
79043
79044- fscache_stat(&fscache_n_allocs);
79045+ fscache_stat_unchecked(&fscache_n_allocs);
79046
79047 if (hlist_empty(&cookie->backing_objects))
79048 goto nobufs;
79049@@ -696,7 +696,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
79050 goto nobufs_unlock_dec;
79051 spin_unlock(&cookie->lock);
79052
79053- fscache_stat(&fscache_n_alloc_ops);
79054+ fscache_stat_unchecked(&fscache_n_alloc_ops);
79055
79056 ret = fscache_wait_for_operation_activation(
79057 object, &op->op,
79058@@ -712,11 +712,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
79059
79060 error:
79061 if (ret == -ERESTARTSYS)
79062- fscache_stat(&fscache_n_allocs_intr);
79063+ fscache_stat_unchecked(&fscache_n_allocs_intr);
79064 else if (ret < 0)
79065- fscache_stat(&fscache_n_allocs_nobufs);
79066+ fscache_stat_unchecked(&fscache_n_allocs_nobufs);
79067 else
79068- fscache_stat(&fscache_n_allocs_ok);
79069+ fscache_stat_unchecked(&fscache_n_allocs_ok);
79070
79071 fscache_put_retrieval(op);
79072 _leave(" = %d", ret);
79073@@ -730,7 +730,7 @@ nobufs_unlock:
79074 if (wake_cookie)
79075 __fscache_wake_unused_cookie(cookie);
79076 nobufs:
79077- fscache_stat(&fscache_n_allocs_nobufs);
79078+ fscache_stat_unchecked(&fscache_n_allocs_nobufs);
79079 _leave(" = -ENOBUFS");
79080 return -ENOBUFS;
79081 }
79082@@ -806,7 +806,7 @@ static void fscache_write_op(struct fscache_operation *_op)
79083
79084 spin_lock(&cookie->stores_lock);
79085
79086- fscache_stat(&fscache_n_store_calls);
79087+ fscache_stat_unchecked(&fscache_n_store_calls);
79088
79089 /* find a page to store */
79090 page = NULL;
79091@@ -817,7 +817,7 @@ static void fscache_write_op(struct fscache_operation *_op)
79092 page = results[0];
79093 _debug("gang %d [%lx]", n, page->index);
79094 if (page->index > op->store_limit) {
79095- fscache_stat(&fscache_n_store_pages_over_limit);
79096+ fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
79097 goto superseded;
79098 }
79099
79100@@ -829,7 +829,7 @@ static void fscache_write_op(struct fscache_operation *_op)
79101 spin_unlock(&cookie->stores_lock);
79102 spin_unlock(&object->lock);
79103
79104- fscache_stat(&fscache_n_store_pages);
79105+ fscache_stat_unchecked(&fscache_n_store_pages);
79106 fscache_stat(&fscache_n_cop_write_page);
79107 ret = object->cache->ops->write_page(op, page);
79108 fscache_stat_d(&fscache_n_cop_write_page);
79109@@ -933,7 +933,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
79110 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
79111 ASSERT(PageFsCache(page));
79112
79113- fscache_stat(&fscache_n_stores);
79114+ fscache_stat_unchecked(&fscache_n_stores);
79115
79116 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
79117 _leave(" = -ENOBUFS [invalidating]");
79118@@ -992,7 +992,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
79119 spin_unlock(&cookie->stores_lock);
79120 spin_unlock(&object->lock);
79121
79122- op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
79123+ op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
79124 op->store_limit = object->store_limit;
79125
79126 __fscache_use_cookie(cookie);
79127@@ -1001,8 +1001,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
79128
79129 spin_unlock(&cookie->lock);
79130 radix_tree_preload_end();
79131- fscache_stat(&fscache_n_store_ops);
79132- fscache_stat(&fscache_n_stores_ok);
79133+ fscache_stat_unchecked(&fscache_n_store_ops);
79134+ fscache_stat_unchecked(&fscache_n_stores_ok);
79135
79136 /* the work queue now carries its own ref on the object */
79137 fscache_put_operation(&op->op);
79138@@ -1010,14 +1010,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
79139 return 0;
79140
79141 already_queued:
79142- fscache_stat(&fscache_n_stores_again);
79143+ fscache_stat_unchecked(&fscache_n_stores_again);
79144 already_pending:
79145 spin_unlock(&cookie->stores_lock);
79146 spin_unlock(&object->lock);
79147 spin_unlock(&cookie->lock);
79148 radix_tree_preload_end();
79149 fscache_put_operation(&op->op);
79150- fscache_stat(&fscache_n_stores_ok);
79151+ fscache_stat_unchecked(&fscache_n_stores_ok);
79152 _leave(" = 0");
79153 return 0;
79154
79155@@ -1039,14 +1039,14 @@ nobufs:
79156 fscache_put_operation(&op->op);
79157 if (wake_cookie)
79158 __fscache_wake_unused_cookie(cookie);
79159- fscache_stat(&fscache_n_stores_nobufs);
79160+ fscache_stat_unchecked(&fscache_n_stores_nobufs);
79161 _leave(" = -ENOBUFS");
79162 return -ENOBUFS;
79163
79164 nomem_free:
79165 fscache_put_operation(&op->op);
79166 nomem:
79167- fscache_stat(&fscache_n_stores_oom);
79168+ fscache_stat_unchecked(&fscache_n_stores_oom);
79169 _leave(" = -ENOMEM");
79170 return -ENOMEM;
79171 }
79172@@ -1064,7 +1064,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
79173 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
79174 ASSERTCMP(page, !=, NULL);
79175
79176- fscache_stat(&fscache_n_uncaches);
79177+ fscache_stat_unchecked(&fscache_n_uncaches);
79178
79179 /* cache withdrawal may beat us to it */
79180 if (!PageFsCache(page))
79181@@ -1115,7 +1115,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
79182 struct fscache_cookie *cookie = op->op.object->cookie;
79183
79184 #ifdef CONFIG_FSCACHE_STATS
79185- atomic_inc(&fscache_n_marks);
79186+ atomic_inc_unchecked(&fscache_n_marks);
79187 #endif
79188
79189 _debug("- mark %p{%lx}", page, page->index);
79190diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
79191index 7cfa0aa..d5ef97b7 100644
79192--- a/fs/fscache/stats.c
79193+++ b/fs/fscache/stats.c
79194@@ -18,100 +18,100 @@
79195 /*
79196 * operation counters
79197 */
79198-atomic_t fscache_n_op_pend;
79199-atomic_t fscache_n_op_run;
79200-atomic_t fscache_n_op_enqueue;
79201-atomic_t fscache_n_op_requeue;
79202-atomic_t fscache_n_op_deferred_release;
79203-atomic_t fscache_n_op_initialised;
79204-atomic_t fscache_n_op_release;
79205-atomic_t fscache_n_op_gc;
79206-atomic_t fscache_n_op_cancelled;
79207-atomic_t fscache_n_op_rejected;
79208+atomic_unchecked_t fscache_n_op_pend;
79209+atomic_unchecked_t fscache_n_op_run;
79210+atomic_unchecked_t fscache_n_op_enqueue;
79211+atomic_unchecked_t fscache_n_op_requeue;
79212+atomic_unchecked_t fscache_n_op_deferred_release;
79213+atomic_unchecked_t fscache_n_op_initialised;
79214+atomic_unchecked_t fscache_n_op_release;
79215+atomic_unchecked_t fscache_n_op_gc;
79216+atomic_unchecked_t fscache_n_op_cancelled;
79217+atomic_unchecked_t fscache_n_op_rejected;
79218
79219-atomic_t fscache_n_attr_changed;
79220-atomic_t fscache_n_attr_changed_ok;
79221-atomic_t fscache_n_attr_changed_nobufs;
79222-atomic_t fscache_n_attr_changed_nomem;
79223-atomic_t fscache_n_attr_changed_calls;
79224+atomic_unchecked_t fscache_n_attr_changed;
79225+atomic_unchecked_t fscache_n_attr_changed_ok;
79226+atomic_unchecked_t fscache_n_attr_changed_nobufs;
79227+atomic_unchecked_t fscache_n_attr_changed_nomem;
79228+atomic_unchecked_t fscache_n_attr_changed_calls;
79229
79230-atomic_t fscache_n_allocs;
79231-atomic_t fscache_n_allocs_ok;
79232-atomic_t fscache_n_allocs_wait;
79233-atomic_t fscache_n_allocs_nobufs;
79234-atomic_t fscache_n_allocs_intr;
79235-atomic_t fscache_n_allocs_object_dead;
79236-atomic_t fscache_n_alloc_ops;
79237-atomic_t fscache_n_alloc_op_waits;
79238+atomic_unchecked_t fscache_n_allocs;
79239+atomic_unchecked_t fscache_n_allocs_ok;
79240+atomic_unchecked_t fscache_n_allocs_wait;
79241+atomic_unchecked_t fscache_n_allocs_nobufs;
79242+atomic_unchecked_t fscache_n_allocs_intr;
79243+atomic_unchecked_t fscache_n_allocs_object_dead;
79244+atomic_unchecked_t fscache_n_alloc_ops;
79245+atomic_unchecked_t fscache_n_alloc_op_waits;
79246
79247-atomic_t fscache_n_retrievals;
79248-atomic_t fscache_n_retrievals_ok;
79249-atomic_t fscache_n_retrievals_wait;
79250-atomic_t fscache_n_retrievals_nodata;
79251-atomic_t fscache_n_retrievals_nobufs;
79252-atomic_t fscache_n_retrievals_intr;
79253-atomic_t fscache_n_retrievals_nomem;
79254-atomic_t fscache_n_retrievals_object_dead;
79255-atomic_t fscache_n_retrieval_ops;
79256-atomic_t fscache_n_retrieval_op_waits;
79257+atomic_unchecked_t fscache_n_retrievals;
79258+atomic_unchecked_t fscache_n_retrievals_ok;
79259+atomic_unchecked_t fscache_n_retrievals_wait;
79260+atomic_unchecked_t fscache_n_retrievals_nodata;
79261+atomic_unchecked_t fscache_n_retrievals_nobufs;
79262+atomic_unchecked_t fscache_n_retrievals_intr;
79263+atomic_unchecked_t fscache_n_retrievals_nomem;
79264+atomic_unchecked_t fscache_n_retrievals_object_dead;
79265+atomic_unchecked_t fscache_n_retrieval_ops;
79266+atomic_unchecked_t fscache_n_retrieval_op_waits;
79267
79268-atomic_t fscache_n_stores;
79269-atomic_t fscache_n_stores_ok;
79270-atomic_t fscache_n_stores_again;
79271-atomic_t fscache_n_stores_nobufs;
79272-atomic_t fscache_n_stores_oom;
79273-atomic_t fscache_n_store_ops;
79274-atomic_t fscache_n_store_calls;
79275-atomic_t fscache_n_store_pages;
79276-atomic_t fscache_n_store_radix_deletes;
79277-atomic_t fscache_n_store_pages_over_limit;
79278+atomic_unchecked_t fscache_n_stores;
79279+atomic_unchecked_t fscache_n_stores_ok;
79280+atomic_unchecked_t fscache_n_stores_again;
79281+atomic_unchecked_t fscache_n_stores_nobufs;
79282+atomic_unchecked_t fscache_n_stores_oom;
79283+atomic_unchecked_t fscache_n_store_ops;
79284+atomic_unchecked_t fscache_n_store_calls;
79285+atomic_unchecked_t fscache_n_store_pages;
79286+atomic_unchecked_t fscache_n_store_radix_deletes;
79287+atomic_unchecked_t fscache_n_store_pages_over_limit;
79288
79289-atomic_t fscache_n_store_vmscan_not_storing;
79290-atomic_t fscache_n_store_vmscan_gone;
79291-atomic_t fscache_n_store_vmscan_busy;
79292-atomic_t fscache_n_store_vmscan_cancelled;
79293-atomic_t fscache_n_store_vmscan_wait;
79294+atomic_unchecked_t fscache_n_store_vmscan_not_storing;
79295+atomic_unchecked_t fscache_n_store_vmscan_gone;
79296+atomic_unchecked_t fscache_n_store_vmscan_busy;
79297+atomic_unchecked_t fscache_n_store_vmscan_cancelled;
79298+atomic_unchecked_t fscache_n_store_vmscan_wait;
79299
79300-atomic_t fscache_n_marks;
79301-atomic_t fscache_n_uncaches;
79302+atomic_unchecked_t fscache_n_marks;
79303+atomic_unchecked_t fscache_n_uncaches;
79304
79305-atomic_t fscache_n_acquires;
79306-atomic_t fscache_n_acquires_null;
79307-atomic_t fscache_n_acquires_no_cache;
79308-atomic_t fscache_n_acquires_ok;
79309-atomic_t fscache_n_acquires_nobufs;
79310-atomic_t fscache_n_acquires_oom;
79311+atomic_unchecked_t fscache_n_acquires;
79312+atomic_unchecked_t fscache_n_acquires_null;
79313+atomic_unchecked_t fscache_n_acquires_no_cache;
79314+atomic_unchecked_t fscache_n_acquires_ok;
79315+atomic_unchecked_t fscache_n_acquires_nobufs;
79316+atomic_unchecked_t fscache_n_acquires_oom;
79317
79318-atomic_t fscache_n_invalidates;
79319-atomic_t fscache_n_invalidates_run;
79320+atomic_unchecked_t fscache_n_invalidates;
79321+atomic_unchecked_t fscache_n_invalidates_run;
79322
79323-atomic_t fscache_n_updates;
79324-atomic_t fscache_n_updates_null;
79325-atomic_t fscache_n_updates_run;
79326+atomic_unchecked_t fscache_n_updates;
79327+atomic_unchecked_t fscache_n_updates_null;
79328+atomic_unchecked_t fscache_n_updates_run;
79329
79330-atomic_t fscache_n_relinquishes;
79331-atomic_t fscache_n_relinquishes_null;
79332-atomic_t fscache_n_relinquishes_waitcrt;
79333-atomic_t fscache_n_relinquishes_retire;
79334+atomic_unchecked_t fscache_n_relinquishes;
79335+atomic_unchecked_t fscache_n_relinquishes_null;
79336+atomic_unchecked_t fscache_n_relinquishes_waitcrt;
79337+atomic_unchecked_t fscache_n_relinquishes_retire;
79338
79339-atomic_t fscache_n_cookie_index;
79340-atomic_t fscache_n_cookie_data;
79341-atomic_t fscache_n_cookie_special;
79342+atomic_unchecked_t fscache_n_cookie_index;
79343+atomic_unchecked_t fscache_n_cookie_data;
79344+atomic_unchecked_t fscache_n_cookie_special;
79345
79346-atomic_t fscache_n_object_alloc;
79347-atomic_t fscache_n_object_no_alloc;
79348-atomic_t fscache_n_object_lookups;
79349-atomic_t fscache_n_object_lookups_negative;
79350-atomic_t fscache_n_object_lookups_positive;
79351-atomic_t fscache_n_object_lookups_timed_out;
79352-atomic_t fscache_n_object_created;
79353-atomic_t fscache_n_object_avail;
79354-atomic_t fscache_n_object_dead;
79355+atomic_unchecked_t fscache_n_object_alloc;
79356+atomic_unchecked_t fscache_n_object_no_alloc;
79357+atomic_unchecked_t fscache_n_object_lookups;
79358+atomic_unchecked_t fscache_n_object_lookups_negative;
79359+atomic_unchecked_t fscache_n_object_lookups_positive;
79360+atomic_unchecked_t fscache_n_object_lookups_timed_out;
79361+atomic_unchecked_t fscache_n_object_created;
79362+atomic_unchecked_t fscache_n_object_avail;
79363+atomic_unchecked_t fscache_n_object_dead;
79364
79365-atomic_t fscache_n_checkaux_none;
79366-atomic_t fscache_n_checkaux_okay;
79367-atomic_t fscache_n_checkaux_update;
79368-atomic_t fscache_n_checkaux_obsolete;
79369+atomic_unchecked_t fscache_n_checkaux_none;
79370+atomic_unchecked_t fscache_n_checkaux_okay;
79371+atomic_unchecked_t fscache_n_checkaux_update;
79372+atomic_unchecked_t fscache_n_checkaux_obsolete;
79373
79374 atomic_t fscache_n_cop_alloc_object;
79375 atomic_t fscache_n_cop_lookup_object;
79376@@ -144,119 +144,119 @@ static int fscache_stats_show(struct seq_file *m, void *v)
79377 seq_puts(m, "FS-Cache statistics\n");
79378
79379 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
79380- atomic_read(&fscache_n_cookie_index),
79381- atomic_read(&fscache_n_cookie_data),
79382- atomic_read(&fscache_n_cookie_special));
79383+ atomic_read_unchecked(&fscache_n_cookie_index),
79384+ atomic_read_unchecked(&fscache_n_cookie_data),
79385+ atomic_read_unchecked(&fscache_n_cookie_special));
79386
79387 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
79388- atomic_read(&fscache_n_object_alloc),
79389- atomic_read(&fscache_n_object_no_alloc),
79390- atomic_read(&fscache_n_object_avail),
79391- atomic_read(&fscache_n_object_dead));
79392+ atomic_read_unchecked(&fscache_n_object_alloc),
79393+ atomic_read_unchecked(&fscache_n_object_no_alloc),
79394+ atomic_read_unchecked(&fscache_n_object_avail),
79395+ atomic_read_unchecked(&fscache_n_object_dead));
79396 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
79397- atomic_read(&fscache_n_checkaux_none),
79398- atomic_read(&fscache_n_checkaux_okay),
79399- atomic_read(&fscache_n_checkaux_update),
79400- atomic_read(&fscache_n_checkaux_obsolete));
79401+ atomic_read_unchecked(&fscache_n_checkaux_none),
79402+ atomic_read_unchecked(&fscache_n_checkaux_okay),
79403+ atomic_read_unchecked(&fscache_n_checkaux_update),
79404+ atomic_read_unchecked(&fscache_n_checkaux_obsolete));
79405
79406 seq_printf(m, "Pages : mrk=%u unc=%u\n",
79407- atomic_read(&fscache_n_marks),
79408- atomic_read(&fscache_n_uncaches));
79409+ atomic_read_unchecked(&fscache_n_marks),
79410+ atomic_read_unchecked(&fscache_n_uncaches));
79411
79412 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
79413 " oom=%u\n",
79414- atomic_read(&fscache_n_acquires),
79415- atomic_read(&fscache_n_acquires_null),
79416- atomic_read(&fscache_n_acquires_no_cache),
79417- atomic_read(&fscache_n_acquires_ok),
79418- atomic_read(&fscache_n_acquires_nobufs),
79419- atomic_read(&fscache_n_acquires_oom));
79420+ atomic_read_unchecked(&fscache_n_acquires),
79421+ atomic_read_unchecked(&fscache_n_acquires_null),
79422+ atomic_read_unchecked(&fscache_n_acquires_no_cache),
79423+ atomic_read_unchecked(&fscache_n_acquires_ok),
79424+ atomic_read_unchecked(&fscache_n_acquires_nobufs),
79425+ atomic_read_unchecked(&fscache_n_acquires_oom));
79426
79427 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
79428- atomic_read(&fscache_n_object_lookups),
79429- atomic_read(&fscache_n_object_lookups_negative),
79430- atomic_read(&fscache_n_object_lookups_positive),
79431- atomic_read(&fscache_n_object_created),
79432- atomic_read(&fscache_n_object_lookups_timed_out));
79433+ atomic_read_unchecked(&fscache_n_object_lookups),
79434+ atomic_read_unchecked(&fscache_n_object_lookups_negative),
79435+ atomic_read_unchecked(&fscache_n_object_lookups_positive),
79436+ atomic_read_unchecked(&fscache_n_object_created),
79437+ atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
79438
79439 seq_printf(m, "Invals : n=%u run=%u\n",
79440- atomic_read(&fscache_n_invalidates),
79441- atomic_read(&fscache_n_invalidates_run));
79442+ atomic_read_unchecked(&fscache_n_invalidates),
79443+ atomic_read_unchecked(&fscache_n_invalidates_run));
79444
79445 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
79446- atomic_read(&fscache_n_updates),
79447- atomic_read(&fscache_n_updates_null),
79448- atomic_read(&fscache_n_updates_run));
79449+ atomic_read_unchecked(&fscache_n_updates),
79450+ atomic_read_unchecked(&fscache_n_updates_null),
79451+ atomic_read_unchecked(&fscache_n_updates_run));
79452
79453 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
79454- atomic_read(&fscache_n_relinquishes),
79455- atomic_read(&fscache_n_relinquishes_null),
79456- atomic_read(&fscache_n_relinquishes_waitcrt),
79457- atomic_read(&fscache_n_relinquishes_retire));
79458+ atomic_read_unchecked(&fscache_n_relinquishes),
79459+ atomic_read_unchecked(&fscache_n_relinquishes_null),
79460+ atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
79461+ atomic_read_unchecked(&fscache_n_relinquishes_retire));
79462
79463 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
79464- atomic_read(&fscache_n_attr_changed),
79465- atomic_read(&fscache_n_attr_changed_ok),
79466- atomic_read(&fscache_n_attr_changed_nobufs),
79467- atomic_read(&fscache_n_attr_changed_nomem),
79468- atomic_read(&fscache_n_attr_changed_calls));
79469+ atomic_read_unchecked(&fscache_n_attr_changed),
79470+ atomic_read_unchecked(&fscache_n_attr_changed_ok),
79471+ atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
79472+ atomic_read_unchecked(&fscache_n_attr_changed_nomem),
79473+ atomic_read_unchecked(&fscache_n_attr_changed_calls));
79474
79475 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
79476- atomic_read(&fscache_n_allocs),
79477- atomic_read(&fscache_n_allocs_ok),
79478- atomic_read(&fscache_n_allocs_wait),
79479- atomic_read(&fscache_n_allocs_nobufs),
79480- atomic_read(&fscache_n_allocs_intr));
79481+ atomic_read_unchecked(&fscache_n_allocs),
79482+ atomic_read_unchecked(&fscache_n_allocs_ok),
79483+ atomic_read_unchecked(&fscache_n_allocs_wait),
79484+ atomic_read_unchecked(&fscache_n_allocs_nobufs),
79485+ atomic_read_unchecked(&fscache_n_allocs_intr));
79486 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
79487- atomic_read(&fscache_n_alloc_ops),
79488- atomic_read(&fscache_n_alloc_op_waits),
79489- atomic_read(&fscache_n_allocs_object_dead));
79490+ atomic_read_unchecked(&fscache_n_alloc_ops),
79491+ atomic_read_unchecked(&fscache_n_alloc_op_waits),
79492+ atomic_read_unchecked(&fscache_n_allocs_object_dead));
79493
79494 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
79495 " int=%u oom=%u\n",
79496- atomic_read(&fscache_n_retrievals),
79497- atomic_read(&fscache_n_retrievals_ok),
79498- atomic_read(&fscache_n_retrievals_wait),
79499- atomic_read(&fscache_n_retrievals_nodata),
79500- atomic_read(&fscache_n_retrievals_nobufs),
79501- atomic_read(&fscache_n_retrievals_intr),
79502- atomic_read(&fscache_n_retrievals_nomem));
79503+ atomic_read_unchecked(&fscache_n_retrievals),
79504+ atomic_read_unchecked(&fscache_n_retrievals_ok),
79505+ atomic_read_unchecked(&fscache_n_retrievals_wait),
79506+ atomic_read_unchecked(&fscache_n_retrievals_nodata),
79507+ atomic_read_unchecked(&fscache_n_retrievals_nobufs),
79508+ atomic_read_unchecked(&fscache_n_retrievals_intr),
79509+ atomic_read_unchecked(&fscache_n_retrievals_nomem));
79510 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
79511- atomic_read(&fscache_n_retrieval_ops),
79512- atomic_read(&fscache_n_retrieval_op_waits),
79513- atomic_read(&fscache_n_retrievals_object_dead));
79514+ atomic_read_unchecked(&fscache_n_retrieval_ops),
79515+ atomic_read_unchecked(&fscache_n_retrieval_op_waits),
79516+ atomic_read_unchecked(&fscache_n_retrievals_object_dead));
79517
79518 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
79519- atomic_read(&fscache_n_stores),
79520- atomic_read(&fscache_n_stores_ok),
79521- atomic_read(&fscache_n_stores_again),
79522- atomic_read(&fscache_n_stores_nobufs),
79523- atomic_read(&fscache_n_stores_oom));
79524+ atomic_read_unchecked(&fscache_n_stores),
79525+ atomic_read_unchecked(&fscache_n_stores_ok),
79526+ atomic_read_unchecked(&fscache_n_stores_again),
79527+ atomic_read_unchecked(&fscache_n_stores_nobufs),
79528+ atomic_read_unchecked(&fscache_n_stores_oom));
79529 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
79530- atomic_read(&fscache_n_store_ops),
79531- atomic_read(&fscache_n_store_calls),
79532- atomic_read(&fscache_n_store_pages),
79533- atomic_read(&fscache_n_store_radix_deletes),
79534- atomic_read(&fscache_n_store_pages_over_limit));
79535+ atomic_read_unchecked(&fscache_n_store_ops),
79536+ atomic_read_unchecked(&fscache_n_store_calls),
79537+ atomic_read_unchecked(&fscache_n_store_pages),
79538+ atomic_read_unchecked(&fscache_n_store_radix_deletes),
79539+ atomic_read_unchecked(&fscache_n_store_pages_over_limit));
79540
79541 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
79542- atomic_read(&fscache_n_store_vmscan_not_storing),
79543- atomic_read(&fscache_n_store_vmscan_gone),
79544- atomic_read(&fscache_n_store_vmscan_busy),
79545- atomic_read(&fscache_n_store_vmscan_cancelled),
79546- atomic_read(&fscache_n_store_vmscan_wait));
79547+ atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
79548+ atomic_read_unchecked(&fscache_n_store_vmscan_gone),
79549+ atomic_read_unchecked(&fscache_n_store_vmscan_busy),
79550+ atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
79551+ atomic_read_unchecked(&fscache_n_store_vmscan_wait));
79552
79553 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
79554- atomic_read(&fscache_n_op_pend),
79555- atomic_read(&fscache_n_op_run),
79556- atomic_read(&fscache_n_op_enqueue),
79557- atomic_read(&fscache_n_op_cancelled),
79558- atomic_read(&fscache_n_op_rejected));
79559+ atomic_read_unchecked(&fscache_n_op_pend),
79560+ atomic_read_unchecked(&fscache_n_op_run),
79561+ atomic_read_unchecked(&fscache_n_op_enqueue),
79562+ atomic_read_unchecked(&fscache_n_op_cancelled),
79563+ atomic_read_unchecked(&fscache_n_op_rejected));
79564 seq_printf(m, "Ops : ini=%u dfr=%u rel=%u gc=%u\n",
79565- atomic_read(&fscache_n_op_initialised),
79566- atomic_read(&fscache_n_op_deferred_release),
79567- atomic_read(&fscache_n_op_release),
79568- atomic_read(&fscache_n_op_gc));
79569+ atomic_read_unchecked(&fscache_n_op_initialised),
79570+ atomic_read_unchecked(&fscache_n_op_deferred_release),
79571+ atomic_read_unchecked(&fscache_n_op_release),
79572+ atomic_read_unchecked(&fscache_n_op_gc));
79573
79574 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
79575 atomic_read(&fscache_n_cop_alloc_object),
79576diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
79577index eae2c11..b277a45 100644
79578--- a/fs/fuse/cuse.c
79579+++ b/fs/fuse/cuse.c
79580@@ -609,10 +609,12 @@ static int __init cuse_init(void)
79581 INIT_LIST_HEAD(&cuse_conntbl[i]);
79582
79583 /* inherit and extend fuse_dev_operations */
79584- cuse_channel_fops = fuse_dev_operations;
79585- cuse_channel_fops.owner = THIS_MODULE;
79586- cuse_channel_fops.open = cuse_channel_open;
79587- cuse_channel_fops.release = cuse_channel_release;
79588+ pax_open_kernel();
79589+ memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
79590+ *(void **)&cuse_channel_fops.owner = THIS_MODULE;
79591+ *(void **)&cuse_channel_fops.open = cuse_channel_open;
79592+ *(void **)&cuse_channel_fops.release = cuse_channel_release;
79593+ pax_close_kernel();
79594
79595 cuse_class = class_create(THIS_MODULE, "cuse");
79596 if (IS_ERR(cuse_class))
79597diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
79598index ebb5e37..beae05b 100644
79599--- a/fs/fuse/dev.c
79600+++ b/fs/fuse/dev.c
79601@@ -1390,7 +1390,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
79602 ret = 0;
79603 pipe_lock(pipe);
79604
79605- if (!pipe->readers) {
79606+ if (!atomic_read(&pipe->readers)) {
79607 send_sig(SIGPIPE, current, 0);
79608 if (!ret)
79609 ret = -EPIPE;
79610@@ -1419,7 +1419,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
79611 page_nr++;
79612 ret += buf->len;
79613
79614- if (pipe->files)
79615+ if (atomic_read(&pipe->files))
79616 do_wakeup = 1;
79617 }
79618
79619diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
79620index a38e38f..6dbdcf6 100644
79621--- a/fs/gfs2/glock.c
79622+++ b/fs/gfs2/glock.c
79623@@ -385,9 +385,9 @@ static void state_change(struct gfs2_glock *gl, unsigned int new_state)
79624 if (held1 != held2) {
79625 GLOCK_BUG_ON(gl, __lockref_is_dead(&gl->gl_lockref));
79626 if (held2)
79627- gl->gl_lockref.count++;
79628+ __lockref_inc(&gl->gl_lockref);
79629 else
79630- gl->gl_lockref.count--;
79631+ __lockref_dec(&gl->gl_lockref);
79632 }
79633 if (held1 && held2 && list_empty(&gl->gl_holders))
79634 clear_bit(GLF_QUEUED, &gl->gl_flags);
79635@@ -614,9 +614,9 @@ out:
79636 out_sched:
79637 clear_bit(GLF_LOCK, &gl->gl_flags);
79638 smp_mb__after_atomic();
79639- gl->gl_lockref.count++;
79640+ __lockref_inc(&gl->gl_lockref);
79641 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
79642- gl->gl_lockref.count--;
79643+ __lockref_dec(&gl->gl_lockref);
79644 return;
79645
79646 out_unlock:
79647@@ -742,7 +742,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
79648 gl->gl_sbd = sdp;
79649 gl->gl_flags = 0;
79650 gl->gl_name = name;
79651- gl->gl_lockref.count = 1;
79652+ __lockref_set(&gl->gl_lockref, 1);
79653 gl->gl_state = LM_ST_UNLOCKED;
79654 gl->gl_target = LM_ST_UNLOCKED;
79655 gl->gl_demote_state = LM_ST_EXCLUSIVE;
79656@@ -1020,9 +1020,9 @@ int gfs2_glock_nq(struct gfs2_holder *gh)
79657 if (unlikely((LM_FLAG_NOEXP & gh->gh_flags) &&
79658 test_and_clear_bit(GLF_FROZEN, &gl->gl_flags))) {
79659 set_bit(GLF_REPLY_PENDING, &gl->gl_flags);
79660- gl->gl_lockref.count++;
79661+ __lockref_inc(&gl->gl_lockref);
79662 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
79663- gl->gl_lockref.count--;
79664+ __lockref_dec(&gl->gl_lockref);
79665 }
79666 run_queue(gl, 1);
79667 spin_unlock(&gl->gl_spin);
79668@@ -1326,7 +1326,7 @@ void gfs2_glock_complete(struct gfs2_glock *gl, int ret)
79669 }
79670 }
79671
79672- gl->gl_lockref.count++;
79673+ __lockref_inc(&gl->gl_lockref);
79674 set_bit(GLF_REPLY_PENDING, &gl->gl_flags);
79675 spin_unlock(&gl->gl_spin);
79676
79677@@ -1385,12 +1385,12 @@ add_back_to_lru:
79678 goto add_back_to_lru;
79679 }
79680 clear_bit(GLF_LRU, &gl->gl_flags);
79681- gl->gl_lockref.count++;
79682+ __lockref_inc(&gl->gl_lockref);
79683 if (demote_ok(gl))
79684 handle_callback(gl, LM_ST_UNLOCKED, 0, false);
79685 WARN_ON(!test_and_clear_bit(GLF_LOCK, &gl->gl_flags));
79686 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
79687- gl->gl_lockref.count--;
79688+ __lockref_dec(&gl->gl_lockref);
79689 spin_unlock(&gl->gl_spin);
79690 cond_resched_lock(&lru_lock);
79691 }
79692@@ -1720,7 +1720,7 @@ void gfs2_dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
79693 state2str(gl->gl_demote_state), dtime,
79694 atomic_read(&gl->gl_ail_count),
79695 atomic_read(&gl->gl_revokes),
79696- (int)gl->gl_lockref.count, gl->gl_hold_time);
79697+ __lockref_read(&gl->gl_lockref), gl->gl_hold_time);
79698
79699 list_for_each_entry(gh, &gl->gl_holders, gh_list)
79700 dump_holder(seq, gh);
79701diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
79702index fa3fa5e..9fe2272 100644
79703--- a/fs/gfs2/glops.c
79704+++ b/fs/gfs2/glops.c
79705@@ -552,9 +552,9 @@ static void iopen_go_callback(struct gfs2_glock *gl, bool remote)
79706
79707 if (gl->gl_demote_state == LM_ST_UNLOCKED &&
79708 gl->gl_state == LM_ST_SHARED && ip) {
79709- gl->gl_lockref.count++;
79710+ __lockref_inc(&gl->gl_lockref);
79711 if (queue_work(gfs2_delete_workqueue, &gl->gl_delete) == 0)
79712- gl->gl_lockref.count--;
79713+ __lockref_dec(&gl->gl_lockref);
79714 }
79715 }
79716
79717diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
79718index 9b61f92..ab84778 100644
79719--- a/fs/gfs2/quota.c
79720+++ b/fs/gfs2/quota.c
79721@@ -154,7 +154,7 @@ static enum lru_status gfs2_qd_isolate(struct list_head *item,
79722 if (!spin_trylock(&qd->qd_lockref.lock))
79723 return LRU_SKIP;
79724
79725- if (qd->qd_lockref.count == 0) {
79726+ if (__lockref_read(&qd->qd_lockref) == 0) {
79727 lockref_mark_dead(&qd->qd_lockref);
79728 list_lru_isolate_move(lru, &qd->qd_lru, dispose);
79729 }
79730@@ -221,7 +221,7 @@ static struct gfs2_quota_data *qd_alloc(unsigned hash, struct gfs2_sbd *sdp, str
79731 return NULL;
79732
79733 qd->qd_sbd = sdp;
79734- qd->qd_lockref.count = 1;
79735+ __lockref_set(&qd->qd_lockref, 1);
79736 spin_lock_init(&qd->qd_lockref.lock);
79737 qd->qd_id = qid;
79738 qd->qd_slot = -1;
79739@@ -312,7 +312,7 @@ static void qd_put(struct gfs2_quota_data *qd)
79740 if (lockref_put_or_lock(&qd->qd_lockref))
79741 return;
79742
79743- qd->qd_lockref.count = 0;
79744+ __lockref_set(&qd->qd_lockref, 0);
79745 list_lru_add(&gfs2_qd_lru, &qd->qd_lru);
79746 spin_unlock(&qd->qd_lockref.lock);
79747
79748diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
79749index 973c24c..a3cbeb3 100644
79750--- a/fs/hugetlbfs/inode.c
79751+++ b/fs/hugetlbfs/inode.c
79752@@ -150,6 +150,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
79753 struct mm_struct *mm = current->mm;
79754 struct vm_area_struct *vma;
79755 struct hstate *h = hstate_file(file);
79756+ unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
79757 struct vm_unmapped_area_info info;
79758
79759 if (len & ~huge_page_mask(h))
79760@@ -163,17 +164,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
79761 return addr;
79762 }
79763
79764+#ifdef CONFIG_PAX_RANDMMAP
79765+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
79766+#endif
79767+
79768 if (addr) {
79769 addr = ALIGN(addr, huge_page_size(h));
79770 vma = find_vma(mm, addr);
79771- if (TASK_SIZE - len >= addr &&
79772- (!vma || addr + len <= vma->vm_start))
79773+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
79774 return addr;
79775 }
79776
79777 info.flags = 0;
79778 info.length = len;
79779 info.low_limit = TASK_UNMAPPED_BASE;
79780+
79781+#ifdef CONFIG_PAX_RANDMMAP
79782+ if (mm->pax_flags & MF_PAX_RANDMMAP)
79783+ info.low_limit += mm->delta_mmap;
79784+#endif
79785+
79786 info.high_limit = TASK_SIZE;
79787 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
79788 info.align_offset = 0;
79789@@ -938,7 +948,7 @@ static struct file_system_type hugetlbfs_fs_type = {
79790 };
79791 MODULE_ALIAS_FS("hugetlbfs");
79792
79793-static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
79794+struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
79795
79796 static int can_do_hugetlb_shm(void)
79797 {
79798diff --git a/fs/inode.c b/fs/inode.c
79799index d30640f..9d909a7 100644
79800--- a/fs/inode.c
79801+++ b/fs/inode.c
79802@@ -832,19 +832,19 @@ unsigned int get_next_ino(void)
79803 unsigned int *p = &get_cpu_var(last_ino);
79804 unsigned int res = *p;
79805
79806+start:
79807+
79808 #ifdef CONFIG_SMP
79809 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
79810- static atomic_t shared_last_ino;
79811- int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
79812+ static atomic_unchecked_t shared_last_ino;
79813+ int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
79814
79815 res = next - LAST_INO_BATCH;
79816 }
79817 #endif
79818
79819- res++;
79820- /* get_next_ino should not provide a 0 inode number */
79821- if (unlikely(!res))
79822- res++;
79823+ if (unlikely(!++res))
79824+ goto start; /* never zero */
79825 *p = res;
79826 put_cpu_var(last_ino);
79827 return res;
79828diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
79829index 4a6cf28..d3a29d3 100644
79830--- a/fs/jffs2/erase.c
79831+++ b/fs/jffs2/erase.c
79832@@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
79833 struct jffs2_unknown_node marker = {
79834 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
79835 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
79836- .totlen = cpu_to_je32(c->cleanmarker_size)
79837+ .totlen = cpu_to_je32(c->cleanmarker_size),
79838+ .hdr_crc = cpu_to_je32(0)
79839 };
79840
79841 jffs2_prealloc_raw_node_refs(c, jeb, 1);
79842diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
79843index 09ed551..45684f8 100644
79844--- a/fs/jffs2/wbuf.c
79845+++ b/fs/jffs2/wbuf.c
79846@@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
79847 {
79848 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
79849 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
79850- .totlen = constant_cpu_to_je32(8)
79851+ .totlen = constant_cpu_to_je32(8),
79852+ .hdr_crc = constant_cpu_to_je32(0)
79853 };
79854
79855 /*
79856diff --git a/fs/jfs/super.c b/fs/jfs/super.c
79857index 4cd9798..8dfe86a 100644
79858--- a/fs/jfs/super.c
79859+++ b/fs/jfs/super.c
79860@@ -901,7 +901,7 @@ static int __init init_jfs_fs(void)
79861
79862 jfs_inode_cachep =
79863 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
79864- SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
79865+ SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
79866 init_once);
79867 if (jfs_inode_cachep == NULL)
79868 return -ENOMEM;
79869diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
79870index 2d48d28..82eddad 100644
79871--- a/fs/kernfs/dir.c
79872+++ b/fs/kernfs/dir.c
79873@@ -182,7 +182,7 @@ struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn)
79874 *
79875 * Returns 31 bit hash of ns + name (so it fits in an off_t )
79876 */
79877-static unsigned int kernfs_name_hash(const char *name, const void *ns)
79878+static unsigned int kernfs_name_hash(const unsigned char *name, const void *ns)
79879 {
79880 unsigned long hash = init_name_hash();
79881 unsigned int len = strlen(name);
79882@@ -873,6 +873,12 @@ static int kernfs_iop_mkdir(struct inode *dir, struct dentry *dentry,
79883 ret = scops->mkdir(parent, dentry->d_name.name, mode);
79884
79885 kernfs_put_active(parent);
79886+
79887+ if (!ret) {
79888+ struct dentry *dentry_ret = kernfs_iop_lookup(dir, dentry, 0);
79889+ ret = PTR_ERR_OR_ZERO(dentry_ret);
79890+ }
79891+
79892 return ret;
79893 }
79894
79895diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
79896index 7247252..c73808e 100644
79897--- a/fs/kernfs/file.c
79898+++ b/fs/kernfs/file.c
79899@@ -34,7 +34,7 @@ static DEFINE_MUTEX(kernfs_open_file_mutex);
79900
79901 struct kernfs_open_node {
79902 atomic_t refcnt;
79903- atomic_t event;
79904+ atomic_unchecked_t event;
79905 wait_queue_head_t poll;
79906 struct list_head files; /* goes through kernfs_open_file.list */
79907 };
79908@@ -163,7 +163,7 @@ static int kernfs_seq_show(struct seq_file *sf, void *v)
79909 {
79910 struct kernfs_open_file *of = sf->private;
79911
79912- of->event = atomic_read(&of->kn->attr.open->event);
79913+ of->event = atomic_read_unchecked(&of->kn->attr.open->event);
79914
79915 return of->kn->attr.ops->seq_show(sf, v);
79916 }
79917@@ -207,7 +207,7 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of,
79918 goto out_free;
79919 }
79920
79921- of->event = atomic_read(&of->kn->attr.open->event);
79922+ of->event = atomic_read_unchecked(&of->kn->attr.open->event);
79923 ops = kernfs_ops(of->kn);
79924 if (ops->read)
79925 len = ops->read(of, buf, len, *ppos);
79926@@ -272,7 +272,7 @@ static ssize_t kernfs_fop_write(struct file *file, const char __user *user_buf,
79927 {
79928 struct kernfs_open_file *of = kernfs_of(file);
79929 const struct kernfs_ops *ops;
79930- size_t len;
79931+ ssize_t len;
79932 char *buf;
79933
79934 if (of->atomic_write_len) {
79935@@ -385,12 +385,12 @@ static int kernfs_vma_page_mkwrite(struct vm_area_struct *vma,
79936 return ret;
79937 }
79938
79939-static int kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr,
79940- void *buf, int len, int write)
79941+static ssize_t kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr,
79942+ void *buf, size_t len, int write)
79943 {
79944 struct file *file = vma->vm_file;
79945 struct kernfs_open_file *of = kernfs_of(file);
79946- int ret;
79947+ ssize_t ret;
79948
79949 if (!of->vm_ops)
79950 return -EINVAL;
79951@@ -569,7 +569,7 @@ static int kernfs_get_open_node(struct kernfs_node *kn,
79952 return -ENOMEM;
79953
79954 atomic_set(&new_on->refcnt, 0);
79955- atomic_set(&new_on->event, 1);
79956+ atomic_set_unchecked(&new_on->event, 1);
79957 init_waitqueue_head(&new_on->poll);
79958 INIT_LIST_HEAD(&new_on->files);
79959 goto retry;
79960@@ -792,7 +792,7 @@ static unsigned int kernfs_fop_poll(struct file *filp, poll_table *wait)
79961
79962 kernfs_put_active(kn);
79963
79964- if (of->event != atomic_read(&on->event))
79965+ if (of->event != atomic_read_unchecked(&on->event))
79966 goto trigger;
79967
79968 return DEFAULT_POLLMASK;
79969@@ -823,7 +823,7 @@ repeat:
79970
79971 on = kn->attr.open;
79972 if (on) {
79973- atomic_inc(&on->event);
79974+ atomic_inc_unchecked(&on->event);
79975 wake_up_interruptible(&on->poll);
79976 }
79977
79978diff --git a/fs/libfs.c b/fs/libfs.c
79979index c7cbfb0..fc3636d4 100644
79980--- a/fs/libfs.c
79981+++ b/fs/libfs.c
79982@@ -155,6 +155,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
79983
79984 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
79985 struct dentry *next = list_entry(p, struct dentry, d_child);
79986+ char d_name[sizeof(next->d_iname)];
79987+ const unsigned char *name;
79988+
79989 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
79990 if (!simple_positive(next)) {
79991 spin_unlock(&next->d_lock);
79992@@ -163,7 +166,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
79993
79994 spin_unlock(&next->d_lock);
79995 spin_unlock(&dentry->d_lock);
79996- if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
79997+ name = next->d_name.name;
79998+ if (name == next->d_iname) {
79999+ memcpy(d_name, name, next->d_name.len);
80000+ name = d_name;
80001+ }
80002+ if (!dir_emit(ctx, name, next->d_name.len,
80003 d_inode(next)->i_ino, dt_type(d_inode(next))))
80004 return 0;
80005 spin_lock(&dentry->d_lock);
80006diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
80007index acd3947..1f896e2 100644
80008--- a/fs/lockd/clntproc.c
80009+++ b/fs/lockd/clntproc.c
80010@@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
80011 /*
80012 * Cookie counter for NLM requests
80013 */
80014-static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
80015+static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
80016
80017 void nlmclnt_next_cookie(struct nlm_cookie *c)
80018 {
80019- u32 cookie = atomic_inc_return(&nlm_cookie);
80020+ u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
80021
80022 memcpy(c->data, &cookie, 4);
80023 c->len=4;
80024diff --git a/fs/mount.h b/fs/mount.h
80025index 14db05d..687f6d8 100644
80026--- a/fs/mount.h
80027+++ b/fs/mount.h
80028@@ -13,7 +13,7 @@ struct mnt_namespace {
80029 u64 seq; /* Sequence number to prevent loops */
80030 wait_queue_head_t poll;
80031 u64 event;
80032-};
80033+} __randomize_layout;
80034
80035 struct mnt_pcp {
80036 int mnt_count;
80037@@ -65,7 +65,7 @@ struct mount {
80038 struct hlist_head mnt_pins;
80039 struct fs_pin mnt_umount;
80040 struct dentry *mnt_ex_mountpoint;
80041-};
80042+} __randomize_layout;
80043
80044 #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
80045
80046diff --git a/fs/namei.c b/fs/namei.c
80047index 36df481..c3045fd 100644
80048--- a/fs/namei.c
80049+++ b/fs/namei.c
80050@@ -336,17 +336,32 @@ int generic_permission(struct inode *inode, int mask)
80051 if (ret != -EACCES)
80052 return ret;
80053
80054+#ifdef CONFIG_GRKERNSEC
80055+ /* we'll block if we have to log due to a denied capability use */
80056+ if (mask & MAY_NOT_BLOCK)
80057+ return -ECHILD;
80058+#endif
80059+
80060 if (S_ISDIR(inode->i_mode)) {
80061 /* DACs are overridable for directories */
80062- if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
80063- return 0;
80064 if (!(mask & MAY_WRITE))
80065- if (capable_wrt_inode_uidgid(inode,
80066- CAP_DAC_READ_SEARCH))
80067+ if (capable_wrt_inode_uidgid_nolog(inode, CAP_DAC_OVERRIDE) ||
80068+ capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
80069 return 0;
80070+ if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
80071+ return 0;
80072 return -EACCES;
80073 }
80074 /*
80075+ * Searching includes executable on directories, else just read.
80076+ */
80077+ mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
80078+ if (mask == MAY_READ)
80079+ if (capable_wrt_inode_uidgid_nolog(inode, CAP_DAC_OVERRIDE) ||
80080+ capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
80081+ return 0;
80082+
80083+ /*
80084 * Read/write DACs are always overridable.
80085 * Executable DACs are overridable when there is
80086 * at least one exec bit set.
80087@@ -355,14 +370,6 @@ int generic_permission(struct inode *inode, int mask)
80088 if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
80089 return 0;
80090
80091- /*
80092- * Searching includes executable on directories, else just read.
80093- */
80094- mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
80095- if (mask == MAY_READ)
80096- if (capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
80097- return 0;
80098-
80099 return -EACCES;
80100 }
80101 EXPORT_SYMBOL(generic_permission);
80102@@ -514,12 +521,35 @@ struct nameidata {
80103 struct nameidata *saved;
80104 unsigned root_seq;
80105 int dfd;
80106-};
80107+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80108+ struct path *symlinkown_stack;
80109+ struct path symlinkown_internal[EMBEDDED_LEVELS];
80110+ unsigned symlinkown_depth;
80111+ int symlinkown_enabled;
80112+#endif
80113+} __randomize_layout;
80114+
80115+static int gr_handle_nameidata_symlinkowner(const struct nameidata *nd, const struct inode *target)
80116+{
80117+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80118+ int i;
80119+
80120+ for (i = 0; i < nd->symlinkown_depth; i++) {
80121+ if (gr_handle_symlink_owner(&nd->symlinkown_stack[i], target))
80122+ return -EACCES;
80123+ }
80124+#endif
80125+ return 0;
80126+}
80127
80128 static void set_nameidata(struct nameidata *p, int dfd, struct filename *name)
80129 {
80130 struct nameidata *old = current->nameidata;
80131 p->stack = p->internal;
80132+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80133+ p->symlinkown_stack = p->symlinkown_internal;
80134+ p->symlinkown_enabled = -1;
80135+#endif
80136 p->dfd = dfd;
80137 p->name = name;
80138 p->total_link_count = old ? old->total_link_count : 0;
80139@@ -538,6 +568,12 @@ static void restore_nameidata(void)
80140 kfree(now->stack);
80141 now->stack = now->internal;
80142 }
80143+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80144+ if (now->symlinkown_stack != now->symlinkown_internal) {
80145+ kfree(now->symlinkown_stack);
80146+ now->symlinkown_stack = now->symlinkown_internal;
80147+ }
80148+#endif
80149 }
80150
80151 static int __nd_alloc_stack(struct nameidata *nd)
80152@@ -557,9 +593,29 @@ static int __nd_alloc_stack(struct nameidata *nd)
80153 }
80154 memcpy(p, nd->internal, sizeof(nd->internal));
80155 nd->stack = p;
80156+
80157 return 0;
80158 }
80159
80160+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80161+static int nd_alloc_symlinkown_stack(struct nameidata *nd)
80162+{
80163+ struct path *p;
80164+
80165+ if (likely(nd->symlinkown_depth != EMBEDDED_LEVELS))
80166+ return 0;
80167+ if (nd->symlinkown_stack != nd->symlinkown_internal)
80168+ return 0;
80169+
80170+ p = kmalloc(MAXSYMLINKS * sizeof(struct path), GFP_KERNEL);
80171+ if (unlikely(!p))
80172+ return -ENOMEM;
80173+ memcpy(p, nd->symlinkown_internal, sizeof(nd->symlinkown_internal));
80174+ nd->symlinkown_stack = p;
80175+ return 0;
80176+}
80177+#endif
80178+
80179 /**
80180 * path_connected - Verify that a path->dentry is below path->mnt.mnt_root
80181 * @path: nameidate to verify
80182@@ -580,6 +636,11 @@ static bool path_connected(const struct path *path)
80183
80184 static inline int nd_alloc_stack(struct nameidata *nd)
80185 {
80186+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80187+ if (nd->flags & LOOKUP_RCU)
80188+ return -ECHILD;
80189+#endif
80190+
80191 if (likely(nd->depth != EMBEDDED_LEVELS))
80192 return 0;
80193 if (likely(nd->stack != nd->internal))
80194@@ -608,6 +669,14 @@ static void terminate_walk(struct nameidata *nd)
80195 path_put(&nd->path);
80196 for (i = 0; i < nd->depth; i++)
80197 path_put(&nd->stack[i].link);
80198+
80199+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80200+ /* we'll only ever set our values in ref-walk mode */
80201+ for (i = 0; i < nd->symlinkown_depth; i++)
80202+ path_put(&nd->symlinkown_stack[i]);
80203+ nd->symlinkown_depth = 0;
80204+#endif
80205+
80206 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) {
80207 path_put(&nd->root);
80208 nd->root.mnt = NULL;
80209@@ -1004,6 +1073,9 @@ const char *get_link(struct nameidata *nd)
80210 if (unlikely(error))
80211 return ERR_PTR(error);
80212
80213+ if (gr_handle_follow_link(dentry, last->link.mnt))
80214+ return ERR_PTR(-EACCES);
80215+
80216 nd->last_type = LAST_BIND;
80217 res = inode->i_link;
80218 if (!res) {
80219@@ -1692,6 +1764,23 @@ static int pick_link(struct nameidata *nd, struct path *link,
80220 }
80221 }
80222
80223+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80224+ if (unlikely(nd->symlinkown_enabled == -1))
80225+ nd->symlinkown_enabled = gr_get_symlinkown_enabled();
80226+ if (nd->symlinkown_enabled && gr_is_global_nonroot(inode->i_uid)) {
80227+ struct path *symlinkownlast;
80228+ error = nd_alloc_symlinkown_stack(nd);
80229+ if (unlikely(error)) {
80230+ path_put(link);
80231+ return error;
80232+ }
80233+ symlinkownlast = nd->symlinkown_stack + nd->symlinkown_depth++;
80234+ symlinkownlast->dentry = link->dentry;
80235+ symlinkownlast->mnt = link->mnt;
80236+ path_get(symlinkownlast);
80237+ }
80238+#endif
80239+
80240 last = nd->stack + nd->depth++;
80241 last->link = *link;
80242 last->cookie = NULL;
80243@@ -1831,7 +1920,7 @@ EXPORT_SYMBOL(full_name_hash);
80244 static inline u64 hash_name(const char *name)
80245 {
80246 unsigned long a, b, adata, bdata, mask, hash, len;
80247- const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80248+ static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80249
80250 hash = a = 0;
80251 len = -sizeof(unsigned long);
80252@@ -2000,6 +2089,9 @@ static const char *path_init(struct nameidata *nd, unsigned flags)
80253 nd->flags = flags | LOOKUP_JUMPED | LOOKUP_PARENT;
80254 nd->depth = 0;
80255 nd->total_link_count = 0;
80256+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80257+ nd->symlinkown_depth = 0;
80258+#endif
80259 if (flags & LOOKUP_ROOT) {
80260 struct dentry *root = nd->root.dentry;
80261 struct inode *inode = root->d_inode;
80262@@ -2137,6 +2229,11 @@ static int path_lookupat(struct nameidata *nd, unsigned flags, struct path *path
80263 if (!err)
80264 err = complete_walk(nd);
80265
80266+ if (!err && !(nd->flags & LOOKUP_PARENT)) {
80267+ if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt))
80268+ err = -ENOENT;
80269+ }
80270+
80271 if (!err && nd->flags & LOOKUP_DIRECTORY)
80272 if (!d_can_lookup(nd->path.dentry))
80273 err = -ENOTDIR;
80274@@ -2185,6 +2282,10 @@ static int path_parentat(struct nameidata *nd, unsigned flags,
80275 err = link_path_walk(s, nd);
80276 if (!err)
80277 err = complete_walk(nd);
80278+
80279+ if (!err && gr_handle_nameidata_symlinkowner(nd, nd->inode))
80280+ err = -EACCES;
80281+
80282 if (!err) {
80283 *parent = nd->path;
80284 nd->path.mnt = NULL;
80285@@ -2716,6 +2817,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
80286 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
80287 return -EPERM;
80288
80289+ if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
80290+ return -EPERM;
80291+ if (gr_handle_rawio(inode))
80292+ return -EPERM;
80293+ if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
80294+ return -EACCES;
80295+
80296 return 0;
80297 }
80298
80299@@ -2982,6 +3090,18 @@ static int lookup_open(struct nameidata *nd, struct path *path,
80300 /* Negative dentry, just create the file */
80301 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
80302 umode_t mode = op->mode;
80303+
80304+
80305+ if (gr_handle_nameidata_symlinkowner(nd, dir_inode)) {
80306+ error = -EACCES;
80307+ goto out_dput;
80308+ }
80309+
80310+ if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
80311+ error = -EACCES;
80312+ goto out_dput;
80313+ }
80314+
80315 if (!IS_POSIXACL(dir->d_inode))
80316 mode &= ~current_umask();
80317 /*
80318@@ -3003,6 +3123,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
80319 nd->flags & LOOKUP_EXCL);
80320 if (error)
80321 goto out_dput;
80322+ else
80323+ gr_handle_create(dentry, nd->path.mnt);
80324 }
80325 out_no_open:
80326 path->dentry = dentry;
80327@@ -3066,6 +3188,9 @@ static int do_last(struct nameidata *nd,
80328 if (error)
80329 return error;
80330
80331+ if (!gr_acl_handle_hidden_file(dir, nd->path.mnt))
80332+ return -ENOENT;
80333+
80334 audit_inode(nd->name, dir, LOOKUP_PARENT);
80335 /* trailing slashes? */
80336 if (unlikely(nd->last.name[nd->last.len]))
80337@@ -3108,11 +3233,24 @@ retry_lookup:
80338 goto finish_open_created;
80339 }
80340
80341+ if (!gr_acl_handle_hidden_file(path.dentry, nd->path.mnt)) {
80342+ path_to_nameidata(&path, nd);
80343+ return -ENOENT;
80344+ }
80345+
80346 /*
80347 * create/update audit record if it already exists.
80348 */
80349- if (d_is_positive(path.dentry))
80350+ if (d_is_positive(path.dentry)) {
80351+ /* only check if O_CREAT is specified, all other checks need to go
80352+ into may_open */
80353+ if (gr_handle_fifo(path.dentry, path.mnt, dir, open_flag, acc_mode)) {
80354+ path_to_nameidata(&path, nd);
80355+ return -EACCES;
80356+ }
80357+
80358 audit_inode(nd->name, path.dentry, 0);
80359+ }
80360
80361 /*
80362 * If atomic_open() acquired write access it is dropped now due to
80363@@ -3148,6 +3286,11 @@ finish_lookup:
80364 if (unlikely(error))
80365 return error;
80366
80367+ if (gr_handle_nameidata_symlinkowner(nd, inode)) {
80368+ path_to_nameidata(&path, nd);
80369+ return -EACCES;
80370+ }
80371+
80372 if (unlikely(d_is_symlink(path.dentry)) && !(open_flag & O_PATH)) {
80373 path_to_nameidata(&path, nd);
80374 return -ELOOP;
80375@@ -3170,6 +3313,12 @@ finish_open:
80376 path_put(&save_parent);
80377 return error;
80378 }
80379+
80380+ if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
80381+ error = -ENOENT;
80382+ goto out;
80383+ }
80384+
80385 audit_inode(nd->name, nd->path.dentry, 0);
80386 error = -EISDIR;
80387 if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry))
80388@@ -3436,9 +3585,11 @@ static struct dentry *filename_create(int dfd, struct filename *name,
80389 goto unlock;
80390
80391 error = -EEXIST;
80392- if (d_is_positive(dentry))
80393+ if (d_is_positive(dentry)) {
80394+ if (!gr_acl_handle_hidden_file(dentry, path->mnt))
80395+ error = -ENOENT;
80396 goto fail;
80397-
80398+ }
80399 /*
80400 * Special case - lookup gave negative, but... we had foo/bar/
80401 * From the vfs_mknod() POV we just have a negative dentry -
80402@@ -3492,6 +3643,20 @@ inline struct dentry *user_path_create(int dfd, const char __user *pathname,
80403 }
80404 EXPORT_SYMBOL(user_path_create);
80405
80406+static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
80407+{
80408+ struct filename *tmp = getname(pathname);
80409+ struct dentry *res;
80410+ if (IS_ERR(tmp))
80411+ return ERR_CAST(tmp);
80412+ res = kern_path_create(dfd, tmp->name, path, lookup_flags);
80413+ if (IS_ERR(res))
80414+ putname(tmp);
80415+ else
80416+ *to = tmp;
80417+ return res;
80418+}
80419+
80420 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
80421 {
80422 int error = may_create(dir, dentry);
80423@@ -3555,6 +3720,17 @@ retry:
80424
80425 if (!IS_POSIXACL(path.dentry->d_inode))
80426 mode &= ~current_umask();
80427+
80428+ if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
80429+ error = -EPERM;
80430+ goto out;
80431+ }
80432+
80433+ if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
80434+ error = -EACCES;
80435+ goto out;
80436+ }
80437+
80438 error = security_path_mknod(&path, dentry, mode, dev);
80439 if (error)
80440 goto out;
80441@@ -3570,6 +3746,8 @@ retry:
80442 error = vfs_mknod(path.dentry->d_inode,dentry,mode,0);
80443 break;
80444 }
80445+ if (!error)
80446+ gr_handle_create(dentry, path.mnt);
80447 out:
80448 done_path_create(&path, dentry);
80449 if (retry_estale(error, lookup_flags)) {
80450@@ -3624,9 +3802,16 @@ retry:
80451
80452 if (!IS_POSIXACL(path.dentry->d_inode))
80453 mode &= ~current_umask();
80454+ if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
80455+ error = -EACCES;
80456+ goto out;
80457+ }
80458 error = security_path_mkdir(&path, dentry, mode);
80459 if (!error)
80460 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
80461+ if (!error)
80462+ gr_handle_create(dentry, path.mnt);
80463+out:
80464 done_path_create(&path, dentry);
80465 if (retry_estale(error, lookup_flags)) {
80466 lookup_flags |= LOOKUP_REVAL;
80467@@ -3659,7 +3844,7 @@ void dentry_unhash(struct dentry *dentry)
80468 {
80469 shrink_dcache_parent(dentry);
80470 spin_lock(&dentry->d_lock);
80471- if (dentry->d_lockref.count == 1)
80472+ if (__lockref_read(&dentry->d_lockref) == 1)
80473 __d_drop(dentry);
80474 spin_unlock(&dentry->d_lock);
80475 }
80476@@ -3712,6 +3897,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
80477 struct path path;
80478 struct qstr last;
80479 int type;
80480+ u64 saved_ino = 0;
80481+ dev_t saved_dev = 0;
80482 unsigned int lookup_flags = 0;
80483 retry:
80484 name = user_path_parent(dfd, pathname,
80485@@ -3744,10 +3931,20 @@ retry:
80486 error = -ENOENT;
80487 goto exit3;
80488 }
80489+ saved_ino = gr_get_ino_from_dentry(dentry);
80490+ saved_dev = gr_get_dev_from_dentry(dentry);
80491+
80492+ if (!gr_acl_handle_rmdir(dentry, path.mnt)) {
80493+ error = -EACCES;
80494+ goto exit3;
80495+ }
80496+
80497 error = security_path_rmdir(&path, dentry);
80498 if (error)
80499 goto exit3;
80500 error = vfs_rmdir(path.dentry->d_inode, dentry);
80501+ if (!error && (saved_dev || saved_ino))
80502+ gr_handle_delete(saved_ino, saved_dev);
80503 exit3:
80504 dput(dentry);
80505 exit2:
80506@@ -3842,6 +4039,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
80507 int type;
80508 struct inode *inode = NULL;
80509 struct inode *delegated_inode = NULL;
80510+ u64 saved_ino = 0;
80511+ dev_t saved_dev = 0;
80512 unsigned int lookup_flags = 0;
80513 retry:
80514 name = user_path_parent(dfd, pathname,
80515@@ -3868,10 +4067,21 @@ retry_deleg:
80516 if (d_is_negative(dentry))
80517 goto slashes;
80518 ihold(inode);
80519+ if (inode->i_nlink <= 1) {
80520+ saved_ino = gr_get_ino_from_dentry(dentry);
80521+ saved_dev = gr_get_dev_from_dentry(dentry);
80522+ }
80523+ if (!gr_acl_handle_unlink(dentry, path.mnt)) {
80524+ error = -EACCES;
80525+ goto exit2;
80526+ }
80527+
80528 error = security_path_unlink(&path, dentry);
80529 if (error)
80530 goto exit2;
80531 error = vfs_unlink(path.dentry->d_inode, dentry, &delegated_inode);
80532+ if (!error && (saved_ino || saved_dev))
80533+ gr_handle_delete(saved_ino, saved_dev);
80534 exit2:
80535 dput(dentry);
80536 }
80537@@ -3960,9 +4170,17 @@ retry:
80538 if (IS_ERR(dentry))
80539 goto out_putname;
80540
80541+ if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
80542+ error = -EACCES;
80543+ goto out;
80544+ }
80545+
80546 error = security_path_symlink(&path, dentry, from->name);
80547 if (!error)
80548 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
80549+ if (!error)
80550+ gr_handle_create(dentry, path.mnt);
80551+out:
80552 done_path_create(&path, dentry);
80553 if (retry_estale(error, lookup_flags)) {
80554 lookup_flags |= LOOKUP_REVAL;
80555@@ -4066,6 +4284,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
80556 struct dentry *new_dentry;
80557 struct path old_path, new_path;
80558 struct inode *delegated_inode = NULL;
80559+ struct filename *to = NULL;
80560 int how = 0;
80561 int error;
80562
80563@@ -4089,7 +4308,7 @@ retry:
80564 if (error)
80565 return error;
80566
80567- new_dentry = user_path_create(newdfd, newname, &new_path,
80568+ new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
80569 (how & LOOKUP_REVAL));
80570 error = PTR_ERR(new_dentry);
80571 if (IS_ERR(new_dentry))
80572@@ -4101,11 +4320,26 @@ retry:
80573 error = may_linkat(&old_path);
80574 if (unlikely(error))
80575 goto out_dput;
80576+
80577+ if (gr_handle_hardlink(old_path.dentry, old_path.mnt, to)) {
80578+ error = -EACCES;
80579+ goto out_dput;
80580+ }
80581+
80582+ if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
80583+ old_path.dentry, old_path.mnt, to)) {
80584+ error = -EACCES;
80585+ goto out_dput;
80586+ }
80587+
80588 error = security_path_link(old_path.dentry, &new_path, new_dentry);
80589 if (error)
80590 goto out_dput;
80591 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry, &delegated_inode);
80592+ if (!error)
80593+ gr_handle_create(new_dentry, new_path.mnt);
80594 out_dput:
80595+ putname(to);
80596 done_path_create(&new_path, new_dentry);
80597 if (delegated_inode) {
80598 error = break_deleg_wait(&delegated_inode);
80599@@ -4420,6 +4654,20 @@ retry_deleg:
80600 if (new_dentry == trap)
80601 goto exit5;
80602
80603+ if (gr_bad_chroot_rename(old_dentry, old_path.mnt, new_dentry, new_path.mnt)) {
80604+ /* use EXDEV error to cause 'mv' to switch to an alternative
80605+ * method for usability
80606+ */
80607+ error = -EXDEV;
80608+ goto exit5;
80609+ }
80610+
80611+ error = gr_acl_handle_rename(new_dentry, new_path.dentry, new_path.mnt,
80612+ old_dentry, d_backing_inode(old_path.dentry), old_path.mnt,
80613+ to, flags);
80614+ if (error)
80615+ goto exit5;
80616+
80617 error = security_path_rename(&old_path, old_dentry,
80618 &new_path, new_dentry, flags);
80619 if (error)
80620@@ -4427,6 +4675,9 @@ retry_deleg:
80621 error = vfs_rename(old_path.dentry->d_inode, old_dentry,
80622 new_path.dentry->d_inode, new_dentry,
80623 &delegated_inode, flags);
80624+ if (!error)
80625+ gr_handle_rename(d_backing_inode(old_path.dentry), d_backing_inode(new_path.dentry), old_dentry,
80626+ new_dentry, old_path.mnt, d_is_positive(new_dentry) ? 1 : 0, flags);
80627 exit5:
80628 dput(new_dentry);
80629 exit4:
80630@@ -4483,14 +4734,24 @@ EXPORT_SYMBOL(vfs_whiteout);
80631
80632 int readlink_copy(char __user *buffer, int buflen, const char *link)
80633 {
80634+ char tmpbuf[64];
80635+ const char *newlink;
80636 int len = PTR_ERR(link);
80637+
80638 if (IS_ERR(link))
80639 goto out;
80640
80641 len = strlen(link);
80642 if (len > (unsigned) buflen)
80643 len = buflen;
80644- if (copy_to_user(buffer, link, len))
80645+
80646+ if (len < sizeof(tmpbuf)) {
80647+ memcpy(tmpbuf, link, len);
80648+ newlink = tmpbuf;
80649+ } else
80650+ newlink = link;
80651+
80652+ if (copy_to_user(buffer, newlink, len))
80653 len = -EFAULT;
80654 out:
80655 return len;
80656diff --git a/fs/namespace.c b/fs/namespace.c
80657index 2b8aa15..3230081 100644
80658--- a/fs/namespace.c
80659+++ b/fs/namespace.c
80660@@ -1516,6 +1516,9 @@ static int do_umount(struct mount *mnt, int flags)
80661 if (!(sb->s_flags & MS_RDONLY))
80662 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
80663 up_write(&sb->s_umount);
80664+
80665+ gr_log_remount(mnt->mnt_devname, retval);
80666+
80667 return retval;
80668 }
80669
80670@@ -1538,6 +1541,9 @@ static int do_umount(struct mount *mnt, int flags)
80671 }
80672 unlock_mount_hash();
80673 namespace_unlock();
80674+
80675+ gr_log_unmount(mnt->mnt_devname, retval);
80676+
80677 return retval;
80678 }
80679
80680@@ -1592,7 +1598,7 @@ static inline bool may_mount(void)
80681 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
80682 */
80683
80684-SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
80685+SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
80686 {
80687 struct path path;
80688 struct mount *mnt;
80689@@ -1637,7 +1643,7 @@ out:
80690 /*
80691 * The 2.0 compatible umount. No flags.
80692 */
80693-SYSCALL_DEFINE1(oldumount, char __user *, name)
80694+SYSCALL_DEFINE1(oldumount, const char __user *, name)
80695 {
80696 return sys_umount(name, 0);
80697 }
80698@@ -2712,6 +2718,16 @@ long do_mount(const char *dev_name, const char __user *dir_name,
80699 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
80700 MS_STRICTATIME);
80701
80702+ if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
80703+ retval = -EPERM;
80704+ goto dput_out;
80705+ }
80706+
80707+ if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
80708+ retval = -EPERM;
80709+ goto dput_out;
80710+ }
80711+
80712 if (flags & MS_REMOUNT)
80713 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
80714 data_page);
80715@@ -2725,7 +2741,10 @@ long do_mount(const char *dev_name, const char __user *dir_name,
80716 retval = do_new_mount(&path, type_page, flags, mnt_flags,
80717 dev_name, data_page);
80718 dput_out:
80719+ gr_log_mount(dev_name, &path, retval);
80720+
80721 path_put(&path);
80722+
80723 return retval;
80724 }
80725
80726@@ -2743,7 +2762,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
80727 * number incrementing at 10Ghz will take 12,427 years to wrap which
80728 * is effectively never, so we can ignore the possibility.
80729 */
80730-static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
80731+static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
80732
80733 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
80734 {
80735@@ -2759,7 +2778,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
80736 return ERR_PTR(ret);
80737 }
80738 new_ns->ns.ops = &mntns_operations;
80739- new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
80740+ new_ns->seq = atomic64_add_return_unchecked(1, &mnt_ns_seq);
80741 atomic_set(&new_ns->count, 1);
80742 new_ns->root = NULL;
80743 INIT_LIST_HEAD(&new_ns->list);
80744@@ -2769,7 +2788,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
80745 return new_ns;
80746 }
80747
80748-struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
80749+__latent_entropy struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
80750 struct user_namespace *user_ns, struct fs_struct *new_fs)
80751 {
80752 struct mnt_namespace *new_ns;
80753@@ -2890,8 +2909,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
80754 }
80755 EXPORT_SYMBOL(mount_subtree);
80756
80757-SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
80758- char __user *, type, unsigned long, flags, void __user *, data)
80759+SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
80760+ const char __user *, type, unsigned long, flags, void __user *, data)
80761 {
80762 int ret;
80763 char *kernel_type;
80764@@ -2997,6 +3016,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
80765 if (error)
80766 goto out2;
80767
80768+ if (gr_handle_chroot_pivot()) {
80769+ error = -EPERM;
80770+ goto out2;
80771+ }
80772+
80773 get_fs_root(current->fs, &root);
80774 old_mp = lock_mount(&old);
80775 error = PTR_ERR(old_mp);
80776@@ -3298,7 +3322,7 @@ static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
80777 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
80778 return -EPERM;
80779
80780- if (fs->users != 1)
80781+ if (atomic_read(&fs->users) != 1)
80782 return -EINVAL;
80783
80784 get_mnt_ns(mnt_ns);
80785diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
80786index 6b1697a..6d5787c 100644
80787--- a/fs/nfs/callback_xdr.c
80788+++ b/fs/nfs/callback_xdr.c
80789@@ -51,7 +51,7 @@ struct callback_op {
80790 callback_decode_arg_t decode_args;
80791 callback_encode_res_t encode_res;
80792 long res_maxsize;
80793-};
80794+} __do_const;
80795
80796 static struct callback_op callback_ops[];
80797
80798diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
80799index 4afbe13..a6a26ce 100644
80800--- a/fs/nfs/inode.c
80801+++ b/fs/nfs/inode.c
80802@@ -1273,16 +1273,16 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
80803 return 0;
80804 }
80805
80806-static atomic_long_t nfs_attr_generation_counter;
80807+static atomic_long_unchecked_t nfs_attr_generation_counter;
80808
80809 static unsigned long nfs_read_attr_generation_counter(void)
80810 {
80811- return atomic_long_read(&nfs_attr_generation_counter);
80812+ return atomic_long_read_unchecked(&nfs_attr_generation_counter);
80813 }
80814
80815 unsigned long nfs_inc_attr_generation_counter(void)
80816 {
80817- return atomic_long_inc_return(&nfs_attr_generation_counter);
80818+ return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
80819 }
80820 EXPORT_SYMBOL_GPL(nfs_inc_attr_generation_counter);
80821
80822diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
80823index 90cfda7..e4b50df 100644
80824--- a/fs/nfsd/nfs4proc.c
80825+++ b/fs/nfsd/nfs4proc.c
80826@@ -1487,7 +1487,7 @@ struct nfsd4_operation {
80827 nfsd4op_rsize op_rsize_bop;
80828 stateid_getter op_get_currentstateid;
80829 stateid_setter op_set_currentstateid;
80830-};
80831+} __do_const;
80832
80833 static struct nfsd4_operation nfsd4_ops[];
80834
80835diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
80836index b81f725..8e36601 100644
80837--- a/fs/nfsd/nfs4xdr.c
80838+++ b/fs/nfsd/nfs4xdr.c
80839@@ -1704,7 +1704,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
80840
80841 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
80842
80843-static nfsd4_dec nfsd4_dec_ops[] = {
80844+static const nfsd4_dec nfsd4_dec_ops[] = {
80845 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
80846 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
80847 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
80848diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
80849index 46ec934..f384e41 100644
80850--- a/fs/nfsd/nfscache.c
80851+++ b/fs/nfsd/nfscache.c
80852@@ -541,7 +541,7 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
80853 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
80854 u32 hash;
80855 struct nfsd_drc_bucket *b;
80856- int len;
80857+ long len;
80858 size_t bufsize = 0;
80859
80860 if (!rp)
80861@@ -550,11 +550,14 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
80862 hash = nfsd_cache_hash(rp->c_xid);
80863 b = &drc_hashtbl[hash];
80864
80865- len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
80866- len >>= 2;
80867+ if (statp) {
80868+ len = (char*)statp - (char*)resv->iov_base;
80869+ len = resv->iov_len - len;
80870+ len >>= 2;
80871+ }
80872
80873 /* Don't cache excessive amounts of data and XDR failures */
80874- if (!statp || len > (256 >> 2)) {
80875+ if (!statp || len > (256 >> 2) || len < 0) {
80876 nfsd_reply_cache_free(b, rp);
80877 return;
80878 }
80879@@ -562,7 +565,7 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
80880 switch (cachetype) {
80881 case RC_REPLSTAT:
80882 if (len != 1)
80883- printk("nfsd: RC_REPLSTAT/reply len %d!\n",len);
80884+ printk("nfsd: RC_REPLSTAT/reply len %ld!\n",len);
80885 rp->c_replstat = *statp;
80886 break;
80887 case RC_REPLBUFF:
80888diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
80889index b5e077a..50cf549 100644
80890--- a/fs/nfsd/vfs.c
80891+++ b/fs/nfsd/vfs.c
80892@@ -855,7 +855,7 @@ __be32 nfsd_readv(struct file *file, loff_t offset, struct kvec *vec, int vlen,
80893
80894 oldfs = get_fs();
80895 set_fs(KERNEL_DS);
80896- host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
80897+ host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
80898 set_fs(oldfs);
80899 return nfsd_finish_read(file, count, host_err);
80900 }
80901@@ -942,7 +942,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
80902
80903 /* Write the data. */
80904 oldfs = get_fs(); set_fs(KERNEL_DS);
80905- host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
80906+ host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
80907 set_fs(oldfs);
80908 if (host_err < 0)
80909 goto out_nfserr;
80910@@ -1455,7 +1455,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
80911 */
80912
80913 oldfs = get_fs(); set_fs(KERNEL_DS);
80914- host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
80915+ host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
80916 set_fs(oldfs);
80917
80918 if (host_err < 0)
80919diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
80920index 52ccd34..7a6b202 100644
80921--- a/fs/nls/nls_base.c
80922+++ b/fs/nls/nls_base.c
80923@@ -234,21 +234,25 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
80924
80925 int __register_nls(struct nls_table *nls, struct module *owner)
80926 {
80927- struct nls_table ** tmp = &tables;
80928+ struct nls_table *tmp = tables;
80929
80930 if (nls->next)
80931 return -EBUSY;
80932
80933- nls->owner = owner;
80934+ pax_open_kernel();
80935+ *(void **)&nls->owner = owner;
80936+ pax_close_kernel();
80937 spin_lock(&nls_lock);
80938- while (*tmp) {
80939- if (nls == *tmp) {
80940+ while (tmp) {
80941+ if (nls == tmp) {
80942 spin_unlock(&nls_lock);
80943 return -EBUSY;
80944 }
80945- tmp = &(*tmp)->next;
80946+ tmp = tmp->next;
80947 }
80948- nls->next = tables;
80949+ pax_open_kernel();
80950+ *(struct nls_table **)&nls->next = tables;
80951+ pax_close_kernel();
80952 tables = nls;
80953 spin_unlock(&nls_lock);
80954 return 0;
80955@@ -257,12 +261,14 @@ EXPORT_SYMBOL(__register_nls);
80956
80957 int unregister_nls(struct nls_table * nls)
80958 {
80959- struct nls_table ** tmp = &tables;
80960+ struct nls_table * const * tmp = &tables;
80961
80962 spin_lock(&nls_lock);
80963 while (*tmp) {
80964 if (nls == *tmp) {
80965- *tmp = nls->next;
80966+ pax_open_kernel();
80967+ *(struct nls_table **)tmp = nls->next;
80968+ pax_close_kernel();
80969 spin_unlock(&nls_lock);
80970 return 0;
80971 }
80972@@ -272,7 +278,7 @@ int unregister_nls(struct nls_table * nls)
80973 return -EINVAL;
80974 }
80975
80976-static struct nls_table *find_nls(char *charset)
80977+static struct nls_table *find_nls(const char *charset)
80978 {
80979 struct nls_table *nls;
80980 spin_lock(&nls_lock);
80981@@ -288,7 +294,7 @@ static struct nls_table *find_nls(char *charset)
80982 return nls;
80983 }
80984
80985-struct nls_table *load_nls(char *charset)
80986+struct nls_table *load_nls(const char *charset)
80987 {
80988 return try_then_request_module(find_nls(charset), "nls_%s", charset);
80989 }
80990diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
80991index 162b3f1..6076a7c 100644
80992--- a/fs/nls/nls_euc-jp.c
80993+++ b/fs/nls/nls_euc-jp.c
80994@@ -560,8 +560,10 @@ static int __init init_nls_euc_jp(void)
80995 p_nls = load_nls("cp932");
80996
80997 if (p_nls) {
80998- table.charset2upper = p_nls->charset2upper;
80999- table.charset2lower = p_nls->charset2lower;
81000+ pax_open_kernel();
81001+ *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
81002+ *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
81003+ pax_close_kernel();
81004 return register_nls(&table);
81005 }
81006
81007diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
81008index a80a741..7b96e1b 100644
81009--- a/fs/nls/nls_koi8-ru.c
81010+++ b/fs/nls/nls_koi8-ru.c
81011@@ -62,8 +62,10 @@ static int __init init_nls_koi8_ru(void)
81012 p_nls = load_nls("koi8-u");
81013
81014 if (p_nls) {
81015- table.charset2upper = p_nls->charset2upper;
81016- table.charset2lower = p_nls->charset2lower;
81017+ pax_open_kernel();
81018+ *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
81019+ *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
81020+ pax_close_kernel();
81021 return register_nls(&table);
81022 }
81023
81024diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
81025index cf27550..6c70f29d 100644
81026--- a/fs/notify/fanotify/fanotify_user.c
81027+++ b/fs/notify/fanotify/fanotify_user.c
81028@@ -216,8 +216,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
81029
81030 fd = fanotify_event_metadata.fd;
81031 ret = -EFAULT;
81032- if (copy_to_user(buf, &fanotify_event_metadata,
81033- fanotify_event_metadata.event_len))
81034+ if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
81035+ copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
81036 goto out_close_fd;
81037
81038 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
81039diff --git a/fs/notify/notification.c b/fs/notify/notification.c
81040index a95d8e0..a91a5fd 100644
81041--- a/fs/notify/notification.c
81042+++ b/fs/notify/notification.c
81043@@ -48,7 +48,7 @@
81044 #include <linux/fsnotify_backend.h>
81045 #include "fsnotify.h"
81046
81047-static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
81048+static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
81049
81050 /**
81051 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
81052@@ -56,7 +56,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
81053 */
81054 u32 fsnotify_get_cookie(void)
81055 {
81056- return atomic_inc_return(&fsnotify_sync_cookie);
81057+ return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
81058 }
81059 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
81060
81061diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
81062index 9e38daf..5727cae 100644
81063--- a/fs/ntfs/dir.c
81064+++ b/fs/ntfs/dir.c
81065@@ -1310,7 +1310,7 @@ find_next_index_buffer:
81066 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
81067 ~(s64)(ndir->itype.index.block_size - 1)));
81068 /* Bounds checks. */
81069- if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
81070+ if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
81071 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
81072 "inode 0x%lx or driver bug.", vdir->i_ino);
81073 goto err_out;
81074diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
81075index 9e1e112..241a52a 100644
81076--- a/fs/ntfs/super.c
81077+++ b/fs/ntfs/super.c
81078@@ -688,7 +688,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
81079 if (!silent)
81080 ntfs_error(sb, "Primary boot sector is invalid.");
81081 } else if (!silent)
81082- ntfs_error(sb, read_err_str, "primary");
81083+ ntfs_error(sb, read_err_str, "%s", "primary");
81084 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
81085 if (bh_primary)
81086 brelse(bh_primary);
81087@@ -704,7 +704,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
81088 goto hotfix_primary_boot_sector;
81089 brelse(bh_backup);
81090 } else if (!silent)
81091- ntfs_error(sb, read_err_str, "backup");
81092+ ntfs_error(sb, read_err_str, "%s", "backup");
81093 /* Try to read NT3.51- backup boot sector. */
81094 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
81095 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
81096@@ -715,7 +715,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
81097 "sector.");
81098 brelse(bh_backup);
81099 } else if (!silent)
81100- ntfs_error(sb, read_err_str, "backup");
81101+ ntfs_error(sb, read_err_str, "%s", "backup");
81102 /* We failed. Cleanup and return. */
81103 if (bh_primary)
81104 brelse(bh_primary);
81105diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
81106index 857bbbc..3c47d15 100644
81107--- a/fs/ocfs2/localalloc.c
81108+++ b/fs/ocfs2/localalloc.c
81109@@ -1320,7 +1320,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
81110 goto bail;
81111 }
81112
81113- atomic_inc(&osb->alloc_stats.moves);
81114+ atomic_inc_unchecked(&osb->alloc_stats.moves);
81115
81116 bail:
81117 if (handle)
81118diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
81119index 690ddc6..f2d4c4d 100644
81120--- a/fs/ocfs2/ocfs2.h
81121+++ b/fs/ocfs2/ocfs2.h
81122@@ -247,11 +247,11 @@ enum ocfs2_vol_state
81123
81124 struct ocfs2_alloc_stats
81125 {
81126- atomic_t moves;
81127- atomic_t local_data;
81128- atomic_t bitmap_data;
81129- atomic_t bg_allocs;
81130- atomic_t bg_extends;
81131+ atomic_unchecked_t moves;
81132+ atomic_unchecked_t local_data;
81133+ atomic_unchecked_t bitmap_data;
81134+ atomic_unchecked_t bg_allocs;
81135+ atomic_unchecked_t bg_extends;
81136 };
81137
81138 enum ocfs2_local_alloc_state
81139diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
81140index 4479029..5de740b 100644
81141--- a/fs/ocfs2/suballoc.c
81142+++ b/fs/ocfs2/suballoc.c
81143@@ -867,7 +867,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
81144 mlog_errno(status);
81145 goto bail;
81146 }
81147- atomic_inc(&osb->alloc_stats.bg_extends);
81148+ atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
81149
81150 /* You should never ask for this much metadata */
81151 BUG_ON(bits_wanted >
81152@@ -2014,7 +2014,7 @@ int ocfs2_claim_metadata(handle_t *handle,
81153 mlog_errno(status);
81154 goto bail;
81155 }
81156- atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81157+ atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81158
81159 *suballoc_loc = res.sr_bg_blkno;
81160 *suballoc_bit_start = res.sr_bit_offset;
81161@@ -2180,7 +2180,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
81162 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
81163 res->sr_bits);
81164
81165- atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81166+ atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81167
81168 BUG_ON(res->sr_bits != 1);
81169
81170@@ -2222,7 +2222,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
81171 mlog_errno(status);
81172 goto bail;
81173 }
81174- atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81175+ atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81176
81177 BUG_ON(res.sr_bits != 1);
81178
81179@@ -2326,7 +2326,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
81180 cluster_start,
81181 num_clusters);
81182 if (!status)
81183- atomic_inc(&osb->alloc_stats.local_data);
81184+ atomic_inc_unchecked(&osb->alloc_stats.local_data);
81185 } else {
81186 if (min_clusters > (osb->bitmap_cpg - 1)) {
81187 /* The only paths asking for contiguousness
81188@@ -2352,7 +2352,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
81189 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
81190 res.sr_bg_blkno,
81191 res.sr_bit_offset);
81192- atomic_inc(&osb->alloc_stats.bitmap_data);
81193+ atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
81194 *num_clusters = res.sr_bits;
81195 }
81196 }
81197diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
81198index a482e31..81b251d 100644
81199--- a/fs/ocfs2/super.c
81200+++ b/fs/ocfs2/super.c
81201@@ -308,11 +308,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
81202 "%10s => GlobalAllocs: %d LocalAllocs: %d "
81203 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
81204 "Stats",
81205- atomic_read(&osb->alloc_stats.bitmap_data),
81206- atomic_read(&osb->alloc_stats.local_data),
81207- atomic_read(&osb->alloc_stats.bg_allocs),
81208- atomic_read(&osb->alloc_stats.moves),
81209- atomic_read(&osb->alloc_stats.bg_extends));
81210+ atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
81211+ atomic_read_unchecked(&osb->alloc_stats.local_data),
81212+ atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
81213+ atomic_read_unchecked(&osb->alloc_stats.moves),
81214+ atomic_read_unchecked(&osb->alloc_stats.bg_extends));
81215
81216 out += snprintf(buf + out, len - out,
81217 "%10s => State: %u Descriptor: %llu Size: %u bits "
81218@@ -2095,11 +2095,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
81219
81220 mutex_init(&osb->system_file_mutex);
81221
81222- atomic_set(&osb->alloc_stats.moves, 0);
81223- atomic_set(&osb->alloc_stats.local_data, 0);
81224- atomic_set(&osb->alloc_stats.bitmap_data, 0);
81225- atomic_set(&osb->alloc_stats.bg_allocs, 0);
81226- atomic_set(&osb->alloc_stats.bg_extends, 0);
81227+ atomic_set_unchecked(&osb->alloc_stats.moves, 0);
81228+ atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
81229+ atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
81230+ atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
81231+ atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
81232
81233 /* Copy the blockcheck stats from the superblock probe */
81234 osb->osb_ecc_stats = *stats;
81235diff --git a/fs/open.c b/fs/open.c
81236index e33dab2..cdbdad9 100644
81237--- a/fs/open.c
81238+++ b/fs/open.c
81239@@ -32,6 +32,8 @@
81240 #include <linux/dnotify.h>
81241 #include <linux/compat.h>
81242
81243+#define CREATE_TRACE_POINTS
81244+#include <trace/events/fs.h>
81245 #include "internal.h"
81246
81247 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
81248@@ -105,6 +107,8 @@ long vfs_truncate(struct path *path, loff_t length)
81249 error = locks_verify_truncate(inode, NULL, length);
81250 if (!error)
81251 error = security_path_truncate(path);
81252+ if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
81253+ error = -EACCES;
81254 if (!error)
81255 error = do_truncate(path->dentry, length, 0, NULL);
81256
81257@@ -189,6 +193,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
81258 error = locks_verify_truncate(inode, f.file, length);
81259 if (!error)
81260 error = security_path_truncate(&f.file->f_path);
81261+ if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
81262+ error = -EACCES;
81263 if (!error)
81264 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
81265 sb_end_write(inode->i_sb);
81266@@ -398,6 +404,9 @@ retry:
81267 if (__mnt_is_readonly(path.mnt))
81268 res = -EROFS;
81269
81270+ if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
81271+ res = -EACCES;
81272+
81273 out_path_release:
81274 path_put(&path);
81275 if (retry_estale(res, lookup_flags)) {
81276@@ -429,6 +438,8 @@ retry:
81277 if (error)
81278 goto dput_and_out;
81279
81280+ gr_log_chdir(path.dentry, path.mnt);
81281+
81282 set_fs_pwd(current->fs, &path);
81283
81284 dput_and_out:
81285@@ -458,6 +469,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
81286 goto out_putf;
81287
81288 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
81289+
81290+ if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
81291+ error = -EPERM;
81292+
81293+ if (!error)
81294+ gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
81295+
81296 if (!error)
81297 set_fs_pwd(current->fs, &f.file->f_path);
81298 out_putf:
81299@@ -487,7 +505,13 @@ retry:
81300 if (error)
81301 goto dput_and_out;
81302
81303+ if (gr_handle_chroot_chroot(path.dentry, path.mnt))
81304+ goto dput_and_out;
81305+
81306 set_fs_root(current->fs, &path);
81307+
81308+ gr_handle_chroot_chdir(&path);
81309+
81310 error = 0;
81311 dput_and_out:
81312 path_put(&path);
81313@@ -511,6 +535,16 @@ static int chmod_common(struct path *path, umode_t mode)
81314 return error;
81315 retry_deleg:
81316 mutex_lock(&inode->i_mutex);
81317+
81318+ if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
81319+ error = -EACCES;
81320+ goto out_unlock;
81321+ }
81322+ if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
81323+ error = -EACCES;
81324+ goto out_unlock;
81325+ }
81326+
81327 error = security_path_chmod(path, mode);
81328 if (error)
81329 goto out_unlock;
81330@@ -576,6 +610,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
81331 uid = make_kuid(current_user_ns(), user);
81332 gid = make_kgid(current_user_ns(), group);
81333
81334+ if (!gr_acl_handle_chown(path->dentry, path->mnt))
81335+ return -EACCES;
81336+
81337 retry_deleg:
81338 newattrs.ia_valid = ATTR_CTIME;
81339 if (user != (uid_t) -1) {
81340@@ -1029,6 +1066,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
81341 } else {
81342 fsnotify_open(f);
81343 fd_install(fd, f);
81344+ trace_do_sys_open(tmp->name, flags, mode);
81345 }
81346 }
81347 putname(tmp);
81348diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
81349index d9da5a4..7ced3c7 100644
81350--- a/fs/overlayfs/inode.c
81351+++ b/fs/overlayfs/inode.c
81352@@ -346,6 +346,9 @@ struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags)
81353 if (d_is_dir(dentry))
81354 return d_backing_inode(dentry);
81355
81356+ if (d_is_dir(dentry))
81357+ return d_backing_inode(dentry);
81358+
81359 type = ovl_path_real(dentry, &realpath);
81360 if (ovl_open_need_copy_up(file_flags, type, realpath.dentry)) {
81361 err = ovl_want_write(dentry);
81362diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
81363index 79073d6..0eb5c27 100644
81364--- a/fs/overlayfs/super.c
81365+++ b/fs/overlayfs/super.c
81366@@ -172,7 +172,7 @@ void ovl_path_lower(struct dentry *dentry, struct path *path)
81367 {
81368 struct ovl_entry *oe = dentry->d_fsdata;
81369
81370- *path = oe->numlower ? oe->lowerstack[0] : (struct path) { NULL, NULL };
81371+ *path = oe->numlower ? oe->lowerstack[0] : (struct path) { .dentry = NULL, .mnt = NULL };
81372 }
81373
81374 int ovl_want_write(struct dentry *dentry)
81375@@ -879,8 +879,8 @@ static unsigned int ovl_split_lowerdirs(char *str)
81376
81377 static int ovl_fill_super(struct super_block *sb, void *data, int silent)
81378 {
81379- struct path upperpath = { NULL, NULL };
81380- struct path workpath = { NULL, NULL };
81381+ struct path upperpath = { .dentry = NULL, .mnt = NULL };
81382+ struct path workpath = { .dentry = NULL, .mnt = NULL };
81383 struct dentry *root_dentry;
81384 struct ovl_entry *oe;
81385 struct ovl_fs *ufs;
81386diff --git a/fs/pipe.c b/fs/pipe.c
81387index 8865f79..bd2c79b 100644
81388--- a/fs/pipe.c
81389+++ b/fs/pipe.c
81390@@ -36,7 +36,7 @@ unsigned int pipe_max_size = 1048576;
81391 /*
81392 * Minimum pipe size, as required by POSIX
81393 */
81394-unsigned int pipe_min_size = PAGE_SIZE;
81395+unsigned int pipe_min_size __read_only = PAGE_SIZE;
81396
81397 /*
81398 * We use a start+len construction, which provides full use of the
81399@@ -55,7 +55,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
81400
81401 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
81402 {
81403- if (pipe->files)
81404+ if (atomic_read(&pipe->files))
81405 mutex_lock_nested(&pipe->mutex, subclass);
81406 }
81407
81408@@ -70,7 +70,7 @@ EXPORT_SYMBOL(pipe_lock);
81409
81410 void pipe_unlock(struct pipe_inode_info *pipe)
81411 {
81412- if (pipe->files)
81413+ if (atomic_read(&pipe->files))
81414 mutex_unlock(&pipe->mutex);
81415 }
81416 EXPORT_SYMBOL(pipe_unlock);
81417@@ -291,9 +291,9 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)
81418 }
81419 if (bufs) /* More to do? */
81420 continue;
81421- if (!pipe->writers)
81422+ if (!atomic_read(&pipe->writers))
81423 break;
81424- if (!pipe->waiting_writers) {
81425+ if (!atomic_read(&pipe->waiting_writers)) {
81426 /* syscall merging: Usually we must not sleep
81427 * if O_NONBLOCK is set, or if we got some data.
81428 * But if a writer sleeps in kernel space, then
81429@@ -350,7 +350,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
81430
81431 __pipe_lock(pipe);
81432
81433- if (!pipe->readers) {
81434+ if (!atomic_read(&pipe->readers)) {
81435 send_sig(SIGPIPE, current, 0);
81436 ret = -EPIPE;
81437 goto out;
81438@@ -386,7 +386,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
81439 for (;;) {
81440 int bufs;
81441
81442- if (!pipe->readers) {
81443+ if (!atomic_read(&pipe->readers)) {
81444 send_sig(SIGPIPE, current, 0);
81445 if (!ret)
81446 ret = -EPIPE;
81447@@ -454,9 +454,9 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
81448 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
81449 do_wakeup = 0;
81450 }
81451- pipe->waiting_writers++;
81452+ atomic_inc(&pipe->waiting_writers);
81453 pipe_wait(pipe);
81454- pipe->waiting_writers--;
81455+ atomic_dec(&pipe->waiting_writers);
81456 }
81457 out:
81458 __pipe_unlock(pipe);
81459@@ -511,7 +511,7 @@ pipe_poll(struct file *filp, poll_table *wait)
81460 mask = 0;
81461 if (filp->f_mode & FMODE_READ) {
81462 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
81463- if (!pipe->writers && filp->f_version != pipe->w_counter)
81464+ if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
81465 mask |= POLLHUP;
81466 }
81467
81468@@ -521,7 +521,7 @@ pipe_poll(struct file *filp, poll_table *wait)
81469 * Most Unices do not set POLLERR for FIFOs but on Linux they
81470 * behave exactly like pipes for poll().
81471 */
81472- if (!pipe->readers)
81473+ if (!atomic_read(&pipe->readers))
81474 mask |= POLLERR;
81475 }
81476
81477@@ -533,7 +533,7 @@ static void put_pipe_info(struct inode *inode, struct pipe_inode_info *pipe)
81478 int kill = 0;
81479
81480 spin_lock(&inode->i_lock);
81481- if (!--pipe->files) {
81482+ if (atomic_dec_and_test(&pipe->files)) {
81483 inode->i_pipe = NULL;
81484 kill = 1;
81485 }
81486@@ -550,11 +550,11 @@ pipe_release(struct inode *inode, struct file *file)
81487
81488 __pipe_lock(pipe);
81489 if (file->f_mode & FMODE_READ)
81490- pipe->readers--;
81491+ atomic_dec(&pipe->readers);
81492 if (file->f_mode & FMODE_WRITE)
81493- pipe->writers--;
81494+ atomic_dec(&pipe->writers);
81495
81496- if (pipe->readers || pipe->writers) {
81497+ if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
81498 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
81499 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
81500 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
81501@@ -619,7 +619,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
81502 kfree(pipe);
81503 }
81504
81505-static struct vfsmount *pipe_mnt __read_mostly;
81506+struct vfsmount *pipe_mnt __read_mostly;
81507
81508 /*
81509 * pipefs_dname() is called from d_path().
81510@@ -649,8 +649,9 @@ static struct inode * get_pipe_inode(void)
81511 goto fail_iput;
81512
81513 inode->i_pipe = pipe;
81514- pipe->files = 2;
81515- pipe->readers = pipe->writers = 1;
81516+ atomic_set(&pipe->files, 2);
81517+ atomic_set(&pipe->readers, 1);
81518+ atomic_set(&pipe->writers, 1);
81519 inode->i_fop = &pipefifo_fops;
81520
81521 /*
81522@@ -829,17 +830,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
81523 spin_lock(&inode->i_lock);
81524 if (inode->i_pipe) {
81525 pipe = inode->i_pipe;
81526- pipe->files++;
81527+ atomic_inc(&pipe->files);
81528 spin_unlock(&inode->i_lock);
81529 } else {
81530 spin_unlock(&inode->i_lock);
81531 pipe = alloc_pipe_info();
81532 if (!pipe)
81533 return -ENOMEM;
81534- pipe->files = 1;
81535+ atomic_set(&pipe->files, 1);
81536 spin_lock(&inode->i_lock);
81537 if (unlikely(inode->i_pipe)) {
81538- inode->i_pipe->files++;
81539+ atomic_inc(&inode->i_pipe->files);
81540 spin_unlock(&inode->i_lock);
81541 free_pipe_info(pipe);
81542 pipe = inode->i_pipe;
81543@@ -864,10 +865,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
81544 * opened, even when there is no process writing the FIFO.
81545 */
81546 pipe->r_counter++;
81547- if (pipe->readers++ == 0)
81548+ if (atomic_inc_return(&pipe->readers) == 1)
81549 wake_up_partner(pipe);
81550
81551- if (!is_pipe && !pipe->writers) {
81552+ if (!is_pipe && !atomic_read(&pipe->writers)) {
81553 if ((filp->f_flags & O_NONBLOCK)) {
81554 /* suppress POLLHUP until we have
81555 * seen a writer */
81556@@ -886,14 +887,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
81557 * errno=ENXIO when there is no process reading the FIFO.
81558 */
81559 ret = -ENXIO;
81560- if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
81561+ if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
81562 goto err;
81563
81564 pipe->w_counter++;
81565- if (!pipe->writers++)
81566+ if (atomic_inc_return(&pipe->writers) == 1)
81567 wake_up_partner(pipe);
81568
81569- if (!is_pipe && !pipe->readers) {
81570+ if (!is_pipe && !atomic_read(&pipe->readers)) {
81571 if (wait_for_partner(pipe, &pipe->r_counter))
81572 goto err_wr;
81573 }
81574@@ -907,11 +908,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
81575 * the process can at least talk to itself.
81576 */
81577
81578- pipe->readers++;
81579- pipe->writers++;
81580+ atomic_inc(&pipe->readers);
81581+ atomic_inc(&pipe->writers);
81582 pipe->r_counter++;
81583 pipe->w_counter++;
81584- if (pipe->readers == 1 || pipe->writers == 1)
81585+ if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
81586 wake_up_partner(pipe);
81587 break;
81588
81589@@ -925,13 +926,13 @@ static int fifo_open(struct inode *inode, struct file *filp)
81590 return 0;
81591
81592 err_rd:
81593- if (!--pipe->readers)
81594+ if (atomic_dec_and_test(&pipe->readers))
81595 wake_up_interruptible(&pipe->wait);
81596 ret = -ERESTARTSYS;
81597 goto err;
81598
81599 err_wr:
81600- if (!--pipe->writers)
81601+ if (atomic_dec_and_test(&pipe->writers))
81602 wake_up_interruptible(&pipe->wait);
81603 ret = -ERESTARTSYS;
81604 goto err;
81605@@ -1007,7 +1008,7 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long nr_pages)
81606 * Currently we rely on the pipe array holding a power-of-2 number
81607 * of pages.
81608 */
81609-static inline unsigned int round_pipe_size(unsigned int size)
81610+static inline unsigned long round_pipe_size(unsigned long size)
81611 {
81612 unsigned long nr_pages;
81613
81614@@ -1055,13 +1056,16 @@ long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
81615
81616 switch (cmd) {
81617 case F_SETPIPE_SZ: {
81618- unsigned int size, nr_pages;
81619+ unsigned long size, nr_pages;
81620+
81621+ ret = -EINVAL;
81622+ if (arg < pipe_min_size)
81623+ goto out;
81624
81625 size = round_pipe_size(arg);
81626 nr_pages = size >> PAGE_SHIFT;
81627
81628- ret = -EINVAL;
81629- if (!nr_pages)
81630+ if (size < pipe_min_size)
81631 goto out;
81632
81633 if (!capable(CAP_SYS_RESOURCE) && size > pipe_max_size) {
81634diff --git a/fs/posix_acl.c b/fs/posix_acl.c
81635index 4fb17de..13d8c0f 100644
81636--- a/fs/posix_acl.c
81637+++ b/fs/posix_acl.c
81638@@ -20,6 +20,7 @@
81639 #include <linux/xattr.h>
81640 #include <linux/export.h>
81641 #include <linux/user_namespace.h>
81642+#include <linux/grsecurity.h>
81643
81644 struct posix_acl **acl_by_type(struct inode *inode, int type)
81645 {
81646@@ -277,7 +278,7 @@ posix_acl_equiv_mode(const struct posix_acl *acl, umode_t *mode_p)
81647 }
81648 }
81649 if (mode_p)
81650- *mode_p = (*mode_p & ~S_IRWXUGO) | mode;
81651+ *mode_p = ((*mode_p & ~S_IRWXUGO) | mode) & ~gr_acl_umask();
81652 return not_equiv;
81653 }
81654 EXPORT_SYMBOL(posix_acl_equiv_mode);
81655@@ -427,7 +428,7 @@ static int posix_acl_create_masq(struct posix_acl *acl, umode_t *mode_p)
81656 mode &= (group_obj->e_perm << 3) | ~S_IRWXG;
81657 }
81658
81659- *mode_p = (*mode_p & ~S_IRWXUGO) | mode;
81660+ *mode_p = ((*mode_p & ~S_IRWXUGO) | mode) & ~gr_acl_umask();
81661 return not_equiv;
81662 }
81663
81664@@ -485,6 +486,8 @@ __posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p)
81665 struct posix_acl *clone = posix_acl_clone(*acl, gfp);
81666 int err = -ENOMEM;
81667 if (clone) {
81668+ *mode_p &= ~gr_acl_umask();
81669+
81670 err = posix_acl_create_masq(clone, mode_p);
81671 if (err < 0) {
81672 posix_acl_release(clone);
81673@@ -657,11 +660,12 @@ struct posix_acl *
81674 posix_acl_from_xattr(struct user_namespace *user_ns,
81675 const void *value, size_t size)
81676 {
81677- posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
81678- posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
81679+ const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
81680+ const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
81681 int count;
81682 struct posix_acl *acl;
81683 struct posix_acl_entry *acl_e;
81684+ umode_t umask = gr_acl_umask();
81685
81686 if (!value)
81687 return NULL;
81688@@ -687,12 +691,18 @@ posix_acl_from_xattr(struct user_namespace *user_ns,
81689
81690 switch(acl_e->e_tag) {
81691 case ACL_USER_OBJ:
81692+ acl_e->e_perm &= ~((umask & S_IRWXU) >> 6);
81693+ break;
81694 case ACL_GROUP_OBJ:
81695 case ACL_MASK:
81696+ acl_e->e_perm &= ~((umask & S_IRWXG) >> 3);
81697+ break;
81698 case ACL_OTHER:
81699+ acl_e->e_perm &= ~(umask & S_IRWXO);
81700 break;
81701
81702 case ACL_USER:
81703+ acl_e->e_perm &= ~((umask & S_IRWXU) >> 6);
81704 acl_e->e_uid =
81705 make_kuid(user_ns,
81706 le32_to_cpu(entry->e_id));
81707@@ -700,6 +710,7 @@ posix_acl_from_xattr(struct user_namespace *user_ns,
81708 goto fail;
81709 break;
81710 case ACL_GROUP:
81711+ acl_e->e_perm &= ~((umask & S_IRWXG) >> 3);
81712 acl_e->e_gid =
81713 make_kgid(user_ns,
81714 le32_to_cpu(entry->e_id));
81715diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
81716index 1ade120..a86f1a2 100644
81717--- a/fs/proc/Kconfig
81718+++ b/fs/proc/Kconfig
81719@@ -30,7 +30,7 @@ config PROC_FS
81720
81721 config PROC_KCORE
81722 bool "/proc/kcore support" if !ARM
81723- depends on PROC_FS && MMU
81724+ depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
81725 help
81726 Provides a virtual ELF core file of the live kernel. This can
81727 be read with gdb and other ELF tools. No modifications can be
81728@@ -38,8 +38,8 @@ config PROC_KCORE
81729
81730 config PROC_VMCORE
81731 bool "/proc/vmcore support"
81732- depends on PROC_FS && CRASH_DUMP
81733- default y
81734+ depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
81735+ default n
81736 help
81737 Exports the dump image of crashed kernel in ELF format.
81738
81739@@ -63,8 +63,8 @@ config PROC_SYSCTL
81740 limited in memory.
81741
81742 config PROC_PAGE_MONITOR
81743- default y
81744- depends on PROC_FS && MMU
81745+ default n
81746+ depends on PROC_FS && MMU && !GRKERNSEC
81747 bool "Enable /proc page monitoring" if EXPERT
81748 help
81749 Various /proc files exist to monitor process memory utilization:
81750diff --git a/fs/proc/array.c b/fs/proc/array.c
81751index ce065cf..8974fed 100644
81752--- a/fs/proc/array.c
81753+++ b/fs/proc/array.c
81754@@ -60,6 +60,7 @@
81755 #include <linux/tty.h>
81756 #include <linux/string.h>
81757 #include <linux/mman.h>
81758+#include <linux/grsecurity.h>
81759 #include <linux/proc_fs.h>
81760 #include <linux/ioport.h>
81761 #include <linux/uaccess.h>
81762@@ -348,6 +349,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
81763 cpumask_pr_args(&task->cpus_allowed));
81764 }
81765
81766+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
81767+static inline void task_pax(struct seq_file *m, struct task_struct *p)
81768+{
81769+ if (p->mm)
81770+ seq_printf(m, "PaX:\t%c%c%c%c%c\n",
81771+ p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
81772+ p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
81773+ p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
81774+ p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
81775+ p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
81776+ else
81777+ seq_printf(m, "PaX:\t-----\n");
81778+}
81779+#endif
81780+
81781 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
81782 struct pid *pid, struct task_struct *task)
81783 {
81784@@ -366,9 +382,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
81785 task_cpus_allowed(m, task);
81786 cpuset_task_status_allowed(m, task);
81787 task_context_switch_counts(m, task);
81788+
81789+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
81790+ task_pax(m, task);
81791+#endif
81792+
81793+#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
81794+ task_grsec_rbac(m, task);
81795+#endif
81796+
81797 return 0;
81798 }
81799
81800+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81801+#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
81802+ (_mm->pax_flags & MF_PAX_RANDMMAP || \
81803+ _mm->pax_flags & MF_PAX_SEGMEXEC))
81804+#endif
81805+
81806 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
81807 struct pid *pid, struct task_struct *task, int whole)
81808 {
81809@@ -390,6 +421,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
81810 char tcomm[sizeof(task->comm)];
81811 unsigned long flags;
81812
81813+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81814+ if (current->exec_id != m->exec_id) {
81815+ gr_log_badprocpid("stat");
81816+ return 0;
81817+ }
81818+#endif
81819+
81820 state = *get_task_state(task);
81821 vsize = eip = esp = 0;
81822 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
81823@@ -460,6 +498,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
81824 gtime = task_gtime(task);
81825 }
81826
81827+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81828+ if (PAX_RAND_FLAGS(mm)) {
81829+ eip = 0;
81830+ esp = 0;
81831+ wchan = 0;
81832+ }
81833+#endif
81834+#ifdef CONFIG_GRKERNSEC_HIDESYM
81835+ wchan = 0;
81836+ eip =0;
81837+ esp =0;
81838+#endif
81839+
81840 /* scale priority and nice values from timeslices to -20..20 */
81841 /* to make it look like a "normal" Unix priority/nice value */
81842 priority = task_prio(task);
81843@@ -491,9 +542,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
81844 seq_put_decimal_ull(m, ' ', vsize);
81845 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
81846 seq_put_decimal_ull(m, ' ', rsslim);
81847+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81848+ seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
81849+ seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
81850+ seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
81851+#else
81852 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
81853 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
81854 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
81855+#endif
81856 seq_put_decimal_ull(m, ' ', esp);
81857 seq_put_decimal_ull(m, ' ', eip);
81858 /* The signal information here is obsolete.
81859@@ -515,7 +572,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
81860 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
81861 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
81862
81863- if (mm && permitted) {
81864+ if (mm && permitted
81865+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81866+ && !PAX_RAND_FLAGS(mm)
81867+#endif
81868+ ) {
81869 seq_put_decimal_ull(m, ' ', mm->start_data);
81870 seq_put_decimal_ull(m, ' ', mm->end_data);
81871 seq_put_decimal_ull(m, ' ', mm->start_brk);
81872@@ -553,8 +614,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
81873 struct pid *pid, struct task_struct *task)
81874 {
81875 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
81876- struct mm_struct *mm = get_task_mm(task);
81877+ struct mm_struct *mm;
81878
81879+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81880+ if (current->exec_id != m->exec_id) {
81881+ gr_log_badprocpid("statm");
81882+ return 0;
81883+ }
81884+#endif
81885+ mm = get_task_mm(task);
81886 if (mm) {
81887 size = task_statm(mm, &shared, &text, &data, &resident);
81888 mmput(mm);
81889@@ -577,6 +645,20 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
81890 return 0;
81891 }
81892
81893+#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
81894+int proc_pid_ipaddr(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task)
81895+{
81896+ unsigned long flags;
81897+ u32 curr_ip = 0;
81898+
81899+ if (lock_task_sighand(task, &flags)) {
81900+ curr_ip = task->signal->curr_ip;
81901+ unlock_task_sighand(task, &flags);
81902+ }
81903+ return seq_printf(m, "%pI4\n", &curr_ip);
81904+}
81905+#endif
81906+
81907 #ifdef CONFIG_PROC_CHILDREN
81908 static struct pid *
81909 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
81910diff --git a/fs/proc/base.c b/fs/proc/base.c
81911index aa50d1a..7a62b7a 100644
81912--- a/fs/proc/base.c
81913+++ b/fs/proc/base.c
81914@@ -113,6 +113,14 @@ struct pid_entry {
81915 union proc_op op;
81916 };
81917
81918+struct getdents_callback {
81919+ struct linux_dirent __user * current_dir;
81920+ struct linux_dirent __user * previous;
81921+ struct file * file;
81922+ int count;
81923+ int error;
81924+};
81925+
81926 #define NOD(NAME, MODE, IOP, FOP, OP) { \
81927 .name = (NAME), \
81928 .len = sizeof(NAME) - 1, \
81929@@ -224,6 +232,11 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
81930 goto out_mmput;
81931 }
81932
81933+ if (gr_acl_handle_procpidmem(tsk)) {
81934+ rv = 0;
81935+ goto out_mmput;
81936+ }
81937+
81938 page = (char *)__get_free_page(GFP_TEMPORARY);
81939 if (!page) {
81940 rv = -ENOMEM;
81941@@ -400,12 +413,28 @@ static const struct file_operations proc_pid_cmdline_ops = {
81942 .llseek = generic_file_llseek,
81943 };
81944
81945+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81946+#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
81947+ (_mm->pax_flags & MF_PAX_RANDMMAP || \
81948+ _mm->pax_flags & MF_PAX_SEGMEXEC))
81949+#endif
81950+
81951 static int proc_pid_auxv(struct seq_file *m, struct pid_namespace *ns,
81952 struct pid *pid, struct task_struct *task)
81953 {
81954 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
81955 if (mm && !IS_ERR(mm)) {
81956 unsigned int nwords = 0;
81957+
81958+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81959+ /* allow if we're currently ptracing this task */
81960+ if (PAX_RAND_FLAGS(mm) &&
81961+ (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
81962+ mmput(mm);
81963+ return 0;
81964+ }
81965+#endif
81966+
81967 do {
81968 nwords += 2;
81969 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
81970@@ -417,7 +446,7 @@ static int proc_pid_auxv(struct seq_file *m, struct pid_namespace *ns,
81971 }
81972
81973
81974-#ifdef CONFIG_KALLSYMS
81975+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
81976 /*
81977 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
81978 * Returns the resolved symbol. If that fails, simply return the address.
81979@@ -459,7 +488,7 @@ static void unlock_trace(struct task_struct *task)
81980 mutex_unlock(&task->signal->cred_guard_mutex);
81981 }
81982
81983-#ifdef CONFIG_STACKTRACE
81984+#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
81985
81986 #define MAX_STACK_TRACE_DEPTH 64
81987
81988@@ -657,7 +686,7 @@ static int proc_pid_limits(struct seq_file *m, struct pid_namespace *ns,
81989 return 0;
81990 }
81991
81992-#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
81993+#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
81994 static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns,
81995 struct pid *pid, struct task_struct *task)
81996 {
81997@@ -690,7 +719,7 @@ static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns,
81998 /************************************************************************/
81999
82000 /* permission checks */
82001-static int proc_fd_access_allowed(struct inode *inode)
82002+static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
82003 {
82004 struct task_struct *task;
82005 int allowed = 0;
82006@@ -700,7 +729,10 @@ static int proc_fd_access_allowed(struct inode *inode)
82007 */
82008 task = get_proc_task(inode);
82009 if (task) {
82010- allowed = ptrace_may_access(task, PTRACE_MODE_READ);
82011+ if (log)
82012+ allowed = ptrace_may_access(task, PTRACE_MODE_READ);
82013+ else
82014+ allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
82015 put_task_struct(task);
82016 }
82017 return allowed;
82018@@ -731,10 +763,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
82019 struct task_struct *task,
82020 int hide_pid_min)
82021 {
82022+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
82023+ return false;
82024+
82025+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82026+ rcu_read_lock();
82027+ {
82028+ const struct cred *tmpcred = current_cred();
82029+ const struct cred *cred = __task_cred(task);
82030+
82031+ if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
82032+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82033+ || in_group_p(grsec_proc_gid)
82034+#endif
82035+ ) {
82036+ rcu_read_unlock();
82037+ return true;
82038+ }
82039+ }
82040+ rcu_read_unlock();
82041+
82042+ if (!pid->hide_pid)
82043+ return false;
82044+#endif
82045+
82046 if (pid->hide_pid < hide_pid_min)
82047 return true;
82048 if (in_group_p(pid->pid_gid))
82049 return true;
82050+
82051 return ptrace_may_access(task, PTRACE_MODE_READ);
82052 }
82053
82054@@ -752,7 +809,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
82055 put_task_struct(task);
82056
82057 if (!has_perms) {
82058+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82059+ {
82060+#else
82061 if (pid->hide_pid == 2) {
82062+#endif
82063 /*
82064 * Let's make getdents(), stat(), and open()
82065 * consistent with each other. If a process
82066@@ -813,6 +874,10 @@ struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode)
82067
82068 if (task) {
82069 mm = mm_access(task, mode);
82070+ if (!IS_ERR_OR_NULL(mm) && gr_acl_handle_procpidmem(task)) {
82071+ mmput(mm);
82072+ mm = ERR_PTR(-EPERM);
82073+ }
82074 put_task_struct(task);
82075
82076 if (!IS_ERR_OR_NULL(mm)) {
82077@@ -834,6 +899,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
82078 return PTR_ERR(mm);
82079
82080 file->private_data = mm;
82081+
82082+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82083+ file->f_version = current->exec_id;
82084+#endif
82085+
82086 return 0;
82087 }
82088
82089@@ -855,6 +925,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
82090 ssize_t copied;
82091 char *page;
82092
82093+#ifdef CONFIG_GRKERNSEC
82094+ if (write)
82095+ return -EPERM;
82096+#endif
82097+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82098+ if (file->f_version != current->exec_id) {
82099+ gr_log_badprocpid("mem");
82100+ return 0;
82101+ }
82102+#endif
82103+
82104 if (!mm)
82105 return 0;
82106
82107@@ -867,7 +948,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
82108 goto free;
82109
82110 while (count > 0) {
82111- int this_len = min_t(int, count, PAGE_SIZE);
82112+ ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
82113
82114 if (write && copy_from_user(page, buf, this_len)) {
82115 copied = -EFAULT;
82116@@ -959,6 +1040,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
82117 if (!mm)
82118 return 0;
82119
82120+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82121+ if (file->f_version != current->exec_id) {
82122+ gr_log_badprocpid("environ");
82123+ return 0;
82124+ }
82125+#endif
82126+
82127 page = (char *)__get_free_page(GFP_TEMPORARY);
82128 if (!page)
82129 return -ENOMEM;
82130@@ -968,7 +1056,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
82131 goto free;
82132 while (count > 0) {
82133 size_t this_len, max_len;
82134- int retval;
82135+ ssize_t retval;
82136
82137 if (src >= (mm->env_end - mm->env_start))
82138 break;
82139@@ -1582,7 +1670,7 @@ static const char *proc_pid_follow_link(struct dentry *dentry, void **cookie)
82140 int error = -EACCES;
82141
82142 /* Are we allowed to snoop on the tasks file descriptors? */
82143- if (!proc_fd_access_allowed(inode))
82144+ if (!proc_fd_access_allowed(inode, 0))
82145 goto out;
82146
82147 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
82148@@ -1626,8 +1714,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
82149 struct path path;
82150
82151 /* Are we allowed to snoop on the tasks file descriptors? */
82152- if (!proc_fd_access_allowed(inode))
82153- goto out;
82154+ /* logging this is needed for learning on chromium to work properly,
82155+ but we don't want to flood the logs from 'ps' which does a readlink
82156+ on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
82157+ CAP_SYS_PTRACE as it's not necessary for its basic functionality
82158+ */
82159+ if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
82160+ if (!proc_fd_access_allowed(inode,0))
82161+ goto out;
82162+ } else {
82163+ if (!proc_fd_access_allowed(inode,1))
82164+ goto out;
82165+ }
82166
82167 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
82168 if (error)
82169@@ -1677,7 +1775,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
82170 rcu_read_lock();
82171 cred = __task_cred(task);
82172 inode->i_uid = cred->euid;
82173+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82174+ inode->i_gid = grsec_proc_gid;
82175+#else
82176 inode->i_gid = cred->egid;
82177+#endif
82178 rcu_read_unlock();
82179 }
82180 security_task_to_inode(task, inode);
82181@@ -1713,10 +1815,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
82182 return -ENOENT;
82183 }
82184 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
82185+#ifdef CONFIG_GRKERNSEC_PROC_USER
82186+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
82187+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82188+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
82189+#endif
82190 task_dumpable(task)) {
82191 cred = __task_cred(task);
82192 stat->uid = cred->euid;
82193+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82194+ stat->gid = grsec_proc_gid;
82195+#else
82196 stat->gid = cred->egid;
82197+#endif
82198 }
82199 }
82200 rcu_read_unlock();
82201@@ -1754,11 +1865,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
82202
82203 if (task) {
82204 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
82205+#ifdef CONFIG_GRKERNSEC_PROC_USER
82206+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
82207+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82208+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
82209+#endif
82210 task_dumpable(task)) {
82211 rcu_read_lock();
82212 cred = __task_cred(task);
82213 inode->i_uid = cred->euid;
82214+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82215+ inode->i_gid = grsec_proc_gid;
82216+#else
82217 inode->i_gid = cred->egid;
82218+#endif
82219 rcu_read_unlock();
82220 } else {
82221 inode->i_uid = GLOBAL_ROOT_UID;
82222@@ -2290,6 +2410,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
82223 if (!task)
82224 goto out_no_task;
82225
82226+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
82227+ goto out;
82228+
82229 /*
82230 * Yes, it does not scale. And it should not. Don't add
82231 * new entries into /proc/<tgid>/ without very good reasons.
82232@@ -2320,6 +2443,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
82233 if (!task)
82234 return -ENOENT;
82235
82236+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
82237+ goto out;
82238+
82239 if (!dir_emit_dots(file, ctx))
82240 goto out;
82241
82242@@ -2764,7 +2890,7 @@ static const struct pid_entry tgid_base_stuff[] = {
82243 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
82244 #endif
82245 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
82246-#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
82247+#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
82248 ONE("syscall", S_IRUSR, proc_pid_syscall),
82249 #endif
82250 REG("cmdline", S_IRUGO, proc_pid_cmdline_ops),
82251@@ -2789,10 +2915,10 @@ static const struct pid_entry tgid_base_stuff[] = {
82252 #ifdef CONFIG_SECURITY
82253 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
82254 #endif
82255-#ifdef CONFIG_KALLSYMS
82256+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82257 ONE("wchan", S_IRUGO, proc_pid_wchan),
82258 #endif
82259-#ifdef CONFIG_STACKTRACE
82260+#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82261 ONE("stack", S_IRUSR, proc_pid_stack),
82262 #endif
82263 #ifdef CONFIG_SCHED_INFO
82264@@ -2826,6 +2952,9 @@ static const struct pid_entry tgid_base_stuff[] = {
82265 #ifdef CONFIG_HARDWALL
82266 ONE("hardwall", S_IRUGO, proc_pid_hardwall),
82267 #endif
82268+#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
82269+ ONE("ipaddr", S_IRUSR, proc_pid_ipaddr),
82270+#endif
82271 #ifdef CONFIG_USER_NS
82272 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
82273 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
82274@@ -2958,7 +3087,14 @@ static int proc_pid_instantiate(struct inode *dir,
82275 if (!inode)
82276 goto out;
82277
82278+#ifdef CONFIG_GRKERNSEC_PROC_USER
82279+ inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
82280+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82281+ inode->i_gid = grsec_proc_gid;
82282+ inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
82283+#else
82284 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
82285+#endif
82286 inode->i_op = &proc_tgid_base_inode_operations;
82287 inode->i_fop = &proc_tgid_base_operations;
82288 inode->i_flags|=S_IMMUTABLE;
82289@@ -2996,7 +3132,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
82290 if (!task)
82291 goto out;
82292
82293+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
82294+ goto out_put_task;
82295+
82296 result = proc_pid_instantiate(dir, dentry, task, NULL);
82297+out_put_task:
82298 put_task_struct(task);
82299 out:
82300 return ERR_PTR(result);
82301@@ -3110,7 +3250,7 @@ static const struct pid_entry tid_base_stuff[] = {
82302 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
82303 #endif
82304 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
82305-#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
82306+#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
82307 ONE("syscall", S_IRUSR, proc_pid_syscall),
82308 #endif
82309 REG("cmdline", S_IRUGO, proc_pid_cmdline_ops),
82310@@ -3137,10 +3277,10 @@ static const struct pid_entry tid_base_stuff[] = {
82311 #ifdef CONFIG_SECURITY
82312 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
82313 #endif
82314-#ifdef CONFIG_KALLSYMS
82315+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82316 ONE("wchan", S_IRUGO, proc_pid_wchan),
82317 #endif
82318-#ifdef CONFIG_STACKTRACE
82319+#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82320 ONE("stack", S_IRUSR, proc_pid_stack),
82321 #endif
82322 #ifdef CONFIG_SCHED_INFO
82323diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
82324index cbd82df..c0407d2 100644
82325--- a/fs/proc/cmdline.c
82326+++ b/fs/proc/cmdline.c
82327@@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
82328
82329 static int __init proc_cmdline_init(void)
82330 {
82331+#ifdef CONFIG_GRKERNSEC_PROC_ADD
82332+ proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
82333+#else
82334 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
82335+#endif
82336 return 0;
82337 }
82338 fs_initcall(proc_cmdline_init);
82339diff --git a/fs/proc/devices.c b/fs/proc/devices.c
82340index 50493ed..248166b 100644
82341--- a/fs/proc/devices.c
82342+++ b/fs/proc/devices.c
82343@@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
82344
82345 static int __init proc_devices_init(void)
82346 {
82347+#ifdef CONFIG_GRKERNSEC_PROC_ADD
82348+ proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
82349+#else
82350 proc_create("devices", 0, NULL, &proc_devinfo_operations);
82351+#endif
82352 return 0;
82353 }
82354 fs_initcall(proc_devices_init);
82355diff --git a/fs/proc/fd.c b/fs/proc/fd.c
82356index 6e5fcd0..06ea074 100644
82357--- a/fs/proc/fd.c
82358+++ b/fs/proc/fd.c
82359@@ -27,7 +27,8 @@ static int seq_show(struct seq_file *m, void *v)
82360 if (!task)
82361 return -ENOENT;
82362
82363- files = get_files_struct(task);
82364+ if (!gr_acl_handle_procpidmem(task))
82365+ files = get_files_struct(task);
82366 put_task_struct(task);
82367
82368 if (files) {
82369@@ -291,11 +292,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
82370 */
82371 int proc_fd_permission(struct inode *inode, int mask)
82372 {
82373+ struct task_struct *task;
82374 int rv = generic_permission(inode, mask);
82375- if (rv == 0)
82376- return 0;
82377+
82378 if (task_tgid(current) == proc_pid(inode))
82379 rv = 0;
82380+
82381+ task = get_proc_task(inode);
82382+ if (task == NULL)
82383+ return rv;
82384+
82385+ if (gr_acl_handle_procpidmem(task))
82386+ rv = -EACCES;
82387+
82388+ put_task_struct(task);
82389+
82390 return rv;
82391 }
82392
82393diff --git a/fs/proc/generic.c b/fs/proc/generic.c
82394index e5dee5c..dafe21b 100644
82395--- a/fs/proc/generic.c
82396+++ b/fs/proc/generic.c
82397@@ -22,6 +22,7 @@
82398 #include <linux/bitops.h>
82399 #include <linux/spinlock.h>
82400 #include <linux/completion.h>
82401+#include <linux/grsecurity.h>
82402 #include <asm/uaccess.h>
82403
82404 #include "internal.h"
82405@@ -253,6 +254,15 @@ struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry,
82406 return proc_lookup_de(PDE(dir), dir, dentry);
82407 }
82408
82409+struct dentry *proc_lookup_restrict(struct inode *dir, struct dentry *dentry,
82410+ unsigned int flags)
82411+{
82412+ if (gr_proc_is_restricted())
82413+ return ERR_PTR(-EACCES);
82414+
82415+ return proc_lookup_de(PDE(dir), dir, dentry);
82416+}
82417+
82418 /*
82419 * This returns non-zero if at EOF, so that the /proc
82420 * root directory can use this and check if it should
82421@@ -310,6 +320,16 @@ int proc_readdir(struct file *file, struct dir_context *ctx)
82422 return proc_readdir_de(PDE(inode), file, ctx);
82423 }
82424
82425+int proc_readdir_restrict(struct file *file, struct dir_context *ctx)
82426+{
82427+ struct inode *inode = file_inode(file);
82428+
82429+ if (gr_proc_is_restricted())
82430+ return -EACCES;
82431+
82432+ return proc_readdir_de(PDE(inode), file, ctx);
82433+}
82434+
82435 /*
82436 * These are the generic /proc directory operations. They
82437 * use the in-memory "struct proc_dir_entry" tree to parse
82438@@ -321,6 +341,12 @@ static const struct file_operations proc_dir_operations = {
82439 .iterate = proc_readdir,
82440 };
82441
82442+static const struct file_operations proc_dir_restricted_operations = {
82443+ .llseek = generic_file_llseek,
82444+ .read = generic_read_dir,
82445+ .iterate = proc_readdir_restrict,
82446+};
82447+
82448 /*
82449 * proc directories can do almost nothing..
82450 */
82451@@ -330,6 +356,12 @@ static const struct inode_operations proc_dir_inode_operations = {
82452 .setattr = proc_notify_change,
82453 };
82454
82455+static const struct inode_operations proc_dir_restricted_inode_operations = {
82456+ .lookup = proc_lookup_restrict,
82457+ .getattr = proc_getattr,
82458+ .setattr = proc_notify_change,
82459+};
82460+
82461 static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp)
82462 {
82463 int ret;
82464@@ -445,6 +477,31 @@ struct proc_dir_entry *proc_mkdir_data(const char *name, umode_t mode,
82465 }
82466 EXPORT_SYMBOL_GPL(proc_mkdir_data);
82467
82468+struct proc_dir_entry *proc_mkdir_data_restrict(const char *name, umode_t mode,
82469+ struct proc_dir_entry *parent, void *data)
82470+{
82471+ struct proc_dir_entry *ent;
82472+
82473+ if (mode == 0)
82474+ mode = S_IRUGO | S_IXUGO;
82475+
82476+ ent = __proc_create(&parent, name, S_IFDIR | mode, 2);
82477+ if (ent) {
82478+ ent->data = data;
82479+ ent->restricted = 1;
82480+ ent->proc_fops = &proc_dir_restricted_operations;
82481+ ent->proc_iops = &proc_dir_restricted_inode_operations;
82482+ parent->nlink++;
82483+ if (proc_register(parent, ent) < 0) {
82484+ kfree(ent);
82485+ parent->nlink--;
82486+ ent = NULL;
82487+ }
82488+ }
82489+ return ent;
82490+}
82491+EXPORT_SYMBOL_GPL(proc_mkdir_data_restrict);
82492+
82493 struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
82494 struct proc_dir_entry *parent)
82495 {
82496@@ -459,6 +516,13 @@ struct proc_dir_entry *proc_mkdir(const char *name,
82497 }
82498 EXPORT_SYMBOL(proc_mkdir);
82499
82500+struct proc_dir_entry *proc_mkdir_restrict(const char *name,
82501+ struct proc_dir_entry *parent)
82502+{
82503+ return proc_mkdir_data_restrict(name, 0, parent, NULL);
82504+}
82505+EXPORT_SYMBOL(proc_mkdir_restrict);
82506+
82507 struct proc_dir_entry *proc_create_mount_point(const char *name)
82508 {
82509 umode_t mode = S_IFDIR | S_IRUGO | S_IXUGO;
82510diff --git a/fs/proc/inode.c b/fs/proc/inode.c
82511index bd95b9f..a64a773 100644
82512--- a/fs/proc/inode.c
82513+++ b/fs/proc/inode.c
82514@@ -23,11 +23,17 @@
82515 #include <linux/slab.h>
82516 #include <linux/mount.h>
82517 #include <linux/magic.h>
82518+#include <linux/grsecurity.h>
82519
82520 #include <asm/uaccess.h>
82521
82522 #include "internal.h"
82523
82524+#ifdef CONFIG_PROC_SYSCTL
82525+extern const struct inode_operations proc_sys_inode_operations;
82526+extern const struct inode_operations proc_sys_dir_operations;
82527+#endif
82528+
82529 static void proc_evict_inode(struct inode *inode)
82530 {
82531 struct proc_dir_entry *de;
82532@@ -48,6 +54,13 @@ static void proc_evict_inode(struct inode *inode)
82533 RCU_INIT_POINTER(PROC_I(inode)->sysctl, NULL);
82534 sysctl_head_put(head);
82535 }
82536+
82537+#ifdef CONFIG_PROC_SYSCTL
82538+ if (inode->i_op == &proc_sys_inode_operations ||
82539+ inode->i_op == &proc_sys_dir_operations)
82540+ gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
82541+#endif
82542+
82543 }
82544
82545 static struct kmem_cache * proc_inode_cachep;
82546@@ -429,7 +442,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
82547 if (de->mode) {
82548 inode->i_mode = de->mode;
82549 inode->i_uid = de->uid;
82550+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82551+ inode->i_gid = grsec_proc_gid;
82552+#else
82553 inode->i_gid = de->gid;
82554+#endif
82555 }
82556 if (de->size)
82557 inode->i_size = de->size;
82558diff --git a/fs/proc/internal.h b/fs/proc/internal.h
82559index aa27810..9f2d3b2 100644
82560--- a/fs/proc/internal.h
82561+++ b/fs/proc/internal.h
82562@@ -47,9 +47,10 @@ struct proc_dir_entry {
82563 struct completion *pde_unload_completion;
82564 struct list_head pde_openers; /* who did ->open, but not ->release */
82565 spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
82566+ u8 restricted; /* a directory in /proc/net that should be restricted via GRKERNSEC_PROC */
82567 u8 namelen;
82568 char name[];
82569-};
82570+} __randomize_layout;
82571
82572 union proc_op {
82573 int (*proc_get_link)(struct dentry *, struct path *);
82574@@ -67,7 +68,7 @@ struct proc_inode {
82575 struct ctl_table *sysctl_entry;
82576 const struct proc_ns_operations *ns_ops;
82577 struct inode vfs_inode;
82578-};
82579+} __randomize_layout;
82580
82581 /*
82582 * General functions
82583@@ -155,6 +156,10 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
82584 struct pid *, struct task_struct *);
82585 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
82586 struct pid *, struct task_struct *);
82587+#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
82588+extern int proc_pid_ipaddr(struct seq_file *, struct pid_namespace *,
82589+ struct pid *, struct task_struct *);
82590+#endif
82591
82592 /*
82593 * base.c
82594@@ -179,9 +184,11 @@ extern bool proc_fill_cache(struct file *, struct dir_context *, const char *, i
82595 * generic.c
82596 */
82597 extern struct dentry *proc_lookup(struct inode *, struct dentry *, unsigned int);
82598+extern struct dentry *proc_lookup_restrict(struct inode *, struct dentry *, unsigned int);
82599 extern struct dentry *proc_lookup_de(struct proc_dir_entry *, struct inode *,
82600 struct dentry *);
82601 extern int proc_readdir(struct file *, struct dir_context *);
82602+extern int proc_readdir_restrict(struct file *, struct dir_context *);
82603 extern int proc_readdir_de(struct proc_dir_entry *, struct file *, struct dir_context *);
82604
82605 static inline struct proc_dir_entry *pde_get(struct proc_dir_entry *pde)
82606diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
82607index a352d57..cb94a5c 100644
82608--- a/fs/proc/interrupts.c
82609+++ b/fs/proc/interrupts.c
82610@@ -47,7 +47,11 @@ static const struct file_operations proc_interrupts_operations = {
82611
82612 static int __init proc_interrupts_init(void)
82613 {
82614+#ifdef CONFIG_GRKERNSEC_PROC_ADD
82615+ proc_create_grsec("interrupts", 0, NULL, &proc_interrupts_operations);
82616+#else
82617 proc_create("interrupts", 0, NULL, &proc_interrupts_operations);
82618+#endif
82619 return 0;
82620 }
82621 fs_initcall(proc_interrupts_init);
82622diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
82623index 92e6726..a600d4fa 100644
82624--- a/fs/proc/kcore.c
82625+++ b/fs/proc/kcore.c
82626@@ -483,9 +483,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
82627 * the addresses in the elf_phdr on our list.
82628 */
82629 start = kc_offset_to_vaddr(*fpos - elf_buflen);
82630- if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
82631+ tsz = PAGE_SIZE - (start & ~PAGE_MASK);
82632+ if (tsz > buflen)
82633 tsz = buflen;
82634-
82635+
82636 while (buflen) {
82637 struct kcore_list *m;
82638
82639@@ -515,19 +516,20 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
82640 } else {
82641 if (kern_addr_valid(start)) {
82642 unsigned long n;
82643+ char *elf_buf;
82644+ mm_segment_t oldfs;
82645
82646- n = copy_to_user(buffer, (char *)start, tsz);
82647- /*
82648- * We cannot distinguish between fault on source
82649- * and fault on destination. When this happens
82650- * we clear too and hope it will trigger the
82651- * EFAULT again.
82652- */
82653- if (n) {
82654- if (clear_user(buffer + tsz - n,
82655- n))
82656- return -EFAULT;
82657- }
82658+ elf_buf = kzalloc(tsz, GFP_KERNEL);
82659+ if (!elf_buf)
82660+ return -ENOMEM;
82661+ oldfs = get_fs();
82662+ set_fs(KERNEL_DS);
82663+ n = __copy_from_user(elf_buf, (const void __user *)start, tsz);
82664+ set_fs(oldfs);
82665+ n = copy_to_user(buffer, elf_buf, tsz);
82666+ kfree(elf_buf);
82667+ if (n)
82668+ return -EFAULT;
82669 } else {
82670 if (clear_user(buffer, tsz))
82671 return -EFAULT;
82672@@ -547,6 +549,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
82673
82674 static int open_kcore(struct inode *inode, struct file *filp)
82675 {
82676+#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
82677+ return -EPERM;
82678+#endif
82679 if (!capable(CAP_SYS_RAWIO))
82680 return -EPERM;
82681 if (kcore_need_update)
82682@@ -580,7 +585,7 @@ static int __meminit kcore_callback(struct notifier_block *self,
82683 return NOTIFY_OK;
82684 }
82685
82686-static struct notifier_block kcore_callback_nb __meminitdata = {
82687+static struct notifier_block kcore_callback_nb __meminitconst = {
82688 .notifier_call = kcore_callback,
82689 .priority = 0,
82690 };
82691diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
82692index d3ebf2e..6ad42d1 100644
82693--- a/fs/proc/meminfo.c
82694+++ b/fs/proc/meminfo.c
82695@@ -194,7 +194,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
82696 vmi.used >> 10,
82697 vmi.largest_chunk >> 10
82698 #ifdef CONFIG_MEMORY_FAILURE
82699- , atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
82700+ , atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
82701 #endif
82702 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
82703 , K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
82704diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
82705index f8595e8..e0d13cbd 100644
82706--- a/fs/proc/nommu.c
82707+++ b/fs/proc/nommu.c
82708@@ -64,7 +64,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
82709
82710 if (file) {
82711 seq_pad(m, ' ');
82712- seq_file_path(m, file, "");
82713+ seq_file_path(m, file, "\n\\");
82714 }
82715
82716 seq_putc(m, '\n');
82717diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
82718index 350984a..0fb02a9 100644
82719--- a/fs/proc/proc_net.c
82720+++ b/fs/proc/proc_net.c
82721@@ -23,9 +23,27 @@
82722 #include <linux/nsproxy.h>
82723 #include <net/net_namespace.h>
82724 #include <linux/seq_file.h>
82725+#include <linux/grsecurity.h>
82726
82727 #include "internal.h"
82728
82729+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
82730+static struct seq_operations *ipv6_seq_ops_addr;
82731+
82732+void register_ipv6_seq_ops_addr(struct seq_operations *addr)
82733+{
82734+ ipv6_seq_ops_addr = addr;
82735+}
82736+
82737+void unregister_ipv6_seq_ops_addr(void)
82738+{
82739+ ipv6_seq_ops_addr = NULL;
82740+}
82741+
82742+EXPORT_SYMBOL_GPL(register_ipv6_seq_ops_addr);
82743+EXPORT_SYMBOL_GPL(unregister_ipv6_seq_ops_addr);
82744+#endif
82745+
82746 static inline struct net *PDE_NET(struct proc_dir_entry *pde)
82747 {
82748 return pde->parent->data;
82749@@ -36,6 +54,8 @@ static struct net *get_proc_net(const struct inode *inode)
82750 return maybe_get_net(PDE_NET(PDE(inode)));
82751 }
82752
82753+extern const struct seq_operations dev_seq_ops;
82754+
82755 int seq_open_net(struct inode *ino, struct file *f,
82756 const struct seq_operations *ops, int size)
82757 {
82758@@ -44,6 +64,14 @@ int seq_open_net(struct inode *ino, struct file *f,
82759
82760 BUG_ON(size < sizeof(*p));
82761
82762+ /* only permit access to /proc/net/dev */
82763+ if (
82764+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
82765+ ops != ipv6_seq_ops_addr &&
82766+#endif
82767+ ops != &dev_seq_ops && gr_proc_is_restricted())
82768+ return -EACCES;
82769+
82770 net = get_proc_net(ino);
82771 if (net == NULL)
82772 return -ENXIO;
82773@@ -66,6 +94,9 @@ int single_open_net(struct inode *inode, struct file *file,
82774 int err;
82775 struct net *net;
82776
82777+ if (gr_proc_is_restricted())
82778+ return -EACCES;
82779+
82780 err = -ENXIO;
82781 net = get_proc_net(inode);
82782 if (net == NULL)
82783diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
82784index fdda62e..cd7c75f 100644
82785--- a/fs/proc/proc_sysctl.c
82786+++ b/fs/proc/proc_sysctl.c
82787@@ -11,13 +11,21 @@
82788 #include <linux/namei.h>
82789 #include <linux/mm.h>
82790 #include <linux/module.h>
82791+#include <linux/nsproxy.h>
82792+#ifdef CONFIG_GRKERNSEC
82793+#include <net/net_namespace.h>
82794+#endif
82795 #include "internal.h"
82796
82797+extern int gr_handle_chroot_sysctl(const int op);
82798+extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
82799+ const int op);
82800+
82801 static const struct dentry_operations proc_sys_dentry_operations;
82802 static const struct file_operations proc_sys_file_operations;
82803-static const struct inode_operations proc_sys_inode_operations;
82804+const struct inode_operations proc_sys_inode_operations;
82805 static const struct file_operations proc_sys_dir_file_operations;
82806-static const struct inode_operations proc_sys_dir_operations;
82807+const struct inode_operations proc_sys_dir_operations;
82808
82809 /* Support for permanently empty directories */
82810
82811@@ -32,13 +40,17 @@ static bool is_empty_dir(struct ctl_table_header *head)
82812
82813 static void set_empty_dir(struct ctl_dir *dir)
82814 {
82815- dir->header.ctl_table[0].child = sysctl_mount_point;
82816+ pax_open_kernel();
82817+ *(const void **)&dir->header.ctl_table[0].child = sysctl_mount_point;
82818+ pax_close_kernel();
82819 }
82820
82821 static void clear_empty_dir(struct ctl_dir *dir)
82822
82823 {
82824- dir->header.ctl_table[0].child = NULL;
82825+ pax_open_kernel();
82826+ *(void **)&dir->header.ctl_table[0].child = NULL;
82827+ pax_close_kernel();
82828 }
82829
82830 void proc_sys_poll_notify(struct ctl_table_poll *poll)
82831@@ -504,6 +516,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
82832
82833 err = NULL;
82834 d_set_d_op(dentry, &proc_sys_dentry_operations);
82835+
82836+ gr_handle_proc_create(dentry, inode);
82837+
82838 d_add(dentry, inode);
82839
82840 out:
82841@@ -519,6 +534,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
82842 struct inode *inode = file_inode(filp);
82843 struct ctl_table_header *head = grab_header(inode);
82844 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
82845+ int op = write ? MAY_WRITE : MAY_READ;
82846 ssize_t error;
82847 size_t res;
82848
82849@@ -530,7 +546,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
82850 * and won't be until we finish.
82851 */
82852 error = -EPERM;
82853- if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
82854+ if (sysctl_perm(head, table, op))
82855 goto out;
82856
82857 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
82858@@ -538,6 +554,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
82859 if (!table->proc_handler)
82860 goto out;
82861
82862+#ifdef CONFIG_GRKERNSEC
82863+ error = -EPERM;
82864+ if (gr_handle_chroot_sysctl(op))
82865+ goto out;
82866+ dget(filp->f_path.dentry);
82867+ if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
82868+ dput(filp->f_path.dentry);
82869+ goto out;
82870+ }
82871+ dput(filp->f_path.dentry);
82872+ if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
82873+ goto out;
82874+ if (write) {
82875+ if (current->nsproxy->net_ns != table->extra2) {
82876+ if (!capable(CAP_SYS_ADMIN))
82877+ goto out;
82878+ } else if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
82879+ goto out;
82880+ }
82881+#endif
82882+
82883 /* careful: calling conventions are nasty here */
82884 res = count;
82885 error = table->proc_handler(table, write, buf, &res, ppos);
82886@@ -635,6 +672,9 @@ static bool proc_sys_fill_cache(struct file *file,
82887 return false;
82888 } else {
82889 d_set_d_op(child, &proc_sys_dentry_operations);
82890+
82891+ gr_handle_proc_create(child, inode);
82892+
82893 d_add(child, inode);
82894 }
82895 } else {
82896@@ -678,6 +718,9 @@ static int scan(struct ctl_table_header *head, struct ctl_table *table,
82897 if ((*pos)++ < ctx->pos)
82898 return true;
82899
82900+ if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
82901+ return 0;
82902+
82903 if (unlikely(S_ISLNK(table->mode)))
82904 res = proc_sys_link_fill_cache(file, ctx, head, table);
82905 else
82906@@ -771,6 +814,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
82907 if (IS_ERR(head))
82908 return PTR_ERR(head);
82909
82910+ if (table && !gr_acl_handle_hidden_file(dentry, mnt))
82911+ return -ENOENT;
82912+
82913 generic_fillattr(inode, stat);
82914 if (table)
82915 stat->mode = (stat->mode & S_IFMT) | table->mode;
82916@@ -793,13 +839,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
82917 .llseek = generic_file_llseek,
82918 };
82919
82920-static const struct inode_operations proc_sys_inode_operations = {
82921+const struct inode_operations proc_sys_inode_operations = {
82922 .permission = proc_sys_permission,
82923 .setattr = proc_sys_setattr,
82924 .getattr = proc_sys_getattr,
82925 };
82926
82927-static const struct inode_operations proc_sys_dir_operations = {
82928+const struct inode_operations proc_sys_dir_operations = {
82929 .lookup = proc_sys_lookup,
82930 .permission = proc_sys_permission,
82931 .setattr = proc_sys_setattr,
82932@@ -876,7 +922,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
82933 static struct ctl_dir *new_dir(struct ctl_table_set *set,
82934 const char *name, int namelen)
82935 {
82936- struct ctl_table *table;
82937+ ctl_table_no_const *table;
82938 struct ctl_dir *new;
82939 struct ctl_node *node;
82940 char *new_name;
82941@@ -888,7 +934,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
82942 return NULL;
82943
82944 node = (struct ctl_node *)(new + 1);
82945- table = (struct ctl_table *)(node + 1);
82946+ table = (ctl_table_no_const *)(node + 1);
82947 new_name = (char *)(table + 2);
82948 memcpy(new_name, name, namelen);
82949 new_name[namelen] = '\0';
82950@@ -1057,7 +1103,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
82951 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
82952 struct ctl_table_root *link_root)
82953 {
82954- struct ctl_table *link_table, *entry, *link;
82955+ ctl_table_no_const *link_table, *link;
82956+ struct ctl_table *entry;
82957 struct ctl_table_header *links;
82958 struct ctl_node *node;
82959 char *link_name;
82960@@ -1080,7 +1127,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
82961 return NULL;
82962
82963 node = (struct ctl_node *)(links + 1);
82964- link_table = (struct ctl_table *)(node + nr_entries);
82965+ link_table = (ctl_table_no_const *)(node + nr_entries);
82966 link_name = (char *)&link_table[nr_entries + 1];
82967
82968 for (link = link_table, entry = table; entry->procname; link++, entry++) {
82969@@ -1328,8 +1375,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
82970 struct ctl_table_header ***subheader, struct ctl_table_set *set,
82971 struct ctl_table *table)
82972 {
82973- struct ctl_table *ctl_table_arg = NULL;
82974- struct ctl_table *entry, *files;
82975+ ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
82976+ struct ctl_table *entry;
82977 int nr_files = 0;
82978 int nr_dirs = 0;
82979 int err = -ENOMEM;
82980@@ -1341,10 +1388,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
82981 nr_files++;
82982 }
82983
82984- files = table;
82985 /* If there are mixed files and directories we need a new table */
82986 if (nr_dirs && nr_files) {
82987- struct ctl_table *new;
82988+ ctl_table_no_const *new;
82989 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
82990 GFP_KERNEL);
82991 if (!files)
82992@@ -1362,7 +1408,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
82993 /* Register everything except a directory full of subdirectories */
82994 if (nr_files || !nr_dirs) {
82995 struct ctl_table_header *header;
82996- header = __register_sysctl_table(set, path, files);
82997+ header = __register_sysctl_table(set, path, files ? files : table);
82998 if (!header) {
82999 kfree(ctl_table_arg);
83000 goto out;
83001diff --git a/fs/proc/root.c b/fs/proc/root.c
83002index 68feb0f..2c04780 100644
83003--- a/fs/proc/root.c
83004+++ b/fs/proc/root.c
83005@@ -185,7 +185,15 @@ void __init proc_root_init(void)
83006 proc_create_mount_point("openprom");
83007 #endif
83008 proc_tty_init();
83009+#ifdef CONFIG_GRKERNSEC_PROC_ADD
83010+#ifdef CONFIG_GRKERNSEC_PROC_USER
83011+ proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
83012+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83013+ proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
83014+#endif
83015+#else
83016 proc_mkdir("bus", NULL);
83017+#endif
83018 proc_sys_init();
83019 }
83020
83021diff --git a/fs/proc/stat.c b/fs/proc/stat.c
83022index 510413eb..34d9a8c 100644
83023--- a/fs/proc/stat.c
83024+++ b/fs/proc/stat.c
83025@@ -11,6 +11,7 @@
83026 #include <linux/irqnr.h>
83027 #include <linux/cputime.h>
83028 #include <linux/tick.h>
83029+#include <linux/grsecurity.h>
83030
83031 #ifndef arch_irq_stat_cpu
83032 #define arch_irq_stat_cpu(cpu) 0
83033@@ -87,6 +88,18 @@ static int show_stat(struct seq_file *p, void *v)
83034 u64 sum_softirq = 0;
83035 unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
83036 struct timespec boottime;
83037+ int unrestricted = 1;
83038+
83039+#ifdef CONFIG_GRKERNSEC_PROC_ADD
83040+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83041+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
83042+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
83043+ && !in_group_p(grsec_proc_gid)
83044+#endif
83045+ )
83046+ unrestricted = 0;
83047+#endif
83048+#endif
83049
83050 user = nice = system = idle = iowait =
83051 irq = softirq = steal = 0;
83052@@ -99,23 +112,25 @@ static int show_stat(struct seq_file *p, void *v)
83053 nice += kcpustat_cpu(i).cpustat[CPUTIME_NICE];
83054 system += kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM];
83055 idle += get_idle_time(i);
83056- iowait += get_iowait_time(i);
83057- irq += kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
83058- softirq += kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
83059- steal += kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
83060- guest += kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
83061- guest_nice += kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
83062- sum += kstat_cpu_irqs_sum(i);
83063- sum += arch_irq_stat_cpu(i);
83064+ if (unrestricted) {
83065+ iowait += get_iowait_time(i);
83066+ irq += kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
83067+ softirq += kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
83068+ steal += kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
83069+ guest += kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
83070+ guest_nice += kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
83071+ sum += kstat_cpu_irqs_sum(i);
83072+ sum += arch_irq_stat_cpu(i);
83073+ for (j = 0; j < NR_SOFTIRQS; j++) {
83074+ unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
83075
83076- for (j = 0; j < NR_SOFTIRQS; j++) {
83077- unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
83078-
83079- per_softirq_sums[j] += softirq_stat;
83080- sum_softirq += softirq_stat;
83081+ per_softirq_sums[j] += softirq_stat;
83082+ sum_softirq += softirq_stat;
83083+ }
83084 }
83085 }
83086- sum += arch_irq_stat();
83087+ if (unrestricted)
83088+ sum += arch_irq_stat();
83089
83090 seq_puts(p, "cpu ");
83091 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
83092@@ -136,12 +151,14 @@ static int show_stat(struct seq_file *p, void *v)
83093 nice = kcpustat_cpu(i).cpustat[CPUTIME_NICE];
83094 system = kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM];
83095 idle = get_idle_time(i);
83096- iowait = get_iowait_time(i);
83097- irq = kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
83098- softirq = kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
83099- steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
83100- guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
83101- guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
83102+ if (unrestricted) {
83103+ iowait = get_iowait_time(i);
83104+ irq = kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
83105+ softirq = kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
83106+ steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
83107+ guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
83108+ guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
83109+ }
83110 seq_printf(p, "cpu%d", i);
83111 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
83112 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(nice));
83113@@ -159,7 +176,7 @@ static int show_stat(struct seq_file *p, void *v)
83114
83115 /* sum again ? it could be updated? */
83116 for_each_irq_nr(j)
83117- seq_put_decimal_ull(p, ' ', kstat_irqs_usr(j));
83118+ seq_put_decimal_ull(p, ' ', unrestricted ? kstat_irqs_usr(j) : 0ULL);
83119
83120 seq_printf(p,
83121 "\nctxt %llu\n"
83122@@ -167,11 +184,11 @@ static int show_stat(struct seq_file *p, void *v)
83123 "processes %lu\n"
83124 "procs_running %lu\n"
83125 "procs_blocked %lu\n",
83126- nr_context_switches(),
83127+ unrestricted ? nr_context_switches() : 0ULL,
83128 (unsigned long)jif,
83129- total_forks,
83130- nr_running(),
83131- nr_iowait());
83132+ unrestricted ? total_forks : 0UL,
83133+ unrestricted ? nr_running() : 0UL,
83134+ unrestricted ? nr_iowait() : 0UL);
83135
83136 seq_printf(p, "softirq %llu", (unsigned long long)sum_softirq);
83137
83138diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
83139index ca1e091..a048795 100644
83140--- a/fs/proc/task_mmu.c
83141+++ b/fs/proc/task_mmu.c
83142@@ -13,12 +13,19 @@
83143 #include <linux/swap.h>
83144 #include <linux/swapops.h>
83145 #include <linux/mmu_notifier.h>
83146+#include <linux/grsecurity.h>
83147
83148 #include <asm/elf.h>
83149 #include <asm/uaccess.h>
83150 #include <asm/tlbflush.h>
83151 #include "internal.h"
83152
83153+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83154+#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
83155+ (_mm->pax_flags & MF_PAX_RANDMMAP || \
83156+ _mm->pax_flags & MF_PAX_SEGMEXEC))
83157+#endif
83158+
83159 void task_mem(struct seq_file *m, struct mm_struct *mm)
83160 {
83161 unsigned long data, text, lib, swap, ptes, pmds;
83162@@ -57,8 +64,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
83163 "VmLib:\t%8lu kB\n"
83164 "VmPTE:\t%8lu kB\n"
83165 "VmPMD:\t%8lu kB\n"
83166- "VmSwap:\t%8lu kB\n",
83167- hiwater_vm << (PAGE_SHIFT-10),
83168+ "VmSwap:\t%8lu kB\n"
83169+
83170+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83171+ "CsBase:\t%8lx\nCsLim:\t%8lx\n"
83172+#endif
83173+
83174+ ,hiwater_vm << (PAGE_SHIFT-10),
83175 total_vm << (PAGE_SHIFT-10),
83176 mm->locked_vm << (PAGE_SHIFT-10),
83177 mm->pinned_vm << (PAGE_SHIFT-10),
83178@@ -68,7 +80,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
83179 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
83180 ptes >> 10,
83181 pmds >> 10,
83182- swap << (PAGE_SHIFT-10));
83183+ swap << (PAGE_SHIFT-10)
83184+
83185+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83186+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83187+ , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
83188+ , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
83189+#else
83190+ , mm->context.user_cs_base
83191+ , mm->context.user_cs_limit
83192+#endif
83193+#endif
83194+
83195+ );
83196 }
83197
83198 unsigned long task_vsize(struct mm_struct *mm)
83199@@ -285,13 +309,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
83200 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
83201 }
83202
83203- /* We don't show the stack guard page in /proc/maps */
83204+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83205+ start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
83206+ end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
83207+#else
83208 start = vma->vm_start;
83209- if (stack_guard_page_start(vma, start))
83210- start += PAGE_SIZE;
83211 end = vma->vm_end;
83212- if (stack_guard_page_end(vma, end))
83213- end -= PAGE_SIZE;
83214+#endif
83215
83216 seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
83217 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
83218@@ -301,7 +325,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
83219 flags & VM_WRITE ? 'w' : '-',
83220 flags & VM_EXEC ? 'x' : '-',
83221 flags & VM_MAYSHARE ? 's' : 'p',
83222+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83223+ PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
83224+#else
83225 pgoff,
83226+#endif
83227 MAJOR(dev), MINOR(dev), ino);
83228
83229 /*
83230@@ -310,7 +338,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
83231 */
83232 if (file) {
83233 seq_pad(m, ' ');
83234- seq_file_path(m, file, "\n");
83235+ seq_file_path(m, file, "\n\\");
83236 goto done;
83237 }
83238
83239@@ -341,8 +369,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
83240 * Thread stack in /proc/PID/task/TID/maps or
83241 * the main process stack.
83242 */
83243- if (!is_pid || (vma->vm_start <= mm->start_stack &&
83244- vma->vm_end >= mm->start_stack)) {
83245+ if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
83246+ (vma->vm_start <= mm->start_stack &&
83247+ vma->vm_end >= mm->start_stack)) {
83248 name = "[stack]";
83249 } else {
83250 /* Thread stack in /proc/PID/maps */
83251@@ -362,6 +391,12 @@ done:
83252
83253 static int show_map(struct seq_file *m, void *v, int is_pid)
83254 {
83255+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83256+ if (current->exec_id != m->exec_id) {
83257+ gr_log_badprocpid("maps");
83258+ return 0;
83259+ }
83260+#endif
83261 show_map_vma(m, v, is_pid);
83262 m_cache_vma(m, v);
83263 return 0;
83264@@ -620,9 +655,18 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
83265 .private = &mss,
83266 };
83267
83268+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83269+ if (current->exec_id != m->exec_id) {
83270+ gr_log_badprocpid("smaps");
83271+ return 0;
83272+ }
83273+#endif
83274 memset(&mss, 0, sizeof mss);
83275- /* mmap_sem is held in m_start */
83276- walk_page_vma(vma, &smaps_walk);
83277+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83278+ if (!PAX_RAND_FLAGS(vma->vm_mm))
83279+#endif
83280+ /* mmap_sem is held in m_start */
83281+ walk_page_vma(vma, &smaps_walk);
83282
83283 show_map_vma(m, vma, is_pid);
83284
83285@@ -641,7 +685,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
83286 "KernelPageSize: %8lu kB\n"
83287 "MMUPageSize: %8lu kB\n"
83288 "Locked: %8lu kB\n",
83289+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83290+ PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
83291+#else
83292 (vma->vm_end - vma->vm_start) >> 10,
83293+#endif
83294 mss.resident >> 10,
83295 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
83296 mss.shared_clean >> 10,
83297@@ -1491,6 +1539,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
83298 char buffer[64];
83299 int nid;
83300
83301+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83302+ if (current->exec_id != m->exec_id) {
83303+ gr_log_badprocpid("numa_maps");
83304+ return 0;
83305+ }
83306+#endif
83307+
83308 if (!mm)
83309 return 0;
83310
83311@@ -1505,11 +1560,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
83312 mpol_to_str(buffer, sizeof(buffer), proc_priv->task_mempolicy);
83313 }
83314
83315+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83316+ seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
83317+#else
83318 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
83319+#endif
83320
83321 if (file) {
83322 seq_puts(m, " file=");
83323- seq_file_path(m, file, "\n\t= ");
83324+ seq_file_path(m, file, "\n\t\\= ");
83325 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
83326 seq_puts(m, " heap");
83327 } else {
83328diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
83329index e0d64c9..c44c96e 100644
83330--- a/fs/proc/task_nommu.c
83331+++ b/fs/proc/task_nommu.c
83332@@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
83333 else
83334 bytes += kobjsize(mm);
83335
83336- if (current->fs && current->fs->users > 1)
83337+ if (current->fs && atomic_read(&current->fs->users) > 1)
83338 sbytes += kobjsize(current->fs);
83339 else
83340 bytes += kobjsize(current->fs);
83341@@ -180,7 +180,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
83342
83343 if (file) {
83344 seq_pad(m, ' ');
83345- seq_file_path(m, file, "");
83346+ seq_file_path(m, file, "\n\\");
83347 } else if (mm) {
83348 pid_t tid = pid_of_stack(priv, vma, is_pid);
83349
83350diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
83351index 4e61388..1a2523d 100644
83352--- a/fs/proc/vmcore.c
83353+++ b/fs/proc/vmcore.c
83354@@ -105,9 +105,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
83355 nr_bytes = count;
83356
83357 /* If pfn is not ram, return zeros for sparse dump files */
83358- if (pfn_is_ram(pfn) == 0)
83359- memset(buf, 0, nr_bytes);
83360- else {
83361+ if (pfn_is_ram(pfn) == 0) {
83362+ if (userbuf) {
83363+ if (clear_user((char __force_user *)buf, nr_bytes))
83364+ return -EFAULT;
83365+ } else
83366+ memset(buf, 0, nr_bytes);
83367+ } else {
83368 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
83369 offset, userbuf);
83370 if (tmp < 0)
83371@@ -170,7 +174,7 @@ int __weak remap_oldmem_pfn_range(struct vm_area_struct *vma,
83372 static int copy_to(void *target, void *src, size_t size, int userbuf)
83373 {
83374 if (userbuf) {
83375- if (copy_to_user((char __user *) target, src, size))
83376+ if (copy_to_user((char __force_user *) target, src, size))
83377 return -EFAULT;
83378 } else {
83379 memcpy(target, src, size);
83380@@ -233,7 +237,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
83381 if (*fpos < m->offset + m->size) {
83382 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
83383 start = m->paddr + *fpos - m->offset;
83384- tmp = read_from_oldmem(buffer, tsz, &start, userbuf);
83385+ tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, userbuf);
83386 if (tmp < 0)
83387 return tmp;
83388 buflen -= tsz;
83389@@ -253,7 +257,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
83390 static ssize_t read_vmcore(struct file *file, char __user *buffer,
83391 size_t buflen, loff_t *fpos)
83392 {
83393- return __read_vmcore((__force char *) buffer, buflen, fpos, 1);
83394+ return __read_vmcore((__force_kernel char *) buffer, buflen, fpos, 1);
83395 }
83396
83397 /*
83398diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
83399index d3fb2b6..43a8140 100644
83400--- a/fs/qnx6/qnx6.h
83401+++ b/fs/qnx6/qnx6.h
83402@@ -74,7 +74,7 @@ enum {
83403 BYTESEX_BE,
83404 };
83405
83406-static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
83407+static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
83408 {
83409 if (sbi->s_bytesex == BYTESEX_LE)
83410 return le64_to_cpu((__force __le64)n);
83411@@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
83412 return (__force __fs64)cpu_to_be64(n);
83413 }
83414
83415-static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
83416+static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
83417 {
83418 if (sbi->s_bytesex == BYTESEX_LE)
83419 return le32_to_cpu((__force __le32)n);
83420diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
83421index bb2869f..d34ada8 100644
83422--- a/fs/quota/netlink.c
83423+++ b/fs/quota/netlink.c
83424@@ -44,7 +44,7 @@ static struct genl_family quota_genl_family = {
83425 void quota_send_warning(struct kqid qid, dev_t dev,
83426 const char warntype)
83427 {
83428- static atomic_t seq;
83429+ static atomic_unchecked_t seq;
83430 struct sk_buff *skb;
83431 void *msg_head;
83432 int ret;
83433@@ -60,7 +60,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
83434 "VFS: Not enough memory to send quota warning.\n");
83435 return;
83436 }
83437- msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
83438+ msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
83439 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
83440 if (!msg_head) {
83441 printk(KERN_ERR
83442diff --git a/fs/read_write.c b/fs/read_write.c
83443index 819ef3f..f07222d 100644
83444--- a/fs/read_write.c
83445+++ b/fs/read_write.c
83446@@ -505,7 +505,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
83447
83448 old_fs = get_fs();
83449 set_fs(get_ds());
83450- p = (__force const char __user *)buf;
83451+ p = (const char __force_user *)buf;
83452 if (count > MAX_RW_COUNT)
83453 count = MAX_RW_COUNT;
83454 ret = __vfs_write(file, p, count, pos);
83455diff --git a/fs/readdir.c b/fs/readdir.c
83456index ced6791..936687b 100644
83457--- a/fs/readdir.c
83458+++ b/fs/readdir.c
83459@@ -18,6 +18,7 @@
83460 #include <linux/security.h>
83461 #include <linux/syscalls.h>
83462 #include <linux/unistd.h>
83463+#include <linux/namei.h>
83464
83465 #include <asm/uaccess.h>
83466
83467@@ -71,6 +72,7 @@ struct old_linux_dirent {
83468 struct readdir_callback {
83469 struct dir_context ctx;
83470 struct old_linux_dirent __user * dirent;
83471+ struct file * file;
83472 int result;
83473 };
83474
83475@@ -89,6 +91,10 @@ static int fillonedir(struct dir_context *ctx, const char *name, int namlen,
83476 buf->result = -EOVERFLOW;
83477 return -EOVERFLOW;
83478 }
83479+
83480+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
83481+ return 0;
83482+
83483 buf->result++;
83484 dirent = buf->dirent;
83485 if (!access_ok(VERIFY_WRITE, dirent,
83486@@ -120,6 +126,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
83487 if (!f.file)
83488 return -EBADF;
83489
83490+ buf.file = f.file;
83491 error = iterate_dir(f.file, &buf.ctx);
83492 if (buf.result)
83493 error = buf.result;
83494@@ -145,6 +152,7 @@ struct getdents_callback {
83495 struct dir_context ctx;
83496 struct linux_dirent __user * current_dir;
83497 struct linux_dirent __user * previous;
83498+ struct file * file;
83499 int count;
83500 int error;
83501 };
83502@@ -167,6 +175,10 @@ static int filldir(struct dir_context *ctx, const char *name, int namlen,
83503 buf->error = -EOVERFLOW;
83504 return -EOVERFLOW;
83505 }
83506+
83507+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
83508+ return 0;
83509+
83510 dirent = buf->previous;
83511 if (dirent) {
83512 if (__put_user(offset, &dirent->d_off))
83513@@ -212,6 +224,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
83514 if (!f.file)
83515 return -EBADF;
83516
83517+ buf.file = f.file;
83518 error = iterate_dir(f.file, &buf.ctx);
83519 if (error >= 0)
83520 error = buf.error;
83521@@ -230,6 +243,7 @@ struct getdents_callback64 {
83522 struct dir_context ctx;
83523 struct linux_dirent64 __user * current_dir;
83524 struct linux_dirent64 __user * previous;
83525+ struct file *file;
83526 int count;
83527 int error;
83528 };
83529@@ -246,6 +260,10 @@ static int filldir64(struct dir_context *ctx, const char *name, int namlen,
83530 buf->error = -EINVAL; /* only used if we fail.. */
83531 if (reclen > buf->count)
83532 return -EINVAL;
83533+
83534+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
83535+ return 0;
83536+
83537 dirent = buf->previous;
83538 if (dirent) {
83539 if (__put_user(offset, &dirent->d_off))
83540@@ -293,6 +311,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
83541 if (!f.file)
83542 return -EBADF;
83543
83544+ buf.file = f.file;
83545 error = iterate_dir(f.file, &buf.ctx);
83546 if (error >= 0)
83547 error = buf.error;
83548diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
83549index 9c02d96..6562c10 100644
83550--- a/fs/reiserfs/do_balan.c
83551+++ b/fs/reiserfs/do_balan.c
83552@@ -1887,7 +1887,7 @@ void do_balance(struct tree_balance *tb, struct item_head *ih,
83553 return;
83554 }
83555
83556- atomic_inc(&fs_generation(tb->tb_sb));
83557+ atomic_inc_unchecked(&fs_generation(tb->tb_sb));
83558 do_balance_starts(tb);
83559
83560 /*
83561diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c
83562index aca73dd..e3c558d 100644
83563--- a/fs/reiserfs/item_ops.c
83564+++ b/fs/reiserfs/item_ops.c
83565@@ -724,18 +724,18 @@ static void errcatch_print_vi(struct virtual_item *vi)
83566 }
83567
83568 static struct item_operations errcatch_ops = {
83569- errcatch_bytes_number,
83570- errcatch_decrement_key,
83571- errcatch_is_left_mergeable,
83572- errcatch_print_item,
83573- errcatch_check_item,
83574+ .bytes_number = errcatch_bytes_number,
83575+ .decrement_key = errcatch_decrement_key,
83576+ .is_left_mergeable = errcatch_is_left_mergeable,
83577+ .print_item = errcatch_print_item,
83578+ .check_item = errcatch_check_item,
83579
83580- errcatch_create_vi,
83581- errcatch_check_left,
83582- errcatch_check_right,
83583- errcatch_part_size,
83584- errcatch_unit_num,
83585- errcatch_print_vi
83586+ .create_vi = errcatch_create_vi,
83587+ .check_left = errcatch_check_left,
83588+ .check_right = errcatch_check_right,
83589+ .part_size = errcatch_part_size,
83590+ .unit_num = errcatch_unit_num,
83591+ .print_vi = errcatch_print_vi
83592 };
83593
83594 #if ! (TYPE_STAT_DATA == 0 && TYPE_INDIRECT == 1 && TYPE_DIRECT == 2 && TYPE_DIRENTRY == 3)
83595diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
83596index 621b9f3..af527fd 100644
83597--- a/fs/reiserfs/procfs.c
83598+++ b/fs/reiserfs/procfs.c
83599@@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
83600 "SMALL_TAILS " : "NO_TAILS ",
83601 replay_only(sb) ? "REPLAY_ONLY " : "",
83602 convert_reiserfs(sb) ? "CONV " : "",
83603- atomic_read(&r->s_generation_counter),
83604+ atomic_read_unchecked(&r->s_generation_counter),
83605 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
83606 SF(s_do_balance), SF(s_unneeded_left_neighbor),
83607 SF(s_good_search_by_key_reada), SF(s_bmaps),
83608diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
83609index 2adcde1..7d27bc8 100644
83610--- a/fs/reiserfs/reiserfs.h
83611+++ b/fs/reiserfs/reiserfs.h
83612@@ -580,7 +580,7 @@ struct reiserfs_sb_info {
83613 /* Comment? -Hans */
83614 wait_queue_head_t s_wait;
83615 /* increased by one every time the tree gets re-balanced */
83616- atomic_t s_generation_counter;
83617+ atomic_unchecked_t s_generation_counter;
83618
83619 /* File system properties. Currently holds on-disk FS format */
83620 unsigned long s_properties;
83621@@ -2300,7 +2300,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
83622 #define REISERFS_USER_MEM 1 /* user memory mode */
83623
83624 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
83625-#define get_generation(s) atomic_read (&fs_generation(s))
83626+#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
83627 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
83628 #define __fs_changed(gen,s) (gen != get_generation (s))
83629 #define fs_changed(gen,s) \
83630diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
83631index 4a62fe8..5dc2f5f 100644
83632--- a/fs/reiserfs/super.c
83633+++ b/fs/reiserfs/super.c
83634@@ -1870,6 +1870,10 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
83635 sbi->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
83636 sbi->s_mount_opt |= (1 << REISERFS_ERROR_RO);
83637 sbi->s_mount_opt |= (1 << REISERFS_BARRIER_FLUSH);
83638+#ifdef CONFIG_REISERFS_FS_XATTR
83639+ /* turn on user xattrs by default */
83640+ sbi->s_mount_opt |= (1 << REISERFS_XATTRS_USER);
83641+#endif
83642 /* no preallocation minimum, be smart in reiserfs_file_write instead */
83643 sbi->s_alloc_options.preallocmin = 0;
83644 /* Preallocate by 16 blocks (17-1) at once */
83645diff --git a/fs/select.c b/fs/select.c
83646index 0155473..29d751f 100644
83647--- a/fs/select.c
83648+++ b/fs/select.c
83649@@ -20,6 +20,7 @@
83650 #include <linux/export.h>
83651 #include <linux/slab.h>
83652 #include <linux/poll.h>
83653+#include <linux/security.h>
83654 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
83655 #include <linux/file.h>
83656 #include <linux/fdtable.h>
83657@@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
83658 struct poll_list *walk = head;
83659 unsigned long todo = nfds;
83660
83661+ gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
83662 if (nfds > rlimit(RLIMIT_NOFILE))
83663 return -EINVAL;
83664
83665diff --git a/fs/seq_file.c b/fs/seq_file.c
83666index ce9e39f..5c5a436 100644
83667--- a/fs/seq_file.c
83668+++ b/fs/seq_file.c
83669@@ -12,6 +12,8 @@
83670 #include <linux/slab.h>
83671 #include <linux/cred.h>
83672 #include <linux/mm.h>
83673+#include <linux/sched.h>
83674+#include <linux/grsecurity.h>
83675
83676 #include <asm/uaccess.h>
83677 #include <asm/page.h>
83678@@ -29,9 +31,9 @@ static void *seq_buf_alloc(unsigned long size)
83679 * __GFP_NORETRY to avoid oom-killings with high-order allocations -
83680 * it's better to fall back to vmalloc() than to kill things.
83681 */
83682- buf = kmalloc(size, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
83683+ buf = kmalloc(size, GFP_KERNEL | GFP_USERCOPY | __GFP_NORETRY | __GFP_NOWARN);
83684 if (!buf && size > PAGE_SIZE)
83685- buf = vmalloc(size);
83686+ buf = vmalloc_usercopy(size);
83687 return buf;
83688 }
83689
83690@@ -68,6 +70,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
83691 #ifdef CONFIG_USER_NS
83692 p->user_ns = file->f_cred->user_ns;
83693 #endif
83694+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83695+ p->exec_id = current->exec_id;
83696+#endif
83697
83698 /*
83699 * Wrappers around seq_open(e.g. swaps_open) need to be
83700@@ -90,6 +95,16 @@ int seq_open(struct file *file, const struct seq_operations *op)
83701 }
83702 EXPORT_SYMBOL(seq_open);
83703
83704+
83705+int seq_open_restrict(struct file *file, const struct seq_operations *op)
83706+{
83707+ if (gr_proc_is_restricted())
83708+ return -EACCES;
83709+
83710+ return seq_open(file, op);
83711+}
83712+EXPORT_SYMBOL(seq_open_restrict);
83713+
83714 static int traverse(struct seq_file *m, loff_t offset)
83715 {
83716 loff_t pos = 0, index;
83717@@ -161,7 +176,7 @@ Eoverflow:
83718 ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
83719 {
83720 struct seq_file *m = file->private_data;
83721- size_t copied = 0;
83722+ ssize_t copied = 0;
83723 loff_t pos;
83724 size_t n;
83725 void *p;
83726@@ -575,7 +590,7 @@ static void single_stop(struct seq_file *p, void *v)
83727 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
83728 void *data)
83729 {
83730- struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
83731+ seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
83732 int res = -ENOMEM;
83733
83734 if (op) {
83735@@ -611,6 +626,17 @@ int single_open_size(struct file *file, int (*show)(struct seq_file *, void *),
83736 }
83737 EXPORT_SYMBOL(single_open_size);
83738
83739+int single_open_restrict(struct file *file, int (*show)(struct seq_file *, void *),
83740+ void *data)
83741+{
83742+ if (gr_proc_is_restricted())
83743+ return -EACCES;
83744+
83745+ return single_open(file, show, data);
83746+}
83747+EXPORT_SYMBOL(single_open_restrict);
83748+
83749+
83750 int single_release(struct inode *inode, struct file *file)
83751 {
83752 const struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
83753diff --git a/fs/splice.c b/fs/splice.c
83754index 5fc1e50..6ae8957 100644
83755--- a/fs/splice.c
83756+++ b/fs/splice.c
83757@@ -192,7 +192,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
83758 pipe_lock(pipe);
83759
83760 for (;;) {
83761- if (!pipe->readers) {
83762+ if (!atomic_read(&pipe->readers)) {
83763 send_sig(SIGPIPE, current, 0);
83764 if (!ret)
83765 ret = -EPIPE;
83766@@ -215,7 +215,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
83767 page_nr++;
83768 ret += buf->len;
83769
83770- if (pipe->files)
83771+ if (atomic_read(&pipe->files))
83772 do_wakeup = 1;
83773
83774 if (!--spd->nr_pages)
83775@@ -246,9 +246,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
83776 do_wakeup = 0;
83777 }
83778
83779- pipe->waiting_writers++;
83780+ atomic_inc(&pipe->waiting_writers);
83781 pipe_wait(pipe);
83782- pipe->waiting_writers--;
83783+ atomic_dec(&pipe->waiting_writers);
83784 }
83785
83786 pipe_unlock(pipe);
83787@@ -579,7 +579,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
83788 old_fs = get_fs();
83789 set_fs(get_ds());
83790 /* The cast to a user pointer is valid due to the set_fs() */
83791- res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
83792+ res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
83793 set_fs(old_fs);
83794
83795 return res;
83796@@ -594,7 +594,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
83797 old_fs = get_fs();
83798 set_fs(get_ds());
83799 /* The cast to a user pointer is valid due to the set_fs() */
83800- res = vfs_write(file, (__force const char __user *)buf, count, &pos);
83801+ res = vfs_write(file, (const char __force_user *)buf, count, &pos);
83802 set_fs(old_fs);
83803
83804 return res;
83805@@ -647,7 +647,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
83806 goto err;
83807
83808 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
83809- vec[i].iov_base = (void __user *) page_address(page);
83810+ vec[i].iov_base = (void __force_user *) page_address(page);
83811 vec[i].iov_len = this_len;
83812 spd.pages[i] = page;
83813 spd.nr_pages++;
83814@@ -786,7 +786,7 @@ static int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_des
83815 ops->release(pipe, buf);
83816 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
83817 pipe->nrbufs--;
83818- if (pipe->files)
83819+ if (atomic_read(&pipe->files))
83820 sd->need_wakeup = true;
83821 }
83822
83823@@ -810,10 +810,10 @@ static int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_des
83824 static int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
83825 {
83826 while (!pipe->nrbufs) {
83827- if (!pipe->writers)
83828+ if (!atomic_read(&pipe->writers))
83829 return 0;
83830
83831- if (!pipe->waiting_writers && sd->num_spliced)
83832+ if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
83833 return 0;
83834
83835 if (sd->flags & SPLICE_F_NONBLOCK)
83836@@ -1028,7 +1028,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
83837 ops->release(pipe, buf);
83838 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
83839 pipe->nrbufs--;
83840- if (pipe->files)
83841+ if (atomic_read(&pipe->files))
83842 sd.need_wakeup = true;
83843 } else {
83844 buf->offset += ret;
83845@@ -1188,7 +1188,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
83846 * out of the pipe right after the splice_to_pipe(). So set
83847 * PIPE_READERS appropriately.
83848 */
83849- pipe->readers = 1;
83850+ atomic_set(&pipe->readers, 1);
83851
83852 current->splice_pipe = pipe;
83853 }
83854@@ -1495,6 +1495,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
83855
83856 partial[buffers].offset = off;
83857 partial[buffers].len = plen;
83858+ partial[buffers].private = 0;
83859
83860 off = 0;
83861 len -= plen;
83862@@ -1726,9 +1727,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
83863 ret = -ERESTARTSYS;
83864 break;
83865 }
83866- if (!pipe->writers)
83867+ if (!atomic_read(&pipe->writers))
83868 break;
83869- if (!pipe->waiting_writers) {
83870+ if (!atomic_read(&pipe->waiting_writers)) {
83871 if (flags & SPLICE_F_NONBLOCK) {
83872 ret = -EAGAIN;
83873 break;
83874@@ -1760,7 +1761,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
83875 pipe_lock(pipe);
83876
83877 while (pipe->nrbufs >= pipe->buffers) {
83878- if (!pipe->readers) {
83879+ if (!atomic_read(&pipe->readers)) {
83880 send_sig(SIGPIPE, current, 0);
83881 ret = -EPIPE;
83882 break;
83883@@ -1773,9 +1774,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
83884 ret = -ERESTARTSYS;
83885 break;
83886 }
83887- pipe->waiting_writers++;
83888+ atomic_inc(&pipe->waiting_writers);
83889 pipe_wait(pipe);
83890- pipe->waiting_writers--;
83891+ atomic_dec(&pipe->waiting_writers);
83892 }
83893
83894 pipe_unlock(pipe);
83895@@ -1811,14 +1812,14 @@ retry:
83896 pipe_double_lock(ipipe, opipe);
83897
83898 do {
83899- if (!opipe->readers) {
83900+ if (!atomic_read(&opipe->readers)) {
83901 send_sig(SIGPIPE, current, 0);
83902 if (!ret)
83903 ret = -EPIPE;
83904 break;
83905 }
83906
83907- if (!ipipe->nrbufs && !ipipe->writers)
83908+ if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
83909 break;
83910
83911 /*
83912@@ -1915,7 +1916,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
83913 pipe_double_lock(ipipe, opipe);
83914
83915 do {
83916- if (!opipe->readers) {
83917+ if (!atomic_read(&opipe->readers)) {
83918 send_sig(SIGPIPE, current, 0);
83919 if (!ret)
83920 ret = -EPIPE;
83921@@ -1960,7 +1961,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
83922 * return EAGAIN if we have the potential of some data in the
83923 * future, otherwise just return 0
83924 */
83925- if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
83926+ if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
83927 ret = -EAGAIN;
83928
83929 pipe_unlock(ipipe);
83930diff --git a/fs/squashfs/xattr.c b/fs/squashfs/xattr.c
83931index e5e0ddf..09598c4 100644
83932--- a/fs/squashfs/xattr.c
83933+++ b/fs/squashfs/xattr.c
83934@@ -46,8 +46,8 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
83935 + msblk->xattr_table;
83936 int offset = SQUASHFS_XATTR_OFFSET(squashfs_i(inode)->xattr);
83937 int count = squashfs_i(inode)->xattr_count;
83938- size_t rest = buffer_size;
83939- int err;
83940+ size_t used = 0;
83941+ ssize_t err;
83942
83943 /* check that the file system has xattrs */
83944 if (msblk->xattr_id_table == NULL)
83945@@ -68,11 +68,11 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
83946 name_size = le16_to_cpu(entry.size);
83947 handler = squashfs_xattr_handler(le16_to_cpu(entry.type));
83948 if (handler)
83949- prefix_size = handler->list(d, buffer, rest, NULL,
83950+ prefix_size = handler->list(d, buffer, buffer ? buffer_size - used : 0, NULL,
83951 name_size, handler->flags);
83952 if (prefix_size) {
83953 if (buffer) {
83954- if (prefix_size + name_size + 1 > rest) {
83955+ if (prefix_size + name_size + 1 > buffer_size - used) {
83956 err = -ERANGE;
83957 goto failed;
83958 }
83959@@ -86,7 +86,7 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
83960 buffer[name_size] = '\0';
83961 buffer += name_size + 1;
83962 }
83963- rest -= prefix_size + name_size + 1;
83964+ used += prefix_size + name_size + 1;
83965 } else {
83966 /* no handler or insuffficient privileges, so skip */
83967 err = squashfs_read_metadata(sb, NULL, &start,
83968@@ -107,7 +107,7 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
83969 if (err < 0)
83970 goto failed;
83971 }
83972- err = buffer_size - rest;
83973+ err = used;
83974
83975 failed:
83976 return err;
83977diff --git a/fs/stat.c b/fs/stat.c
83978index cccc1aa..7fe8951 100644
83979--- a/fs/stat.c
83980+++ b/fs/stat.c
83981@@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
83982 stat->gid = inode->i_gid;
83983 stat->rdev = inode->i_rdev;
83984 stat->size = i_size_read(inode);
83985- stat->atime = inode->i_atime;
83986- stat->mtime = inode->i_mtime;
83987+ if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
83988+ stat->atime = inode->i_ctime;
83989+ stat->mtime = inode->i_ctime;
83990+ } else {
83991+ stat->atime = inode->i_atime;
83992+ stat->mtime = inode->i_mtime;
83993+ }
83994 stat->ctime = inode->i_ctime;
83995 stat->blksize = (1 << inode->i_blkbits);
83996 stat->blocks = inode->i_blocks;
83997@@ -52,9 +57,16 @@ EXPORT_SYMBOL(generic_fillattr);
83998 int vfs_getattr_nosec(struct path *path, struct kstat *stat)
83999 {
84000 struct inode *inode = d_backing_inode(path->dentry);
84001+ int retval;
84002
84003- if (inode->i_op->getattr)
84004- return inode->i_op->getattr(path->mnt, path->dentry, stat);
84005+ if (inode->i_op->getattr) {
84006+ retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
84007+ if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
84008+ stat->atime = stat->ctime;
84009+ stat->mtime = stat->ctime;
84010+ }
84011+ return retval;
84012+ }
84013
84014 generic_fillattr(inode, stat);
84015 return 0;
84016diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
84017index 94374e4..b5da3a1 100644
84018--- a/fs/sysfs/dir.c
84019+++ b/fs/sysfs/dir.c
84020@@ -33,6 +33,10 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name)
84021 kfree(buf);
84022 }
84023
84024+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
84025+extern int grsec_enable_sysfs_restrict;
84026+#endif
84027+
84028 /**
84029 * sysfs_create_dir_ns - create a directory for an object with a namespace tag
84030 * @kobj: object we're creating directory for
84031@@ -41,9 +45,16 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name)
84032 int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
84033 {
84034 struct kernfs_node *parent, *kn;
84035+ const char *name;
84036+ umode_t mode = S_IRWXU | S_IRUGO | S_IXUGO;
84037+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
84038+ const char *parent_name;
84039+#endif
84040
84041 BUG_ON(!kobj);
84042
84043+ name = kobject_name(kobj);
84044+
84045 if (kobj->parent)
84046 parent = kobj->parent->sd;
84047 else
84048@@ -52,11 +63,24 @@ int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
84049 if (!parent)
84050 return -ENOENT;
84051
84052- kn = kernfs_create_dir_ns(parent, kobject_name(kobj),
84053- S_IRWXU | S_IRUGO | S_IXUGO, kobj, ns);
84054+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
84055+ parent_name = parent->name;
84056+ mode = S_IRWXU;
84057+
84058+ if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
84059+ (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
84060+ (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
84061+ (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
84062+ mode = S_IRWXU | S_IRUGO | S_IXUGO;
84063+ if (!grsec_enable_sysfs_restrict)
84064+ mode = S_IRWXU | S_IRUGO | S_IXUGO;
84065+#endif
84066+
84067+ kn = kernfs_create_dir_ns(parent, name,
84068+ mode, kobj, ns);
84069 if (IS_ERR(kn)) {
84070 if (PTR_ERR(kn) == -EEXIST)
84071- sysfs_warn_dup(parent, kobject_name(kobj));
84072+ sysfs_warn_dup(parent, name);
84073 return PTR_ERR(kn);
84074 }
84075
84076diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
84077index 6c21228..9afd5fe 100644
84078--- a/fs/sysv/sysv.h
84079+++ b/fs/sysv/sysv.h
84080@@ -187,7 +187,7 @@ static inline u32 PDP_swab(u32 x)
84081 #endif
84082 }
84083
84084-static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
84085+static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
84086 {
84087 if (sbi->s_bytesex == BYTESEX_PDP)
84088 return PDP_swab((__force __u32)n);
84089diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
84090index cbc8d5d..56d2600 100644
84091--- a/fs/tracefs/inode.c
84092+++ b/fs/tracefs/inode.c
84093@@ -53,7 +53,7 @@ static const struct file_operations tracefs_file_operations = {
84094 static struct tracefs_dir_ops {
84095 int (*mkdir)(const char *name);
84096 int (*rmdir)(const char *name);
84097-} tracefs_ops;
84098+} __no_const tracefs_ops __read_only;
84099
84100 static char *get_dname(struct dentry *dentry)
84101 {
84102@@ -490,8 +490,10 @@ struct dentry *tracefs_create_instance_dir(const char *name, struct dentry *pare
84103 if (!dentry)
84104 return NULL;
84105
84106- tracefs_ops.mkdir = mkdir;
84107- tracefs_ops.rmdir = rmdir;
84108+ pax_open_kernel();
84109+ *(void **)&tracefs_ops.mkdir = mkdir;
84110+ *(void **)&tracefs_ops.rmdir = rmdir;
84111+ pax_close_kernel();
84112
84113 return dentry;
84114 }
84115diff --git a/fs/udf/misc.c b/fs/udf/misc.c
84116index 71d1c25..084e2ad 100644
84117--- a/fs/udf/misc.c
84118+++ b/fs/udf/misc.c
84119@@ -288,7 +288,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
84120
84121 u8 udf_tag_checksum(const struct tag *t)
84122 {
84123- u8 *data = (u8 *)t;
84124+ const u8 *data = (const u8 *)t;
84125 u8 checksum = 0;
84126 int i;
84127 for (i = 0; i < sizeof(struct tag); ++i)
84128diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
84129index 8d974c4..b82f6ec 100644
84130--- a/fs/ufs/swab.h
84131+++ b/fs/ufs/swab.h
84132@@ -22,7 +22,7 @@ enum {
84133 BYTESEX_BE
84134 };
84135
84136-static inline u64
84137+static inline u64 __intentional_overflow(-1)
84138 fs64_to_cpu(struct super_block *sbp, __fs64 n)
84139 {
84140 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
84141@@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
84142 return (__force __fs64)cpu_to_be64(n);
84143 }
84144
84145-static inline u32
84146+static inline u32 __intentional_overflow(-1)
84147 fs32_to_cpu(struct super_block *sbp, __fs32 n)
84148 {
84149 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
84150diff --git a/fs/utimes.c b/fs/utimes.c
84151index aa138d6..5f3a811 100644
84152--- a/fs/utimes.c
84153+++ b/fs/utimes.c
84154@@ -1,6 +1,7 @@
84155 #include <linux/compiler.h>
84156 #include <linux/file.h>
84157 #include <linux/fs.h>
84158+#include <linux/security.h>
84159 #include <linux/linkage.h>
84160 #include <linux/mount.h>
84161 #include <linux/namei.h>
84162@@ -103,6 +104,12 @@ static int utimes_common(struct path *path, struct timespec *times)
84163 }
84164 }
84165 retry_deleg:
84166+
84167+ if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
84168+ error = -EACCES;
84169+ goto mnt_drop_write_and_out;
84170+ }
84171+
84172 mutex_lock(&inode->i_mutex);
84173 error = notify_change(path->dentry, &newattrs, &delegated_inode);
84174 mutex_unlock(&inode->i_mutex);
84175diff --git a/fs/xattr.c b/fs/xattr.c
84176index 072fee1..9e497b0 100644
84177--- a/fs/xattr.c
84178+++ b/fs/xattr.c
84179@@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
84180 return rc;
84181 }
84182
84183+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84184+ssize_t
84185+pax_getxattr(struct dentry *dentry, void *value, size_t size)
84186+{
84187+ struct inode *inode = dentry->d_inode;
84188+ ssize_t error;
84189+
84190+ error = inode_permission(inode, MAY_EXEC);
84191+ if (error)
84192+ return error;
84193+
84194+ if (inode->i_op->getxattr)
84195+ error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
84196+ else
84197+ error = -EOPNOTSUPP;
84198+
84199+ return error;
84200+}
84201+EXPORT_SYMBOL(pax_getxattr);
84202+#endif
84203+
84204 ssize_t
84205 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
84206 {
84207@@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
84208 * Extended attribute SET operations
84209 */
84210 static long
84211-setxattr(struct dentry *d, const char __user *name, const void __user *value,
84212+setxattr(struct path *path, const char __user *name, const void __user *value,
84213 size_t size, int flags)
84214 {
84215 int error;
84216@@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
84217 posix_acl_fix_xattr_from_user(kvalue, size);
84218 }
84219
84220- error = vfs_setxattr(d, kname, kvalue, size, flags);
84221+ if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
84222+ error = -EACCES;
84223+ goto out;
84224+ }
84225+
84226+ error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
84227 out:
84228 if (vvalue)
84229 vfree(vvalue);
84230@@ -376,7 +402,7 @@ retry:
84231 return error;
84232 error = mnt_want_write(path.mnt);
84233 if (!error) {
84234- error = setxattr(path.dentry, name, value, size, flags);
84235+ error = setxattr(&path, name, value, size, flags);
84236 mnt_drop_write(path.mnt);
84237 }
84238 path_put(&path);
84239@@ -412,7 +438,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
84240 audit_file(f.file);
84241 error = mnt_want_write_file(f.file);
84242 if (!error) {
84243- error = setxattr(f.file->f_path.dentry, name, value, size, flags);
84244+ error = setxattr(&f.file->f_path, name, value, size, flags);
84245 mnt_drop_write_file(f.file);
84246 }
84247 fdput(f);
84248@@ -598,7 +624,7 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
84249 * Extended attribute REMOVE operations
84250 */
84251 static long
84252-removexattr(struct dentry *d, const char __user *name)
84253+removexattr(struct path *path, const char __user *name)
84254 {
84255 int error;
84256 char kname[XATTR_NAME_MAX + 1];
84257@@ -609,7 +635,10 @@ removexattr(struct dentry *d, const char __user *name)
84258 if (error < 0)
84259 return error;
84260
84261- return vfs_removexattr(d, kname);
84262+ if (!gr_acl_handle_removexattr(path->dentry, path->mnt))
84263+ return -EACCES;
84264+
84265+ return vfs_removexattr(path->dentry, kname);
84266 }
84267
84268 static int path_removexattr(const char __user *pathname,
84269@@ -623,7 +652,7 @@ retry:
84270 return error;
84271 error = mnt_want_write(path.mnt);
84272 if (!error) {
84273- error = removexattr(path.dentry, name);
84274+ error = removexattr(&path, name);
84275 mnt_drop_write(path.mnt);
84276 }
84277 path_put(&path);
84278@@ -649,14 +678,16 @@ SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname,
84279 SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
84280 {
84281 struct fd f = fdget(fd);
84282+ struct path *path;
84283 int error = -EBADF;
84284
84285 if (!f.file)
84286 return error;
84287+ path = &f.file->f_path;
84288 audit_file(f.file);
84289 error = mnt_want_write_file(f.file);
84290 if (!error) {
84291- error = removexattr(f.file->f_path.dentry, name);
84292+ error = removexattr(path, name);
84293 mnt_drop_write_file(f.file);
84294 }
84295 fdput(f);
84296diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
84297index 63e05b6..249b043 100644
84298--- a/fs/xfs/libxfs/xfs_bmap.c
84299+++ b/fs/xfs/libxfs/xfs_bmap.c
84300@@ -554,7 +554,7 @@ xfs_bmap_validate_ret(
84301
84302 #else
84303 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
84304-#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
84305+#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
84306 #endif /* DEBUG */
84307
84308 /*
84309diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
84310index 098cd78..724d3f8 100644
84311--- a/fs/xfs/xfs_dir2_readdir.c
84312+++ b/fs/xfs/xfs_dir2_readdir.c
84313@@ -140,7 +140,12 @@ xfs_dir2_sf_getdents(
84314 ino = dp->d_ops->sf_get_ino(sfp, sfep);
84315 filetype = dp->d_ops->sf_get_ftype(sfep);
84316 ctx->pos = off & 0x7fffffff;
84317- if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
84318+ if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
84319+ char name[sfep->namelen];
84320+ memcpy(name, sfep->name, sfep->namelen);
84321+ if (!dir_emit(ctx, name, sfep->namelen, ino, xfs_dir3_get_dtype(dp->i_mount, filetype)))
84322+ return 0;
84323+ } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
84324 xfs_dir3_get_dtype(dp->i_mount, filetype)))
84325 return 0;
84326 sfep = dp->d_ops->sf_nextentry(sfp, sfep);
84327diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
84328index ea7d85a..6d4b24b 100644
84329--- a/fs/xfs/xfs_ioctl.c
84330+++ b/fs/xfs/xfs_ioctl.c
84331@@ -120,7 +120,7 @@ xfs_find_handle(
84332 }
84333
84334 error = -EFAULT;
84335- if (copy_to_user(hreq->ohandle, &handle, hsize) ||
84336+ if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
84337 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
84338 goto out_put;
84339
84340diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
84341index 85f883d..db6eecc 100644
84342--- a/fs/xfs/xfs_linux.h
84343+++ b/fs/xfs/xfs_linux.h
84344@@ -211,7 +211,7 @@ static inline kgid_t xfs_gid_to_kgid(__uint32_t gid)
84345 * of the compiler which do not like us using do_div in the middle
84346 * of large functions.
84347 */
84348-static inline __u32 xfs_do_div(void *a, __u32 b, int n)
84349+static inline __u32 __intentional_overflow(-1) xfs_do_div(void *a, __u32 b, int n)
84350 {
84351 __u32 mod;
84352
84353@@ -267,7 +267,7 @@ static inline __u32 xfs_do_mod(void *a, __u32 b, int n)
84354 return 0;
84355 }
84356 #else
84357-static inline __u32 xfs_do_div(void *a, __u32 b, int n)
84358+static inline __u32 __intentional_overflow(-1) xfs_do_div(void *a, __u32 b, int n)
84359 {
84360 __u32 mod;
84361
84362diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
84363new file mode 100644
84364index 0000000..31f8fe4
84365--- /dev/null
84366+++ b/grsecurity/Kconfig
84367@@ -0,0 +1,1182 @@
84368+#
84369+# grecurity configuration
84370+#
84371+menu "Memory Protections"
84372+depends on GRKERNSEC
84373+
84374+config GRKERNSEC_KMEM
84375+ bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
84376+ default y if GRKERNSEC_CONFIG_AUTO
84377+ select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
84378+ help
84379+ If you say Y here, /dev/kmem and /dev/mem won't be allowed to
84380+ be written to or read from to modify or leak the contents of the running
84381+ kernel. /dev/port will also not be allowed to be opened, writing to
84382+ /dev/cpu/*/msr will be prevented, and support for kexec will be removed.
84383+ If you have module support disabled, enabling this will close up several
84384+ ways that are currently used to insert malicious code into the running
84385+ kernel.
84386+
84387+ Even with this feature enabled, we still highly recommend that
84388+ you use the RBAC system, as it is still possible for an attacker to
84389+ modify the running kernel through other more obscure methods.
84390+
84391+ It is highly recommended that you say Y here if you meet all the
84392+ conditions above.
84393+
84394+config GRKERNSEC_VM86
84395+ bool "Restrict VM86 mode"
84396+ default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
84397+ depends on X86_32
84398+
84399+ help
84400+ If you say Y here, only processes with CAP_SYS_RAWIO will be able to
84401+ make use of a special execution mode on 32bit x86 processors called
84402+ Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
84403+ video cards and will still work with this option enabled. The purpose
84404+ of the option is to prevent exploitation of emulation errors in
84405+ virtualization of vm86 mode like the one discovered in VMWare in 2009.
84406+ Nearly all users should be able to enable this option.
84407+
84408+config GRKERNSEC_IO
84409+ bool "Disable privileged I/O"
84410+ default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
84411+ depends on X86
84412+ select RTC_CLASS
84413+ select RTC_INTF_DEV
84414+ select RTC_DRV_CMOS
84415+
84416+ help
84417+ If you say Y here, all ioperm and iopl calls will return an error.
84418+ Ioperm and iopl can be used to modify the running kernel.
84419+ Unfortunately, some programs need this access to operate properly,
84420+ the most notable of which are XFree86 and hwclock. hwclock can be
84421+ remedied by having RTC support in the kernel, so real-time
84422+ clock support is enabled if this option is enabled, to ensure
84423+ that hwclock operates correctly. If hwclock still does not work,
84424+ either update udev or symlink /dev/rtc to /dev/rtc0.
84425+
84426+ If you're using XFree86 or a version of Xorg from 2012 or earlier,
84427+ you may not be able to boot into a graphical environment with this
84428+ option enabled. In this case, you should use the RBAC system instead.
84429+
84430+config GRKERNSEC_BPF_HARDEN
84431+ bool "Harden BPF interpreter"
84432+ default y if GRKERNSEC_CONFIG_AUTO
84433+ help
84434+ Unlike previous versions of grsecurity that hardened both the BPF
84435+ interpreted code against corruption at rest as well as the JIT code
84436+ against JIT-spray attacks and attacker-controlled immediate values
84437+ for ROP, this feature will enforce disabling of the new eBPF JIT engine
84438+ and will ensure the interpreted code is read-only at rest. This feature
84439+ may be removed at a later time when eBPF stabilizes to entirely revert
84440+ back to the more secure pre-3.16 BPF interpreter/JIT.
84441+
84442+ If you're using KERNEXEC, it's recommended that you enable this option
84443+ to supplement the hardening of the kernel.
84444+
84445+config GRKERNSEC_PERF_HARDEN
84446+ bool "Disable unprivileged PERF_EVENTS usage by default"
84447+ default y if GRKERNSEC_CONFIG_AUTO
84448+ depends on PERF_EVENTS
84449+ help
84450+ If you say Y here, the range of acceptable values for the
84451+ /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
84452+ default to a new value: 3. When the sysctl is set to this value, no
84453+ unprivileged use of the PERF_EVENTS syscall interface will be permitted.
84454+
84455+ Though PERF_EVENTS can be used legitimately for performance monitoring
84456+ and low-level application profiling, it is forced on regardless of
84457+ configuration, has been at fault for several vulnerabilities, and
84458+ creates new opportunities for side channels and other information leaks.
84459+
84460+ This feature puts PERF_EVENTS into a secure default state and permits
84461+ the administrator to change out of it temporarily if unprivileged
84462+ application profiling is needed.
84463+
84464+config GRKERNSEC_RAND_THREADSTACK
84465+ bool "Insert random gaps between thread stacks"
84466+ default y if GRKERNSEC_CONFIG_AUTO
84467+ depends on PAX_RANDMMAP && !PPC
84468+ help
84469+ If you say Y here, a random-sized gap will be enforced between allocated
84470+ thread stacks. Glibc's NPTL and other threading libraries that
84471+ pass MAP_STACK to the kernel for thread stack allocation are supported.
84472+ The implementation currently provides 8 bits of entropy for the gap.
84473+
84474+ Many distributions do not compile threaded remote services with the
84475+ -fstack-check argument to GCC, causing the variable-sized stack-based
84476+ allocator, alloca(), to not probe the stack on allocation. This
84477+ permits an unbounded alloca() to skip over any guard page and potentially
84478+ modify another thread's stack reliably. An enforced random gap
84479+ reduces the reliability of such an attack and increases the chance
84480+ that such a read/write to another thread's stack instead lands in
84481+ an unmapped area, causing a crash and triggering grsecurity's
84482+ anti-bruteforcing logic.
84483+
84484+config GRKERNSEC_PROC_MEMMAP
84485+ bool "Harden ASLR against information leaks and entropy reduction"
84486+ default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
84487+ depends on PAX_NOEXEC || PAX_ASLR
84488+ help
84489+ If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
84490+ give no information about the addresses of its mappings if
84491+ PaX features that rely on random addresses are enabled on the task.
84492+ In addition to sanitizing this information and disabling other
84493+ dangerous sources of information, this option causes reads of sensitive
84494+ /proc/<pid> entries where the file descriptor was opened in a different
84495+ task than the one performing the read. Such attempts are logged.
84496+ This option also limits argv/env strings for suid/sgid binaries
84497+ to 512KB to prevent a complete exhaustion of the stack entropy provided
84498+ by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
84499+ binaries to prevent alternative mmap layouts from being abused.
84500+
84501+ If you use PaX it is essential that you say Y here as it closes up
84502+ several holes that make full ASLR useless locally.
84503+
84504+
84505+config GRKERNSEC_KSTACKOVERFLOW
84506+ bool "Prevent kernel stack overflows"
84507+ default y if GRKERNSEC_CONFIG_AUTO
84508+ depends on !IA64 && 64BIT
84509+ help
84510+ If you say Y here, the kernel's process stacks will be allocated
84511+ with vmalloc instead of the kernel's default allocator. This
84512+ introduces guard pages that in combination with the alloca checking
84513+ of the STACKLEAK feature prevents all forms of kernel process stack
84514+ overflow abuse. Note that this is different from kernel stack
84515+ buffer overflows.
84516+
84517+config GRKERNSEC_BRUTE
84518+ bool "Deter exploit bruteforcing"
84519+ default y if GRKERNSEC_CONFIG_AUTO
84520+ help
84521+ If you say Y here, attempts to bruteforce exploits against forking
84522+ daemons such as apache or sshd, as well as against suid/sgid binaries
84523+ will be deterred. When a child of a forking daemon is killed by PaX
84524+ or crashes due to an illegal instruction or other suspicious signal,
84525+ the parent process will be delayed 30 seconds upon every subsequent
84526+ fork until the administrator is able to assess the situation and
84527+ restart the daemon.
84528+ In the suid/sgid case, the attempt is logged, the user has all their
84529+ existing instances of the suid/sgid binary terminated and will
84530+ be unable to execute any suid/sgid binaries for 15 minutes.
84531+
84532+ It is recommended that you also enable signal logging in the auditing
84533+ section so that logs are generated when a process triggers a suspicious
84534+ signal.
84535+ If the sysctl option is enabled, a sysctl option with name
84536+ "deter_bruteforce" is created.
84537+
84538+config GRKERNSEC_MODHARDEN
84539+ bool "Harden module auto-loading"
84540+ default y if GRKERNSEC_CONFIG_AUTO
84541+ depends on MODULES
84542+ help
84543+ If you say Y here, module auto-loading in response to use of some
84544+ feature implemented by an unloaded module will be restricted to
84545+ root users. Enabling this option helps defend against attacks
84546+ by unprivileged users who abuse the auto-loading behavior to
84547+ cause a vulnerable module to load that is then exploited.
84548+
84549+ If this option prevents a legitimate use of auto-loading for a
84550+ non-root user, the administrator can execute modprobe manually
84551+ with the exact name of the module mentioned in the alert log.
84552+ Alternatively, the administrator can add the module to the list
84553+ of modules loaded at boot by modifying init scripts.
84554+
84555+ Modification of init scripts will most likely be needed on
84556+ Ubuntu servers with encrypted home directory support enabled,
84557+ as the first non-root user logging in will cause the ecb(aes),
84558+ ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
84559+
84560+config GRKERNSEC_HIDESYM
84561+ bool "Hide kernel symbols"
84562+ default y if GRKERNSEC_CONFIG_AUTO
84563+ select PAX_USERCOPY_SLABS
84564+ help
84565+ If you say Y here, getting information on loaded modules, and
84566+ displaying all kernel symbols through a syscall will be restricted
84567+ to users with CAP_SYS_MODULE. For software compatibility reasons,
84568+ /proc/kallsyms will be restricted to the root user. The RBAC
84569+ system can hide that entry even from root.
84570+
84571+ This option also prevents leaking of kernel addresses through
84572+ several /proc entries.
84573+
84574+ Note that this option is only effective provided the following
84575+ conditions are met:
84576+ 1) The kernel using grsecurity is not precompiled by some distribution
84577+ 2) You have also enabled GRKERNSEC_DMESG
84578+ 3) You are using the RBAC system and hiding other files such as your
84579+ kernel image and System.map. Alternatively, enabling this option
84580+ causes the permissions on /boot, /lib/modules, and the kernel
84581+ source directory to change at compile time to prevent
84582+ reading by non-root users.
84583+ If the above conditions are met, this option will aid in providing a
84584+ useful protection against local kernel exploitation of overflows
84585+ and arbitrary read/write vulnerabilities.
84586+
84587+ It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
84588+ in addition to this feature.
84589+
84590+config GRKERNSEC_RANDSTRUCT
84591+ bool "Randomize layout of sensitive kernel structures"
84592+ default y if GRKERNSEC_CONFIG_AUTO
84593+ select GRKERNSEC_HIDESYM
84594+ select MODVERSIONS if MODULES
84595+ help
84596+ If you say Y here, the layouts of a number of sensitive kernel
84597+ structures (task, fs, cred, etc) and all structures composed entirely
84598+ of function pointers (aka "ops" structs) will be randomized at compile-time.
84599+ This can introduce the requirement of an additional infoleak
84600+ vulnerability for exploits targeting these structure types.
84601+
84602+ Enabling this feature will introduce some performance impact, slightly
84603+ increase memory usage, and prevent the use of forensic tools like
84604+ Volatility against the system (unless the kernel source tree isn't
84605+ cleaned after kernel installation).
84606+
84607+ The seed used for compilation is located at tools/gcc/randomize_layout_seed.h.
84608+ It remains after a make clean to allow for external modules to be compiled
84609+ with the existing seed and will be removed by a make mrproper or
84610+ make distclean.
84611+
84612+ Note that the implementation requires gcc 4.6.4. or newer. You may need
84613+ to install the supporting headers explicitly in addition to the normal
84614+ gcc package.
84615+
84616+config GRKERNSEC_RANDSTRUCT_PERFORMANCE
84617+ bool "Use cacheline-aware structure randomization"
84618+ depends on GRKERNSEC_RANDSTRUCT
84619+ default y if GRKERNSEC_CONFIG_PRIORITY_PERF
84620+ help
84621+ If you say Y here, the RANDSTRUCT randomization will make a best effort
84622+ at restricting randomization to cacheline-sized groups of elements. It
84623+ will further not randomize bitfields in structures. This reduces the
84624+ performance hit of RANDSTRUCT at the cost of weakened randomization.
84625+
84626+config GRKERNSEC_KERN_LOCKOUT
84627+ bool "Active kernel exploit response"
84628+ default y if GRKERNSEC_CONFIG_AUTO
84629+ depends on X86 || ARM || PPC || SPARC
84630+ help
84631+ If you say Y here, when a PaX alert is triggered due to suspicious
84632+ activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
84633+ or an OOPS occurs due to bad memory accesses, instead of just
84634+ terminating the offending process (and potentially allowing
84635+ a subsequent exploit from the same user), we will take one of two
84636+ actions:
84637+ If the user was root, we will panic the system
84638+ If the user was non-root, we will log the attempt, terminate
84639+ all processes owned by the user, then prevent them from creating
84640+ any new processes until the system is restarted
84641+ This deters repeated kernel exploitation/bruteforcing attempts
84642+ and is useful for later forensics.
84643+
84644+config GRKERNSEC_OLD_ARM_USERLAND
84645+ bool "Old ARM userland compatibility"
84646+ depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
84647+ help
84648+ If you say Y here, stubs of executable code to perform such operations
84649+ as "compare-exchange" will be placed at fixed locations in the ARM vector
84650+ table. This is unfortunately needed for old ARM userland meant to run
84651+ across a wide range of processors. Without this option enabled,
84652+ the get_tls and data memory barrier stubs will be emulated by the kernel,
84653+ which is enough for Linaro userlands or other userlands designed for v6
84654+ and newer ARM CPUs. It's recommended that you try without this option enabled
84655+ first, and only enable it if your userland does not boot (it will likely fail
84656+ at init time).
84657+
84658+endmenu
84659+menu "Role Based Access Control Options"
84660+depends on GRKERNSEC
84661+
84662+config GRKERNSEC_RBAC_DEBUG
84663+ bool
84664+
84665+config GRKERNSEC_NO_RBAC
84666+ bool "Disable RBAC system"
84667+ help
84668+ If you say Y here, the /dev/grsec device will be removed from the kernel,
84669+ preventing the RBAC system from being enabled. You should only say Y
84670+ here if you have no intention of using the RBAC system, so as to prevent
84671+ an attacker with root access from misusing the RBAC system to hide files
84672+ and processes when loadable module support and /dev/[k]mem have been
84673+ locked down.
84674+
84675+config GRKERNSEC_ACL_HIDEKERN
84676+ bool "Hide kernel processes"
84677+ help
84678+ If you say Y here, all kernel threads will be hidden to all
84679+ processes but those whose subject has the "view hidden processes"
84680+ flag.
84681+
84682+config GRKERNSEC_ACL_MAXTRIES
84683+ int "Maximum tries before password lockout"
84684+ default 3
84685+ help
84686+ This option enforces the maximum number of times a user can attempt
84687+ to authorize themselves with the grsecurity RBAC system before being
84688+ denied the ability to attempt authorization again for a specified time.
84689+ The lower the number, the harder it will be to brute-force a password.
84690+
84691+config GRKERNSEC_ACL_TIMEOUT
84692+ int "Time to wait after max password tries, in seconds"
84693+ default 30
84694+ help
84695+ This option specifies the time the user must wait after attempting to
84696+ authorize to the RBAC system with the maximum number of invalid
84697+ passwords. The higher the number, the harder it will be to brute-force
84698+ a password.
84699+
84700+endmenu
84701+menu "Filesystem Protections"
84702+depends on GRKERNSEC
84703+
84704+config GRKERNSEC_PROC
84705+ bool "Proc restrictions"
84706+ default y if GRKERNSEC_CONFIG_AUTO
84707+ help
84708+ If you say Y here, the permissions of the /proc filesystem
84709+ will be altered to enhance system security and privacy. You MUST
84710+ choose either a user only restriction or a user and group restriction.
84711+ Depending upon the option you choose, you can either restrict users to
84712+ see only the processes they themselves run, or choose a group that can
84713+ view all processes and files normally restricted to root if you choose
84714+ the "restrict to user only" option. NOTE: If you're running identd or
84715+ ntpd as a non-root user, you will have to run it as the group you
84716+ specify here.
84717+
84718+config GRKERNSEC_PROC_USER
84719+ bool "Restrict /proc to user only"
84720+ depends on GRKERNSEC_PROC
84721+ help
84722+ If you say Y here, non-root users will only be able to view their own
84723+ processes, and restricts them from viewing network-related information,
84724+ and viewing kernel symbol and module information.
84725+
84726+config GRKERNSEC_PROC_USERGROUP
84727+ bool "Allow special group"
84728+ default y if GRKERNSEC_CONFIG_AUTO
84729+ depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
84730+ help
84731+ If you say Y here, you will be able to select a group that will be
84732+ able to view all processes and network-related information. If you've
84733+ enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
84734+ remain hidden. This option is useful if you want to run identd as
84735+ a non-root user. The group you select may also be chosen at boot time
84736+ via "grsec_proc_gid=" on the kernel commandline.
84737+
84738+config GRKERNSEC_PROC_GID
84739+ int "GID for special group"
84740+ depends on GRKERNSEC_PROC_USERGROUP
84741+ default 1001
84742+
84743+config GRKERNSEC_PROC_ADD
84744+ bool "Additional restrictions"
84745+ default y if GRKERNSEC_CONFIG_AUTO
84746+ depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
84747+ help
84748+ If you say Y here, additional restrictions will be placed on
84749+ /proc that keep normal users from viewing device information and
84750+ slabinfo information that could be useful for exploits.
84751+
84752+config GRKERNSEC_LINK
84753+ bool "Linking restrictions"
84754+ default y if GRKERNSEC_CONFIG_AUTO
84755+ help
84756+ If you say Y here, /tmp race exploits will be prevented, since users
84757+ will no longer be able to follow symlinks owned by other users in
84758+ world-writable +t directories (e.g. /tmp), unless the owner of the
84759+ symlink is the owner of the directory. users will also not be
84760+ able to hardlink to files they do not own. If the sysctl option is
84761+ enabled, a sysctl option with name "linking_restrictions" is created.
84762+
84763+config GRKERNSEC_SYMLINKOWN
84764+ bool "Kernel-enforced SymlinksIfOwnerMatch"
84765+ default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
84766+ help
84767+ Apache's SymlinksIfOwnerMatch option has an inherent race condition
84768+ that prevents it from being used as a security feature. As Apache
84769+ verifies the symlink by performing a stat() against the target of
84770+ the symlink before it is followed, an attacker can setup a symlink
84771+ to point to a same-owned file, then replace the symlink with one
84772+ that targets another user's file just after Apache "validates" the
84773+ symlink -- a classic TOCTOU race. If you say Y here, a complete,
84774+ race-free replacement for Apache's "SymlinksIfOwnerMatch" option
84775+ will be in place for the group you specify. If the sysctl option
84776+ is enabled, a sysctl option with name "enforce_symlinksifowner" is
84777+ created.
84778+
84779+config GRKERNSEC_SYMLINKOWN_GID
84780+ int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
84781+ depends on GRKERNSEC_SYMLINKOWN
84782+ default 1006
84783+ help
84784+ Setting this GID determines what group kernel-enforced
84785+ SymlinksIfOwnerMatch will be enabled for. If the sysctl option
84786+ is enabled, a sysctl option with name "symlinkown_gid" is created.
84787+
84788+config GRKERNSEC_FIFO
84789+ bool "FIFO restrictions"
84790+ default y if GRKERNSEC_CONFIG_AUTO
84791+ help
84792+ If you say Y here, users will not be able to write to FIFOs they don't
84793+ own in world-writable +t directories (e.g. /tmp), unless the owner of
84794+ the FIFO is the same owner of the directory it's held in. If the sysctl
84795+ option is enabled, a sysctl option with name "fifo_restrictions" is
84796+ created.
84797+
84798+config GRKERNSEC_SYSFS_RESTRICT
84799+ bool "Sysfs/debugfs restriction"
84800+ default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
84801+ depends on SYSFS
84802+ help
84803+ If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
84804+ any filesystem normally mounted under it (e.g. debugfs) will be
84805+ mostly accessible only by root. These filesystems generally provide access
84806+ to hardware and debug information that isn't appropriate for unprivileged
84807+ users of the system. Sysfs and debugfs have also become a large source
84808+ of new vulnerabilities, ranging from infoleaks to local compromise.
84809+ There has been very little oversight with an eye toward security involved
84810+ in adding new exporters of information to these filesystems, so their
84811+ use is discouraged.
84812+ For reasons of compatibility, a few directories have been whitelisted
84813+ for access by non-root users:
84814+ /sys/fs/selinux
84815+ /sys/fs/fuse
84816+ /sys/devices/system/cpu
84817+
84818+config GRKERNSEC_ROFS
84819+ bool "Runtime read-only mount protection"
84820+ depends on SYSCTL
84821+ help
84822+ If you say Y here, a sysctl option with name "romount_protect" will
84823+ be created. By setting this option to 1 at runtime, filesystems
84824+ will be protected in the following ways:
84825+ * No new writable mounts will be allowed
84826+ * Existing read-only mounts won't be able to be remounted read/write
84827+ * Write operations will be denied on all block devices
84828+ This option acts independently of grsec_lock: once it is set to 1,
84829+ it cannot be turned off. Therefore, please be mindful of the resulting
84830+ behavior if this option is enabled in an init script on a read-only
84831+ filesystem.
84832+ Also be aware that as with other root-focused features, GRKERNSEC_KMEM
84833+ and GRKERNSEC_IO should be enabled and module loading disabled via
84834+ config or at runtime.
84835+ This feature is mainly intended for secure embedded systems.
84836+
84837+
84838+config GRKERNSEC_DEVICE_SIDECHANNEL
84839+ bool "Eliminate stat/notify-based device sidechannels"
84840+ default y if GRKERNSEC_CONFIG_AUTO
84841+ help
84842+ If you say Y here, timing analyses on block or character
84843+ devices like /dev/ptmx using stat or inotify/dnotify/fanotify
84844+ will be thwarted for unprivileged users. If a process without
84845+ CAP_MKNOD stats such a device, the last access and last modify times
84846+ will match the device's create time. No access or modify events
84847+ will be triggered through inotify/dnotify/fanotify for such devices.
84848+ This feature will prevent attacks that may at a minimum
84849+ allow an attacker to determine the administrator's password length.
84850+
84851+config GRKERNSEC_CHROOT
84852+ bool "Chroot jail restrictions"
84853+ default y if GRKERNSEC_CONFIG_AUTO
84854+ help
84855+ If you say Y here, you will be able to choose several options that will
84856+ make breaking out of a chrooted jail much more difficult. If you
84857+ encounter no software incompatibilities with the following options, it
84858+ is recommended that you enable each one.
84859+
84860+ Note that the chroot restrictions are not intended to apply to "chroots"
84861+ to directories that are simple bind mounts of the global root filesystem.
84862+ For several other reasons, a user shouldn't expect any significant
84863+ security by performing such a chroot.
84864+
84865+config GRKERNSEC_CHROOT_MOUNT
84866+ bool "Deny mounts"
84867+ default y if GRKERNSEC_CONFIG_AUTO
84868+ depends on GRKERNSEC_CHROOT
84869+ help
84870+ If you say Y here, processes inside a chroot will not be able to
84871+ mount or remount filesystems. If the sysctl option is enabled, a
84872+ sysctl option with name "chroot_deny_mount" is created.
84873+
84874+config GRKERNSEC_CHROOT_DOUBLE
84875+ bool "Deny double-chroots"
84876+ default y if GRKERNSEC_CONFIG_AUTO
84877+ depends on GRKERNSEC_CHROOT
84878+ help
84879+ If you say Y here, processes inside a chroot will not be able to chroot
84880+ again outside the chroot. This is a widely used method of breaking
84881+ out of a chroot jail and should not be allowed. If the sysctl
84882+ option is enabled, a sysctl option with name
84883+ "chroot_deny_chroot" is created.
84884+
84885+config GRKERNSEC_CHROOT_PIVOT
84886+ bool "Deny pivot_root in chroot"
84887+ default y if GRKERNSEC_CONFIG_AUTO
84888+ depends on GRKERNSEC_CHROOT
84889+ help
84890+ If you say Y here, processes inside a chroot will not be able to use
84891+ a function called pivot_root() that was introduced in Linux 2.3.41. It
84892+ works similar to chroot in that it changes the root filesystem. This
84893+ function could be misused in a chrooted process to attempt to break out
84894+ of the chroot, and therefore should not be allowed. If the sysctl
84895+ option is enabled, a sysctl option with name "chroot_deny_pivot" is
84896+ created.
84897+
84898+config GRKERNSEC_CHROOT_CHDIR
84899+ bool "Enforce chdir(\"/\") on all chroots"
84900+ default y if GRKERNSEC_CONFIG_AUTO
84901+ depends on GRKERNSEC_CHROOT
84902+ help
84903+ If you say Y here, the current working directory of all newly-chrooted
84904+ applications will be set to the the root directory of the chroot.
84905+ The man page on chroot(2) states:
84906+ Note that this call does not change the current working
84907+ directory, so that `.' can be outside the tree rooted at
84908+ `/'. In particular, the super-user can escape from a
84909+ `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
84910+
84911+ It is recommended that you say Y here, since it's not known to break
84912+ any software. If the sysctl option is enabled, a sysctl option with
84913+ name "chroot_enforce_chdir" is created.
84914+
84915+config GRKERNSEC_CHROOT_CHMOD
84916+ bool "Deny (f)chmod +s"
84917+ default y if GRKERNSEC_CONFIG_AUTO
84918+ depends on GRKERNSEC_CHROOT
84919+ help
84920+ If you say Y here, processes inside a chroot will not be able to chmod
84921+ or fchmod files to make them have suid or sgid bits. This protects
84922+ against another published method of breaking a chroot. If the sysctl
84923+ option is enabled, a sysctl option with name "chroot_deny_chmod" is
84924+ created.
84925+
84926+config GRKERNSEC_CHROOT_FCHDIR
84927+ bool "Deny fchdir and fhandle out of chroot"
84928+ default y if GRKERNSEC_CONFIG_AUTO
84929+ depends on GRKERNSEC_CHROOT
84930+ help
84931+ If you say Y here, a well-known method of breaking chroots by fchdir'ing
84932+ to a file descriptor of the chrooting process that points to a directory
84933+ outside the filesystem will be stopped. Additionally, this option prevents
84934+ use of the recently-created syscall for opening files by a guessable "file
84935+ handle" inside a chroot. If the sysctl option is enabled, a sysctl option
84936+ with name "chroot_deny_fchdir" is created.
84937+
84938+config GRKERNSEC_CHROOT_MKNOD
84939+ bool "Deny mknod"
84940+ default y if GRKERNSEC_CONFIG_AUTO
84941+ depends on GRKERNSEC_CHROOT
84942+ help
84943+ If you say Y here, processes inside a chroot will not be allowed to
84944+ mknod. The problem with using mknod inside a chroot is that it
84945+ would allow an attacker to create a device entry that is the same
84946+ as one on the physical root of your system, which could range from
84947+ anything from the console device to a device for your harddrive (which
84948+ they could then use to wipe the drive or steal data). It is recommended
84949+ that you say Y here, unless you run into software incompatibilities.
84950+ If the sysctl option is enabled, a sysctl option with name
84951+ "chroot_deny_mknod" is created.
84952+
84953+config GRKERNSEC_CHROOT_SHMAT
84954+ bool "Deny shmat() out of chroot"
84955+ default y if GRKERNSEC_CONFIG_AUTO
84956+ depends on GRKERNSEC_CHROOT
84957+ help
84958+ If you say Y here, processes inside a chroot will not be able to attach
84959+ to shared memory segments that were created outside of the chroot jail.
84960+ It is recommended that you say Y here. If the sysctl option is enabled,
84961+ a sysctl option with name "chroot_deny_shmat" is created.
84962+
84963+config GRKERNSEC_CHROOT_UNIX
84964+ bool "Deny access to abstract AF_UNIX sockets out of chroot"
84965+ default y if GRKERNSEC_CONFIG_AUTO
84966+ depends on GRKERNSEC_CHROOT
84967+ help
84968+ If you say Y here, processes inside a chroot will not be able to
84969+ connect to abstract (meaning not belonging to a filesystem) Unix
84970+ domain sockets that were bound outside of a chroot. It is recommended
84971+ that you say Y here. If the sysctl option is enabled, a sysctl option
84972+ with name "chroot_deny_unix" is created.
84973+
84974+config GRKERNSEC_CHROOT_FINDTASK
84975+ bool "Protect outside processes"
84976+ default y if GRKERNSEC_CONFIG_AUTO
84977+ depends on GRKERNSEC_CHROOT
84978+ help
84979+ If you say Y here, processes inside a chroot will not be able to
84980+ kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
84981+ getsid, or view any process outside of the chroot. If the sysctl
84982+ option is enabled, a sysctl option with name "chroot_findtask" is
84983+ created.
84984+
84985+config GRKERNSEC_CHROOT_NICE
84986+ bool "Restrict priority changes"
84987+ default y if GRKERNSEC_CONFIG_AUTO
84988+ depends on GRKERNSEC_CHROOT
84989+ help
84990+ If you say Y here, processes inside a chroot will not be able to raise
84991+ the priority of processes in the chroot, or alter the priority of
84992+ processes outside the chroot. This provides more security than simply
84993+ removing CAP_SYS_NICE from the process' capability set. If the
84994+ sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
84995+ is created.
84996+
84997+config GRKERNSEC_CHROOT_SYSCTL
84998+ bool "Deny sysctl writes"
84999+ default y if GRKERNSEC_CONFIG_AUTO
85000+ depends on GRKERNSEC_CHROOT
85001+ help
85002+ If you say Y here, an attacker in a chroot will not be able to
85003+ write to sysctl entries, either by sysctl(2) or through a /proc
85004+ interface. It is strongly recommended that you say Y here. If the
85005+ sysctl option is enabled, a sysctl option with name
85006+ "chroot_deny_sysctl" is created.
85007+
85008+config GRKERNSEC_CHROOT_RENAME
85009+ bool "Deny bad renames"
85010+ default y if GRKERNSEC_CONFIG_AUTO
85011+ depends on GRKERNSEC_CHROOT
85012+ help
85013+ If you say Y here, an attacker in a chroot will not be able to
85014+ abuse the ability to create double chroots to break out of the
85015+ chroot by exploiting a race condition between a rename of a directory
85016+ within a chroot against an open of a symlink with relative path
85017+ components. This feature will likewise prevent an accomplice outside
85018+ a chroot from enabling a user inside the chroot to break out and make
85019+ use of their credentials on the global filesystem. Enabling this
85020+ feature is essential to prevent root users from breaking out of a
85021+ chroot. If the sysctl option is enabled, a sysctl option with name
85022+ "chroot_deny_bad_rename" is created.
85023+
85024+config GRKERNSEC_CHROOT_CAPS
85025+ bool "Capability restrictions"
85026+ default y if GRKERNSEC_CONFIG_AUTO
85027+ depends on GRKERNSEC_CHROOT
85028+ help
85029+ If you say Y here, the capabilities on all processes within a
85030+ chroot jail will be lowered to stop module insertion, raw i/o,
85031+ system and net admin tasks, rebooting the system, modifying immutable
85032+ files, modifying IPC owned by another, and changing the system time.
85033+ This is left an option because it can break some apps. Disable this
85034+ if your chrooted apps are having problems performing those kinds of
85035+ tasks. If the sysctl option is enabled, a sysctl option with
85036+ name "chroot_caps" is created.
85037+
85038+config GRKERNSEC_CHROOT_INITRD
85039+ bool "Exempt initrd tasks from restrictions"
85040+ default y if GRKERNSEC_CONFIG_AUTO
85041+ depends on GRKERNSEC_CHROOT && BLK_DEV_INITRD
85042+ help
85043+ If you say Y here, tasks started prior to init will be exempted from
85044+ grsecurity's chroot restrictions. This option is mainly meant to
85045+ resolve Plymouth's performing privileged operations unnecessarily
85046+ in a chroot.
85047+
85048+endmenu
85049+menu "Kernel Auditing"
85050+depends on GRKERNSEC
85051+
85052+config GRKERNSEC_AUDIT_GROUP
85053+ bool "Single group for auditing"
85054+ help
85055+ If you say Y here, the exec and chdir logging features will only operate
85056+ on a group you specify. This option is recommended if you only want to
85057+ watch certain users instead of having a large amount of logs from the
85058+ entire system. If the sysctl option is enabled, a sysctl option with
85059+ name "audit_group" is created.
85060+
85061+config GRKERNSEC_AUDIT_GID
85062+ int "GID for auditing"
85063+ depends on GRKERNSEC_AUDIT_GROUP
85064+ default 1007
85065+
85066+config GRKERNSEC_EXECLOG
85067+ bool "Exec logging"
85068+ help
85069+ If you say Y here, all execve() calls will be logged (since the
85070+ other exec*() calls are frontends to execve(), all execution
85071+ will be logged). Useful for shell-servers that like to keep track
85072+ of their users. If the sysctl option is enabled, a sysctl option with
85073+ name "exec_logging" is created.
85074+ WARNING: This option when enabled will produce a LOT of logs, especially
85075+ on an active system.
85076+
85077+config GRKERNSEC_RESLOG
85078+ bool "Resource logging"
85079+ default y if GRKERNSEC_CONFIG_AUTO
85080+ help
85081+ If you say Y here, all attempts to overstep resource limits will
85082+ be logged with the resource name, the requested size, and the current
85083+ limit. It is highly recommended that you say Y here. If the sysctl
85084+ option is enabled, a sysctl option with name "resource_logging" is
85085+ created. If the RBAC system is enabled, the sysctl value is ignored.
85086+
85087+config GRKERNSEC_CHROOT_EXECLOG
85088+ bool "Log execs within chroot"
85089+ help
85090+ If you say Y here, all executions inside a chroot jail will be logged
85091+ to syslog. This can cause a large amount of logs if certain
85092+ applications (eg. djb's daemontools) are installed on the system, and
85093+ is therefore left as an option. If the sysctl option is enabled, a
85094+ sysctl option with name "chroot_execlog" is created.
85095+
85096+config GRKERNSEC_AUDIT_PTRACE
85097+ bool "Ptrace logging"
85098+ help
85099+ If you say Y here, all attempts to attach to a process via ptrace
85100+ will be logged. If the sysctl option is enabled, a sysctl option
85101+ with name "audit_ptrace" is created.
85102+
85103+config GRKERNSEC_AUDIT_CHDIR
85104+ bool "Chdir logging"
85105+ help
85106+ If you say Y here, all chdir() calls will be logged. If the sysctl
85107+ option is enabled, a sysctl option with name "audit_chdir" is created.
85108+
85109+config GRKERNSEC_AUDIT_MOUNT
85110+ bool "(Un)Mount logging"
85111+ help
85112+ If you say Y here, all mounts and unmounts will be logged. If the
85113+ sysctl option is enabled, a sysctl option with name "audit_mount" is
85114+ created.
85115+
85116+config GRKERNSEC_SIGNAL
85117+ bool "Signal logging"
85118+ default y if GRKERNSEC_CONFIG_AUTO
85119+ help
85120+ If you say Y here, certain important signals will be logged, such as
85121+ SIGSEGV, which will as a result inform you of when a error in a program
85122+ occurred, which in some cases could mean a possible exploit attempt.
85123+ If the sysctl option is enabled, a sysctl option with name
85124+ "signal_logging" is created.
85125+
85126+config GRKERNSEC_FORKFAIL
85127+ bool "Fork failure logging"
85128+ help
85129+ If you say Y here, all failed fork() attempts will be logged.
85130+ This could suggest a fork bomb, or someone attempting to overstep
85131+ their process limit. If the sysctl option is enabled, a sysctl option
85132+ with name "forkfail_logging" is created.
85133+
85134+config GRKERNSEC_TIME
85135+ bool "Time change logging"
85136+ default y if GRKERNSEC_CONFIG_AUTO
85137+ help
85138+ If you say Y here, any changes of the system clock will be logged.
85139+ If the sysctl option is enabled, a sysctl option with name
85140+ "timechange_logging" is created.
85141+
85142+config GRKERNSEC_PROC_IPADDR
85143+ bool "/proc/<pid>/ipaddr support"
85144+ default y if GRKERNSEC_CONFIG_AUTO
85145+ help
85146+ If you say Y here, a new entry will be added to each /proc/<pid>
85147+ directory that contains the IP address of the person using the task.
85148+ The IP is carried across local TCP and AF_UNIX stream sockets.
85149+ This information can be useful for IDS/IPSes to perform remote response
85150+ to a local attack. The entry is readable by only the owner of the
85151+ process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
85152+ the RBAC system), and thus does not create privacy concerns.
85153+
85154+config GRKERNSEC_RWXMAP_LOG
85155+ bool 'Denied RWX mmap/mprotect logging'
85156+ default y if GRKERNSEC_CONFIG_AUTO
85157+ depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
85158+ help
85159+ If you say Y here, calls to mmap() and mprotect() with explicit
85160+ usage of PROT_WRITE and PROT_EXEC together will be logged when
85161+ denied by the PAX_MPROTECT feature. This feature will also
85162+ log other problematic scenarios that can occur when PAX_MPROTECT
85163+ is enabled on a binary, like textrels and PT_GNU_STACK. If the
85164+ sysctl option is enabled, a sysctl option with name "rwxmap_logging"
85165+ is created.
85166+
85167+endmenu
85168+
85169+menu "Executable Protections"
85170+depends on GRKERNSEC
85171+
85172+config GRKERNSEC_DMESG
85173+ bool "Dmesg(8) restriction"
85174+ default y if GRKERNSEC_CONFIG_AUTO
85175+ help
85176+ If you say Y here, non-root users will not be able to use dmesg(8)
85177+ to view the contents of the kernel's circular log buffer.
85178+ The kernel's log buffer often contains kernel addresses and other
85179+ identifying information useful to an attacker in fingerprinting a
85180+ system for a targeted exploit.
85181+ If the sysctl option is enabled, a sysctl option with name "dmesg" is
85182+ created.
85183+
85184+config GRKERNSEC_HARDEN_PTRACE
85185+ bool "Deter ptrace-based process snooping"
85186+ default y if GRKERNSEC_CONFIG_AUTO
85187+ help
85188+ If you say Y here, TTY sniffers and other malicious monitoring
85189+ programs implemented through ptrace will be defeated. If you
85190+ have been using the RBAC system, this option has already been
85191+ enabled for several years for all users, with the ability to make
85192+ fine-grained exceptions.
85193+
85194+ This option only affects the ability of non-root users to ptrace
85195+ processes that are not a descendent of the ptracing process.
85196+ This means that strace ./binary and gdb ./binary will still work,
85197+ but attaching to arbitrary processes will not. If the sysctl
85198+ option is enabled, a sysctl option with name "harden_ptrace" is
85199+ created.
85200+
85201+config GRKERNSEC_PTRACE_READEXEC
85202+ bool "Require read access to ptrace sensitive binaries"
85203+ default y if GRKERNSEC_CONFIG_AUTO
85204+ help
85205+ If you say Y here, unprivileged users will not be able to ptrace unreadable
85206+ binaries. This option is useful in environments that
85207+ remove the read bits (e.g. file mode 4711) from suid binaries to
85208+ prevent infoleaking of their contents. This option adds
85209+ consistency to the use of that file mode, as the binary could normally
85210+ be read out when run without privileges while ptracing.
85211+
85212+ If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
85213+ is created.
85214+
85215+config GRKERNSEC_SETXID
85216+ bool "Enforce consistent multithreaded privileges"
85217+ default y if GRKERNSEC_CONFIG_AUTO
85218+ depends on (X86 || SPARC64 || PPC || ARM || MIPS)
85219+ help
85220+ If you say Y here, a change from a root uid to a non-root uid
85221+ in a multithreaded application will cause the resulting uids,
85222+ gids, supplementary groups, and capabilities in that thread
85223+ to be propagated to the other threads of the process. In most
85224+ cases this is unnecessary, as glibc will emulate this behavior
85225+ on behalf of the application. Other libcs do not act in the
85226+ same way, allowing the other threads of the process to continue
85227+ running with root privileges. If the sysctl option is enabled,
85228+ a sysctl option with name "consistent_setxid" is created.
85229+
85230+config GRKERNSEC_HARDEN_IPC
85231+ bool "Disallow access to overly-permissive IPC objects"
85232+ default y if GRKERNSEC_CONFIG_AUTO
85233+ depends on SYSVIPC
85234+ help
85235+ If you say Y here, access to overly-permissive IPC objects (shared
85236+ memory, message queues, and semaphores) will be denied for processes
85237+ given the following criteria beyond normal permission checks:
85238+ 1) If the IPC object is world-accessible and the euid doesn't match
85239+ that of the creator or current uid for the IPC object
85240+ 2) If the IPC object is group-accessible and the egid doesn't
85241+ match that of the creator or current gid for the IPC object
85242+ It's a common error to grant too much permission to these objects,
85243+ with impact ranging from denial of service and information leaking to
85244+ privilege escalation. This feature was developed in response to
85245+ research by Tim Brown:
85246+ http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
85247+ who found hundreds of such insecure usages. Processes with
85248+ CAP_IPC_OWNER are still permitted to access these IPC objects.
85249+ If the sysctl option is enabled, a sysctl option with name
85250+ "harden_ipc" is created.
85251+
85252+config GRKERNSEC_TPE
85253+ bool "Trusted Path Execution (TPE)"
85254+ default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
85255+ help
85256+ If you say Y here, you will be able to choose a gid to add to the
85257+ supplementary groups of users you want to mark as "untrusted."
85258+ These users will not be able to execute any files that are not in
85259+ root-owned directories writable only by root. If the sysctl option
85260+ is enabled, a sysctl option with name "tpe" is created.
85261+
85262+config GRKERNSEC_TPE_ALL
85263+ bool "Partially restrict all non-root users"
85264+ depends on GRKERNSEC_TPE
85265+ help
85266+ If you say Y here, all non-root users will be covered under
85267+ a weaker TPE restriction. This is separate from, and in addition to,
85268+ the main TPE options that you have selected elsewhere. Thus, if a
85269+ "trusted" GID is chosen, this restriction applies to even that GID.
85270+ Under this restriction, all non-root users will only be allowed to
85271+ execute files in directories they own that are not group or
85272+ world-writable, or in directories owned by root and writable only by
85273+ root. If the sysctl option is enabled, a sysctl option with name
85274+ "tpe_restrict_all" is created.
85275+
85276+config GRKERNSEC_TPE_INVERT
85277+ bool "Invert GID option"
85278+ depends on GRKERNSEC_TPE
85279+ help
85280+ If you say Y here, the group you specify in the TPE configuration will
85281+ decide what group TPE restrictions will be *disabled* for. This
85282+ option is useful if you want TPE restrictions to be applied to most
85283+ users on the system. If the sysctl option is enabled, a sysctl option
85284+ with name "tpe_invert" is created. Unlike other sysctl options, this
85285+ entry will default to on for backward-compatibility.
85286+
85287+config GRKERNSEC_TPE_GID
85288+ int
85289+ default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
85290+ default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
85291+
85292+config GRKERNSEC_TPE_UNTRUSTED_GID
85293+ int "GID for TPE-untrusted users"
85294+ depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
85295+ default 1005
85296+ help
85297+ Setting this GID determines what group TPE restrictions will be
85298+ *enabled* for. If the sysctl option is enabled, a sysctl option
85299+ with name "tpe_gid" is created.
85300+
85301+config GRKERNSEC_TPE_TRUSTED_GID
85302+ int "GID for TPE-trusted users"
85303+ depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
85304+ default 1005
85305+ help
85306+ Setting this GID determines what group TPE restrictions will be
85307+ *disabled* for. If the sysctl option is enabled, a sysctl option
85308+ with name "tpe_gid" is created.
85309+
85310+endmenu
85311+menu "Network Protections"
85312+depends on GRKERNSEC
85313+
85314+config GRKERNSEC_BLACKHOLE
85315+ bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
85316+ default y if GRKERNSEC_CONFIG_AUTO
85317+ depends on NET
85318+ help
85319+ If you say Y here, neither TCP resets nor ICMP
85320+ destination-unreachable packets will be sent in response to packets
85321+ sent to ports for which no associated listening process exists.
85322+ It will also prevent the sending of ICMP protocol unreachable packets
85323+ in response to packets with unknown protocols.
85324+ This feature supports both IPV4 and IPV6 and exempts the
85325+ loopback interface from blackholing. Enabling this feature
85326+ makes a host more resilient to DoS attacks and reduces network
85327+ visibility against scanners.
85328+
85329+ The blackhole feature as-implemented is equivalent to the FreeBSD
85330+ blackhole feature, as it prevents RST responses to all packets, not
85331+ just SYNs. Under most application behavior this causes no
85332+ problems, but applications (like haproxy) may not close certain
85333+ connections in a way that cleanly terminates them on the remote
85334+ end, leaving the remote host in LAST_ACK state. Because of this
85335+ side-effect and to prevent intentional LAST_ACK DoSes, this
85336+ feature also adds automatic mitigation against such attacks.
85337+ The mitigation drastically reduces the amount of time a socket
85338+ can spend in LAST_ACK state. If you're using haproxy and not
85339+ all servers it connects to have this option enabled, consider
85340+ disabling this feature on the haproxy host.
85341+
85342+ If the sysctl option is enabled, two sysctl options with names
85343+ "ip_blackhole" and "lastack_retries" will be created.
85344+ While "ip_blackhole" takes the standard zero/non-zero on/off
85345+ toggle, "lastack_retries" uses the same kinds of values as
85346+ "tcp_retries1" and "tcp_retries2". The default value of 4
85347+ prevents a socket from lasting more than 45 seconds in LAST_ACK
85348+ state.
85349+
85350+config GRKERNSEC_NO_SIMULT_CONNECT
85351+ bool "Disable TCP Simultaneous Connect"
85352+ default y if GRKERNSEC_CONFIG_AUTO
85353+ depends on NET
85354+ help
85355+ If you say Y here, a feature by Willy Tarreau will be enabled that
85356+ removes a weakness in Linux's strict implementation of TCP that
85357+ allows two clients to connect to each other without either entering
85358+ a listening state. The weakness allows an attacker to easily prevent
85359+ a client from connecting to a known server provided the source port
85360+ for the connection is guessed correctly.
85361+
85362+ As the weakness could be used to prevent an antivirus or IPS from
85363+ fetching updates, or prevent an SSL gateway from fetching a CRL,
85364+ it should be eliminated by enabling this option. Though Linux is
85365+ one of few operating systems supporting simultaneous connect, it
85366+ has no legitimate use in practice and is rarely supported by firewalls.
85367+
85368+config GRKERNSEC_SOCKET
85369+ bool "Socket restrictions"
85370+ depends on NET
85371+ help
85372+ If you say Y here, you will be able to choose from several options.
85373+ If you assign a GID on your system and add it to the supplementary
85374+ groups of users you want to restrict socket access to, this patch
85375+ will perform up to three things, based on the option(s) you choose.
85376+
85377+config GRKERNSEC_SOCKET_ALL
85378+ bool "Deny any sockets to group"
85379+ depends on GRKERNSEC_SOCKET
85380+ help
85381+ If you say Y here, you will be able to choose a GID of whose users will
85382+ be unable to connect to other hosts from your machine or run server
85383+ applications from your machine. If the sysctl option is enabled, a
85384+ sysctl option with name "socket_all" is created.
85385+
85386+config GRKERNSEC_SOCKET_ALL_GID
85387+ int "GID to deny all sockets for"
85388+ depends on GRKERNSEC_SOCKET_ALL
85389+ default 1004
85390+ help
85391+ Here you can choose the GID to disable socket access for. Remember to
85392+ add the users you want socket access disabled for to the GID
85393+ specified here. If the sysctl option is enabled, a sysctl option
85394+ with name "socket_all_gid" is created.
85395+
85396+config GRKERNSEC_SOCKET_CLIENT
85397+ bool "Deny client sockets to group"
85398+ depends on GRKERNSEC_SOCKET
85399+ help
85400+ If you say Y here, you will be able to choose a GID of whose users will
85401+ be unable to connect to other hosts from your machine, but will be
85402+ able to run servers. If this option is enabled, all users in the group
85403+ you specify will have to use passive mode when initiating ftp transfers
85404+ from the shell on your machine. If the sysctl option is enabled, a
85405+ sysctl option with name "socket_client" is created.
85406+
85407+config GRKERNSEC_SOCKET_CLIENT_GID
85408+ int "GID to deny client sockets for"
85409+ depends on GRKERNSEC_SOCKET_CLIENT
85410+ default 1003
85411+ help
85412+ Here you can choose the GID to disable client socket access for.
85413+ Remember to add the users you want client socket access disabled for to
85414+ the GID specified here. If the sysctl option is enabled, a sysctl
85415+ option with name "socket_client_gid" is created.
85416+
85417+config GRKERNSEC_SOCKET_SERVER
85418+ bool "Deny server sockets to group"
85419+ depends on GRKERNSEC_SOCKET
85420+ help
85421+ If you say Y here, you will be able to choose a GID of whose users will
85422+ be unable to run server applications from your machine. If the sysctl
85423+ option is enabled, a sysctl option with name "socket_server" is created.
85424+
85425+config GRKERNSEC_SOCKET_SERVER_GID
85426+ int "GID to deny server sockets for"
85427+ depends on GRKERNSEC_SOCKET_SERVER
85428+ default 1002
85429+ help
85430+ Here you can choose the GID to disable server socket access for.
85431+ Remember to add the users you want server socket access disabled for to
85432+ the GID specified here. If the sysctl option is enabled, a sysctl
85433+ option with name "socket_server_gid" is created.
85434+
85435+endmenu
85436+
85437+menu "Physical Protections"
85438+depends on GRKERNSEC
85439+
85440+config GRKERNSEC_DENYUSB
85441+ bool "Deny new USB connections after toggle"
85442+ default y if GRKERNSEC_CONFIG_AUTO
85443+ depends on SYSCTL && USB_SUPPORT
85444+ help
85445+ If you say Y here, a new sysctl option with name "deny_new_usb"
85446+ will be created. Setting its value to 1 will prevent any new
85447+ USB devices from being recognized by the OS. Any attempted USB
85448+ device insertion will be logged. This option is intended to be
85449+ used against custom USB devices designed to exploit vulnerabilities
85450+ in various USB device drivers.
85451+
85452+ For greatest effectiveness, this sysctl should be set after any
85453+ relevant init scripts. This option is safe to enable in distros
85454+ as each user can choose whether or not to toggle the sysctl.
85455+
85456+config GRKERNSEC_DENYUSB_FORCE
85457+ bool "Reject all USB devices not connected at boot"
85458+ select USB
85459+ depends on GRKERNSEC_DENYUSB
85460+ help
85461+ If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
85462+ that doesn't involve a sysctl entry. This option should only be
85463+ enabled if you're sure you want to deny all new USB connections
85464+ at runtime and don't want to modify init scripts. This should not
85465+ be enabled by distros. It forces the core USB code to be built
85466+ into the kernel image so that all devices connected at boot time
85467+ can be recognized and new USB device connections can be prevented
85468+ prior to init running.
85469+
85470+endmenu
85471+
85472+menu "Sysctl Support"
85473+depends on GRKERNSEC && SYSCTL
85474+
85475+config GRKERNSEC_SYSCTL
85476+ bool "Sysctl support"
85477+ default y if GRKERNSEC_CONFIG_AUTO
85478+ help
85479+ If you say Y here, you will be able to change the options that
85480+ grsecurity runs with at bootup, without having to recompile your
85481+ kernel. You can echo values to files in /proc/sys/kernel/grsecurity
85482+ to enable (1) or disable (0) various features. All the sysctl entries
85483+ are mutable until the "grsec_lock" entry is set to a non-zero value.
85484+ All features enabled in the kernel configuration are disabled at boot
85485+ if you do not say Y to the "Turn on features by default" option.
85486+ All options should be set at startup, and the grsec_lock entry should
85487+ be set to a non-zero value after all the options are set.
85488+ *THIS IS EXTREMELY IMPORTANT*
85489+
85490+config GRKERNSEC_SYSCTL_DISTRO
85491+ bool "Extra sysctl support for distro makers (READ HELP)"
85492+ depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
85493+ help
85494+ If you say Y here, additional sysctl options will be created
85495+ for features that affect processes running as root. Therefore,
85496+ it is critical when using this option that the grsec_lock entry be
85497+ enabled after boot. Only distros with prebuilt kernel packages
85498+ with this option enabled that can ensure grsec_lock is enabled
85499+ after boot should use this option.
85500+ *Failure to set grsec_lock after boot makes all grsec features
85501+ this option covers useless*
85502+
85503+ Currently this option creates the following sysctl entries:
85504+ "Disable Privileged I/O": "disable_priv_io"
85505+
85506+config GRKERNSEC_SYSCTL_ON
85507+ bool "Turn on features by default"
85508+ default y if GRKERNSEC_CONFIG_AUTO
85509+ depends on GRKERNSEC_SYSCTL
85510+ help
85511+ If you say Y here, instead of having all features enabled in the
85512+ kernel configuration disabled at boot time, the features will be
85513+ enabled at boot time. It is recommended you say Y here unless
85514+ there is some reason you would want all sysctl-tunable features to
85515+ be disabled by default. As mentioned elsewhere, it is important
85516+ to enable the grsec_lock entry once you have finished modifying
85517+ the sysctl entries.
85518+
85519+endmenu
85520+menu "Logging Options"
85521+depends on GRKERNSEC
85522+
85523+config GRKERNSEC_FLOODTIME
85524+ int "Seconds in between log messages (minimum)"
85525+ default 10
85526+ help
85527+ This option allows you to enforce the number of seconds between
85528+ grsecurity log messages. The default should be suitable for most
85529+ people, however, if you choose to change it, choose a value small enough
85530+ to allow informative logs to be produced, but large enough to
85531+ prevent flooding.
85532+
85533+ Setting both this value and GRKERNSEC_FLOODBURST to 0 will disable
85534+ any rate limiting on grsecurity log messages.
85535+
85536+config GRKERNSEC_FLOODBURST
85537+ int "Number of messages in a burst (maximum)"
85538+ default 6
85539+ help
85540+ This option allows you to choose the maximum number of messages allowed
85541+ within the flood time interval you chose in a separate option. The
85542+ default should be suitable for most people, however if you find that
85543+ many of your logs are being interpreted as flooding, you may want to
85544+ raise this value.
85545+
85546+ Setting both this value and GRKERNSEC_FLOODTIME to 0 will disable
85547+ any rate limiting on grsecurity log messages.
85548+
85549+endmenu
85550diff --git a/grsecurity/Makefile b/grsecurity/Makefile
85551new file mode 100644
85552index 0000000..30ababb
85553--- /dev/null
85554+++ b/grsecurity/Makefile
85555@@ -0,0 +1,54 @@
85556+# grsecurity – access control and security hardening for Linux
85557+# All code in this directory and various hooks located throughout the Linux kernel are
85558+# Copyright (C) 2001-2014 Bradley Spengler, Open Source Security, Inc.
85559+# http://www.grsecurity.net spender@grsecurity.net
85560+#
85561+# This program is free software; you can redistribute it and/or
85562+# modify it under the terms of the GNU General Public License version 2
85563+# as published by the Free Software Foundation.
85564+#
85565+# This program is distributed in the hope that it will be useful,
85566+# but WITHOUT ANY WARRANTY; without even the implied warranty of
85567+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
85568+# GNU General Public License for more details.
85569+#
85570+# You should have received a copy of the GNU General Public License
85571+# along with this program; if not, write to the Free Software
85572+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
85573+
85574+KBUILD_CFLAGS += -Werror
85575+
85576+obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
85577+ grsec_mount.o grsec_sig.o grsec_sysctl.o \
85578+ grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
85579+ grsec_usb.o grsec_ipc.o grsec_proc.o
85580+
85581+obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
85582+ gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
85583+ gracl_learn.o grsec_log.o gracl_policy.o
85584+ifdef CONFIG_COMPAT
85585+obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
85586+endif
85587+
85588+obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
85589+
85590+ifdef CONFIG_NET
85591+obj-y += grsec_sock.o
85592+obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
85593+endif
85594+
85595+ifndef CONFIG_GRKERNSEC
85596+obj-y += grsec_disabled.o
85597+endif
85598+
85599+ifdef CONFIG_GRKERNSEC_HIDESYM
85600+extra-y := grsec_hidesym.o
85601+$(obj)/grsec_hidesym.o:
85602+ @-chmod -f 500 /boot
85603+ @-chmod -f 500 /lib/modules
85604+ @-chmod -f 500 /lib64/modules
85605+ @-chmod -f 500 /lib32/modules
85606+ @-chmod -f 700 .
85607+ @-chmod -f 700 $(objtree)
85608+ @echo ' grsec: protected kernel image paths'
85609+endif
85610diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
85611new file mode 100644
85612index 0000000..7ad630a
85613--- /dev/null
85614+++ b/grsecurity/gracl.c
85615@@ -0,0 +1,2757 @@
85616+#include <linux/kernel.h>
85617+#include <linux/module.h>
85618+#include <linux/sched.h>
85619+#include <linux/mm.h>
85620+#include <linux/file.h>
85621+#include <linux/fs.h>
85622+#include <linux/namei.h>
85623+#include <linux/mount.h>
85624+#include <linux/tty.h>
85625+#include <linux/proc_fs.h>
85626+#include <linux/lglock.h>
85627+#include <linux/slab.h>
85628+#include <linux/vmalloc.h>
85629+#include <linux/types.h>
85630+#include <linux/sysctl.h>
85631+#include <linux/netdevice.h>
85632+#include <linux/ptrace.h>
85633+#include <linux/gracl.h>
85634+#include <linux/gralloc.h>
85635+#include <linux/security.h>
85636+#include <linux/grinternal.h>
85637+#include <linux/pid_namespace.h>
85638+#include <linux/stop_machine.h>
85639+#include <linux/fdtable.h>
85640+#include <linux/percpu.h>
85641+#include <linux/lglock.h>
85642+#include <linux/hugetlb.h>
85643+#include <linux/posix-timers.h>
85644+#include <linux/prefetch.h>
85645+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
85646+#include <linux/magic.h>
85647+#include <linux/pagemap.h>
85648+#include "../fs/btrfs/async-thread.h"
85649+#include "../fs/btrfs/ctree.h"
85650+#include "../fs/btrfs/btrfs_inode.h"
85651+#endif
85652+#include "../fs/mount.h"
85653+
85654+#include <asm/uaccess.h>
85655+#include <asm/errno.h>
85656+#include <asm/mman.h>
85657+
85658+#define FOR_EACH_ROLE_START(role) \
85659+ role = running_polstate.role_list; \
85660+ while (role) {
85661+
85662+#define FOR_EACH_ROLE_END(role) \
85663+ role = role->prev; \
85664+ }
85665+
85666+extern struct path gr_real_root;
85667+
85668+static struct gr_policy_state running_polstate;
85669+struct gr_policy_state *polstate = &running_polstate;
85670+extern struct gr_alloc_state *current_alloc_state;
85671+
85672+extern char *gr_shared_page[4];
85673+DEFINE_RWLOCK(gr_inode_lock);
85674+
85675+static unsigned int gr_status __read_only = GR_STATUS_INIT;
85676+
85677+#ifdef CONFIG_NET
85678+extern struct vfsmount *sock_mnt;
85679+#endif
85680+
85681+extern struct vfsmount *pipe_mnt;
85682+extern struct vfsmount *shm_mnt;
85683+
85684+#ifdef CONFIG_HUGETLBFS
85685+extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
85686+#endif
85687+
85688+extern u16 acl_sp_role_value;
85689+extern struct acl_object_label *fakefs_obj_rw;
85690+extern struct acl_object_label *fakefs_obj_rwx;
85691+
85692+int gr_acl_is_enabled(void)
85693+{
85694+ return (gr_status & GR_READY);
85695+}
85696+
85697+void gr_enable_rbac_system(void)
85698+{
85699+ pax_open_kernel();
85700+ gr_status |= GR_READY;
85701+ pax_close_kernel();
85702+}
85703+
85704+int gr_rbac_disable(void *unused)
85705+{
85706+ pax_open_kernel();
85707+ gr_status &= ~GR_READY;
85708+ pax_close_kernel();
85709+
85710+ return 0;
85711+}
85712+
85713+static inline dev_t __get_dev(const struct dentry *dentry)
85714+{
85715+ struct dentry *ldentry = d_backing_dentry((struct dentry *)dentry);
85716+
85717+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
85718+ if (ldentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
85719+ return BTRFS_I(d_inode(ldentry))->root->anon_dev;
85720+ else
85721+#endif
85722+ return d_inode(ldentry)->i_sb->s_dev;
85723+}
85724+
85725+static inline u64 __get_ino(const struct dentry *dentry)
85726+{
85727+ struct dentry *ldentry = d_backing_dentry((struct dentry *)dentry);
85728+
85729+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
85730+ if (ldentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
85731+ return btrfs_ino(d_inode(dentry));
85732+ else
85733+#endif
85734+ return d_inode(ldentry)->i_ino;
85735+}
85736+
85737+dev_t gr_get_dev_from_dentry(struct dentry *dentry)
85738+{
85739+ return __get_dev(dentry);
85740+}
85741+
85742+u64 gr_get_ino_from_dentry(struct dentry *dentry)
85743+{
85744+ return __get_ino(dentry);
85745+}
85746+
85747+static char gr_task_roletype_to_char(struct task_struct *task)
85748+{
85749+ switch (task->role->roletype &
85750+ (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
85751+ GR_ROLE_SPECIAL)) {
85752+ case GR_ROLE_DEFAULT:
85753+ return 'D';
85754+ case GR_ROLE_USER:
85755+ return 'U';
85756+ case GR_ROLE_GROUP:
85757+ return 'G';
85758+ case GR_ROLE_SPECIAL:
85759+ return 'S';
85760+ }
85761+
85762+ return 'X';
85763+}
85764+
85765+char gr_roletype_to_char(void)
85766+{
85767+ return gr_task_roletype_to_char(current);
85768+}
85769+
85770+int
85771+gr_acl_tpe_check(void)
85772+{
85773+ if (unlikely(!(gr_status & GR_READY)))
85774+ return 0;
85775+ if (current->role->roletype & GR_ROLE_TPE)
85776+ return 1;
85777+ else
85778+ return 0;
85779+}
85780+
85781+int
85782+gr_handle_rawio(const struct inode *inode)
85783+{
85784+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
85785+ if (inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR)) &&
85786+ grsec_enable_chroot_caps && proc_is_chrooted(current) &&
85787+ !capable(CAP_SYS_RAWIO))
85788+ return 1;
85789+#endif
85790+ return 0;
85791+}
85792+
85793+int
85794+gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
85795+{
85796+ if (likely(lena != lenb))
85797+ return 0;
85798+
85799+ return !memcmp(a, b, lena);
85800+}
85801+
85802+static int prepend(char **buffer, int *buflen, const char *str, int namelen)
85803+{
85804+ *buflen -= namelen;
85805+ if (*buflen < 0)
85806+ return -ENAMETOOLONG;
85807+ *buffer -= namelen;
85808+ memcpy(*buffer, str, namelen);
85809+ return 0;
85810+}
85811+
85812+static int prepend_name(char **buffer, int *buflen, struct qstr *name)
85813+{
85814+ return prepend(buffer, buflen, name->name, name->len);
85815+}
85816+
85817+static int prepend_path(const struct path *path, struct path *root,
85818+ char **buffer, int *buflen)
85819+{
85820+ struct dentry *dentry = path->dentry;
85821+ struct vfsmount *vfsmnt = path->mnt;
85822+ struct mount *mnt = real_mount(vfsmnt);
85823+ bool slash = false;
85824+ int error = 0;
85825+
85826+ while (dentry != root->dentry || vfsmnt != root->mnt) {
85827+ struct dentry * parent;
85828+
85829+ if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
85830+ /* Global root? */
85831+ if (!mnt_has_parent(mnt)) {
85832+ goto out;
85833+ }
85834+ dentry = mnt->mnt_mountpoint;
85835+ mnt = mnt->mnt_parent;
85836+ vfsmnt = &mnt->mnt;
85837+ continue;
85838+ }
85839+ parent = dentry->d_parent;
85840+ prefetch(parent);
85841+ spin_lock(&dentry->d_lock);
85842+ error = prepend_name(buffer, buflen, &dentry->d_name);
85843+ spin_unlock(&dentry->d_lock);
85844+ if (!error)
85845+ error = prepend(buffer, buflen, "/", 1);
85846+ if (error)
85847+ break;
85848+
85849+ slash = true;
85850+ dentry = parent;
85851+ }
85852+
85853+out:
85854+ if (!error && !slash)
85855+ error = prepend(buffer, buflen, "/", 1);
85856+
85857+ return error;
85858+}
85859+
85860+/* this must be called with mount_lock and rename_lock held */
85861+
85862+static char *__our_d_path(const struct path *path, struct path *root,
85863+ char *buf, int buflen)
85864+{
85865+ char *res = buf + buflen;
85866+ int error;
85867+
85868+ prepend(&res, &buflen, "\0", 1);
85869+ error = prepend_path(path, root, &res, &buflen);
85870+ if (error)
85871+ return ERR_PTR(error);
85872+
85873+ return res;
85874+}
85875+
85876+static char *
85877+gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
85878+{
85879+ char *retval;
85880+
85881+ retval = __our_d_path(path, root, buf, buflen);
85882+ if (unlikely(IS_ERR(retval)))
85883+ retval = strcpy(buf, "<path too long>");
85884+ else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
85885+ retval[1] = '\0';
85886+
85887+ return retval;
85888+}
85889+
85890+static char *
85891+__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
85892+ char *buf, int buflen)
85893+{
85894+ struct path path;
85895+ char *res;
85896+
85897+ path.dentry = (struct dentry *)dentry;
85898+ path.mnt = (struct vfsmount *)vfsmnt;
85899+
85900+ /* we can use gr_real_root.dentry, gr_real_root.mnt, because this is only called
85901+ by the RBAC system */
85902+ res = gen_full_path(&path, &gr_real_root, buf, buflen);
85903+
85904+ return res;
85905+}
85906+
85907+static char *
85908+d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
85909+ char *buf, int buflen)
85910+{
85911+ char *res;
85912+ struct path path;
85913+ struct path root;
85914+ struct task_struct *reaper = init_pid_ns.child_reaper;
85915+
85916+ path.dentry = (struct dentry *)dentry;
85917+ path.mnt = (struct vfsmount *)vfsmnt;
85918+
85919+ /* we can't use gr_real_root.dentry, gr_real_root.mnt, because they belong only to the RBAC system */
85920+ get_fs_root(reaper->fs, &root);
85921+
85922+ read_seqlock_excl(&mount_lock);
85923+ write_seqlock(&rename_lock);
85924+ res = gen_full_path(&path, &root, buf, buflen);
85925+ write_sequnlock(&rename_lock);
85926+ read_sequnlock_excl(&mount_lock);
85927+
85928+ path_put(&root);
85929+ return res;
85930+}
85931+
85932+char *
85933+gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
85934+{
85935+ char *ret;
85936+ read_seqlock_excl(&mount_lock);
85937+ write_seqlock(&rename_lock);
85938+ ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
85939+ PAGE_SIZE);
85940+ write_sequnlock(&rename_lock);
85941+ read_sequnlock_excl(&mount_lock);
85942+ return ret;
85943+}
85944+
85945+static char *
85946+gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
85947+{
85948+ char *ret;
85949+ char *buf;
85950+ int buflen;
85951+
85952+ read_seqlock_excl(&mount_lock);
85953+ write_seqlock(&rename_lock);
85954+ buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
85955+ ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
85956+ buflen = (int)(ret - buf);
85957+ if (buflen >= 5)
85958+ prepend(&ret, &buflen, "/proc", 5);
85959+ else
85960+ ret = strcpy(buf, "<path too long>");
85961+ write_sequnlock(&rename_lock);
85962+ read_sequnlock_excl(&mount_lock);
85963+ return ret;
85964+}
85965+
85966+char *
85967+gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
85968+{
85969+ return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
85970+ PAGE_SIZE);
85971+}
85972+
85973+char *
85974+gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
85975+{
85976+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
85977+ PAGE_SIZE);
85978+}
85979+
85980+char *
85981+gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
85982+{
85983+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
85984+ PAGE_SIZE);
85985+}
85986+
85987+char *
85988+gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
85989+{
85990+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
85991+ PAGE_SIZE);
85992+}
85993+
85994+char *
85995+gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
85996+{
85997+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
85998+ PAGE_SIZE);
85999+}
86000+
86001+__u32
86002+to_gr_audit(const __u32 reqmode)
86003+{
86004+ /* masks off auditable permission flags, then shifts them to create
86005+ auditing flags, and adds the special case of append auditing if
86006+ we're requesting write */
86007+ return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
86008+}
86009+
86010+struct acl_role_label *
86011+__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid,
86012+ const gid_t gid)
86013+{
86014+ unsigned int index = gr_rhash(uid, GR_ROLE_USER, state->acl_role_set.r_size);
86015+ struct acl_role_label *match;
86016+ struct role_allowed_ip *ipp;
86017+ unsigned int x;
86018+ u32 curr_ip = task->signal->saved_ip;
86019+
86020+ match = state->acl_role_set.r_hash[index];
86021+
86022+ while (match) {
86023+ if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
86024+ for (x = 0; x < match->domain_child_num; x++) {
86025+ if (match->domain_children[x] == uid)
86026+ goto found;
86027+ }
86028+ } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
86029+ break;
86030+ match = match->next;
86031+ }
86032+found:
86033+ if (match == NULL) {
86034+ try_group:
86035+ index = gr_rhash(gid, GR_ROLE_GROUP, state->acl_role_set.r_size);
86036+ match = state->acl_role_set.r_hash[index];
86037+
86038+ while (match) {
86039+ if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
86040+ for (x = 0; x < match->domain_child_num; x++) {
86041+ if (match->domain_children[x] == gid)
86042+ goto found2;
86043+ }
86044+ } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
86045+ break;
86046+ match = match->next;
86047+ }
86048+found2:
86049+ if (match == NULL)
86050+ match = state->default_role;
86051+ if (match->allowed_ips == NULL)
86052+ return match;
86053+ else {
86054+ for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
86055+ if (likely
86056+ ((ntohl(curr_ip) & ipp->netmask) ==
86057+ (ntohl(ipp->addr) & ipp->netmask)))
86058+ return match;
86059+ }
86060+ match = state->default_role;
86061+ }
86062+ } else if (match->allowed_ips == NULL) {
86063+ return match;
86064+ } else {
86065+ for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
86066+ if (likely
86067+ ((ntohl(curr_ip) & ipp->netmask) ==
86068+ (ntohl(ipp->addr) & ipp->netmask)))
86069+ return match;
86070+ }
86071+ goto try_group;
86072+ }
86073+
86074+ return match;
86075+}
86076+
86077+static struct acl_role_label *
86078+lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
86079+ const gid_t gid)
86080+{
86081+ return __lookup_acl_role_label(&running_polstate, task, uid, gid);
86082+}
86083+
86084+struct acl_subject_label *
86085+lookup_acl_subj_label(const u64 ino, const dev_t dev,
86086+ const struct acl_role_label *role)
86087+{
86088+ unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
86089+ struct acl_subject_label *match;
86090+
86091+ match = role->subj_hash[index];
86092+
86093+ while (match && (match->inode != ino || match->device != dev ||
86094+ (match->mode & GR_DELETED))) {
86095+ match = match->next;
86096+ }
86097+
86098+ if (match && !(match->mode & GR_DELETED))
86099+ return match;
86100+ else
86101+ return NULL;
86102+}
86103+
86104+struct acl_subject_label *
86105+lookup_acl_subj_label_deleted(const u64 ino, const dev_t dev,
86106+ const struct acl_role_label *role)
86107+{
86108+ unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
86109+ struct acl_subject_label *match;
86110+
86111+ match = role->subj_hash[index];
86112+
86113+ while (match && (match->inode != ino || match->device != dev ||
86114+ !(match->mode & GR_DELETED))) {
86115+ match = match->next;
86116+ }
86117+
86118+ if (match && (match->mode & GR_DELETED))
86119+ return match;
86120+ else
86121+ return NULL;
86122+}
86123+
86124+static struct acl_object_label *
86125+lookup_acl_obj_label(const u64 ino, const dev_t dev,
86126+ const struct acl_subject_label *subj)
86127+{
86128+ unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
86129+ struct acl_object_label *match;
86130+
86131+ match = subj->obj_hash[index];
86132+
86133+ while (match && (match->inode != ino || match->device != dev ||
86134+ (match->mode & GR_DELETED))) {
86135+ match = match->next;
86136+ }
86137+
86138+ if (match && !(match->mode & GR_DELETED))
86139+ return match;
86140+ else
86141+ return NULL;
86142+}
86143+
86144+static struct acl_object_label *
86145+lookup_acl_obj_label_create(const u64 ino, const dev_t dev,
86146+ const struct acl_subject_label *subj)
86147+{
86148+ unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
86149+ struct acl_object_label *match;
86150+
86151+ match = subj->obj_hash[index];
86152+
86153+ while (match && (match->inode != ino || match->device != dev ||
86154+ !(match->mode & GR_DELETED))) {
86155+ match = match->next;
86156+ }
86157+
86158+ if (match && (match->mode & GR_DELETED))
86159+ return match;
86160+
86161+ match = subj->obj_hash[index];
86162+
86163+ while (match && (match->inode != ino || match->device != dev ||
86164+ (match->mode & GR_DELETED))) {
86165+ match = match->next;
86166+ }
86167+
86168+ if (match && !(match->mode & GR_DELETED))
86169+ return match;
86170+ else
86171+ return NULL;
86172+}
86173+
86174+struct name_entry *
86175+__lookup_name_entry(const struct gr_policy_state *state, const char *name)
86176+{
86177+ unsigned int len = strlen(name);
86178+ unsigned int key = full_name_hash(name, len);
86179+ unsigned int index = key % state->name_set.n_size;
86180+ struct name_entry *match;
86181+
86182+ match = state->name_set.n_hash[index];
86183+
86184+ while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
86185+ match = match->next;
86186+
86187+ return match;
86188+}
86189+
86190+static struct name_entry *
86191+lookup_name_entry(const char *name)
86192+{
86193+ return __lookup_name_entry(&running_polstate, name);
86194+}
86195+
86196+static struct name_entry *
86197+lookup_name_entry_create(const char *name)
86198+{
86199+ unsigned int len = strlen(name);
86200+ unsigned int key = full_name_hash(name, len);
86201+ unsigned int index = key % running_polstate.name_set.n_size;
86202+ struct name_entry *match;
86203+
86204+ match = running_polstate.name_set.n_hash[index];
86205+
86206+ while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
86207+ !match->deleted))
86208+ match = match->next;
86209+
86210+ if (match && match->deleted)
86211+ return match;
86212+
86213+ match = running_polstate.name_set.n_hash[index];
86214+
86215+ while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
86216+ match->deleted))
86217+ match = match->next;
86218+
86219+ if (match && !match->deleted)
86220+ return match;
86221+ else
86222+ return NULL;
86223+}
86224+
86225+static struct inodev_entry *
86226+lookup_inodev_entry(const u64 ino, const dev_t dev)
86227+{
86228+ unsigned int index = gr_fhash(ino, dev, running_polstate.inodev_set.i_size);
86229+ struct inodev_entry *match;
86230+
86231+ match = running_polstate.inodev_set.i_hash[index];
86232+
86233+ while (match && (match->nentry->inode != ino || match->nentry->device != dev))
86234+ match = match->next;
86235+
86236+ return match;
86237+}
86238+
86239+void
86240+__insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry)
86241+{
86242+ unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
86243+ state->inodev_set.i_size);
86244+ struct inodev_entry **curr;
86245+
86246+ entry->prev = NULL;
86247+
86248+ curr = &state->inodev_set.i_hash[index];
86249+ if (*curr != NULL)
86250+ (*curr)->prev = entry;
86251+
86252+ entry->next = *curr;
86253+ *curr = entry;
86254+
86255+ return;
86256+}
86257+
86258+static void
86259+insert_inodev_entry(struct inodev_entry *entry)
86260+{
86261+ __insert_inodev_entry(&running_polstate, entry);
86262+}
86263+
86264+void
86265+insert_acl_obj_label(struct acl_object_label *obj,
86266+ struct acl_subject_label *subj)
86267+{
86268+ unsigned int index =
86269+ gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
86270+ struct acl_object_label **curr;
86271+
86272+ obj->prev = NULL;
86273+
86274+ curr = &subj->obj_hash[index];
86275+ if (*curr != NULL)
86276+ (*curr)->prev = obj;
86277+
86278+ obj->next = *curr;
86279+ *curr = obj;
86280+
86281+ return;
86282+}
86283+
86284+void
86285+insert_acl_subj_label(struct acl_subject_label *obj,
86286+ struct acl_role_label *role)
86287+{
86288+ unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
86289+ struct acl_subject_label **curr;
86290+
86291+ obj->prev = NULL;
86292+
86293+ curr = &role->subj_hash[index];
86294+ if (*curr != NULL)
86295+ (*curr)->prev = obj;
86296+
86297+ obj->next = *curr;
86298+ *curr = obj;
86299+
86300+ return;
86301+}
86302+
86303+/* derived from glibc fnmatch() 0: match, 1: no match*/
86304+
86305+static int
86306+glob_match(const char *p, const char *n)
86307+{
86308+ char c;
86309+
86310+ while ((c = *p++) != '\0') {
86311+ switch (c) {
86312+ case '?':
86313+ if (*n == '\0')
86314+ return 1;
86315+ else if (*n == '/')
86316+ return 1;
86317+ break;
86318+ case '\\':
86319+ if (*n != c)
86320+ return 1;
86321+ break;
86322+ case '*':
86323+ for (c = *p++; c == '?' || c == '*'; c = *p++) {
86324+ if (*n == '/')
86325+ return 1;
86326+ else if (c == '?') {
86327+ if (*n == '\0')
86328+ return 1;
86329+ else
86330+ ++n;
86331+ }
86332+ }
86333+ if (c == '\0') {
86334+ return 0;
86335+ } else {
86336+ const char *endp;
86337+
86338+ if ((endp = strchr(n, '/')) == NULL)
86339+ endp = n + strlen(n);
86340+
86341+ if (c == '[') {
86342+ for (--p; n < endp; ++n)
86343+ if (!glob_match(p, n))
86344+ return 0;
86345+ } else if (c == '/') {
86346+ while (*n != '\0' && *n != '/')
86347+ ++n;
86348+ if (*n == '/' && !glob_match(p, n + 1))
86349+ return 0;
86350+ } else {
86351+ for (--p; n < endp; ++n)
86352+ if (*n == c && !glob_match(p, n))
86353+ return 0;
86354+ }
86355+
86356+ return 1;
86357+ }
86358+ case '[':
86359+ {
86360+ int not;
86361+ char cold;
86362+
86363+ if (*n == '\0' || *n == '/')
86364+ return 1;
86365+
86366+ not = (*p == '!' || *p == '^');
86367+ if (not)
86368+ ++p;
86369+
86370+ c = *p++;
86371+ for (;;) {
86372+ unsigned char fn = (unsigned char)*n;
86373+
86374+ if (c == '\0')
86375+ return 1;
86376+ else {
86377+ if (c == fn)
86378+ goto matched;
86379+ cold = c;
86380+ c = *p++;
86381+
86382+ if (c == '-' && *p != ']') {
86383+ unsigned char cend = *p++;
86384+
86385+ if (cend == '\0')
86386+ return 1;
86387+
86388+ if (cold <= fn && fn <= cend)
86389+ goto matched;
86390+
86391+ c = *p++;
86392+ }
86393+ }
86394+
86395+ if (c == ']')
86396+ break;
86397+ }
86398+ if (!not)
86399+ return 1;
86400+ break;
86401+ matched:
86402+ while (c != ']') {
86403+ if (c == '\0')
86404+ return 1;
86405+
86406+ c = *p++;
86407+ }
86408+ if (not)
86409+ return 1;
86410+ }
86411+ break;
86412+ default:
86413+ if (c != *n)
86414+ return 1;
86415+ }
86416+
86417+ ++n;
86418+ }
86419+
86420+ if (*n == '\0')
86421+ return 0;
86422+
86423+ if (*n == '/')
86424+ return 0;
86425+
86426+ return 1;
86427+}
86428+
86429+static struct acl_object_label *
86430+chk_glob_label(struct acl_object_label *globbed,
86431+ const struct dentry *dentry, const struct vfsmount *mnt, char **path)
86432+{
86433+ struct acl_object_label *tmp;
86434+
86435+ if (*path == NULL)
86436+ *path = gr_to_filename_nolock(dentry, mnt);
86437+
86438+ tmp = globbed;
86439+
86440+ while (tmp) {
86441+ if (!glob_match(tmp->filename, *path))
86442+ return tmp;
86443+ tmp = tmp->next;
86444+ }
86445+
86446+ return NULL;
86447+}
86448+
86449+static struct acl_object_label *
86450+__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
86451+ const u64 curr_ino, const dev_t curr_dev,
86452+ const struct acl_subject_label *subj, char **path, const int checkglob)
86453+{
86454+ struct acl_subject_label *tmpsubj;
86455+ struct acl_object_label *retval;
86456+ struct acl_object_label *retval2;
86457+
86458+ tmpsubj = (struct acl_subject_label *) subj;
86459+ read_lock(&gr_inode_lock);
86460+ do {
86461+ retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
86462+ if (retval) {
86463+ if (checkglob && retval->globbed) {
86464+ retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
86465+ if (retval2)
86466+ retval = retval2;
86467+ }
86468+ break;
86469+ }
86470+ } while ((tmpsubj = tmpsubj->parent_subject));
86471+ read_unlock(&gr_inode_lock);
86472+
86473+ return retval;
86474+}
86475+
86476+static struct acl_object_label *
86477+full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
86478+ struct dentry *curr_dentry,
86479+ const struct acl_subject_label *subj, char **path, const int checkglob)
86480+{
86481+ int newglob = checkglob;
86482+ u64 inode;
86483+ dev_t device;
86484+
86485+ /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
86486+ as we don't want a / * rule to match instead of the / object
86487+ don't do this for create lookups that call this function though, since they're looking up
86488+ on the parent and thus need globbing checks on all paths
86489+ */
86490+ if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
86491+ newglob = GR_NO_GLOB;
86492+
86493+ spin_lock(&curr_dentry->d_lock);
86494+ inode = __get_ino(curr_dentry);
86495+ device = __get_dev(curr_dentry);
86496+ spin_unlock(&curr_dentry->d_lock);
86497+
86498+ return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
86499+}
86500+
86501+#ifdef CONFIG_HUGETLBFS
86502+static inline bool
86503+is_hugetlbfs_mnt(const struct vfsmount *mnt)
86504+{
86505+ int i;
86506+ for (i = 0; i < HUGE_MAX_HSTATE; i++) {
86507+ if (unlikely(hugetlbfs_vfsmount[i] == mnt))
86508+ return true;
86509+ }
86510+
86511+ return false;
86512+}
86513+#endif
86514+
86515+static struct acl_object_label *
86516+__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86517+ const struct acl_subject_label *subj, char *path, const int checkglob)
86518+{
86519+ struct dentry *dentry = (struct dentry *) l_dentry;
86520+ struct vfsmount *mnt = (struct vfsmount *) l_mnt;
86521+ struct inode * inode = d_backing_inode(dentry);
86522+ struct mount *real_mnt = real_mount(mnt);
86523+ struct acl_object_label *retval;
86524+ struct dentry *parent;
86525+
86526+ read_seqlock_excl(&mount_lock);
86527+ write_seqlock(&rename_lock);
86528+
86529+ if (unlikely((mnt == shm_mnt && inode->i_nlink == 0) || mnt == pipe_mnt ||
86530+#ifdef CONFIG_NET
86531+ mnt == sock_mnt ||
86532+#endif
86533+#ifdef CONFIG_HUGETLBFS
86534+ (is_hugetlbfs_mnt(mnt) && inode->i_nlink == 0) ||
86535+#endif
86536+ /* ignore Eric Biederman */
86537+ IS_PRIVATE(inode))) {
86538+ retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
86539+ goto out;
86540+ }
86541+
86542+ for (;;) {
86543+ if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
86544+ break;
86545+
86546+ if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
86547+ if (!mnt_has_parent(real_mnt))
86548+ break;
86549+
86550+ retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
86551+ if (retval != NULL)
86552+ goto out;
86553+
86554+ dentry = real_mnt->mnt_mountpoint;
86555+ real_mnt = real_mnt->mnt_parent;
86556+ mnt = &real_mnt->mnt;
86557+ continue;
86558+ }
86559+
86560+ parent = dentry->d_parent;
86561+ retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
86562+ if (retval != NULL)
86563+ goto out;
86564+
86565+ dentry = parent;
86566+ }
86567+
86568+ retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
86569+
86570+ /* gr_real_root is pinned so we don't have to hold a reference */
86571+ if (retval == NULL)
86572+ retval = full_lookup(l_dentry, l_mnt, gr_real_root.dentry, subj, &path, checkglob);
86573+out:
86574+ write_sequnlock(&rename_lock);
86575+ read_sequnlock_excl(&mount_lock);
86576+
86577+ BUG_ON(retval == NULL);
86578+
86579+ return retval;
86580+}
86581+
86582+static struct acl_object_label *
86583+chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86584+ const struct acl_subject_label *subj)
86585+{
86586+ char *path = NULL;
86587+ return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
86588+}
86589+
86590+static struct acl_object_label *
86591+chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86592+ const struct acl_subject_label *subj)
86593+{
86594+ char *path = NULL;
86595+ return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
86596+}
86597+
86598+static struct acl_object_label *
86599+chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86600+ const struct acl_subject_label *subj, char *path)
86601+{
86602+ return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
86603+}
86604+
86605+struct acl_subject_label *
86606+chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86607+ const struct acl_role_label *role)
86608+{
86609+ struct dentry *dentry = (struct dentry *) l_dentry;
86610+ struct vfsmount *mnt = (struct vfsmount *) l_mnt;
86611+ struct mount *real_mnt = real_mount(mnt);
86612+ struct acl_subject_label *retval;
86613+ struct dentry *parent;
86614+
86615+ read_seqlock_excl(&mount_lock);
86616+ write_seqlock(&rename_lock);
86617+
86618+ for (;;) {
86619+ if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
86620+ break;
86621+ if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
86622+ if (!mnt_has_parent(real_mnt))
86623+ break;
86624+
86625+ spin_lock(&dentry->d_lock);
86626+ read_lock(&gr_inode_lock);
86627+ retval =
86628+ lookup_acl_subj_label(__get_ino(dentry),
86629+ __get_dev(dentry), role);
86630+ read_unlock(&gr_inode_lock);
86631+ spin_unlock(&dentry->d_lock);
86632+ if (retval != NULL)
86633+ goto out;
86634+
86635+ dentry = real_mnt->mnt_mountpoint;
86636+ real_mnt = real_mnt->mnt_parent;
86637+ mnt = &real_mnt->mnt;
86638+ continue;
86639+ }
86640+
86641+ spin_lock(&dentry->d_lock);
86642+ read_lock(&gr_inode_lock);
86643+ retval = lookup_acl_subj_label(__get_ino(dentry),
86644+ __get_dev(dentry), role);
86645+ read_unlock(&gr_inode_lock);
86646+ parent = dentry->d_parent;
86647+ spin_unlock(&dentry->d_lock);
86648+
86649+ if (retval != NULL)
86650+ goto out;
86651+
86652+ dentry = parent;
86653+ }
86654+
86655+ spin_lock(&dentry->d_lock);
86656+ read_lock(&gr_inode_lock);
86657+ retval = lookup_acl_subj_label(__get_ino(dentry),
86658+ __get_dev(dentry), role);
86659+ read_unlock(&gr_inode_lock);
86660+ spin_unlock(&dentry->d_lock);
86661+
86662+ if (unlikely(retval == NULL)) {
86663+ /* gr_real_root is pinned, we don't need to hold a reference */
86664+ read_lock(&gr_inode_lock);
86665+ retval = lookup_acl_subj_label(__get_ino(gr_real_root.dentry),
86666+ __get_dev(gr_real_root.dentry), role);
86667+ read_unlock(&gr_inode_lock);
86668+ }
86669+out:
86670+ write_sequnlock(&rename_lock);
86671+ read_sequnlock_excl(&mount_lock);
86672+
86673+ BUG_ON(retval == NULL);
86674+
86675+ return retval;
86676+}
86677+
86678+void
86679+assign_special_role(const char *rolename)
86680+{
86681+ struct acl_object_label *obj;
86682+ struct acl_role_label *r;
86683+ struct acl_role_label *assigned = NULL;
86684+ struct task_struct *tsk;
86685+ struct file *filp;
86686+
86687+ FOR_EACH_ROLE_START(r)
86688+ if (!strcmp(rolename, r->rolename) &&
86689+ (r->roletype & GR_ROLE_SPECIAL)) {
86690+ assigned = r;
86691+ break;
86692+ }
86693+ FOR_EACH_ROLE_END(r)
86694+
86695+ if (!assigned)
86696+ return;
86697+
86698+ read_lock(&tasklist_lock);
86699+ read_lock(&grsec_exec_file_lock);
86700+
86701+ tsk = current->real_parent;
86702+ if (tsk == NULL)
86703+ goto out_unlock;
86704+
86705+ filp = tsk->exec_file;
86706+ if (filp == NULL)
86707+ goto out_unlock;
86708+
86709+ tsk->is_writable = 0;
86710+ tsk->inherited = 0;
86711+
86712+ tsk->acl_sp_role = 1;
86713+ tsk->acl_role_id = ++acl_sp_role_value;
86714+ tsk->role = assigned;
86715+ tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
86716+
86717+ /* ignore additional mmap checks for processes that are writable
86718+ by the default ACL */
86719+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
86720+ if (unlikely(obj->mode & GR_WRITE))
86721+ tsk->is_writable = 1;
86722+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
86723+ if (unlikely(obj->mode & GR_WRITE))
86724+ tsk->is_writable = 1;
86725+
86726+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
86727+ printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename,
86728+ tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
86729+#endif
86730+
86731+out_unlock:
86732+ read_unlock(&grsec_exec_file_lock);
86733+ read_unlock(&tasklist_lock);
86734+ return;
86735+}
86736+
86737+
86738+static void
86739+gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
86740+{
86741+ struct task_struct *task = current;
86742+ const struct cred *cred = current_cred();
86743+
86744+ security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
86745+ GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
86746+ task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
86747+ 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
86748+
86749+ return;
86750+}
86751+
86752+static void
86753+gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
86754+{
86755+ struct task_struct *task = current;
86756+ const struct cred *cred = current_cred();
86757+
86758+ security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
86759+ GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
86760+ task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
86761+ 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
86762+
86763+ return;
86764+}
86765+
86766+static void
86767+gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
86768+{
86769+ struct task_struct *task = current;
86770+ const struct cred *cred = current_cred();
86771+
86772+ security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
86773+ GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
86774+ task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
86775+ 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
86776+
86777+ return;
86778+}
86779+
86780+static void
86781+gr_set_proc_res(struct task_struct *task)
86782+{
86783+ struct acl_subject_label *proc;
86784+ unsigned short i;
86785+
86786+ proc = task->acl;
86787+
86788+ if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
86789+ return;
86790+
86791+ for (i = 0; i < RLIM_NLIMITS; i++) {
86792+ unsigned long rlim_cur, rlim_max;
86793+
86794+ if (!(proc->resmask & (1U << i)))
86795+ continue;
86796+
86797+ rlim_cur = proc->res[i].rlim_cur;
86798+ rlim_max = proc->res[i].rlim_max;
86799+
86800+ if (i == RLIMIT_NOFILE) {
86801+ unsigned long saved_sysctl_nr_open = sysctl_nr_open;
86802+ if (rlim_cur > saved_sysctl_nr_open)
86803+ rlim_cur = saved_sysctl_nr_open;
86804+ if (rlim_max > saved_sysctl_nr_open)
86805+ rlim_max = saved_sysctl_nr_open;
86806+ }
86807+
86808+ task->signal->rlim[i].rlim_cur = rlim_cur;
86809+ task->signal->rlim[i].rlim_max = rlim_max;
86810+
86811+ if (i == RLIMIT_CPU)
86812+ update_rlimit_cpu(task, rlim_cur);
86813+ }
86814+
86815+ return;
86816+}
86817+
86818+/* both of the below must be called with
86819+ rcu_read_lock();
86820+ read_lock(&tasklist_lock);
86821+ read_lock(&grsec_exec_file_lock);
86822+ except in the case of gr_set_role_label() (for __gr_get_subject_for_task)
86823+*/
86824+
86825+struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename, int fallback)
86826+{
86827+ char *tmpname;
86828+ struct acl_subject_label *tmpsubj;
86829+ struct file *filp;
86830+ struct name_entry *nmatch;
86831+
86832+ filp = task->exec_file;
86833+ if (filp == NULL)
86834+ return NULL;
86835+
86836+ /* the following is to apply the correct subject
86837+ on binaries running when the RBAC system
86838+ is enabled, when the binaries have been
86839+ replaced or deleted since their execution
86840+ -----
86841+ when the RBAC system starts, the inode/dev
86842+ from exec_file will be one the RBAC system
86843+ is unaware of. It only knows the inode/dev
86844+ of the present file on disk, or the absence
86845+ of it.
86846+ */
86847+
86848+ if (filename)
86849+ nmatch = __lookup_name_entry(state, filename);
86850+ else {
86851+ preempt_disable();
86852+ tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
86853+
86854+ nmatch = __lookup_name_entry(state, tmpname);
86855+ preempt_enable();
86856+ }
86857+ tmpsubj = NULL;
86858+ if (nmatch) {
86859+ if (nmatch->deleted)
86860+ tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
86861+ else
86862+ tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
86863+ }
86864+ /* this also works for the reload case -- if we don't match a potentially inherited subject
86865+ then we fall back to a normal lookup based on the binary's ino/dev
86866+ */
86867+ if (tmpsubj == NULL && fallback)
86868+ tmpsubj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, task->role);
86869+
86870+ return tmpsubj;
86871+}
86872+
86873+static struct acl_subject_label *gr_get_subject_for_task(struct task_struct *task, const char *filename, int fallback)
86874+{
86875+ return __gr_get_subject_for_task(&running_polstate, task, filename, fallback);
86876+}
86877+
86878+void __gr_apply_subject_to_task(const struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj)
86879+{
86880+ struct acl_object_label *obj;
86881+ struct file *filp;
86882+
86883+ filp = task->exec_file;
86884+
86885+ task->acl = subj;
86886+ task->is_writable = 0;
86887+ /* ignore additional mmap checks for processes that are writable
86888+ by the default ACL */
86889+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, state->default_role->root_label);
86890+ if (unlikely(obj->mode & GR_WRITE))
86891+ task->is_writable = 1;
86892+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
86893+ if (unlikely(obj->mode & GR_WRITE))
86894+ task->is_writable = 1;
86895+
86896+ gr_set_proc_res(task);
86897+
86898+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
86899+ 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);
86900+#endif
86901+}
86902+
86903+static void gr_apply_subject_to_task(struct task_struct *task, struct acl_subject_label *subj)
86904+{
86905+ __gr_apply_subject_to_task(&running_polstate, task, subj);
86906+}
86907+
86908+__u32
86909+gr_search_file(const struct dentry * dentry, const __u32 mode,
86910+ const struct vfsmount * mnt)
86911+{
86912+ __u32 retval = mode;
86913+ struct acl_subject_label *curracl;
86914+ struct acl_object_label *currobj;
86915+
86916+ if (unlikely(!(gr_status & GR_READY)))
86917+ return (mode & ~GR_AUDITS);
86918+
86919+ curracl = current->acl;
86920+
86921+ currobj = chk_obj_label(dentry, mnt, curracl);
86922+ retval = currobj->mode & mode;
86923+
86924+ /* if we're opening a specified transfer file for writing
86925+ (e.g. /dev/initctl), then transfer our role to init
86926+ */
86927+ if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
86928+ current->role->roletype & GR_ROLE_PERSIST)) {
86929+ struct task_struct *task = init_pid_ns.child_reaper;
86930+
86931+ if (task->role != current->role) {
86932+ struct acl_subject_label *subj;
86933+
86934+ task->acl_sp_role = 0;
86935+ task->acl_role_id = current->acl_role_id;
86936+ task->role = current->role;
86937+ rcu_read_lock();
86938+ read_lock(&grsec_exec_file_lock);
86939+ subj = gr_get_subject_for_task(task, NULL, 1);
86940+ gr_apply_subject_to_task(task, subj);
86941+ read_unlock(&grsec_exec_file_lock);
86942+ rcu_read_unlock();
86943+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
86944+ }
86945+ }
86946+
86947+ if (unlikely
86948+ ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
86949+ && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
86950+ __u32 new_mode = mode;
86951+
86952+ new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
86953+
86954+ retval = new_mode;
86955+
86956+ if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
86957+ new_mode |= GR_INHERIT;
86958+
86959+ if (!(mode & GR_NOLEARN))
86960+ gr_log_learn(dentry, mnt, new_mode);
86961+ }
86962+
86963+ return retval;
86964+}
86965+
86966+struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
86967+ const struct dentry *parent,
86968+ const struct vfsmount *mnt)
86969+{
86970+ struct name_entry *match;
86971+ struct acl_object_label *matchpo;
86972+ struct acl_subject_label *curracl;
86973+ char *path;
86974+
86975+ if (unlikely(!(gr_status & GR_READY)))
86976+ return NULL;
86977+
86978+ preempt_disable();
86979+ path = gr_to_filename_rbac(new_dentry, mnt);
86980+ match = lookup_name_entry_create(path);
86981+
86982+ curracl = current->acl;
86983+
86984+ if (match) {
86985+ read_lock(&gr_inode_lock);
86986+ matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
86987+ read_unlock(&gr_inode_lock);
86988+
86989+ if (matchpo) {
86990+ preempt_enable();
86991+ return matchpo;
86992+ }
86993+ }
86994+
86995+ // lookup parent
86996+
86997+ matchpo = chk_obj_create_label(parent, mnt, curracl, path);
86998+
86999+ preempt_enable();
87000+ return matchpo;
87001+}
87002+
87003+__u32
87004+gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
87005+ const struct vfsmount * mnt, const __u32 mode)
87006+{
87007+ struct acl_object_label *matchpo;
87008+ __u32 retval;
87009+
87010+ if (unlikely(!(gr_status & GR_READY)))
87011+ return (mode & ~GR_AUDITS);
87012+
87013+ matchpo = gr_get_create_object(new_dentry, parent, mnt);
87014+
87015+ retval = matchpo->mode & mode;
87016+
87017+ if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
87018+ && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
87019+ __u32 new_mode = mode;
87020+
87021+ new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
87022+
87023+ gr_log_learn(new_dentry, mnt, new_mode);
87024+ return new_mode;
87025+ }
87026+
87027+ return retval;
87028+}
87029+
87030+__u32
87031+gr_check_link(const struct dentry * new_dentry,
87032+ const struct dentry * parent_dentry,
87033+ const struct vfsmount * parent_mnt,
87034+ const struct dentry * old_dentry, const struct vfsmount * old_mnt)
87035+{
87036+ struct acl_object_label *obj;
87037+ __u32 oldmode, newmode;
87038+ __u32 needmode;
87039+ __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
87040+ GR_DELETE | GR_INHERIT;
87041+
87042+ if (unlikely(!(gr_status & GR_READY)))
87043+ return (GR_CREATE | GR_LINK);
87044+
87045+ obj = chk_obj_label(old_dentry, old_mnt, current->acl);
87046+ oldmode = obj->mode;
87047+
87048+ obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
87049+ newmode = obj->mode;
87050+
87051+ needmode = newmode & checkmodes;
87052+
87053+ // old name for hardlink must have at least the permissions of the new name
87054+ if ((oldmode & needmode) != needmode)
87055+ goto bad;
87056+
87057+ // if old name had restrictions/auditing, make sure the new name does as well
87058+ needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
87059+
87060+ // don't allow hardlinking of suid/sgid/fcapped files without permission
87061+ if (is_privileged_binary(old_dentry))
87062+ needmode |= GR_SETID;
87063+
87064+ if ((newmode & needmode) != needmode)
87065+ goto bad;
87066+
87067+ // enforce minimum permissions
87068+ if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
87069+ return newmode;
87070+bad:
87071+ needmode = oldmode;
87072+ if (is_privileged_binary(old_dentry))
87073+ needmode |= GR_SETID;
87074+
87075+ if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
87076+ gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
87077+ return (GR_CREATE | GR_LINK);
87078+ } else if (newmode & GR_SUPPRESS)
87079+ return GR_SUPPRESS;
87080+ else
87081+ return 0;
87082+}
87083+
87084+int
87085+gr_check_hidden_task(const struct task_struct *task)
87086+{
87087+ if (unlikely(!(gr_status & GR_READY)))
87088+ return 0;
87089+
87090+ if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
87091+ return 1;
87092+
87093+ return 0;
87094+}
87095+
87096+int
87097+gr_check_protected_task(const struct task_struct *task)
87098+{
87099+ if (unlikely(!(gr_status & GR_READY) || !task))
87100+ return 0;
87101+
87102+ if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
87103+ task->acl != current->acl)
87104+ return 1;
87105+
87106+ return 0;
87107+}
87108+
87109+int
87110+gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
87111+{
87112+ struct task_struct *p;
87113+ int ret = 0;
87114+
87115+ if (unlikely(!(gr_status & GR_READY) || !pid))
87116+ return ret;
87117+
87118+ read_lock(&tasklist_lock);
87119+ do_each_pid_task(pid, type, p) {
87120+ if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
87121+ p->acl != current->acl) {
87122+ ret = 1;
87123+ goto out;
87124+ }
87125+ } while_each_pid_task(pid, type, p);
87126+out:
87127+ read_unlock(&tasklist_lock);
87128+
87129+ return ret;
87130+}
87131+
87132+void
87133+gr_copy_label(struct task_struct *tsk)
87134+{
87135+ struct task_struct *p = current;
87136+
87137+ tsk->inherited = p->inherited;
87138+ tsk->acl_sp_role = 0;
87139+ tsk->acl_role_id = p->acl_role_id;
87140+ tsk->acl = p->acl;
87141+ tsk->role = p->role;
87142+ tsk->signal->used_accept = 0;
87143+ tsk->signal->curr_ip = p->signal->curr_ip;
87144+ tsk->signal->saved_ip = p->signal->saved_ip;
87145+ if (p->exec_file)
87146+ get_file(p->exec_file);
87147+ tsk->exec_file = p->exec_file;
87148+ tsk->is_writable = p->is_writable;
87149+ if (unlikely(p->signal->used_accept)) {
87150+ p->signal->curr_ip = 0;
87151+ p->signal->saved_ip = 0;
87152+ }
87153+
87154+ return;
87155+}
87156+
87157+extern int gr_process_kernel_setuid_ban(struct user_struct *user);
87158+
87159+int
87160+gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
87161+{
87162+ unsigned int i;
87163+ __u16 num;
87164+ uid_t *uidlist;
87165+ uid_t curuid;
87166+ int realok = 0;
87167+ int effectiveok = 0;
87168+ int fsok = 0;
87169+ uid_t globalreal, globaleffective, globalfs;
87170+
87171+#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
87172+ struct user_struct *user;
87173+
87174+ if (!uid_valid(real))
87175+ goto skipit;
87176+
87177+ /* find user based on global namespace */
87178+
87179+ globalreal = GR_GLOBAL_UID(real);
87180+
87181+ user = find_user(make_kuid(&init_user_ns, globalreal));
87182+ if (user == NULL)
87183+ goto skipit;
87184+
87185+ if (gr_process_kernel_setuid_ban(user)) {
87186+ /* for find_user */
87187+ free_uid(user);
87188+ return 1;
87189+ }
87190+
87191+ /* for find_user */
87192+ free_uid(user);
87193+
87194+skipit:
87195+#endif
87196+
87197+ if (unlikely(!(gr_status & GR_READY)))
87198+ return 0;
87199+
87200+ if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
87201+ gr_log_learn_uid_change(real, effective, fs);
87202+
87203+ num = current->acl->user_trans_num;
87204+ uidlist = current->acl->user_transitions;
87205+
87206+ if (uidlist == NULL)
87207+ return 0;
87208+
87209+ if (!uid_valid(real)) {
87210+ realok = 1;
87211+ globalreal = (uid_t)-1;
87212+ } else {
87213+ globalreal = GR_GLOBAL_UID(real);
87214+ }
87215+ if (!uid_valid(effective)) {
87216+ effectiveok = 1;
87217+ globaleffective = (uid_t)-1;
87218+ } else {
87219+ globaleffective = GR_GLOBAL_UID(effective);
87220+ }
87221+ if (!uid_valid(fs)) {
87222+ fsok = 1;
87223+ globalfs = (uid_t)-1;
87224+ } else {
87225+ globalfs = GR_GLOBAL_UID(fs);
87226+ }
87227+
87228+ if (current->acl->user_trans_type & GR_ID_ALLOW) {
87229+ for (i = 0; i < num; i++) {
87230+ curuid = uidlist[i];
87231+ if (globalreal == curuid)
87232+ realok = 1;
87233+ if (globaleffective == curuid)
87234+ effectiveok = 1;
87235+ if (globalfs == curuid)
87236+ fsok = 1;
87237+ }
87238+ } else if (current->acl->user_trans_type & GR_ID_DENY) {
87239+ for (i = 0; i < num; i++) {
87240+ curuid = uidlist[i];
87241+ if (globalreal == curuid)
87242+ break;
87243+ if (globaleffective == curuid)
87244+ break;
87245+ if (globalfs == curuid)
87246+ break;
87247+ }
87248+ /* not in deny list */
87249+ if (i == num) {
87250+ realok = 1;
87251+ effectiveok = 1;
87252+ fsok = 1;
87253+ }
87254+ }
87255+
87256+ if (realok && effectiveok && fsok)
87257+ return 0;
87258+ else {
87259+ gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
87260+ return 1;
87261+ }
87262+}
87263+
87264+int
87265+gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
87266+{
87267+ unsigned int i;
87268+ __u16 num;
87269+ gid_t *gidlist;
87270+ gid_t curgid;
87271+ int realok = 0;
87272+ int effectiveok = 0;
87273+ int fsok = 0;
87274+ gid_t globalreal, globaleffective, globalfs;
87275+
87276+ if (unlikely(!(gr_status & GR_READY)))
87277+ return 0;
87278+
87279+ if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
87280+ gr_log_learn_gid_change(real, effective, fs);
87281+
87282+ num = current->acl->group_trans_num;
87283+ gidlist = current->acl->group_transitions;
87284+
87285+ if (gidlist == NULL)
87286+ return 0;
87287+
87288+ if (!gid_valid(real)) {
87289+ realok = 1;
87290+ globalreal = (gid_t)-1;
87291+ } else {
87292+ globalreal = GR_GLOBAL_GID(real);
87293+ }
87294+ if (!gid_valid(effective)) {
87295+ effectiveok = 1;
87296+ globaleffective = (gid_t)-1;
87297+ } else {
87298+ globaleffective = GR_GLOBAL_GID(effective);
87299+ }
87300+ if (!gid_valid(fs)) {
87301+ fsok = 1;
87302+ globalfs = (gid_t)-1;
87303+ } else {
87304+ globalfs = GR_GLOBAL_GID(fs);
87305+ }
87306+
87307+ if (current->acl->group_trans_type & GR_ID_ALLOW) {
87308+ for (i = 0; i < num; i++) {
87309+ curgid = gidlist[i];
87310+ if (globalreal == curgid)
87311+ realok = 1;
87312+ if (globaleffective == curgid)
87313+ effectiveok = 1;
87314+ if (globalfs == curgid)
87315+ fsok = 1;
87316+ }
87317+ } else if (current->acl->group_trans_type & GR_ID_DENY) {
87318+ for (i = 0; i < num; i++) {
87319+ curgid = gidlist[i];
87320+ if (globalreal == curgid)
87321+ break;
87322+ if (globaleffective == curgid)
87323+ break;
87324+ if (globalfs == curgid)
87325+ break;
87326+ }
87327+ /* not in deny list */
87328+ if (i == num) {
87329+ realok = 1;
87330+ effectiveok = 1;
87331+ fsok = 1;
87332+ }
87333+ }
87334+
87335+ if (realok && effectiveok && fsok)
87336+ return 0;
87337+ else {
87338+ gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
87339+ return 1;
87340+ }
87341+}
87342+
87343+extern int gr_acl_is_capable(const int cap);
87344+
87345+void
87346+gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
87347+{
87348+ struct acl_role_label *role = task->role;
87349+ struct acl_role_label *origrole = role;
87350+ struct acl_subject_label *subj = NULL;
87351+ struct acl_object_label *obj;
87352+ struct file *filp;
87353+ uid_t uid;
87354+ gid_t gid;
87355+
87356+ if (unlikely(!(gr_status & GR_READY)))
87357+ return;
87358+
87359+ uid = GR_GLOBAL_UID(kuid);
87360+ gid = GR_GLOBAL_GID(kgid);
87361+
87362+ filp = task->exec_file;
87363+
87364+ /* kernel process, we'll give them the kernel role */
87365+ if (unlikely(!filp)) {
87366+ task->role = running_polstate.kernel_role;
87367+ task->acl = running_polstate.kernel_role->root_label;
87368+ return;
87369+ } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL)) {
87370+ /* save the current ip at time of role lookup so that the proper
87371+ IP will be learned for role_allowed_ip */
87372+ task->signal->saved_ip = task->signal->curr_ip;
87373+ role = lookup_acl_role_label(task, uid, gid);
87374+ }
87375+
87376+ /* don't change the role if we're not a privileged process */
87377+ if (role && task->role != role &&
87378+ (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
87379+ ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
87380+ return;
87381+
87382+ task->role = role;
87383+
87384+ if (task->inherited) {
87385+ /* if we reached our subject through inheritance, then first see
87386+ if there's a subject of the same name in the new role that has
87387+ an object that would result in the same inherited subject
87388+ */
87389+ subj = gr_get_subject_for_task(task, task->acl->filename, 0);
87390+ if (subj) {
87391+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, subj);
87392+ if (!(obj->mode & GR_INHERIT))
87393+ subj = NULL;
87394+ }
87395+
87396+ }
87397+ if (subj == NULL) {
87398+ /* otherwise:
87399+ perform subject lookup in possibly new role
87400+ we can use this result below in the case where role == task->role
87401+ */
87402+ subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
87403+ }
87404+
87405+ /* if we changed uid/gid, but result in the same role
87406+ and are using inheritance, don't lose the inherited subject
87407+ if current subject is other than what normal lookup
87408+ would result in, we arrived via inheritance, don't
87409+ lose subject
87410+ */
87411+ if (role != origrole || (!(task->acl->mode & GR_INHERITLEARN) &&
87412+ (subj == task->acl)))
87413+ task->acl = subj;
87414+
87415+ /* leave task->inherited unaffected */
87416+
87417+ task->is_writable = 0;
87418+
87419+ /* ignore additional mmap checks for processes that are writable
87420+ by the default ACL */
87421+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
87422+ if (unlikely(obj->mode & GR_WRITE))
87423+ task->is_writable = 1;
87424+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
87425+ if (unlikely(obj->mode & GR_WRITE))
87426+ task->is_writable = 1;
87427+
87428+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
87429+ 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);
87430+#endif
87431+
87432+ gr_set_proc_res(task);
87433+
87434+ return;
87435+}
87436+
87437+int
87438+gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
87439+ const int unsafe_flags)
87440+{
87441+ struct task_struct *task = current;
87442+ struct acl_subject_label *newacl;
87443+ struct acl_object_label *obj;
87444+ __u32 retmode;
87445+
87446+ if (unlikely(!(gr_status & GR_READY)))
87447+ return 0;
87448+
87449+ newacl = chk_subj_label(dentry, mnt, task->role);
87450+
87451+ /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
87452+ did an exec
87453+ */
87454+ rcu_read_lock();
87455+ read_lock(&tasklist_lock);
87456+ if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
87457+ (task->parent->acl->mode & GR_POVERRIDE))) {
87458+ read_unlock(&tasklist_lock);
87459+ rcu_read_unlock();
87460+ goto skip_check;
87461+ }
87462+ read_unlock(&tasklist_lock);
87463+ rcu_read_unlock();
87464+
87465+ if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
87466+ !(task->role->roletype & GR_ROLE_GOD) &&
87467+ !gr_search_file(dentry, GR_PTRACERD, mnt) &&
87468+ !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
87469+ if (unsafe_flags & LSM_UNSAFE_SHARE)
87470+ gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
87471+ else
87472+ gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
87473+ return -EACCES;
87474+ }
87475+
87476+skip_check:
87477+
87478+ obj = chk_obj_label(dentry, mnt, task->acl);
87479+ retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
87480+
87481+ if (!(task->acl->mode & GR_INHERITLEARN) &&
87482+ ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
87483+ if (obj->nested)
87484+ task->acl = obj->nested;
87485+ else
87486+ task->acl = newacl;
87487+ task->inherited = 0;
87488+ } else {
87489+ task->inherited = 1;
87490+ if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
87491+ gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
87492+ }
87493+
87494+ task->is_writable = 0;
87495+
87496+ /* ignore additional mmap checks for processes that are writable
87497+ by the default ACL */
87498+ obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
87499+ if (unlikely(obj->mode & GR_WRITE))
87500+ task->is_writable = 1;
87501+ obj = chk_obj_label(dentry, mnt, task->role->root_label);
87502+ if (unlikely(obj->mode & GR_WRITE))
87503+ task->is_writable = 1;
87504+
87505+ gr_set_proc_res(task);
87506+
87507+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
87508+ 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);
87509+#endif
87510+ return 0;
87511+}
87512+
87513+/* always called with valid inodev ptr */
87514+static void
87515+do_handle_delete(struct inodev_entry *inodev, const u64 ino, const dev_t dev)
87516+{
87517+ struct acl_object_label *matchpo;
87518+ struct acl_subject_label *matchps;
87519+ struct acl_subject_label *subj;
87520+ struct acl_role_label *role;
87521+ unsigned int x;
87522+
87523+ FOR_EACH_ROLE_START(role)
87524+ FOR_EACH_SUBJECT_START(role, subj, x)
87525+ if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
87526+ matchpo->mode |= GR_DELETED;
87527+ FOR_EACH_SUBJECT_END(subj,x)
87528+ FOR_EACH_NESTED_SUBJECT_START(role, subj)
87529+ /* nested subjects aren't in the role's subj_hash table */
87530+ if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
87531+ matchpo->mode |= GR_DELETED;
87532+ FOR_EACH_NESTED_SUBJECT_END(subj)
87533+ if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
87534+ matchps->mode |= GR_DELETED;
87535+ FOR_EACH_ROLE_END(role)
87536+
87537+ inodev->nentry->deleted = 1;
87538+
87539+ return;
87540+}
87541+
87542+void
87543+gr_handle_delete(const u64 ino, const dev_t dev)
87544+{
87545+ struct inodev_entry *inodev;
87546+
87547+ if (unlikely(!(gr_status & GR_READY)))
87548+ return;
87549+
87550+ write_lock(&gr_inode_lock);
87551+ inodev = lookup_inodev_entry(ino, dev);
87552+ if (inodev != NULL)
87553+ do_handle_delete(inodev, ino, dev);
87554+ write_unlock(&gr_inode_lock);
87555+
87556+ return;
87557+}
87558+
87559+static void
87560+update_acl_obj_label(const u64 oldinode, const dev_t olddevice,
87561+ const u64 newinode, const dev_t newdevice,
87562+ struct acl_subject_label *subj)
87563+{
87564+ unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
87565+ struct acl_object_label *match;
87566+
87567+ match = subj->obj_hash[index];
87568+
87569+ while (match && (match->inode != oldinode ||
87570+ match->device != olddevice ||
87571+ !(match->mode & GR_DELETED)))
87572+ match = match->next;
87573+
87574+ if (match && (match->inode == oldinode)
87575+ && (match->device == olddevice)
87576+ && (match->mode & GR_DELETED)) {
87577+ if (match->prev == NULL) {
87578+ subj->obj_hash[index] = match->next;
87579+ if (match->next != NULL)
87580+ match->next->prev = NULL;
87581+ } else {
87582+ match->prev->next = match->next;
87583+ if (match->next != NULL)
87584+ match->next->prev = match->prev;
87585+ }
87586+ match->prev = NULL;
87587+ match->next = NULL;
87588+ match->inode = newinode;
87589+ match->device = newdevice;
87590+ match->mode &= ~GR_DELETED;
87591+
87592+ insert_acl_obj_label(match, subj);
87593+ }
87594+
87595+ return;
87596+}
87597+
87598+static void
87599+update_acl_subj_label(const u64 oldinode, const dev_t olddevice,
87600+ const u64 newinode, const dev_t newdevice,
87601+ struct acl_role_label *role)
87602+{
87603+ unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
87604+ struct acl_subject_label *match;
87605+
87606+ match = role->subj_hash[index];
87607+
87608+ while (match && (match->inode != oldinode ||
87609+ match->device != olddevice ||
87610+ !(match->mode & GR_DELETED)))
87611+ match = match->next;
87612+
87613+ if (match && (match->inode == oldinode)
87614+ && (match->device == olddevice)
87615+ && (match->mode & GR_DELETED)) {
87616+ if (match->prev == NULL) {
87617+ role->subj_hash[index] = match->next;
87618+ if (match->next != NULL)
87619+ match->next->prev = NULL;
87620+ } else {
87621+ match->prev->next = match->next;
87622+ if (match->next != NULL)
87623+ match->next->prev = match->prev;
87624+ }
87625+ match->prev = NULL;
87626+ match->next = NULL;
87627+ match->inode = newinode;
87628+ match->device = newdevice;
87629+ match->mode &= ~GR_DELETED;
87630+
87631+ insert_acl_subj_label(match, role);
87632+ }
87633+
87634+ return;
87635+}
87636+
87637+static void
87638+update_inodev_entry(const u64 oldinode, const dev_t olddevice,
87639+ const u64 newinode, const dev_t newdevice)
87640+{
87641+ unsigned int index = gr_fhash(oldinode, olddevice, running_polstate.inodev_set.i_size);
87642+ struct inodev_entry *match;
87643+
87644+ match = running_polstate.inodev_set.i_hash[index];
87645+
87646+ while (match && (match->nentry->inode != oldinode ||
87647+ match->nentry->device != olddevice || !match->nentry->deleted))
87648+ match = match->next;
87649+
87650+ if (match && (match->nentry->inode == oldinode)
87651+ && (match->nentry->device == olddevice) &&
87652+ match->nentry->deleted) {
87653+ if (match->prev == NULL) {
87654+ running_polstate.inodev_set.i_hash[index] = match->next;
87655+ if (match->next != NULL)
87656+ match->next->prev = NULL;
87657+ } else {
87658+ match->prev->next = match->next;
87659+ if (match->next != NULL)
87660+ match->next->prev = match->prev;
87661+ }
87662+ match->prev = NULL;
87663+ match->next = NULL;
87664+ match->nentry->inode = newinode;
87665+ match->nentry->device = newdevice;
87666+ match->nentry->deleted = 0;
87667+
87668+ insert_inodev_entry(match);
87669+ }
87670+
87671+ return;
87672+}
87673+
87674+static void
87675+__do_handle_create(const struct name_entry *matchn, u64 ino, dev_t dev)
87676+{
87677+ struct acl_subject_label *subj;
87678+ struct acl_role_label *role;
87679+ unsigned int x;
87680+
87681+ FOR_EACH_ROLE_START(role)
87682+ update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
87683+
87684+ FOR_EACH_NESTED_SUBJECT_START(role, subj)
87685+ if ((subj->inode == ino) && (subj->device == dev)) {
87686+ subj->inode = ino;
87687+ subj->device = dev;
87688+ }
87689+ /* nested subjects aren't in the role's subj_hash table */
87690+ update_acl_obj_label(matchn->inode, matchn->device,
87691+ ino, dev, subj);
87692+ FOR_EACH_NESTED_SUBJECT_END(subj)
87693+ FOR_EACH_SUBJECT_START(role, subj, x)
87694+ update_acl_obj_label(matchn->inode, matchn->device,
87695+ ino, dev, subj);
87696+ FOR_EACH_SUBJECT_END(subj,x)
87697+ FOR_EACH_ROLE_END(role)
87698+
87699+ update_inodev_entry(matchn->inode, matchn->device, ino, dev);
87700+
87701+ return;
87702+}
87703+
87704+static void
87705+do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
87706+ const struct vfsmount *mnt)
87707+{
87708+ u64 ino = __get_ino(dentry);
87709+ dev_t dev = __get_dev(dentry);
87710+
87711+ __do_handle_create(matchn, ino, dev);
87712+
87713+ return;
87714+}
87715+
87716+void
87717+gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
87718+{
87719+ struct name_entry *matchn;
87720+
87721+ if (unlikely(!(gr_status & GR_READY)))
87722+ return;
87723+
87724+ preempt_disable();
87725+ matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
87726+
87727+ if (unlikely((unsigned long)matchn)) {
87728+ write_lock(&gr_inode_lock);
87729+ do_handle_create(matchn, dentry, mnt);
87730+ write_unlock(&gr_inode_lock);
87731+ }
87732+ preempt_enable();
87733+
87734+ return;
87735+}
87736+
87737+void
87738+gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
87739+{
87740+ struct name_entry *matchn;
87741+
87742+ if (unlikely(!(gr_status & GR_READY)))
87743+ return;
87744+
87745+ preempt_disable();
87746+ matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
87747+
87748+ if (unlikely((unsigned long)matchn)) {
87749+ write_lock(&gr_inode_lock);
87750+ __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
87751+ write_unlock(&gr_inode_lock);
87752+ }
87753+ preempt_enable();
87754+
87755+ return;
87756+}
87757+
87758+void
87759+gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
87760+ struct dentry *old_dentry,
87761+ struct dentry *new_dentry,
87762+ struct vfsmount *mnt, const __u8 replace, unsigned int flags)
87763+{
87764+ struct name_entry *matchn;
87765+ struct name_entry *matchn2 = NULL;
87766+ struct inodev_entry *inodev;
87767+ struct inode *inode = d_backing_inode(new_dentry);
87768+ struct inode *old_inode = d_backing_inode(old_dentry);
87769+ u64 old_ino = __get_ino(old_dentry);
87770+ dev_t old_dev = __get_dev(old_dentry);
87771+ unsigned int exchange = flags & RENAME_EXCHANGE;
87772+
87773+ /* vfs_rename swaps the name and parent link for old_dentry and
87774+ new_dentry
87775+ at this point, old_dentry has the new name, parent link, and inode
87776+ for the renamed file
87777+ if a file is being replaced by a rename, new_dentry has the inode
87778+ and name for the replaced file
87779+ */
87780+
87781+ if (unlikely(!(gr_status & GR_READY)))
87782+ return;
87783+
87784+ preempt_disable();
87785+ matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
87786+
87787+ /* exchange cases:
87788+ a filename exists for the source, but not dest
87789+ do a recreate on source
87790+ a filename exists for the dest, but not source
87791+ do a recreate on dest
87792+ a filename exists for both source and dest
87793+ delete source and dest, then create source and dest
87794+ a filename exists for neither source nor dest
87795+ no updates needed
87796+
87797+ the name entry lookups get us the old inode/dev associated with
87798+ each name, so do the deletes first (if possible) so that when
87799+ we do the create, we pick up on the right entries
87800+ */
87801+
87802+ if (exchange)
87803+ matchn2 = lookup_name_entry(gr_to_filename_rbac(new_dentry, mnt));
87804+
87805+ /* we wouldn't have to check d_inode if it weren't for
87806+ NFS silly-renaming
87807+ */
87808+
87809+ write_lock(&gr_inode_lock);
87810+ if (unlikely((replace || exchange) && inode)) {
87811+ u64 new_ino = __get_ino(new_dentry);
87812+ dev_t new_dev = __get_dev(new_dentry);
87813+
87814+ inodev = lookup_inodev_entry(new_ino, new_dev);
87815+ if (inodev != NULL && ((inode->i_nlink <= 1) || d_is_dir(new_dentry)))
87816+ do_handle_delete(inodev, new_ino, new_dev);
87817+ }
87818+
87819+ inodev = lookup_inodev_entry(old_ino, old_dev);
87820+ if (inodev != NULL && ((old_inode->i_nlink <= 1) || d_is_dir(old_dentry)))
87821+ do_handle_delete(inodev, old_ino, old_dev);
87822+
87823+ if (unlikely(matchn != NULL))
87824+ do_handle_create(matchn, old_dentry, mnt);
87825+
87826+ if (unlikely(matchn2 != NULL))
87827+ do_handle_create(matchn2, new_dentry, mnt);
87828+
87829+ write_unlock(&gr_inode_lock);
87830+ preempt_enable();
87831+
87832+ return;
87833+}
87834+
87835+#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
87836+static const unsigned long res_learn_bumps[GR_NLIMITS] = {
87837+ [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
87838+ [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
87839+ [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
87840+ [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
87841+ [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
87842+ [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
87843+ [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
87844+ [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
87845+ [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
87846+ [RLIMIT_AS] = GR_RLIM_AS_BUMP,
87847+ [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
87848+ [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
87849+ [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
87850+ [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
87851+ [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
87852+ [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
87853+};
87854+
87855+void
87856+gr_learn_resource(const struct task_struct *task,
87857+ const int res, const unsigned long wanted, const int gt)
87858+{
87859+ struct acl_subject_label *acl;
87860+ const struct cred *cred;
87861+
87862+ if (unlikely((gr_status & GR_READY) &&
87863+ task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
87864+ goto skip_reslog;
87865+
87866+ gr_log_resource(task, res, wanted, gt);
87867+skip_reslog:
87868+
87869+ if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
87870+ return;
87871+
87872+ acl = task->acl;
87873+
87874+ if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
87875+ !(acl->resmask & (1U << (unsigned short) res))))
87876+ return;
87877+
87878+ if (wanted >= acl->res[res].rlim_cur) {
87879+ unsigned long res_add;
87880+
87881+ res_add = wanted + res_learn_bumps[res];
87882+
87883+ acl->res[res].rlim_cur = res_add;
87884+
87885+ if (wanted > acl->res[res].rlim_max)
87886+ acl->res[res].rlim_max = res_add;
87887+
87888+ /* only log the subject filename, since resource logging is supported for
87889+ single-subject learning only */
87890+ rcu_read_lock();
87891+ cred = __task_cred(task);
87892+ security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
87893+ task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
87894+ acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
87895+ "", (unsigned long) res, &task->signal->saved_ip);
87896+ rcu_read_unlock();
87897+ }
87898+
87899+ return;
87900+}
87901+EXPORT_SYMBOL_GPL(gr_learn_resource);
87902+#endif
87903+
87904+#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
87905+void
87906+pax_set_initial_flags(struct linux_binprm *bprm)
87907+{
87908+ struct task_struct *task = current;
87909+ struct acl_subject_label *proc;
87910+ unsigned long flags;
87911+
87912+ if (unlikely(!(gr_status & GR_READY)))
87913+ return;
87914+
87915+ flags = pax_get_flags(task);
87916+
87917+ proc = task->acl;
87918+
87919+ if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
87920+ flags &= ~MF_PAX_PAGEEXEC;
87921+ if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
87922+ flags &= ~MF_PAX_SEGMEXEC;
87923+ if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
87924+ flags &= ~MF_PAX_RANDMMAP;
87925+ if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
87926+ flags &= ~MF_PAX_EMUTRAMP;
87927+ if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
87928+ flags &= ~MF_PAX_MPROTECT;
87929+
87930+ if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
87931+ flags |= MF_PAX_PAGEEXEC;
87932+ if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
87933+ flags |= MF_PAX_SEGMEXEC;
87934+ if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
87935+ flags |= MF_PAX_RANDMMAP;
87936+ if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
87937+ flags |= MF_PAX_EMUTRAMP;
87938+ if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
87939+ flags |= MF_PAX_MPROTECT;
87940+
87941+ pax_set_flags(task, flags);
87942+
87943+ return;
87944+}
87945+#endif
87946+
87947+int
87948+gr_handle_proc_ptrace(struct task_struct *task)
87949+{
87950+ struct file *filp;
87951+ struct task_struct *tmp = task;
87952+ struct task_struct *curtemp = current;
87953+ __u32 retmode;
87954+
87955+#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
87956+ if (unlikely(!(gr_status & GR_READY)))
87957+ return 0;
87958+#endif
87959+
87960+ read_lock(&tasklist_lock);
87961+ read_lock(&grsec_exec_file_lock);
87962+ filp = task->exec_file;
87963+
87964+ while (task_pid_nr(tmp) > 0) {
87965+ if (tmp == curtemp)
87966+ break;
87967+ tmp = tmp->real_parent;
87968+ }
87969+
87970+ if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
87971+ ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
87972+ read_unlock(&grsec_exec_file_lock);
87973+ read_unlock(&tasklist_lock);
87974+ return 1;
87975+ }
87976+
87977+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
87978+ if (!(gr_status & GR_READY)) {
87979+ read_unlock(&grsec_exec_file_lock);
87980+ read_unlock(&tasklist_lock);
87981+ return 0;
87982+ }
87983+#endif
87984+
87985+ retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
87986+ read_unlock(&grsec_exec_file_lock);
87987+ read_unlock(&tasklist_lock);
87988+
87989+ if (retmode & GR_NOPTRACE)
87990+ return 1;
87991+
87992+ if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
87993+ && (current->acl != task->acl || (current->acl != current->role->root_label
87994+ && task_pid_nr(current) != task_pid_nr(task))))
87995+ return 1;
87996+
87997+ return 0;
87998+}
87999+
88000+void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
88001+{
88002+ if (unlikely(!(gr_status & GR_READY)))
88003+ return;
88004+
88005+ if (!(current->role->roletype & GR_ROLE_GOD))
88006+ return;
88007+
88008+ seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
88009+ p->role->rolename, gr_task_roletype_to_char(p),
88010+ p->acl->filename);
88011+}
88012+
88013+int
88014+gr_handle_ptrace(struct task_struct *task, const long request)
88015+{
88016+ struct task_struct *tmp = task;
88017+ struct task_struct *curtemp = current;
88018+ __u32 retmode;
88019+
88020+#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
88021+ if (unlikely(!(gr_status & GR_READY)))
88022+ return 0;
88023+#endif
88024+ if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
88025+ read_lock(&tasklist_lock);
88026+ while (task_pid_nr(tmp) > 0) {
88027+ if (tmp == curtemp)
88028+ break;
88029+ tmp = tmp->real_parent;
88030+ }
88031+
88032+ if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
88033+ ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
88034+ read_unlock(&tasklist_lock);
88035+ gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
88036+ return 1;
88037+ }
88038+ read_unlock(&tasklist_lock);
88039+ }
88040+
88041+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
88042+ if (!(gr_status & GR_READY))
88043+ return 0;
88044+#endif
88045+
88046+ read_lock(&grsec_exec_file_lock);
88047+ if (unlikely(!task->exec_file)) {
88048+ read_unlock(&grsec_exec_file_lock);
88049+ return 0;
88050+ }
88051+
88052+ retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
88053+ read_unlock(&grsec_exec_file_lock);
88054+
88055+ if (retmode & GR_NOPTRACE) {
88056+ gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
88057+ return 1;
88058+ }
88059+
88060+ if (retmode & GR_PTRACERD) {
88061+ switch (request) {
88062+ case PTRACE_SEIZE:
88063+ case PTRACE_POKETEXT:
88064+ case PTRACE_POKEDATA:
88065+ case PTRACE_POKEUSR:
88066+#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
88067+ case PTRACE_SETREGS:
88068+ case PTRACE_SETFPREGS:
88069+#endif
88070+#ifdef CONFIG_X86
88071+ case PTRACE_SETFPXREGS:
88072+#endif
88073+#ifdef CONFIG_ALTIVEC
88074+ case PTRACE_SETVRREGS:
88075+#endif
88076+ return 1;
88077+ default:
88078+ return 0;
88079+ }
88080+ } else if (!(current->acl->mode & GR_POVERRIDE) &&
88081+ !(current->role->roletype & GR_ROLE_GOD) &&
88082+ (current->acl != task->acl)) {
88083+ gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
88084+ return 1;
88085+ }
88086+
88087+ return 0;
88088+}
88089+
88090+static int is_writable_mmap(const struct file *filp)
88091+{
88092+ struct task_struct *task = current;
88093+ struct acl_object_label *obj, *obj2;
88094+ struct dentry *dentry = filp->f_path.dentry;
88095+ struct vfsmount *mnt = filp->f_path.mnt;
88096+ struct inode *inode = d_backing_inode(dentry);
88097+
88098+ if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
88099+ !task->is_writable && d_is_reg(dentry) && (mnt != shm_mnt || (inode->i_nlink > 0))) {
88100+ obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
88101+ obj2 = chk_obj_label(dentry, mnt, task->role->root_label);
88102+ if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
88103+ gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, dentry, mnt);
88104+ return 1;
88105+ }
88106+ }
88107+ return 0;
88108+}
88109+
88110+int
88111+gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
88112+{
88113+ __u32 mode;
88114+
88115+ if (unlikely(!file || !(prot & PROT_EXEC)))
88116+ return 1;
88117+
88118+ if (is_writable_mmap(file))
88119+ return 0;
88120+
88121+ mode =
88122+ gr_search_file(file->f_path.dentry,
88123+ GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
88124+ file->f_path.mnt);
88125+
88126+ if (!gr_tpe_allow(file))
88127+ return 0;
88128+
88129+ if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
88130+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
88131+ return 0;
88132+ } else if (unlikely(!(mode & GR_EXEC))) {
88133+ return 0;
88134+ } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
88135+ gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
88136+ return 1;
88137+ }
88138+
88139+ return 1;
88140+}
88141+
88142+int
88143+gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
88144+{
88145+ __u32 mode;
88146+
88147+ if (unlikely(!file || !(prot & PROT_EXEC)))
88148+ return 1;
88149+
88150+ if (is_writable_mmap(file))
88151+ return 0;
88152+
88153+ mode =
88154+ gr_search_file(file->f_path.dentry,
88155+ GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
88156+ file->f_path.mnt);
88157+
88158+ if (!gr_tpe_allow(file))
88159+ return 0;
88160+
88161+ if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
88162+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
88163+ return 0;
88164+ } else if (unlikely(!(mode & GR_EXEC))) {
88165+ return 0;
88166+ } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
88167+ gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
88168+ return 1;
88169+ }
88170+
88171+ return 1;
88172+}
88173+
88174+void
88175+gr_acl_handle_psacct(struct task_struct *task, const long code)
88176+{
88177+ unsigned long runtime, cputime;
88178+ cputime_t utime, stime;
88179+ unsigned int wday, cday;
88180+ __u8 whr, chr;
88181+ __u8 wmin, cmin;
88182+ __u8 wsec, csec;
88183+ struct timespec curtime, starttime;
88184+
88185+ if (unlikely(!(gr_status & GR_READY) || !task->acl ||
88186+ !(task->acl->mode & GR_PROCACCT)))
88187+ return;
88188+
88189+ curtime = ns_to_timespec(ktime_get_ns());
88190+ starttime = ns_to_timespec(task->start_time);
88191+ runtime = curtime.tv_sec - starttime.tv_sec;
88192+ wday = runtime / (60 * 60 * 24);
88193+ runtime -= wday * (60 * 60 * 24);
88194+ whr = runtime / (60 * 60);
88195+ runtime -= whr * (60 * 60);
88196+ wmin = runtime / 60;
88197+ runtime -= wmin * 60;
88198+ wsec = runtime;
88199+
88200+ task_cputime(task, &utime, &stime);
88201+ cputime = cputime_to_secs(utime + stime);
88202+ cday = cputime / (60 * 60 * 24);
88203+ cputime -= cday * (60 * 60 * 24);
88204+ chr = cputime / (60 * 60);
88205+ cputime -= chr * (60 * 60);
88206+ cmin = cputime / 60;
88207+ cputime -= cmin * 60;
88208+ csec = cputime;
88209+
88210+ gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
88211+
88212+ return;
88213+}
88214+
88215+#ifdef CONFIG_TASKSTATS
88216+int gr_is_taskstats_denied(int pid)
88217+{
88218+ struct task_struct *task;
88219+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
88220+ const struct cred *cred;
88221+#endif
88222+ int ret = 0;
88223+
88224+ /* restrict taskstats viewing to un-chrooted root users
88225+ who have the 'view' subject flag if the RBAC system is enabled
88226+ */
88227+
88228+ rcu_read_lock();
88229+ read_lock(&tasklist_lock);
88230+ task = find_task_by_vpid(pid);
88231+ if (task) {
88232+#ifdef CONFIG_GRKERNSEC_CHROOT
88233+ if (proc_is_chrooted(task))
88234+ ret = -EACCES;
88235+#endif
88236+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
88237+ cred = __task_cred(task);
88238+#ifdef CONFIG_GRKERNSEC_PROC_USER
88239+ if (gr_is_global_nonroot(cred->uid))
88240+ ret = -EACCES;
88241+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
88242+ if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
88243+ ret = -EACCES;
88244+#endif
88245+#endif
88246+ if (gr_status & GR_READY) {
88247+ if (!(task->acl->mode & GR_VIEW))
88248+ ret = -EACCES;
88249+ }
88250+ } else
88251+ ret = -ENOENT;
88252+
88253+ read_unlock(&tasklist_lock);
88254+ rcu_read_unlock();
88255+
88256+ return ret;
88257+}
88258+#endif
88259+
88260+/* AUXV entries are filled via a descendant of search_binary_handler
88261+ after we've already applied the subject for the target
88262+*/
88263+int gr_acl_enable_at_secure(void)
88264+{
88265+ if (unlikely(!(gr_status & GR_READY)))
88266+ return 0;
88267+
88268+ if (current->acl->mode & GR_ATSECURE)
88269+ return 1;
88270+
88271+ return 0;
88272+}
88273+
88274+int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const u64 ino)
88275+{
88276+ struct task_struct *task = current;
88277+ struct dentry *dentry = file->f_path.dentry;
88278+ struct vfsmount *mnt = file->f_path.mnt;
88279+ struct acl_object_label *obj, *tmp;
88280+ struct acl_subject_label *subj;
88281+ unsigned int bufsize;
88282+ int is_not_root;
88283+ char *path;
88284+ dev_t dev = __get_dev(dentry);
88285+
88286+ if (unlikely(!(gr_status & GR_READY)))
88287+ return 1;
88288+
88289+ if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
88290+ return 1;
88291+
88292+ /* ignore Eric Biederman */
88293+ if (IS_PRIVATE(d_backing_inode(dentry)))
88294+ return 1;
88295+
88296+ subj = task->acl;
88297+ read_lock(&gr_inode_lock);
88298+ do {
88299+ obj = lookup_acl_obj_label(ino, dev, subj);
88300+ if (obj != NULL) {
88301+ read_unlock(&gr_inode_lock);
88302+ return (obj->mode & GR_FIND) ? 1 : 0;
88303+ }
88304+ } while ((subj = subj->parent_subject));
88305+ read_unlock(&gr_inode_lock);
88306+
88307+ /* this is purely an optimization since we're looking for an object
88308+ for the directory we're doing a readdir on
88309+ if it's possible for any globbed object to match the entry we're
88310+ filling into the directory, then the object we find here will be
88311+ an anchor point with attached globbed objects
88312+ */
88313+ obj = chk_obj_label_noglob(dentry, mnt, task->acl);
88314+ if (obj->globbed == NULL)
88315+ return (obj->mode & GR_FIND) ? 1 : 0;
88316+
88317+ is_not_root = ((obj->filename[0] == '/') &&
88318+ (obj->filename[1] == '\0')) ? 0 : 1;
88319+ bufsize = PAGE_SIZE - namelen - is_not_root;
88320+
88321+ /* check bufsize > PAGE_SIZE || bufsize == 0 */
88322+ if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
88323+ return 1;
88324+
88325+ preempt_disable();
88326+ path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
88327+ bufsize);
88328+
88329+ bufsize = strlen(path);
88330+
88331+ /* if base is "/", don't append an additional slash */
88332+ if (is_not_root)
88333+ *(path + bufsize) = '/';
88334+ memcpy(path + bufsize + is_not_root, name, namelen);
88335+ *(path + bufsize + namelen + is_not_root) = '\0';
88336+
88337+ tmp = obj->globbed;
88338+ while (tmp) {
88339+ if (!glob_match(tmp->filename, path)) {
88340+ preempt_enable();
88341+ return (tmp->mode & GR_FIND) ? 1 : 0;
88342+ }
88343+ tmp = tmp->next;
88344+ }
88345+ preempt_enable();
88346+ return (obj->mode & GR_FIND) ? 1 : 0;
88347+}
88348+
88349+void gr_put_exec_file(struct task_struct *task)
88350+{
88351+ struct file *filp;
88352+
88353+ write_lock(&grsec_exec_file_lock);
88354+ filp = task->exec_file;
88355+ task->exec_file = NULL;
88356+ write_unlock(&grsec_exec_file_lock);
88357+
88358+ if (filp)
88359+ fput(filp);
88360+
88361+ return;
88362+}
88363+
88364+
88365+#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
88366+EXPORT_SYMBOL_GPL(gr_acl_is_enabled);
88367+#endif
88368+#ifdef CONFIG_SECURITY
88369+EXPORT_SYMBOL_GPL(gr_check_user_change);
88370+EXPORT_SYMBOL_GPL(gr_check_group_change);
88371+#endif
88372+
88373diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
88374new file mode 100644
88375index 0000000..9adc75c
88376--- /dev/null
88377+++ b/grsecurity/gracl_alloc.c
88378@@ -0,0 +1,105 @@
88379+#include <linux/kernel.h>
88380+#include <linux/mm.h>
88381+#include <linux/slab.h>
88382+#include <linux/vmalloc.h>
88383+#include <linux/gracl.h>
88384+#include <linux/grsecurity.h>
88385+
88386+static struct gr_alloc_state __current_alloc_state = { 1, 1, NULL };
88387+struct gr_alloc_state *current_alloc_state = &__current_alloc_state;
88388+
88389+static int
88390+alloc_pop(void)
88391+{
88392+ if (current_alloc_state->alloc_stack_next == 1)
88393+ return 0;
88394+
88395+ kfree(current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 2]);
88396+
88397+ current_alloc_state->alloc_stack_next--;
88398+
88399+ return 1;
88400+}
88401+
88402+static int
88403+alloc_push(void *buf)
88404+{
88405+ if (current_alloc_state->alloc_stack_next >= current_alloc_state->alloc_stack_size)
88406+ return 1;
88407+
88408+ current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 1] = buf;
88409+
88410+ current_alloc_state->alloc_stack_next++;
88411+
88412+ return 0;
88413+}
88414+
88415+void *
88416+acl_alloc(unsigned long len)
88417+{
88418+ void *ret = NULL;
88419+
88420+ if (!len || len > PAGE_SIZE)
88421+ goto out;
88422+
88423+ ret = kmalloc(len, GFP_KERNEL);
88424+
88425+ if (ret) {
88426+ if (alloc_push(ret)) {
88427+ kfree(ret);
88428+ ret = NULL;
88429+ }
88430+ }
88431+
88432+out:
88433+ return ret;
88434+}
88435+
88436+void *
88437+acl_alloc_num(unsigned long num, unsigned long len)
88438+{
88439+ if (!len || (num > (PAGE_SIZE / len)))
88440+ return NULL;
88441+
88442+ return acl_alloc(num * len);
88443+}
88444+
88445+void
88446+acl_free_all(void)
88447+{
88448+ if (!current_alloc_state->alloc_stack)
88449+ return;
88450+
88451+ while (alloc_pop()) ;
88452+
88453+ if (current_alloc_state->alloc_stack) {
88454+ if ((current_alloc_state->alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
88455+ kfree(current_alloc_state->alloc_stack);
88456+ else
88457+ vfree(current_alloc_state->alloc_stack);
88458+ }
88459+
88460+ current_alloc_state->alloc_stack = NULL;
88461+ current_alloc_state->alloc_stack_size = 1;
88462+ current_alloc_state->alloc_stack_next = 1;
88463+
88464+ return;
88465+}
88466+
88467+int
88468+acl_alloc_stack_init(unsigned long size)
88469+{
88470+ if ((size * sizeof (void *)) <= PAGE_SIZE)
88471+ current_alloc_state->alloc_stack =
88472+ (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
88473+ else
88474+ current_alloc_state->alloc_stack = (void **) vmalloc(size * sizeof (void *));
88475+
88476+ current_alloc_state->alloc_stack_size = size;
88477+ current_alloc_state->alloc_stack_next = 1;
88478+
88479+ if (!current_alloc_state->alloc_stack)
88480+ return 0;
88481+ else
88482+ return 1;
88483+}
88484diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
88485new file mode 100644
88486index 0000000..1a94c11
88487--- /dev/null
88488+++ b/grsecurity/gracl_cap.c
88489@@ -0,0 +1,127 @@
88490+#include <linux/kernel.h>
88491+#include <linux/module.h>
88492+#include <linux/sched.h>
88493+#include <linux/gracl.h>
88494+#include <linux/grsecurity.h>
88495+#include <linux/grinternal.h>
88496+
88497+extern const char *captab_log[];
88498+extern int captab_log_entries;
88499+
88500+int gr_learn_cap(const struct task_struct *task, const struct cred *cred, const int cap)
88501+{
88502+ struct acl_subject_label *curracl;
88503+
88504+ if (!gr_acl_is_enabled())
88505+ return 1;
88506+
88507+ curracl = task->acl;
88508+
88509+ if (curracl->mode & (GR_LEARN | GR_INHERITLEARN)) {
88510+ security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
88511+ task->role->roletype, GR_GLOBAL_UID(cred->uid),
88512+ GR_GLOBAL_GID(cred->gid), task->exec_file ?
88513+ gr_to_filename(task->exec_file->f_path.dentry,
88514+ task->exec_file->f_path.mnt) : curracl->filename,
88515+ curracl->filename, 0UL,
88516+ 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
88517+ return 1;
88518+ }
88519+
88520+ return 0;
88521+}
88522+
88523+int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
88524+{
88525+ struct acl_subject_label *curracl;
88526+ kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
88527+ kernel_cap_t cap_audit = __cap_empty_set;
88528+
88529+ if (!gr_acl_is_enabled())
88530+ return 1;
88531+
88532+ curracl = task->acl;
88533+
88534+ cap_drop = curracl->cap_lower;
88535+ cap_mask = curracl->cap_mask;
88536+ cap_audit = curracl->cap_invert_audit;
88537+
88538+ while ((curracl = curracl->parent_subject)) {
88539+ /* if the cap isn't specified in the current computed mask but is specified in the
88540+ current level subject, and is lowered in the current level subject, then add
88541+ it to the set of dropped capabilities
88542+ otherwise, add the current level subject's mask to the current computed mask
88543+ */
88544+ if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
88545+ cap_raise(cap_mask, cap);
88546+ if (cap_raised(curracl->cap_lower, cap))
88547+ cap_raise(cap_drop, cap);
88548+ if (cap_raised(curracl->cap_invert_audit, cap))
88549+ cap_raise(cap_audit, cap);
88550+ }
88551+ }
88552+
88553+ if (!cap_raised(cap_drop, cap)) {
88554+ if (cap_raised(cap_audit, cap))
88555+ gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
88556+ return 1;
88557+ }
88558+
88559+ /* only learn the capability use if the process has the capability in the
88560+ general case, the two uses in sys.c of gr_learn_cap are an exception
88561+ to this rule to ensure any role transition involves what the full-learned
88562+ policy believes in a privileged process
88563+ */
88564+ if (cap_raised(cred->cap_effective, cap) && gr_learn_cap(task, cred, cap))
88565+ return 1;
88566+
88567+ if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
88568+ gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
88569+
88570+ return 0;
88571+}
88572+
88573+int
88574+gr_acl_is_capable(const int cap)
88575+{
88576+ return gr_task_acl_is_capable(current, current_cred(), cap);
88577+}
88578+
88579+int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
88580+{
88581+ struct acl_subject_label *curracl;
88582+ kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
88583+
88584+ if (!gr_acl_is_enabled())
88585+ return 1;
88586+
88587+ curracl = task->acl;
88588+
88589+ cap_drop = curracl->cap_lower;
88590+ cap_mask = curracl->cap_mask;
88591+
88592+ while ((curracl = curracl->parent_subject)) {
88593+ /* if the cap isn't specified in the current computed mask but is specified in the
88594+ current level subject, and is lowered in the current level subject, then add
88595+ it to the set of dropped capabilities
88596+ otherwise, add the current level subject's mask to the current computed mask
88597+ */
88598+ if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
88599+ cap_raise(cap_mask, cap);
88600+ if (cap_raised(curracl->cap_lower, cap))
88601+ cap_raise(cap_drop, cap);
88602+ }
88603+ }
88604+
88605+ if (!cap_raised(cap_drop, cap))
88606+ return 1;
88607+
88608+ return 0;
88609+}
88610+
88611+int
88612+gr_acl_is_capable_nolog(const int cap)
88613+{
88614+ return gr_task_acl_is_capable_nolog(current, cap);
88615+}
88616+
88617diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
88618new file mode 100644
88619index 0000000..a43dd06
88620--- /dev/null
88621+++ b/grsecurity/gracl_compat.c
88622@@ -0,0 +1,269 @@
88623+#include <linux/kernel.h>
88624+#include <linux/gracl.h>
88625+#include <linux/compat.h>
88626+#include <linux/gracl_compat.h>
88627+
88628+#include <asm/uaccess.h>
88629+
88630+int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
88631+{
88632+ struct gr_arg_wrapper_compat uwrapcompat;
88633+
88634+ if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
88635+ return -EFAULT;
88636+
88637+ if ((uwrapcompat.version != GRSECURITY_VERSION) ||
88638+ (uwrapcompat.size != sizeof(struct gr_arg_compat)))
88639+ return -EINVAL;
88640+
88641+ uwrap->arg = compat_ptr(uwrapcompat.arg);
88642+ uwrap->version = uwrapcompat.version;
88643+ uwrap->size = sizeof(struct gr_arg);
88644+
88645+ return 0;
88646+}
88647+
88648+int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
88649+{
88650+ struct gr_arg_compat argcompat;
88651+
88652+ if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
88653+ return -EFAULT;
88654+
88655+ arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
88656+ arg->role_db.num_pointers = argcompat.role_db.num_pointers;
88657+ arg->role_db.num_roles = argcompat.role_db.num_roles;
88658+ arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
88659+ arg->role_db.num_subjects = argcompat.role_db.num_subjects;
88660+ arg->role_db.num_objects = argcompat.role_db.num_objects;
88661+
88662+ memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
88663+ memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
88664+ memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
88665+ memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
88666+ arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
88667+ arg->segv_device = argcompat.segv_device;
88668+ arg->segv_inode = argcompat.segv_inode;
88669+ arg->segv_uid = argcompat.segv_uid;
88670+ arg->num_sprole_pws = argcompat.num_sprole_pws;
88671+ arg->mode = argcompat.mode;
88672+
88673+ return 0;
88674+}
88675+
88676+int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
88677+{
88678+ struct acl_object_label_compat objcompat;
88679+
88680+ if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
88681+ return -EFAULT;
88682+
88683+ obj->filename = compat_ptr(objcompat.filename);
88684+ obj->inode = objcompat.inode;
88685+ obj->device = objcompat.device;
88686+ obj->mode = objcompat.mode;
88687+
88688+ obj->nested = compat_ptr(objcompat.nested);
88689+ obj->globbed = compat_ptr(objcompat.globbed);
88690+
88691+ obj->prev = compat_ptr(objcompat.prev);
88692+ obj->next = compat_ptr(objcompat.next);
88693+
88694+ return 0;
88695+}
88696+
88697+int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
88698+{
88699+ unsigned int i;
88700+ struct acl_subject_label_compat subjcompat;
88701+
88702+ if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
88703+ return -EFAULT;
88704+
88705+ subj->filename = compat_ptr(subjcompat.filename);
88706+ subj->inode = subjcompat.inode;
88707+ subj->device = subjcompat.device;
88708+ subj->mode = subjcompat.mode;
88709+ subj->cap_mask = subjcompat.cap_mask;
88710+ subj->cap_lower = subjcompat.cap_lower;
88711+ subj->cap_invert_audit = subjcompat.cap_invert_audit;
88712+
88713+ for (i = 0; i < GR_NLIMITS; i++) {
88714+ if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
88715+ subj->res[i].rlim_cur = RLIM_INFINITY;
88716+ else
88717+ subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
88718+ if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
88719+ subj->res[i].rlim_max = RLIM_INFINITY;
88720+ else
88721+ subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
88722+ }
88723+ subj->resmask = subjcompat.resmask;
88724+
88725+ subj->user_trans_type = subjcompat.user_trans_type;
88726+ subj->group_trans_type = subjcompat.group_trans_type;
88727+ subj->user_transitions = compat_ptr(subjcompat.user_transitions);
88728+ subj->group_transitions = compat_ptr(subjcompat.group_transitions);
88729+ subj->user_trans_num = subjcompat.user_trans_num;
88730+ subj->group_trans_num = subjcompat.group_trans_num;
88731+
88732+ memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
88733+ memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
88734+ subj->ip_type = subjcompat.ip_type;
88735+ subj->ips = compat_ptr(subjcompat.ips);
88736+ subj->ip_num = subjcompat.ip_num;
88737+ subj->inaddr_any_override = subjcompat.inaddr_any_override;
88738+
88739+ subj->crashes = subjcompat.crashes;
88740+ subj->expires = subjcompat.expires;
88741+
88742+ subj->parent_subject = compat_ptr(subjcompat.parent_subject);
88743+ subj->hash = compat_ptr(subjcompat.hash);
88744+ subj->prev = compat_ptr(subjcompat.prev);
88745+ subj->next = compat_ptr(subjcompat.next);
88746+
88747+ subj->obj_hash = compat_ptr(subjcompat.obj_hash);
88748+ subj->obj_hash_size = subjcompat.obj_hash_size;
88749+ subj->pax_flags = subjcompat.pax_flags;
88750+
88751+ return 0;
88752+}
88753+
88754+int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
88755+{
88756+ struct acl_role_label_compat rolecompat;
88757+
88758+ if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
88759+ return -EFAULT;
88760+
88761+ role->rolename = compat_ptr(rolecompat.rolename);
88762+ role->uidgid = rolecompat.uidgid;
88763+ role->roletype = rolecompat.roletype;
88764+
88765+ role->auth_attempts = rolecompat.auth_attempts;
88766+ role->expires = rolecompat.expires;
88767+
88768+ role->root_label = compat_ptr(rolecompat.root_label);
88769+ role->hash = compat_ptr(rolecompat.hash);
88770+
88771+ role->prev = compat_ptr(rolecompat.prev);
88772+ role->next = compat_ptr(rolecompat.next);
88773+
88774+ role->transitions = compat_ptr(rolecompat.transitions);
88775+ role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
88776+ role->domain_children = compat_ptr(rolecompat.domain_children);
88777+ role->domain_child_num = rolecompat.domain_child_num;
88778+
88779+ role->umask = rolecompat.umask;
88780+
88781+ role->subj_hash = compat_ptr(rolecompat.subj_hash);
88782+ role->subj_hash_size = rolecompat.subj_hash_size;
88783+
88784+ return 0;
88785+}
88786+
88787+int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
88788+{
88789+ struct role_allowed_ip_compat roleip_compat;
88790+
88791+ if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
88792+ return -EFAULT;
88793+
88794+ roleip->addr = roleip_compat.addr;
88795+ roleip->netmask = roleip_compat.netmask;
88796+
88797+ roleip->prev = compat_ptr(roleip_compat.prev);
88798+ roleip->next = compat_ptr(roleip_compat.next);
88799+
88800+ return 0;
88801+}
88802+
88803+int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
88804+{
88805+ struct role_transition_compat trans_compat;
88806+
88807+ if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
88808+ return -EFAULT;
88809+
88810+ trans->rolename = compat_ptr(trans_compat.rolename);
88811+
88812+ trans->prev = compat_ptr(trans_compat.prev);
88813+ trans->next = compat_ptr(trans_compat.next);
88814+
88815+ return 0;
88816+
88817+}
88818+
88819+int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
88820+{
88821+ struct gr_hash_struct_compat hash_compat;
88822+
88823+ if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
88824+ return -EFAULT;
88825+
88826+ hash->table = compat_ptr(hash_compat.table);
88827+ hash->nametable = compat_ptr(hash_compat.nametable);
88828+ hash->first = compat_ptr(hash_compat.first);
88829+
88830+ hash->table_size = hash_compat.table_size;
88831+ hash->used_size = hash_compat.used_size;
88832+
88833+ hash->type = hash_compat.type;
88834+
88835+ return 0;
88836+}
88837+
88838+int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
88839+{
88840+ compat_uptr_t ptrcompat;
88841+
88842+ if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
88843+ return -EFAULT;
88844+
88845+ *(void **)ptr = compat_ptr(ptrcompat);
88846+
88847+ return 0;
88848+}
88849+
88850+int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
88851+{
88852+ struct acl_ip_label_compat ip_compat;
88853+
88854+ if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
88855+ return -EFAULT;
88856+
88857+ ip->iface = compat_ptr(ip_compat.iface);
88858+ ip->addr = ip_compat.addr;
88859+ ip->netmask = ip_compat.netmask;
88860+ ip->low = ip_compat.low;
88861+ ip->high = ip_compat.high;
88862+ ip->mode = ip_compat.mode;
88863+ ip->type = ip_compat.type;
88864+
88865+ memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
88866+
88867+ ip->prev = compat_ptr(ip_compat.prev);
88868+ ip->next = compat_ptr(ip_compat.next);
88869+
88870+ return 0;
88871+}
88872+
88873+int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
88874+{
88875+ struct sprole_pw_compat pw_compat;
88876+
88877+ if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
88878+ return -EFAULT;
88879+
88880+ pw->rolename = compat_ptr(pw_compat.rolename);
88881+ memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
88882+ memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
88883+
88884+ return 0;
88885+}
88886+
88887+size_t get_gr_arg_wrapper_size_compat(void)
88888+{
88889+ return sizeof(struct gr_arg_wrapper_compat);
88890+}
88891+
88892diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
88893new file mode 100644
88894index 0000000..fce7f71
88895--- /dev/null
88896+++ b/grsecurity/gracl_fs.c
88897@@ -0,0 +1,448 @@
88898+#include <linux/kernel.h>
88899+#include <linux/sched.h>
88900+#include <linux/types.h>
88901+#include <linux/fs.h>
88902+#include <linux/file.h>
88903+#include <linux/stat.h>
88904+#include <linux/grsecurity.h>
88905+#include <linux/grinternal.h>
88906+#include <linux/gracl.h>
88907+
88908+umode_t
88909+gr_acl_umask(void)
88910+{
88911+ if (unlikely(!gr_acl_is_enabled()))
88912+ return 0;
88913+
88914+ return current->role->umask;
88915+}
88916+
88917+__u32
88918+gr_acl_handle_hidden_file(const struct dentry * dentry,
88919+ const struct vfsmount * mnt)
88920+{
88921+ __u32 mode;
88922+
88923+ if (unlikely(d_is_negative(dentry)))
88924+ return GR_FIND;
88925+
88926+ mode =
88927+ gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
88928+
88929+ if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
88930+ gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
88931+ return mode;
88932+ } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
88933+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
88934+ return 0;
88935+ } else if (unlikely(!(mode & GR_FIND)))
88936+ return 0;
88937+
88938+ return GR_FIND;
88939+}
88940+
88941+__u32
88942+gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
88943+ int acc_mode)
88944+{
88945+ __u32 reqmode = GR_FIND;
88946+ __u32 mode;
88947+
88948+ if (unlikely(d_is_negative(dentry)))
88949+ return reqmode;
88950+
88951+ if (acc_mode & MAY_APPEND)
88952+ reqmode |= GR_APPEND;
88953+ else if (acc_mode & MAY_WRITE)
88954+ reqmode |= GR_WRITE;
88955+ if ((acc_mode & MAY_READ) && !d_is_dir(dentry))
88956+ reqmode |= GR_READ;
88957+
88958+ mode =
88959+ gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
88960+ mnt);
88961+
88962+ if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
88963+ gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
88964+ reqmode & GR_READ ? " reading" : "",
88965+ reqmode & GR_WRITE ? " writing" : reqmode &
88966+ GR_APPEND ? " appending" : "");
88967+ return reqmode;
88968+ } else
88969+ if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
88970+ {
88971+ gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
88972+ reqmode & GR_READ ? " reading" : "",
88973+ reqmode & GR_WRITE ? " writing" : reqmode &
88974+ GR_APPEND ? " appending" : "");
88975+ return 0;
88976+ } else if (unlikely((mode & reqmode) != reqmode))
88977+ return 0;
88978+
88979+ return reqmode;
88980+}
88981+
88982+__u32
88983+gr_acl_handle_creat(const struct dentry * dentry,
88984+ const struct dentry * p_dentry,
88985+ const struct vfsmount * p_mnt, int open_flags, int acc_mode,
88986+ const int imode)
88987+{
88988+ __u32 reqmode = GR_WRITE | GR_CREATE;
88989+ __u32 mode;
88990+
88991+ if (acc_mode & MAY_APPEND)
88992+ reqmode |= GR_APPEND;
88993+ // if a directory was required or the directory already exists, then
88994+ // don't count this open as a read
88995+ if ((acc_mode & MAY_READ) &&
88996+ !((open_flags & O_DIRECTORY) || d_is_dir(dentry)))
88997+ reqmode |= GR_READ;
88998+ if ((open_flags & O_CREAT) &&
88999+ ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
89000+ reqmode |= GR_SETID;
89001+
89002+ mode =
89003+ gr_check_create(dentry, p_dentry, p_mnt,
89004+ reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
89005+
89006+ if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
89007+ gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
89008+ reqmode & GR_READ ? " reading" : "",
89009+ reqmode & GR_WRITE ? " writing" : reqmode &
89010+ GR_APPEND ? " appending" : "");
89011+ return reqmode;
89012+ } else
89013+ if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
89014+ {
89015+ gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
89016+ reqmode & GR_READ ? " reading" : "",
89017+ reqmode & GR_WRITE ? " writing" : reqmode &
89018+ GR_APPEND ? " appending" : "");
89019+ return 0;
89020+ } else if (unlikely((mode & reqmode) != reqmode))
89021+ return 0;
89022+
89023+ return reqmode;
89024+}
89025+
89026+__u32
89027+gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
89028+ const int fmode)
89029+{
89030+ __u32 mode, reqmode = GR_FIND;
89031+
89032+ if ((fmode & S_IXOTH) && !d_is_dir(dentry))
89033+ reqmode |= GR_EXEC;
89034+ if (fmode & S_IWOTH)
89035+ reqmode |= GR_WRITE;
89036+ if (fmode & S_IROTH)
89037+ reqmode |= GR_READ;
89038+
89039+ mode =
89040+ gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
89041+ mnt);
89042+
89043+ if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
89044+ gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
89045+ reqmode & GR_READ ? " reading" : "",
89046+ reqmode & GR_WRITE ? " writing" : "",
89047+ reqmode & GR_EXEC ? " executing" : "");
89048+ return reqmode;
89049+ } else
89050+ if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
89051+ {
89052+ gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
89053+ reqmode & GR_READ ? " reading" : "",
89054+ reqmode & GR_WRITE ? " writing" : "",
89055+ reqmode & GR_EXEC ? " executing" : "");
89056+ return 0;
89057+ } else if (unlikely((mode & reqmode) != reqmode))
89058+ return 0;
89059+
89060+ return reqmode;
89061+}
89062+
89063+static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
89064+{
89065+ __u32 mode;
89066+
89067+ mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
89068+
89069+ if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
89070+ gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
89071+ return mode;
89072+ } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
89073+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
89074+ return 0;
89075+ } else if (unlikely((mode & (reqmode)) != (reqmode)))
89076+ return 0;
89077+
89078+ return (reqmode);
89079+}
89080+
89081+__u32
89082+gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
89083+{
89084+ return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
89085+}
89086+
89087+__u32
89088+gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
89089+{
89090+ return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
89091+}
89092+
89093+__u32
89094+gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
89095+{
89096+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
89097+}
89098+
89099+__u32
89100+gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
89101+{
89102+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
89103+}
89104+
89105+__u32
89106+gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
89107+ umode_t *modeptr)
89108+{
89109+ umode_t mode;
89110+ struct inode *inode = d_backing_inode(dentry);
89111+
89112+ *modeptr &= ~gr_acl_umask();
89113+ mode = *modeptr;
89114+
89115+ if (unlikely(inode && S_ISSOCK(inode->i_mode)))
89116+ return 1;
89117+
89118+ if (unlikely(!d_is_dir(dentry) &&
89119+ ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
89120+ return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
89121+ GR_CHMOD_ACL_MSG);
89122+ } else {
89123+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
89124+ }
89125+}
89126+
89127+__u32
89128+gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
89129+{
89130+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
89131+}
89132+
89133+__u32
89134+gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
89135+{
89136+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
89137+}
89138+
89139+__u32
89140+gr_acl_handle_removexattr(const struct dentry *dentry, const struct vfsmount *mnt)
89141+{
89142+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_REMOVEXATTR_ACL_MSG);
89143+}
89144+
89145+__u32
89146+gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
89147+{
89148+ return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
89149+}
89150+
89151+__u32
89152+gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
89153+{
89154+ return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
89155+ GR_UNIXCONNECT_ACL_MSG);
89156+}
89157+
89158+/* hardlinks require at minimum create and link permission,
89159+ any additional privilege required is based on the
89160+ privilege of the file being linked to
89161+*/
89162+__u32
89163+gr_acl_handle_link(const struct dentry * new_dentry,
89164+ const struct dentry * parent_dentry,
89165+ const struct vfsmount * parent_mnt,
89166+ const struct dentry * old_dentry,
89167+ const struct vfsmount * old_mnt, const struct filename *to)
89168+{
89169+ __u32 mode;
89170+ __u32 needmode = GR_CREATE | GR_LINK;
89171+ __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
89172+
89173+ mode =
89174+ gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
89175+ old_mnt);
89176+
89177+ if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
89178+ gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
89179+ return mode;
89180+ } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
89181+ gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
89182+ return 0;
89183+ } else if (unlikely((mode & needmode) != needmode))
89184+ return 0;
89185+
89186+ return 1;
89187+}
89188+
89189+__u32
89190+gr_acl_handle_symlink(const struct dentry * new_dentry,
89191+ const struct dentry * parent_dentry,
89192+ const struct vfsmount * parent_mnt, const struct filename *from)
89193+{
89194+ __u32 needmode = GR_WRITE | GR_CREATE;
89195+ __u32 mode;
89196+
89197+ mode =
89198+ gr_check_create(new_dentry, parent_dentry, parent_mnt,
89199+ GR_CREATE | GR_AUDIT_CREATE |
89200+ GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
89201+
89202+ if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
89203+ gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
89204+ return mode;
89205+ } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
89206+ gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
89207+ return 0;
89208+ } else if (unlikely((mode & needmode) != needmode))
89209+ return 0;
89210+
89211+ return (GR_WRITE | GR_CREATE);
89212+}
89213+
89214+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)
89215+{
89216+ __u32 mode;
89217+
89218+ mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
89219+
89220+ if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
89221+ gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
89222+ return mode;
89223+ } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
89224+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
89225+ return 0;
89226+ } else if (unlikely((mode & (reqmode)) != (reqmode)))
89227+ return 0;
89228+
89229+ return (reqmode);
89230+}
89231+
89232+__u32
89233+gr_acl_handle_mknod(const struct dentry * new_dentry,
89234+ const struct dentry * parent_dentry,
89235+ const struct vfsmount * parent_mnt,
89236+ const int mode)
89237+{
89238+ __u32 reqmode = GR_WRITE | GR_CREATE;
89239+ if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
89240+ reqmode |= GR_SETID;
89241+
89242+ return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
89243+ reqmode, GR_MKNOD_ACL_MSG);
89244+}
89245+
89246+__u32
89247+gr_acl_handle_mkdir(const struct dentry *new_dentry,
89248+ const struct dentry *parent_dentry,
89249+ const struct vfsmount *parent_mnt)
89250+{
89251+ return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
89252+ GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
89253+}
89254+
89255+#define RENAME_CHECK_SUCCESS(old, new) \
89256+ (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
89257+ ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
89258+
89259+int
89260+gr_acl_handle_rename(struct dentry *new_dentry,
89261+ struct dentry *parent_dentry,
89262+ const struct vfsmount *parent_mnt,
89263+ struct dentry *old_dentry,
89264+ struct inode *old_parent_inode,
89265+ struct vfsmount *old_mnt, const struct filename *newname, unsigned int flags)
89266+{
89267+ __u32 comp1, comp2;
89268+ int error = 0;
89269+
89270+ if (unlikely(!gr_acl_is_enabled()))
89271+ return 0;
89272+
89273+ if (flags & RENAME_EXCHANGE) {
89274+ comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
89275+ GR_AUDIT_READ | GR_AUDIT_WRITE |
89276+ GR_SUPPRESS, parent_mnt);
89277+ comp2 =
89278+ gr_search_file(old_dentry,
89279+ GR_READ | GR_WRITE | GR_AUDIT_READ |
89280+ GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
89281+ } else if (d_is_negative(new_dentry)) {
89282+ comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
89283+ GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
89284+ GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
89285+ comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
89286+ GR_DELETE | GR_AUDIT_DELETE |
89287+ GR_AUDIT_READ | GR_AUDIT_WRITE |
89288+ GR_SUPPRESS, old_mnt);
89289+ } else {
89290+ comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
89291+ GR_CREATE | GR_DELETE |
89292+ GR_AUDIT_CREATE | GR_AUDIT_DELETE |
89293+ GR_AUDIT_READ | GR_AUDIT_WRITE |
89294+ GR_SUPPRESS, parent_mnt);
89295+ comp2 =
89296+ gr_search_file(old_dentry,
89297+ GR_READ | GR_WRITE | GR_AUDIT_READ |
89298+ GR_DELETE | GR_AUDIT_DELETE |
89299+ GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
89300+ }
89301+
89302+ if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
89303+ ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
89304+ gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
89305+ else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
89306+ && !(comp2 & GR_SUPPRESS)) {
89307+ gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
89308+ error = -EACCES;
89309+ } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
89310+ error = -EACCES;
89311+
89312+ return error;
89313+}
89314+
89315+void
89316+gr_acl_handle_exit(void)
89317+{
89318+ u16 id;
89319+ char *rolename;
89320+
89321+ if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
89322+ !(current->role->roletype & GR_ROLE_PERSIST))) {
89323+ id = current->acl_role_id;
89324+ rolename = current->role->rolename;
89325+ gr_set_acls(1);
89326+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
89327+ }
89328+
89329+ gr_put_exec_file(current);
89330+ return;
89331+}
89332+
89333+int
89334+gr_acl_handle_procpidmem(const struct task_struct *task)
89335+{
89336+ if (unlikely(!gr_acl_is_enabled()))
89337+ return 0;
89338+
89339+ if (task != current && (task->acl->mode & GR_PROTPROCFD) &&
89340+ !(current->acl->mode & GR_POVERRIDE) &&
89341+ !(current->role->roletype & GR_ROLE_GOD))
89342+ return -EACCES;
89343+
89344+ return 0;
89345+}
89346diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
89347new file mode 100644
89348index 0000000..ed6ee43
89349--- /dev/null
89350+++ b/grsecurity/gracl_ip.c
89351@@ -0,0 +1,386 @@
89352+#include <linux/kernel.h>
89353+#include <asm/uaccess.h>
89354+#include <asm/errno.h>
89355+#include <net/sock.h>
89356+#include <linux/file.h>
89357+#include <linux/fs.h>
89358+#include <linux/net.h>
89359+#include <linux/in.h>
89360+#include <linux/skbuff.h>
89361+#include <linux/ip.h>
89362+#include <linux/udp.h>
89363+#include <linux/types.h>
89364+#include <linux/sched.h>
89365+#include <linux/netdevice.h>
89366+#include <linux/inetdevice.h>
89367+#include <linux/gracl.h>
89368+#include <linux/grsecurity.h>
89369+#include <linux/grinternal.h>
89370+
89371+#define GR_BIND 0x01
89372+#define GR_CONNECT 0x02
89373+#define GR_INVERT 0x04
89374+#define GR_BINDOVERRIDE 0x08
89375+#define GR_CONNECTOVERRIDE 0x10
89376+#define GR_SOCK_FAMILY 0x20
89377+
89378+static const char * gr_protocols[IPPROTO_MAX] = {
89379+ "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
89380+ "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
89381+ "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
89382+ "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
89383+ "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
89384+ "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
89385+ "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
89386+ "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
89387+ "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
89388+ "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
89389+ "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
89390+ "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
89391+ "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
89392+ "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
89393+ "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
89394+ "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
89395+ "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
89396+ "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
89397+ "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
89398+ "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
89399+ "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
89400+ "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
89401+ "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
89402+ "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
89403+ "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
89404+ "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
89405+ "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
89406+ "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
89407+ "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
89408+ "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
89409+ "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
89410+ "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
89411+ };
89412+
89413+static const char * gr_socktypes[SOCK_MAX] = {
89414+ "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
89415+ "unknown:7", "unknown:8", "unknown:9", "packet"
89416+ };
89417+
89418+static const char * gr_sockfamilies[AF_MAX+1] = {
89419+ "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
89420+ "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
89421+ "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
89422+ "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf", "alg", "nfc", "vsock"
89423+ };
89424+
89425+const char *
89426+gr_proto_to_name(unsigned char proto)
89427+{
89428+ return gr_protocols[proto];
89429+}
89430+
89431+const char *
89432+gr_socktype_to_name(unsigned char type)
89433+{
89434+ return gr_socktypes[type];
89435+}
89436+
89437+const char *
89438+gr_sockfamily_to_name(unsigned char family)
89439+{
89440+ return gr_sockfamilies[family];
89441+}
89442+
89443+extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
89444+
89445+int
89446+gr_search_socket(const int domain, const int type, const int protocol)
89447+{
89448+ struct acl_subject_label *curr;
89449+ const struct cred *cred = current_cred();
89450+
89451+ if (unlikely(!gr_acl_is_enabled()))
89452+ goto exit;
89453+
89454+ if ((domain < 0) || (type < 0) || (protocol < 0) ||
89455+ (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
89456+ goto exit; // let the kernel handle it
89457+
89458+ curr = current->acl;
89459+
89460+ if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
89461+ /* the family is allowed, if this is PF_INET allow it only if
89462+ the extra sock type/protocol checks pass */
89463+ if (domain == PF_INET)
89464+ goto inet_check;
89465+ goto exit;
89466+ } else {
89467+ if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
89468+ __u32 fakeip = 0;
89469+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
89470+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
89471+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
89472+ gr_to_filename(current->exec_file->f_path.dentry,
89473+ current->exec_file->f_path.mnt) :
89474+ curr->filename, curr->filename,
89475+ &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
89476+ &current->signal->saved_ip);
89477+ goto exit;
89478+ }
89479+ goto exit_fail;
89480+ }
89481+
89482+inet_check:
89483+ /* the rest of this checking is for IPv4 only */
89484+ if (!curr->ips)
89485+ goto exit;
89486+
89487+ if ((curr->ip_type & (1U << type)) &&
89488+ (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
89489+ goto exit;
89490+
89491+ if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
89492+ /* we don't place acls on raw sockets , and sometimes
89493+ dgram/ip sockets are opened for ioctl and not
89494+ bind/connect, so we'll fake a bind learn log */
89495+ if (type == SOCK_RAW || type == SOCK_PACKET) {
89496+ __u32 fakeip = 0;
89497+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
89498+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
89499+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
89500+ gr_to_filename(current->exec_file->f_path.dentry,
89501+ current->exec_file->f_path.mnt) :
89502+ curr->filename, curr->filename,
89503+ &fakeip, 0, type,
89504+ protocol, GR_CONNECT, &current->signal->saved_ip);
89505+ } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
89506+ __u32 fakeip = 0;
89507+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
89508+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
89509+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
89510+ gr_to_filename(current->exec_file->f_path.dentry,
89511+ current->exec_file->f_path.mnt) :
89512+ curr->filename, curr->filename,
89513+ &fakeip, 0, type,
89514+ protocol, GR_BIND, &current->signal->saved_ip);
89515+ }
89516+ /* we'll log when they use connect or bind */
89517+ goto exit;
89518+ }
89519+
89520+exit_fail:
89521+ if (domain == PF_INET)
89522+ gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
89523+ gr_socktype_to_name(type), gr_proto_to_name(protocol));
89524+ else if (rcu_access_pointer(net_families[domain]) != NULL)
89525+ gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
89526+ gr_socktype_to_name(type), protocol);
89527+
89528+ return 0;
89529+exit:
89530+ return 1;
89531+}
89532+
89533+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)
89534+{
89535+ if ((ip->mode & mode) &&
89536+ (ip_port >= ip->low) &&
89537+ (ip_port <= ip->high) &&
89538+ ((ntohl(ip_addr) & our_netmask) ==
89539+ (ntohl(our_addr) & our_netmask))
89540+ && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
89541+ && (ip->type & (1U << type))) {
89542+ if (ip->mode & GR_INVERT)
89543+ return 2; // specifically denied
89544+ else
89545+ return 1; // allowed
89546+ }
89547+
89548+ return 0; // not specifically allowed, may continue parsing
89549+}
89550+
89551+static int
89552+gr_search_connectbind(const int full_mode, struct sock *sk,
89553+ struct sockaddr_in *addr, const int type)
89554+{
89555+ char iface[IFNAMSIZ] = {0};
89556+ struct acl_subject_label *curr;
89557+ struct acl_ip_label *ip;
89558+ struct inet_sock *isk;
89559+ struct net_device *dev;
89560+ struct in_device *idev;
89561+ unsigned long i;
89562+ int ret;
89563+ int mode = full_mode & (GR_BIND | GR_CONNECT);
89564+ __u32 ip_addr = 0;
89565+ __u32 our_addr;
89566+ __u32 our_netmask;
89567+ char *p;
89568+ __u16 ip_port = 0;
89569+ const struct cred *cred = current_cred();
89570+
89571+ if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
89572+ return 0;
89573+
89574+ curr = current->acl;
89575+ isk = inet_sk(sk);
89576+
89577+ /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
89578+ if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
89579+ addr->sin_addr.s_addr = curr->inaddr_any_override;
89580+ if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
89581+ struct sockaddr_in saddr;
89582+ int err;
89583+
89584+ saddr.sin_family = AF_INET;
89585+ saddr.sin_addr.s_addr = curr->inaddr_any_override;
89586+ saddr.sin_port = isk->inet_sport;
89587+
89588+ err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
89589+ if (err)
89590+ return err;
89591+
89592+ err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
89593+ if (err)
89594+ return err;
89595+ }
89596+
89597+ if (!curr->ips)
89598+ return 0;
89599+
89600+ ip_addr = addr->sin_addr.s_addr;
89601+ ip_port = ntohs(addr->sin_port);
89602+
89603+ if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
89604+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
89605+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
89606+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
89607+ gr_to_filename(current->exec_file->f_path.dentry,
89608+ current->exec_file->f_path.mnt) :
89609+ curr->filename, curr->filename,
89610+ &ip_addr, ip_port, type,
89611+ sk->sk_protocol, mode, &current->signal->saved_ip);
89612+ return 0;
89613+ }
89614+
89615+ for (i = 0; i < curr->ip_num; i++) {
89616+ ip = *(curr->ips + i);
89617+ if (ip->iface != NULL) {
89618+ strncpy(iface, ip->iface, IFNAMSIZ - 1);
89619+ p = strchr(iface, ':');
89620+ if (p != NULL)
89621+ *p = '\0';
89622+ dev = dev_get_by_name(sock_net(sk), iface);
89623+ if (dev == NULL)
89624+ continue;
89625+ idev = in_dev_get(dev);
89626+ if (idev == NULL) {
89627+ dev_put(dev);
89628+ continue;
89629+ }
89630+ rcu_read_lock();
89631+ for_ifa(idev) {
89632+ if (!strcmp(ip->iface, ifa->ifa_label)) {
89633+ our_addr = ifa->ifa_address;
89634+ our_netmask = 0xffffffff;
89635+ ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
89636+ if (ret == 1) {
89637+ rcu_read_unlock();
89638+ in_dev_put(idev);
89639+ dev_put(dev);
89640+ return 0;
89641+ } else if (ret == 2) {
89642+ rcu_read_unlock();
89643+ in_dev_put(idev);
89644+ dev_put(dev);
89645+ goto denied;
89646+ }
89647+ }
89648+ } endfor_ifa(idev);
89649+ rcu_read_unlock();
89650+ in_dev_put(idev);
89651+ dev_put(dev);
89652+ } else {
89653+ our_addr = ip->addr;
89654+ our_netmask = ip->netmask;
89655+ ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
89656+ if (ret == 1)
89657+ return 0;
89658+ else if (ret == 2)
89659+ goto denied;
89660+ }
89661+ }
89662+
89663+denied:
89664+ if (mode == GR_BIND)
89665+ 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));
89666+ else if (mode == GR_CONNECT)
89667+ 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));
89668+
89669+ return -EACCES;
89670+}
89671+
89672+int
89673+gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
89674+{
89675+ /* always allow disconnection of dgram sockets with connect */
89676+ if (addr->sin_family == AF_UNSPEC)
89677+ return 0;
89678+ return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
89679+}
89680+
89681+int
89682+gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
89683+{
89684+ return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
89685+}
89686+
89687+int gr_search_listen(struct socket *sock)
89688+{
89689+ struct sock *sk = sock->sk;
89690+ struct sockaddr_in addr;
89691+
89692+ addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
89693+ addr.sin_port = inet_sk(sk)->inet_sport;
89694+
89695+ return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
89696+}
89697+
89698+int gr_search_accept(struct socket *sock)
89699+{
89700+ struct sock *sk = sock->sk;
89701+ struct sockaddr_in addr;
89702+
89703+ addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
89704+ addr.sin_port = inet_sk(sk)->inet_sport;
89705+
89706+ return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
89707+}
89708+
89709+int
89710+gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
89711+{
89712+ if (addr)
89713+ return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
89714+ else {
89715+ struct sockaddr_in sin;
89716+ const struct inet_sock *inet = inet_sk(sk);
89717+
89718+ sin.sin_addr.s_addr = inet->inet_daddr;
89719+ sin.sin_port = inet->inet_dport;
89720+
89721+ return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
89722+ }
89723+}
89724+
89725+int
89726+gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
89727+{
89728+ struct sockaddr_in sin;
89729+
89730+ if (unlikely(skb->len < sizeof (struct udphdr)))
89731+ return 0; // skip this packet
89732+
89733+ sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
89734+ sin.sin_port = udp_hdr(skb)->source;
89735+
89736+ return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
89737+}
89738diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
89739new file mode 100644
89740index 0000000..25f54ef
89741--- /dev/null
89742+++ b/grsecurity/gracl_learn.c
89743@@ -0,0 +1,207 @@
89744+#include <linux/kernel.h>
89745+#include <linux/mm.h>
89746+#include <linux/sched.h>
89747+#include <linux/poll.h>
89748+#include <linux/string.h>
89749+#include <linux/file.h>
89750+#include <linux/types.h>
89751+#include <linux/vmalloc.h>
89752+#include <linux/grinternal.h>
89753+
89754+extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
89755+ size_t count, loff_t *ppos);
89756+extern int gr_acl_is_enabled(void);
89757+
89758+static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
89759+static int gr_learn_attached;
89760+
89761+/* use a 512k buffer */
89762+#define LEARN_BUFFER_SIZE (512 * 1024)
89763+
89764+static DEFINE_SPINLOCK(gr_learn_lock);
89765+static DEFINE_MUTEX(gr_learn_user_mutex);
89766+
89767+/* we need to maintain two buffers, so that the kernel context of grlearn
89768+ uses a semaphore around the userspace copying, and the other kernel contexts
89769+ use a spinlock when copying into the buffer, since they cannot sleep
89770+*/
89771+static char *learn_buffer;
89772+static char *learn_buffer_user;
89773+static int learn_buffer_len;
89774+static int learn_buffer_user_len;
89775+
89776+static ssize_t
89777+read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
89778+{
89779+ DECLARE_WAITQUEUE(wait, current);
89780+ ssize_t retval = 0;
89781+
89782+ add_wait_queue(&learn_wait, &wait);
89783+ set_current_state(TASK_INTERRUPTIBLE);
89784+ do {
89785+ mutex_lock(&gr_learn_user_mutex);
89786+ spin_lock(&gr_learn_lock);
89787+ if (learn_buffer_len)
89788+ break;
89789+ spin_unlock(&gr_learn_lock);
89790+ mutex_unlock(&gr_learn_user_mutex);
89791+ if (file->f_flags & O_NONBLOCK) {
89792+ retval = -EAGAIN;
89793+ goto out;
89794+ }
89795+ if (signal_pending(current)) {
89796+ retval = -ERESTARTSYS;
89797+ goto out;
89798+ }
89799+
89800+ schedule();
89801+ } while (1);
89802+
89803+ memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
89804+ learn_buffer_user_len = learn_buffer_len;
89805+ retval = learn_buffer_len;
89806+ learn_buffer_len = 0;
89807+
89808+ spin_unlock(&gr_learn_lock);
89809+
89810+ if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
89811+ retval = -EFAULT;
89812+
89813+ mutex_unlock(&gr_learn_user_mutex);
89814+out:
89815+ set_current_state(TASK_RUNNING);
89816+ remove_wait_queue(&learn_wait, &wait);
89817+ return retval;
89818+}
89819+
89820+static unsigned int
89821+poll_learn(struct file * file, poll_table * wait)
89822+{
89823+ poll_wait(file, &learn_wait, wait);
89824+
89825+ if (learn_buffer_len)
89826+ return (POLLIN | POLLRDNORM);
89827+
89828+ return 0;
89829+}
89830+
89831+void
89832+gr_clear_learn_entries(void)
89833+{
89834+ char *tmp;
89835+
89836+ mutex_lock(&gr_learn_user_mutex);
89837+ spin_lock(&gr_learn_lock);
89838+ tmp = learn_buffer;
89839+ learn_buffer = NULL;
89840+ spin_unlock(&gr_learn_lock);
89841+ if (tmp)
89842+ vfree(tmp);
89843+ if (learn_buffer_user != NULL) {
89844+ vfree(learn_buffer_user);
89845+ learn_buffer_user = NULL;
89846+ }
89847+ learn_buffer_len = 0;
89848+ mutex_unlock(&gr_learn_user_mutex);
89849+
89850+ return;
89851+}
89852+
89853+void
89854+gr_add_learn_entry(const char *fmt, ...)
89855+{
89856+ va_list args;
89857+ unsigned int len;
89858+
89859+ if (!gr_learn_attached)
89860+ return;
89861+
89862+ spin_lock(&gr_learn_lock);
89863+
89864+ /* leave a gap at the end so we know when it's "full" but don't have to
89865+ compute the exact length of the string we're trying to append
89866+ */
89867+ if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
89868+ spin_unlock(&gr_learn_lock);
89869+ wake_up_interruptible(&learn_wait);
89870+ return;
89871+ }
89872+ if (learn_buffer == NULL) {
89873+ spin_unlock(&gr_learn_lock);
89874+ return;
89875+ }
89876+
89877+ va_start(args, fmt);
89878+ len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
89879+ va_end(args);
89880+
89881+ learn_buffer_len += len + 1;
89882+
89883+ spin_unlock(&gr_learn_lock);
89884+ wake_up_interruptible(&learn_wait);
89885+
89886+ return;
89887+}
89888+
89889+static int
89890+open_learn(struct inode *inode, struct file *file)
89891+{
89892+ if (file->f_mode & FMODE_READ && gr_learn_attached)
89893+ return -EBUSY;
89894+ if (file->f_mode & FMODE_READ) {
89895+ int retval = 0;
89896+ mutex_lock(&gr_learn_user_mutex);
89897+ if (learn_buffer == NULL)
89898+ learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
89899+ if (learn_buffer_user == NULL)
89900+ learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
89901+ if (learn_buffer == NULL) {
89902+ retval = -ENOMEM;
89903+ goto out_error;
89904+ }
89905+ if (learn_buffer_user == NULL) {
89906+ retval = -ENOMEM;
89907+ goto out_error;
89908+ }
89909+ learn_buffer_len = 0;
89910+ learn_buffer_user_len = 0;
89911+ gr_learn_attached = 1;
89912+out_error:
89913+ mutex_unlock(&gr_learn_user_mutex);
89914+ return retval;
89915+ }
89916+ return 0;
89917+}
89918+
89919+static int
89920+close_learn(struct inode *inode, struct file *file)
89921+{
89922+ if (file->f_mode & FMODE_READ) {
89923+ char *tmp = NULL;
89924+ mutex_lock(&gr_learn_user_mutex);
89925+ spin_lock(&gr_learn_lock);
89926+ tmp = learn_buffer;
89927+ learn_buffer = NULL;
89928+ spin_unlock(&gr_learn_lock);
89929+ if (tmp)
89930+ vfree(tmp);
89931+ if (learn_buffer_user != NULL) {
89932+ vfree(learn_buffer_user);
89933+ learn_buffer_user = NULL;
89934+ }
89935+ learn_buffer_len = 0;
89936+ learn_buffer_user_len = 0;
89937+ gr_learn_attached = 0;
89938+ mutex_unlock(&gr_learn_user_mutex);
89939+ }
89940+
89941+ return 0;
89942+}
89943+
89944+const struct file_operations grsec_fops = {
89945+ .read = read_learn,
89946+ .write = write_grsec_handler,
89947+ .open = open_learn,
89948+ .release = close_learn,
89949+ .poll = poll_learn,
89950+};
89951diff --git a/grsecurity/gracl_policy.c b/grsecurity/gracl_policy.c
89952new file mode 100644
89953index 0000000..0773423
89954--- /dev/null
89955+++ b/grsecurity/gracl_policy.c
89956@@ -0,0 +1,1786 @@
89957+#include <linux/kernel.h>
89958+#include <linux/module.h>
89959+#include <linux/sched.h>
89960+#include <linux/mm.h>
89961+#include <linux/file.h>
89962+#include <linux/fs.h>
89963+#include <linux/namei.h>
89964+#include <linux/mount.h>
89965+#include <linux/tty.h>
89966+#include <linux/proc_fs.h>
89967+#include <linux/lglock.h>
89968+#include <linux/slab.h>
89969+#include <linux/vmalloc.h>
89970+#include <linux/types.h>
89971+#include <linux/sysctl.h>
89972+#include <linux/netdevice.h>
89973+#include <linux/ptrace.h>
89974+#include <linux/gracl.h>
89975+#include <linux/gralloc.h>
89976+#include <linux/security.h>
89977+#include <linux/grinternal.h>
89978+#include <linux/pid_namespace.h>
89979+#include <linux/stop_machine.h>
89980+#include <linux/fdtable.h>
89981+#include <linux/percpu.h>
89982+#include <linux/lglock.h>
89983+#include <linux/hugetlb.h>
89984+#include <linux/posix-timers.h>
89985+#include "../fs/mount.h"
89986+
89987+#include <asm/uaccess.h>
89988+#include <asm/errno.h>
89989+#include <asm/mman.h>
89990+
89991+extern struct gr_policy_state *polstate;
89992+
89993+#define FOR_EACH_ROLE_START(role) \
89994+ role = polstate->role_list; \
89995+ while (role) {
89996+
89997+#define FOR_EACH_ROLE_END(role) \
89998+ role = role->prev; \
89999+ }
90000+
90001+struct path gr_real_root;
90002+
90003+extern struct gr_alloc_state *current_alloc_state;
90004+
90005+u16 acl_sp_role_value;
90006+
90007+static DEFINE_MUTEX(gr_dev_mutex);
90008+
90009+extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
90010+extern void gr_clear_learn_entries(void);
90011+
90012+struct gr_arg *gr_usermode __read_only;
90013+unsigned char *gr_system_salt __read_only;
90014+unsigned char *gr_system_sum __read_only;
90015+
90016+static unsigned int gr_auth_attempts = 0;
90017+static unsigned long gr_auth_expires = 0UL;
90018+
90019+struct acl_object_label *fakefs_obj_rw;
90020+struct acl_object_label *fakefs_obj_rwx;
90021+
90022+extern int gr_init_uidset(void);
90023+extern void gr_free_uidset(void);
90024+extern void gr_remove_uid(uid_t uid);
90025+extern int gr_find_uid(uid_t uid);
90026+
90027+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);
90028+extern void __gr_apply_subject_to_task(struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj);
90029+extern int gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb);
90030+extern void __insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry);
90031+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);
90032+extern void insert_acl_obj_label(struct acl_object_label *obj, struct acl_subject_label *subj);
90033+extern void insert_acl_subj_label(struct acl_subject_label *obj, struct acl_role_label *role);
90034+extern struct name_entry * __lookup_name_entry(const struct gr_policy_state *state, const char *name);
90035+extern char *gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt);
90036+extern struct acl_subject_label *lookup_acl_subj_label(const u64 ino, const dev_t dev, const struct acl_role_label *role);
90037+extern struct acl_subject_label *lookup_acl_subj_label_deleted(const u64 ino, const dev_t dev, const struct acl_role_label *role);
90038+extern void assign_special_role(const char *rolename);
90039+extern struct acl_subject_label *chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt, const struct acl_role_label *role);
90040+extern int gr_rbac_disable(void *unused);
90041+extern void gr_enable_rbac_system(void);
90042+
90043+static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
90044+{
90045+ if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
90046+ return -EFAULT;
90047+
90048+ return 0;
90049+}
90050+
90051+static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
90052+{
90053+ if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
90054+ return -EFAULT;
90055+
90056+ return 0;
90057+}
90058+
90059+static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
90060+{
90061+ if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
90062+ return -EFAULT;
90063+
90064+ return 0;
90065+}
90066+
90067+static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
90068+{
90069+ if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
90070+ return -EFAULT;
90071+
90072+ return 0;
90073+}
90074+
90075+static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
90076+{
90077+ if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
90078+ return -EFAULT;
90079+
90080+ return 0;
90081+}
90082+
90083+static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
90084+{
90085+ if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
90086+ return -EFAULT;
90087+
90088+ return 0;
90089+}
90090+
90091+static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
90092+{
90093+ if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
90094+ return -EFAULT;
90095+
90096+ return 0;
90097+}
90098+
90099+static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
90100+{
90101+ if (copy_from_user(trans, userp, sizeof(struct role_transition)))
90102+ return -EFAULT;
90103+
90104+ return 0;
90105+}
90106+
90107+int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
90108+{
90109+ if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
90110+ return -EFAULT;
90111+
90112+ return 0;
90113+}
90114+
90115+static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
90116+{
90117+ if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
90118+ return -EFAULT;
90119+
90120+ if ((uwrap->version != GRSECURITY_VERSION) ||
90121+ (uwrap->size != sizeof(struct gr_arg)))
90122+ return -EINVAL;
90123+
90124+ return 0;
90125+}
90126+
90127+static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
90128+{
90129+ if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
90130+ return -EFAULT;
90131+
90132+ return 0;
90133+}
90134+
90135+static size_t get_gr_arg_wrapper_size_normal(void)
90136+{
90137+ return sizeof(struct gr_arg_wrapper);
90138+}
90139+
90140+#ifdef CONFIG_COMPAT
90141+extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
90142+extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
90143+extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
90144+extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
90145+extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
90146+extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
90147+extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
90148+extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
90149+extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
90150+extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
90151+extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
90152+extern size_t get_gr_arg_wrapper_size_compat(void);
90153+
90154+int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
90155+int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
90156+int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
90157+int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
90158+int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
90159+int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
90160+int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
90161+int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
90162+int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
90163+int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
90164+int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
90165+size_t (* get_gr_arg_wrapper_size)(void) __read_only;
90166+
90167+#else
90168+#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
90169+#define copy_gr_arg copy_gr_arg_normal
90170+#define copy_gr_hash_struct copy_gr_hash_struct_normal
90171+#define copy_acl_object_label copy_acl_object_label_normal
90172+#define copy_acl_subject_label copy_acl_subject_label_normal
90173+#define copy_acl_role_label copy_acl_role_label_normal
90174+#define copy_acl_ip_label copy_acl_ip_label_normal
90175+#define copy_pointer_from_array copy_pointer_from_array_normal
90176+#define copy_sprole_pw copy_sprole_pw_normal
90177+#define copy_role_transition copy_role_transition_normal
90178+#define copy_role_allowed_ip copy_role_allowed_ip_normal
90179+#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
90180+#endif
90181+
90182+static struct acl_subject_label *
90183+lookup_subject_map(const struct acl_subject_label *userp)
90184+{
90185+ unsigned int index = gr_shash(userp, polstate->subj_map_set.s_size);
90186+ struct subject_map *match;
90187+
90188+ match = polstate->subj_map_set.s_hash[index];
90189+
90190+ while (match && match->user != userp)
90191+ match = match->next;
90192+
90193+ if (match != NULL)
90194+ return match->kernel;
90195+ else
90196+ return NULL;
90197+}
90198+
90199+static void
90200+insert_subj_map_entry(struct subject_map *subjmap)
90201+{
90202+ unsigned int index = gr_shash(subjmap->user, polstate->subj_map_set.s_size);
90203+ struct subject_map **curr;
90204+
90205+ subjmap->prev = NULL;
90206+
90207+ curr = &polstate->subj_map_set.s_hash[index];
90208+ if (*curr != NULL)
90209+ (*curr)->prev = subjmap;
90210+
90211+ subjmap->next = *curr;
90212+ *curr = subjmap;
90213+
90214+ return;
90215+}
90216+
90217+static void
90218+__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
90219+{
90220+ unsigned int index =
90221+ gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), polstate->acl_role_set.r_size);
90222+ struct acl_role_label **curr;
90223+ struct acl_role_label *tmp, *tmp2;
90224+
90225+ curr = &polstate->acl_role_set.r_hash[index];
90226+
90227+ /* simple case, slot is empty, just set it to our role */
90228+ if (*curr == NULL) {
90229+ *curr = role;
90230+ } else {
90231+ /* example:
90232+ 1 -> 2 -> 3 (adding 2 -> 3 to here)
90233+ 2 -> 3
90234+ */
90235+ /* first check to see if we can already be reached via this slot */
90236+ tmp = *curr;
90237+ while (tmp && tmp != role)
90238+ tmp = tmp->next;
90239+ if (tmp == role) {
90240+ /* we don't need to add ourselves to this slot's chain */
90241+ return;
90242+ }
90243+ /* we need to add ourselves to this chain, two cases */
90244+ if (role->next == NULL) {
90245+ /* simple case, append the current chain to our role */
90246+ role->next = *curr;
90247+ *curr = role;
90248+ } else {
90249+ /* 1 -> 2 -> 3 -> 4
90250+ 2 -> 3 -> 4
90251+ 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
90252+ */
90253+ /* trickier case: walk our role's chain until we find
90254+ the role for the start of the current slot's chain */
90255+ tmp = role;
90256+ tmp2 = *curr;
90257+ while (tmp->next && tmp->next != tmp2)
90258+ tmp = tmp->next;
90259+ if (tmp->next == tmp2) {
90260+ /* from example above, we found 3, so just
90261+ replace this slot's chain with ours */
90262+ *curr = role;
90263+ } else {
90264+ /* we didn't find a subset of our role's chain
90265+ in the current slot's chain, so append their
90266+ chain to ours, and set us as the first role in
90267+ the slot's chain
90268+
90269+ we could fold this case with the case above,
90270+ but making it explicit for clarity
90271+ */
90272+ tmp->next = tmp2;
90273+ *curr = role;
90274+ }
90275+ }
90276+ }
90277+
90278+ return;
90279+}
90280+
90281+static void
90282+insert_acl_role_label(struct acl_role_label *role)
90283+{
90284+ int i;
90285+
90286+ if (polstate->role_list == NULL) {
90287+ polstate->role_list = role;
90288+ role->prev = NULL;
90289+ } else {
90290+ role->prev = polstate->role_list;
90291+ polstate->role_list = role;
90292+ }
90293+
90294+ /* used for hash chains */
90295+ role->next = NULL;
90296+
90297+ if (role->roletype & GR_ROLE_DOMAIN) {
90298+ for (i = 0; i < role->domain_child_num; i++)
90299+ __insert_acl_role_label(role, role->domain_children[i]);
90300+ } else
90301+ __insert_acl_role_label(role, role->uidgid);
90302+}
90303+
90304+static int
90305+insert_name_entry(char *name, const u64 inode, const dev_t device, __u8 deleted)
90306+{
90307+ struct name_entry **curr, *nentry;
90308+ struct inodev_entry *ientry;
90309+ unsigned int len = strlen(name);
90310+ unsigned int key = full_name_hash(name, len);
90311+ unsigned int index = key % polstate->name_set.n_size;
90312+
90313+ curr = &polstate->name_set.n_hash[index];
90314+
90315+ while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
90316+ curr = &((*curr)->next);
90317+
90318+ if (*curr != NULL)
90319+ return 1;
90320+
90321+ nentry = acl_alloc(sizeof (struct name_entry));
90322+ if (nentry == NULL)
90323+ return 0;
90324+ ientry = acl_alloc(sizeof (struct inodev_entry));
90325+ if (ientry == NULL)
90326+ return 0;
90327+ ientry->nentry = nentry;
90328+
90329+ nentry->key = key;
90330+ nentry->name = name;
90331+ nentry->inode = inode;
90332+ nentry->device = device;
90333+ nentry->len = len;
90334+ nentry->deleted = deleted;
90335+
90336+ nentry->prev = NULL;
90337+ curr = &polstate->name_set.n_hash[index];
90338+ if (*curr != NULL)
90339+ (*curr)->prev = nentry;
90340+ nentry->next = *curr;
90341+ *curr = nentry;
90342+
90343+ /* insert us into the table searchable by inode/dev */
90344+ __insert_inodev_entry(polstate, ientry);
90345+
90346+ return 1;
90347+}
90348+
90349+/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
90350+
90351+static void *
90352+create_table(__u32 * len, int elementsize)
90353+{
90354+ unsigned int table_sizes[] = {
90355+ 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
90356+ 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
90357+ 4194301, 8388593, 16777213, 33554393, 67108859
90358+ };
90359+ void *newtable = NULL;
90360+ unsigned int pwr = 0;
90361+
90362+ while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
90363+ table_sizes[pwr] <= *len)
90364+ pwr++;
90365+
90366+ if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
90367+ return newtable;
90368+
90369+ if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
90370+ newtable =
90371+ kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
90372+ else
90373+ newtable = vmalloc(table_sizes[pwr] * elementsize);
90374+
90375+ *len = table_sizes[pwr];
90376+
90377+ return newtable;
90378+}
90379+
90380+static int
90381+init_variables(const struct gr_arg *arg, bool reload)
90382+{
90383+ struct task_struct *reaper = init_pid_ns.child_reaper;
90384+ unsigned int stacksize;
90385+
90386+ polstate->subj_map_set.s_size = arg->role_db.num_subjects;
90387+ polstate->acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
90388+ polstate->name_set.n_size = arg->role_db.num_objects;
90389+ polstate->inodev_set.i_size = arg->role_db.num_objects;
90390+
90391+ if (!polstate->subj_map_set.s_size || !polstate->acl_role_set.r_size ||
90392+ !polstate->name_set.n_size || !polstate->inodev_set.i_size)
90393+ return 1;
90394+
90395+ if (!reload) {
90396+ if (!gr_init_uidset())
90397+ return 1;
90398+ }
90399+
90400+ /* set up the stack that holds allocation info */
90401+
90402+ stacksize = arg->role_db.num_pointers + 5;
90403+
90404+ if (!acl_alloc_stack_init(stacksize))
90405+ return 1;
90406+
90407+ if (!reload) {
90408+ /* grab reference for the real root dentry and vfsmount */
90409+ get_fs_root(reaper->fs, &gr_real_root);
90410+
90411+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
90412+ 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));
90413+#endif
90414+
90415+ fakefs_obj_rw = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
90416+ if (fakefs_obj_rw == NULL)
90417+ return 1;
90418+ fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
90419+
90420+ fakefs_obj_rwx = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
90421+ if (fakefs_obj_rwx == NULL)
90422+ return 1;
90423+ fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
90424+ }
90425+
90426+ polstate->subj_map_set.s_hash =
90427+ (struct subject_map **) create_table(&polstate->subj_map_set.s_size, sizeof(void *));
90428+ polstate->acl_role_set.r_hash =
90429+ (struct acl_role_label **) create_table(&polstate->acl_role_set.r_size, sizeof(void *));
90430+ polstate->name_set.n_hash = (struct name_entry **) create_table(&polstate->name_set.n_size, sizeof(void *));
90431+ polstate->inodev_set.i_hash =
90432+ (struct inodev_entry **) create_table(&polstate->inodev_set.i_size, sizeof(void *));
90433+
90434+ if (!polstate->subj_map_set.s_hash || !polstate->acl_role_set.r_hash ||
90435+ !polstate->name_set.n_hash || !polstate->inodev_set.i_hash)
90436+ return 1;
90437+
90438+ memset(polstate->subj_map_set.s_hash, 0,
90439+ sizeof(struct subject_map *) * polstate->subj_map_set.s_size);
90440+ memset(polstate->acl_role_set.r_hash, 0,
90441+ sizeof (struct acl_role_label *) * polstate->acl_role_set.r_size);
90442+ memset(polstate->name_set.n_hash, 0,
90443+ sizeof (struct name_entry *) * polstate->name_set.n_size);
90444+ memset(polstate->inodev_set.i_hash, 0,
90445+ sizeof (struct inodev_entry *) * polstate->inodev_set.i_size);
90446+
90447+ return 0;
90448+}
90449+
90450+/* free information not needed after startup
90451+ currently contains user->kernel pointer mappings for subjects
90452+*/
90453+
90454+static void
90455+free_init_variables(void)
90456+{
90457+ __u32 i;
90458+
90459+ if (polstate->subj_map_set.s_hash) {
90460+ for (i = 0; i < polstate->subj_map_set.s_size; i++) {
90461+ if (polstate->subj_map_set.s_hash[i]) {
90462+ kfree(polstate->subj_map_set.s_hash[i]);
90463+ polstate->subj_map_set.s_hash[i] = NULL;
90464+ }
90465+ }
90466+
90467+ if ((polstate->subj_map_set.s_size * sizeof (struct subject_map *)) <=
90468+ PAGE_SIZE)
90469+ kfree(polstate->subj_map_set.s_hash);
90470+ else
90471+ vfree(polstate->subj_map_set.s_hash);
90472+ }
90473+
90474+ return;
90475+}
90476+
90477+static void
90478+free_variables(bool reload)
90479+{
90480+ struct acl_subject_label *s;
90481+ struct acl_role_label *r;
90482+ struct task_struct *task, *task2;
90483+ unsigned int x;
90484+
90485+ if (!reload) {
90486+ gr_clear_learn_entries();
90487+
90488+ read_lock(&tasklist_lock);
90489+ do_each_thread(task2, task) {
90490+ task->acl_sp_role = 0;
90491+ task->acl_role_id = 0;
90492+ task->inherited = 0;
90493+ task->acl = NULL;
90494+ task->role = NULL;
90495+ } while_each_thread(task2, task);
90496+ read_unlock(&tasklist_lock);
90497+
90498+ kfree(fakefs_obj_rw);
90499+ fakefs_obj_rw = NULL;
90500+ kfree(fakefs_obj_rwx);
90501+ fakefs_obj_rwx = NULL;
90502+
90503+ /* release the reference to the real root dentry and vfsmount */
90504+ path_put(&gr_real_root);
90505+ memset(&gr_real_root, 0, sizeof(gr_real_root));
90506+ }
90507+
90508+ /* free all object hash tables */
90509+
90510+ FOR_EACH_ROLE_START(r)
90511+ if (r->subj_hash == NULL)
90512+ goto next_role;
90513+ FOR_EACH_SUBJECT_START(r, s, x)
90514+ if (s->obj_hash == NULL)
90515+ break;
90516+ if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
90517+ kfree(s->obj_hash);
90518+ else
90519+ vfree(s->obj_hash);
90520+ FOR_EACH_SUBJECT_END(s, x)
90521+ FOR_EACH_NESTED_SUBJECT_START(r, s)
90522+ if (s->obj_hash == NULL)
90523+ break;
90524+ if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
90525+ kfree(s->obj_hash);
90526+ else
90527+ vfree(s->obj_hash);
90528+ FOR_EACH_NESTED_SUBJECT_END(s)
90529+ if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
90530+ kfree(r->subj_hash);
90531+ else
90532+ vfree(r->subj_hash);
90533+ r->subj_hash = NULL;
90534+next_role:
90535+ FOR_EACH_ROLE_END(r)
90536+
90537+ acl_free_all();
90538+
90539+ if (polstate->acl_role_set.r_hash) {
90540+ if ((polstate->acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
90541+ PAGE_SIZE)
90542+ kfree(polstate->acl_role_set.r_hash);
90543+ else
90544+ vfree(polstate->acl_role_set.r_hash);
90545+ }
90546+ if (polstate->name_set.n_hash) {
90547+ if ((polstate->name_set.n_size * sizeof (struct name_entry *)) <=
90548+ PAGE_SIZE)
90549+ kfree(polstate->name_set.n_hash);
90550+ else
90551+ vfree(polstate->name_set.n_hash);
90552+ }
90553+
90554+ if (polstate->inodev_set.i_hash) {
90555+ if ((polstate->inodev_set.i_size * sizeof (struct inodev_entry *)) <=
90556+ PAGE_SIZE)
90557+ kfree(polstate->inodev_set.i_hash);
90558+ else
90559+ vfree(polstate->inodev_set.i_hash);
90560+ }
90561+
90562+ if (!reload)
90563+ gr_free_uidset();
90564+
90565+ memset(&polstate->name_set, 0, sizeof (struct name_db));
90566+ memset(&polstate->inodev_set, 0, sizeof (struct inodev_db));
90567+ memset(&polstate->acl_role_set, 0, sizeof (struct acl_role_db));
90568+ memset(&polstate->subj_map_set, 0, sizeof (struct acl_subj_map_db));
90569+
90570+ polstate->default_role = NULL;
90571+ polstate->kernel_role = NULL;
90572+ polstate->role_list = NULL;
90573+
90574+ return;
90575+}
90576+
90577+static struct acl_subject_label *
90578+do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
90579+
90580+static int alloc_and_copy_string(char **name, unsigned int maxlen)
90581+{
90582+ unsigned int len = strnlen_user(*name, maxlen);
90583+ char *tmp;
90584+
90585+ if (!len || len >= maxlen)
90586+ return -EINVAL;
90587+
90588+ if ((tmp = (char *) acl_alloc(len)) == NULL)
90589+ return -ENOMEM;
90590+
90591+ if (copy_from_user(tmp, *name, len))
90592+ return -EFAULT;
90593+
90594+ tmp[len-1] = '\0';
90595+ *name = tmp;
90596+
90597+ return 0;
90598+}
90599+
90600+static int
90601+copy_user_glob(struct acl_object_label *obj)
90602+{
90603+ struct acl_object_label *g_tmp, **guser;
90604+ int error;
90605+
90606+ if (obj->globbed == NULL)
90607+ return 0;
90608+
90609+ guser = &obj->globbed;
90610+ while (*guser) {
90611+ g_tmp = (struct acl_object_label *)
90612+ acl_alloc(sizeof (struct acl_object_label));
90613+ if (g_tmp == NULL)
90614+ return -ENOMEM;
90615+
90616+ if (copy_acl_object_label(g_tmp, *guser))
90617+ return -EFAULT;
90618+
90619+ error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
90620+ if (error)
90621+ return error;
90622+
90623+ *guser = g_tmp;
90624+ guser = &(g_tmp->next);
90625+ }
90626+
90627+ return 0;
90628+}
90629+
90630+static int
90631+copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
90632+ struct acl_role_label *role)
90633+{
90634+ struct acl_object_label *o_tmp;
90635+ int ret;
90636+
90637+ while (userp) {
90638+ if ((o_tmp = (struct acl_object_label *)
90639+ acl_alloc(sizeof (struct acl_object_label))) == NULL)
90640+ return -ENOMEM;
90641+
90642+ if (copy_acl_object_label(o_tmp, userp))
90643+ return -EFAULT;
90644+
90645+ userp = o_tmp->prev;
90646+
90647+ ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
90648+ if (ret)
90649+ return ret;
90650+
90651+ insert_acl_obj_label(o_tmp, subj);
90652+ if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
90653+ o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
90654+ return -ENOMEM;
90655+
90656+ ret = copy_user_glob(o_tmp);
90657+ if (ret)
90658+ return ret;
90659+
90660+ if (o_tmp->nested) {
90661+ int already_copied;
90662+
90663+ o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
90664+ if (IS_ERR(o_tmp->nested))
90665+ return PTR_ERR(o_tmp->nested);
90666+
90667+ /* insert into nested subject list if we haven't copied this one yet
90668+ to prevent duplicate entries */
90669+ if (!already_copied) {
90670+ o_tmp->nested->next = role->hash->first;
90671+ role->hash->first = o_tmp->nested;
90672+ }
90673+ }
90674+ }
90675+
90676+ return 0;
90677+}
90678+
90679+static __u32
90680+count_user_subjs(struct acl_subject_label *userp)
90681+{
90682+ struct acl_subject_label s_tmp;
90683+ __u32 num = 0;
90684+
90685+ while (userp) {
90686+ if (copy_acl_subject_label(&s_tmp, userp))
90687+ break;
90688+
90689+ userp = s_tmp.prev;
90690+ }
90691+
90692+ return num;
90693+}
90694+
90695+static int
90696+copy_user_allowedips(struct acl_role_label *rolep)
90697+{
90698+ struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
90699+
90700+ ruserip = rolep->allowed_ips;
90701+
90702+ while (ruserip) {
90703+ rlast = rtmp;
90704+
90705+ if ((rtmp = (struct role_allowed_ip *)
90706+ acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
90707+ return -ENOMEM;
90708+
90709+ if (copy_role_allowed_ip(rtmp, ruserip))
90710+ return -EFAULT;
90711+
90712+ ruserip = rtmp->prev;
90713+
90714+ if (!rlast) {
90715+ rtmp->prev = NULL;
90716+ rolep->allowed_ips = rtmp;
90717+ } else {
90718+ rlast->next = rtmp;
90719+ rtmp->prev = rlast;
90720+ }
90721+
90722+ if (!ruserip)
90723+ rtmp->next = NULL;
90724+ }
90725+
90726+ return 0;
90727+}
90728+
90729+static int
90730+copy_user_transitions(struct acl_role_label *rolep)
90731+{
90732+ struct role_transition *rusertp, *rtmp = NULL, *rlast;
90733+ int error;
90734+
90735+ rusertp = rolep->transitions;
90736+
90737+ while (rusertp) {
90738+ rlast = rtmp;
90739+
90740+ if ((rtmp = (struct role_transition *)
90741+ acl_alloc(sizeof (struct role_transition))) == NULL)
90742+ return -ENOMEM;
90743+
90744+ if (copy_role_transition(rtmp, rusertp))
90745+ return -EFAULT;
90746+
90747+ rusertp = rtmp->prev;
90748+
90749+ error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
90750+ if (error)
90751+ return error;
90752+
90753+ if (!rlast) {
90754+ rtmp->prev = NULL;
90755+ rolep->transitions = rtmp;
90756+ } else {
90757+ rlast->next = rtmp;
90758+ rtmp->prev = rlast;
90759+ }
90760+
90761+ if (!rusertp)
90762+ rtmp->next = NULL;
90763+ }
90764+
90765+ return 0;
90766+}
90767+
90768+static __u32 count_user_objs(const struct acl_object_label __user *userp)
90769+{
90770+ struct acl_object_label o_tmp;
90771+ __u32 num = 0;
90772+
90773+ while (userp) {
90774+ if (copy_acl_object_label(&o_tmp, userp))
90775+ break;
90776+
90777+ userp = o_tmp.prev;
90778+ num++;
90779+ }
90780+
90781+ return num;
90782+}
90783+
90784+static struct acl_subject_label *
90785+do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
90786+{
90787+ struct acl_subject_label *s_tmp = NULL, *s_tmp2;
90788+ __u32 num_objs;
90789+ struct acl_ip_label **i_tmp, *i_utmp2;
90790+ struct gr_hash_struct ghash;
90791+ struct subject_map *subjmap;
90792+ unsigned int i_num;
90793+ int err;
90794+
90795+ if (already_copied != NULL)
90796+ *already_copied = 0;
90797+
90798+ s_tmp = lookup_subject_map(userp);
90799+
90800+ /* we've already copied this subject into the kernel, just return
90801+ the reference to it, and don't copy it over again
90802+ */
90803+ if (s_tmp) {
90804+ if (already_copied != NULL)
90805+ *already_copied = 1;
90806+ return(s_tmp);
90807+ }
90808+
90809+ if ((s_tmp = (struct acl_subject_label *)
90810+ acl_alloc(sizeof (struct acl_subject_label))) == NULL)
90811+ return ERR_PTR(-ENOMEM);
90812+
90813+ subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
90814+ if (subjmap == NULL)
90815+ return ERR_PTR(-ENOMEM);
90816+
90817+ subjmap->user = userp;
90818+ subjmap->kernel = s_tmp;
90819+ insert_subj_map_entry(subjmap);
90820+
90821+ if (copy_acl_subject_label(s_tmp, userp))
90822+ return ERR_PTR(-EFAULT);
90823+
90824+ err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
90825+ if (err)
90826+ return ERR_PTR(err);
90827+
90828+ if (!strcmp(s_tmp->filename, "/"))
90829+ role->root_label = s_tmp;
90830+
90831+ if (copy_gr_hash_struct(&ghash, s_tmp->hash))
90832+ return ERR_PTR(-EFAULT);
90833+
90834+ /* copy user and group transition tables */
90835+
90836+ if (s_tmp->user_trans_num) {
90837+ uid_t *uidlist;
90838+
90839+ uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
90840+ if (uidlist == NULL)
90841+ return ERR_PTR(-ENOMEM);
90842+ if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
90843+ return ERR_PTR(-EFAULT);
90844+
90845+ s_tmp->user_transitions = uidlist;
90846+ }
90847+
90848+ if (s_tmp->group_trans_num) {
90849+ gid_t *gidlist;
90850+
90851+ gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
90852+ if (gidlist == NULL)
90853+ return ERR_PTR(-ENOMEM);
90854+ if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
90855+ return ERR_PTR(-EFAULT);
90856+
90857+ s_tmp->group_transitions = gidlist;
90858+ }
90859+
90860+ /* set up object hash table */
90861+ num_objs = count_user_objs(ghash.first);
90862+
90863+ s_tmp->obj_hash_size = num_objs;
90864+ s_tmp->obj_hash =
90865+ (struct acl_object_label **)
90866+ create_table(&(s_tmp->obj_hash_size), sizeof(void *));
90867+
90868+ if (!s_tmp->obj_hash)
90869+ return ERR_PTR(-ENOMEM);
90870+
90871+ memset(s_tmp->obj_hash, 0,
90872+ s_tmp->obj_hash_size *
90873+ sizeof (struct acl_object_label *));
90874+
90875+ /* add in objects */
90876+ err = copy_user_objs(ghash.first, s_tmp, role);
90877+
90878+ if (err)
90879+ return ERR_PTR(err);
90880+
90881+ /* set pointer for parent subject */
90882+ if (s_tmp->parent_subject) {
90883+ s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
90884+
90885+ if (IS_ERR(s_tmp2))
90886+ return s_tmp2;
90887+
90888+ s_tmp->parent_subject = s_tmp2;
90889+ }
90890+
90891+ /* add in ip acls */
90892+
90893+ if (!s_tmp->ip_num) {
90894+ s_tmp->ips = NULL;
90895+ goto insert;
90896+ }
90897+
90898+ i_tmp =
90899+ (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
90900+ sizeof (struct acl_ip_label *));
90901+
90902+ if (!i_tmp)
90903+ return ERR_PTR(-ENOMEM);
90904+
90905+ for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
90906+ *(i_tmp + i_num) =
90907+ (struct acl_ip_label *)
90908+ acl_alloc(sizeof (struct acl_ip_label));
90909+ if (!*(i_tmp + i_num))
90910+ return ERR_PTR(-ENOMEM);
90911+
90912+ if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
90913+ return ERR_PTR(-EFAULT);
90914+
90915+ if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
90916+ return ERR_PTR(-EFAULT);
90917+
90918+ if ((*(i_tmp + i_num))->iface == NULL)
90919+ continue;
90920+
90921+ err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
90922+ if (err)
90923+ return ERR_PTR(err);
90924+ }
90925+
90926+ s_tmp->ips = i_tmp;
90927+
90928+insert:
90929+ if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
90930+ s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
90931+ return ERR_PTR(-ENOMEM);
90932+
90933+ return s_tmp;
90934+}
90935+
90936+static int
90937+copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
90938+{
90939+ struct acl_subject_label s_pre;
90940+ struct acl_subject_label * ret;
90941+ int err;
90942+
90943+ while (userp) {
90944+ if (copy_acl_subject_label(&s_pre, userp))
90945+ return -EFAULT;
90946+
90947+ ret = do_copy_user_subj(userp, role, NULL);
90948+
90949+ err = PTR_ERR(ret);
90950+ if (IS_ERR(ret))
90951+ return err;
90952+
90953+ insert_acl_subj_label(ret, role);
90954+
90955+ userp = s_pre.prev;
90956+ }
90957+
90958+ return 0;
90959+}
90960+
90961+static int
90962+copy_user_acl(struct gr_arg *arg)
90963+{
90964+ struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
90965+ struct acl_subject_label *subj_list;
90966+ struct sprole_pw *sptmp;
90967+ struct gr_hash_struct *ghash;
90968+ uid_t *domainlist;
90969+ unsigned int r_num;
90970+ int err = 0;
90971+ __u16 i;
90972+ __u32 num_subjs;
90973+
90974+ /* we need a default and kernel role */
90975+ if (arg->role_db.num_roles < 2)
90976+ return -EINVAL;
90977+
90978+ /* copy special role authentication info from userspace */
90979+
90980+ polstate->num_sprole_pws = arg->num_sprole_pws;
90981+ polstate->acl_special_roles = (struct sprole_pw **) acl_alloc_num(polstate->num_sprole_pws, sizeof(struct sprole_pw *));
90982+
90983+ if (!polstate->acl_special_roles && polstate->num_sprole_pws)
90984+ return -ENOMEM;
90985+
90986+ for (i = 0; i < polstate->num_sprole_pws; i++) {
90987+ sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
90988+ if (!sptmp)
90989+ return -ENOMEM;
90990+ if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
90991+ return -EFAULT;
90992+
90993+ err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
90994+ if (err)
90995+ return err;
90996+
90997+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
90998+ printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
90999+#endif
91000+
91001+ polstate->acl_special_roles[i] = sptmp;
91002+ }
91003+
91004+ r_utmp = (struct acl_role_label **) arg->role_db.r_table;
91005+
91006+ for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
91007+ r_tmp = acl_alloc(sizeof (struct acl_role_label));
91008+
91009+ if (!r_tmp)
91010+ return -ENOMEM;
91011+
91012+ if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
91013+ return -EFAULT;
91014+
91015+ if (copy_acl_role_label(r_tmp, r_utmp2))
91016+ return -EFAULT;
91017+
91018+ err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
91019+ if (err)
91020+ return err;
91021+
91022+ if (!strcmp(r_tmp->rolename, "default")
91023+ && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
91024+ polstate->default_role = r_tmp;
91025+ } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
91026+ polstate->kernel_role = r_tmp;
91027+ }
91028+
91029+ if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
91030+ return -ENOMEM;
91031+
91032+ if (copy_gr_hash_struct(ghash, r_tmp->hash))
91033+ return -EFAULT;
91034+
91035+ r_tmp->hash = ghash;
91036+
91037+ num_subjs = count_user_subjs(r_tmp->hash->first);
91038+
91039+ r_tmp->subj_hash_size = num_subjs;
91040+ r_tmp->subj_hash =
91041+ (struct acl_subject_label **)
91042+ create_table(&(r_tmp->subj_hash_size), sizeof(void *));
91043+
91044+ if (!r_tmp->subj_hash)
91045+ return -ENOMEM;
91046+
91047+ err = copy_user_allowedips(r_tmp);
91048+ if (err)
91049+ return err;
91050+
91051+ /* copy domain info */
91052+ if (r_tmp->domain_children != NULL) {
91053+ domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
91054+ if (domainlist == NULL)
91055+ return -ENOMEM;
91056+
91057+ if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
91058+ return -EFAULT;
91059+
91060+ r_tmp->domain_children = domainlist;
91061+ }
91062+
91063+ err = copy_user_transitions(r_tmp);
91064+ if (err)
91065+ return err;
91066+
91067+ memset(r_tmp->subj_hash, 0,
91068+ r_tmp->subj_hash_size *
91069+ sizeof (struct acl_subject_label *));
91070+
91071+ /* acquire the list of subjects, then NULL out
91072+ the list prior to parsing the subjects for this role,
91073+ as during this parsing the list is replaced with a list
91074+ of *nested* subjects for the role
91075+ */
91076+ subj_list = r_tmp->hash->first;
91077+
91078+ /* set nested subject list to null */
91079+ r_tmp->hash->first = NULL;
91080+
91081+ err = copy_user_subjs(subj_list, r_tmp);
91082+
91083+ if (err)
91084+ return err;
91085+
91086+ insert_acl_role_label(r_tmp);
91087+ }
91088+
91089+ if (polstate->default_role == NULL || polstate->kernel_role == NULL)
91090+ return -EINVAL;
91091+
91092+ return err;
91093+}
91094+
91095+static int gracl_reload_apply_policies(void *reload)
91096+{
91097+ struct gr_reload_state *reload_state = (struct gr_reload_state *)reload;
91098+ struct task_struct *task, *task2;
91099+ struct acl_role_label *role, *rtmp;
91100+ struct acl_subject_label *subj;
91101+ const struct cred *cred;
91102+ int role_applied;
91103+ int ret = 0;
91104+
91105+ memcpy(&reload_state->oldpolicy, reload_state->oldpolicy_ptr, sizeof(struct gr_policy_state));
91106+ memcpy(&reload_state->oldalloc, reload_state->oldalloc_ptr, sizeof(struct gr_alloc_state));
91107+
91108+ /* first make sure we'll be able to apply the new policy cleanly */
91109+ do_each_thread(task2, task) {
91110+ if (task->exec_file == NULL)
91111+ continue;
91112+ role_applied = 0;
91113+ if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
91114+ /* preserve special roles */
91115+ FOR_EACH_ROLE_START(role)
91116+ if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
91117+ rtmp = task->role;
91118+ task->role = role;
91119+ role_applied = 1;
91120+ break;
91121+ }
91122+ FOR_EACH_ROLE_END(role)
91123+ }
91124+ if (!role_applied) {
91125+ cred = __task_cred(task);
91126+ rtmp = task->role;
91127+ task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
91128+ }
91129+ /* this handles non-nested inherited subjects, nested subjects will still
91130+ be dropped currently */
91131+ subj = __gr_get_subject_for_task(polstate, task, task->acl->filename, 1);
91132+ task->tmpacl = __gr_get_subject_for_task(polstate, task, NULL, 1);
91133+ /* change the role back so that we've made no modifications to the policy */
91134+ task->role = rtmp;
91135+
91136+ if (subj == NULL || task->tmpacl == NULL) {
91137+ ret = -EINVAL;
91138+ goto out;
91139+ }
91140+ } while_each_thread(task2, task);
91141+
91142+ /* now actually apply the policy */
91143+
91144+ do_each_thread(task2, task) {
91145+ if (task->exec_file) {
91146+ role_applied = 0;
91147+ if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
91148+ /* preserve special roles */
91149+ FOR_EACH_ROLE_START(role)
91150+ if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
91151+ task->role = role;
91152+ role_applied = 1;
91153+ break;
91154+ }
91155+ FOR_EACH_ROLE_END(role)
91156+ }
91157+ if (!role_applied) {
91158+ cred = __task_cred(task);
91159+ task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
91160+ }
91161+ /* this handles non-nested inherited subjects, nested subjects will still
91162+ be dropped currently */
91163+ if (!reload_state->oldmode && task->inherited)
91164+ subj = __gr_get_subject_for_task(polstate, task, task->acl->filename, 1);
91165+ else {
91166+ /* looked up and tagged to the task previously */
91167+ subj = task->tmpacl;
91168+ }
91169+ /* subj will be non-null */
91170+ __gr_apply_subject_to_task(polstate, task, subj);
91171+ if (reload_state->oldmode) {
91172+ task->acl_role_id = 0;
91173+ task->acl_sp_role = 0;
91174+ task->inherited = 0;
91175+ }
91176+ } else {
91177+ // it's a kernel process
91178+ task->role = polstate->kernel_role;
91179+ task->acl = polstate->kernel_role->root_label;
91180+#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
91181+ task->acl->mode &= ~GR_PROCFIND;
91182+#endif
91183+ }
91184+ } while_each_thread(task2, task);
91185+
91186+ memcpy(reload_state->oldpolicy_ptr, &reload_state->newpolicy, sizeof(struct gr_policy_state));
91187+ memcpy(reload_state->oldalloc_ptr, &reload_state->newalloc, sizeof(struct gr_alloc_state));
91188+
91189+out:
91190+
91191+ return ret;
91192+}
91193+
91194+static int gracl_reload(struct gr_arg *args, unsigned char oldmode)
91195+{
91196+ struct gr_reload_state new_reload_state = { };
91197+ int err;
91198+
91199+ new_reload_state.oldpolicy_ptr = polstate;
91200+ new_reload_state.oldalloc_ptr = current_alloc_state;
91201+ new_reload_state.oldmode = oldmode;
91202+
91203+ current_alloc_state = &new_reload_state.newalloc;
91204+ polstate = &new_reload_state.newpolicy;
91205+
91206+ /* everything relevant is now saved off, copy in the new policy */
91207+ if (init_variables(args, true)) {
91208+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
91209+ err = -ENOMEM;
91210+ goto error;
91211+ }
91212+
91213+ err = copy_user_acl(args);
91214+ free_init_variables();
91215+ if (err)
91216+ goto error;
91217+ /* the new policy is copied in, with the old policy available via saved_state
91218+ first go through applying roles, making sure to preserve special roles
91219+ then apply new subjects, making sure to preserve inherited and nested subjects,
91220+ though currently only inherited subjects will be preserved
91221+ */
91222+ err = stop_machine(gracl_reload_apply_policies, &new_reload_state, NULL);
91223+ if (err)
91224+ goto error;
91225+
91226+ /* we've now applied the new policy, so restore the old policy state to free it */
91227+ polstate = &new_reload_state.oldpolicy;
91228+ current_alloc_state = &new_reload_state.oldalloc;
91229+ free_variables(true);
91230+
91231+ /* oldpolicy/oldalloc_ptr point to the new policy/alloc states as they were copied
91232+ to running_polstate/current_alloc_state inside stop_machine
91233+ */
91234+ err = 0;
91235+ goto out;
91236+error:
91237+ /* on error of loading the new policy, we'll just keep the previous
91238+ policy set around
91239+ */
91240+ free_variables(true);
91241+
91242+ /* doesn't affect runtime, but maintains consistent state */
91243+out:
91244+ polstate = new_reload_state.oldpolicy_ptr;
91245+ current_alloc_state = new_reload_state.oldalloc_ptr;
91246+
91247+ return err;
91248+}
91249+
91250+static int
91251+gracl_init(struct gr_arg *args)
91252+{
91253+ int error = 0;
91254+
91255+ memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
91256+ memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
91257+
91258+ if (init_variables(args, false)) {
91259+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
91260+ error = -ENOMEM;
91261+ goto out;
91262+ }
91263+
91264+ error = copy_user_acl(args);
91265+ free_init_variables();
91266+ if (error)
91267+ goto out;
91268+
91269+ error = gr_set_acls(0);
91270+ if (error)
91271+ goto out;
91272+
91273+ gr_enable_rbac_system();
91274+
91275+ return 0;
91276+
91277+out:
91278+ free_variables(false);
91279+ return error;
91280+}
91281+
91282+static int
91283+lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
91284+ unsigned char **sum)
91285+{
91286+ struct acl_role_label *r;
91287+ struct role_allowed_ip *ipp;
91288+ struct role_transition *trans;
91289+ unsigned int i;
91290+ int found = 0;
91291+ u32 curr_ip = current->signal->curr_ip;
91292+
91293+ current->signal->saved_ip = curr_ip;
91294+
91295+ /* check transition table */
91296+
91297+ for (trans = current->role->transitions; trans; trans = trans->next) {
91298+ if (!strcmp(rolename, trans->rolename)) {
91299+ found = 1;
91300+ break;
91301+ }
91302+ }
91303+
91304+ if (!found)
91305+ return 0;
91306+
91307+ /* handle special roles that do not require authentication
91308+ and check ip */
91309+
91310+ FOR_EACH_ROLE_START(r)
91311+ if (!strcmp(rolename, r->rolename) &&
91312+ (r->roletype & GR_ROLE_SPECIAL)) {
91313+ found = 0;
91314+ if (r->allowed_ips != NULL) {
91315+ for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
91316+ if ((ntohl(curr_ip) & ipp->netmask) ==
91317+ (ntohl(ipp->addr) & ipp->netmask))
91318+ found = 1;
91319+ }
91320+ } else
91321+ found = 2;
91322+ if (!found)
91323+ return 0;
91324+
91325+ if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
91326+ ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
91327+ *salt = NULL;
91328+ *sum = NULL;
91329+ return 1;
91330+ }
91331+ }
91332+ FOR_EACH_ROLE_END(r)
91333+
91334+ for (i = 0; i < polstate->num_sprole_pws; i++) {
91335+ if (!strcmp(rolename, polstate->acl_special_roles[i]->rolename)) {
91336+ *salt = polstate->acl_special_roles[i]->salt;
91337+ *sum = polstate->acl_special_roles[i]->sum;
91338+ return 1;
91339+ }
91340+ }
91341+
91342+ return 0;
91343+}
91344+
91345+int gr_check_secure_terminal(struct task_struct *task)
91346+{
91347+ struct task_struct *p, *p2, *p3;
91348+ struct files_struct *files;
91349+ struct fdtable *fdt;
91350+ struct file *our_file = NULL, *file;
91351+ struct inode *our_inode = NULL;
91352+ int i;
91353+
91354+ if (task->signal->tty == NULL)
91355+ return 1;
91356+
91357+ files = get_files_struct(task);
91358+ if (files != NULL) {
91359+ rcu_read_lock();
91360+ fdt = files_fdtable(files);
91361+ for (i=0; i < fdt->max_fds; i++) {
91362+ file = fcheck_files(files, i);
91363+ if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
91364+ get_file(file);
91365+ our_file = file;
91366+ }
91367+ }
91368+ rcu_read_unlock();
91369+ put_files_struct(files);
91370+ }
91371+
91372+ if (our_file == NULL)
91373+ return 1;
91374+
91375+ our_inode = d_backing_inode(our_file->f_path.dentry);
91376+
91377+ read_lock(&tasklist_lock);
91378+ do_each_thread(p2, p) {
91379+ files = get_files_struct(p);
91380+ if (files == NULL ||
91381+ (p->signal && p->signal->tty == task->signal->tty)) {
91382+ if (files != NULL)
91383+ put_files_struct(files);
91384+ continue;
91385+ }
91386+ rcu_read_lock();
91387+ fdt = files_fdtable(files);
91388+ for (i=0; i < fdt->max_fds; i++) {
91389+ struct inode *inode = NULL;
91390+ file = fcheck_files(files, i);
91391+ if (file)
91392+ inode = d_backing_inode(file->f_path.dentry);
91393+ if (inode && S_ISCHR(inode->i_mode) && inode->i_rdev == our_inode->i_rdev) {
91394+ p3 = task;
91395+ while (task_pid_nr(p3) > 0) {
91396+ if (p3 == p)
91397+ break;
91398+ p3 = p3->real_parent;
91399+ }
91400+ if (p3 == p)
91401+ break;
91402+ gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
91403+ gr_handle_alertkill(p);
91404+ rcu_read_unlock();
91405+ put_files_struct(files);
91406+ read_unlock(&tasklist_lock);
91407+ fput(our_file);
91408+ return 0;
91409+ }
91410+ }
91411+ rcu_read_unlock();
91412+ put_files_struct(files);
91413+ } while_each_thread(p2, p);
91414+ read_unlock(&tasklist_lock);
91415+
91416+ fput(our_file);
91417+ return 1;
91418+}
91419+
91420+ssize_t
91421+write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
91422+{
91423+ struct gr_arg_wrapper uwrap;
91424+ unsigned char *sprole_salt = NULL;
91425+ unsigned char *sprole_sum = NULL;
91426+ int error = 0;
91427+ int error2 = 0;
91428+ size_t req_count = 0;
91429+ unsigned char oldmode = 0;
91430+
91431+ mutex_lock(&gr_dev_mutex);
91432+
91433+ if (gr_acl_is_enabled() && !(current->acl->mode & GR_KERNELAUTH)) {
91434+ error = -EPERM;
91435+ goto out;
91436+ }
91437+
91438+#ifdef CONFIG_COMPAT
91439+ pax_open_kernel();
91440+ if (is_compat_task()) {
91441+ copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
91442+ copy_gr_arg = &copy_gr_arg_compat;
91443+ copy_acl_object_label = &copy_acl_object_label_compat;
91444+ copy_acl_subject_label = &copy_acl_subject_label_compat;
91445+ copy_acl_role_label = &copy_acl_role_label_compat;
91446+ copy_acl_ip_label = &copy_acl_ip_label_compat;
91447+ copy_role_allowed_ip = &copy_role_allowed_ip_compat;
91448+ copy_role_transition = &copy_role_transition_compat;
91449+ copy_sprole_pw = &copy_sprole_pw_compat;
91450+ copy_gr_hash_struct = &copy_gr_hash_struct_compat;
91451+ copy_pointer_from_array = &copy_pointer_from_array_compat;
91452+ get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
91453+ } else {
91454+ copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
91455+ copy_gr_arg = &copy_gr_arg_normal;
91456+ copy_acl_object_label = &copy_acl_object_label_normal;
91457+ copy_acl_subject_label = &copy_acl_subject_label_normal;
91458+ copy_acl_role_label = &copy_acl_role_label_normal;
91459+ copy_acl_ip_label = &copy_acl_ip_label_normal;
91460+ copy_role_allowed_ip = &copy_role_allowed_ip_normal;
91461+ copy_role_transition = &copy_role_transition_normal;
91462+ copy_sprole_pw = &copy_sprole_pw_normal;
91463+ copy_gr_hash_struct = &copy_gr_hash_struct_normal;
91464+ copy_pointer_from_array = &copy_pointer_from_array_normal;
91465+ get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
91466+ }
91467+ pax_close_kernel();
91468+#endif
91469+
91470+ req_count = get_gr_arg_wrapper_size();
91471+
91472+ if (count != req_count) {
91473+ gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
91474+ error = -EINVAL;
91475+ goto out;
91476+ }
91477+
91478+
91479+ if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
91480+ gr_auth_expires = 0;
91481+ gr_auth_attempts = 0;
91482+ }
91483+
91484+ error = copy_gr_arg_wrapper(buf, &uwrap);
91485+ if (error)
91486+ goto out;
91487+
91488+ error = copy_gr_arg(uwrap.arg, gr_usermode);
91489+ if (error)
91490+ goto out;
91491+
91492+ if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
91493+ gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
91494+ time_after(gr_auth_expires, get_seconds())) {
91495+ error = -EBUSY;
91496+ goto out;
91497+ }
91498+
91499+ /* if non-root trying to do anything other than use a special role,
91500+ do not attempt authentication, do not count towards authentication
91501+ locking
91502+ */
91503+
91504+ if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
91505+ gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
91506+ gr_is_global_nonroot(current_uid())) {
91507+ error = -EPERM;
91508+ goto out;
91509+ }
91510+
91511+ /* ensure pw and special role name are null terminated */
91512+
91513+ gr_usermode->pw[GR_PW_LEN - 1] = '\0';
91514+ gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
91515+
91516+ /* Okay.
91517+ * We have our enough of the argument structure..(we have yet
91518+ * to copy_from_user the tables themselves) . Copy the tables
91519+ * only if we need them, i.e. for loading operations. */
91520+
91521+ switch (gr_usermode->mode) {
91522+ case GR_STATUS:
91523+ if (gr_acl_is_enabled()) {
91524+ error = 1;
91525+ if (!gr_check_secure_terminal(current))
91526+ error = 3;
91527+ } else
91528+ error = 2;
91529+ goto out;
91530+ case GR_SHUTDOWN:
91531+ if (gr_acl_is_enabled() && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
91532+ stop_machine(gr_rbac_disable, NULL, NULL);
91533+ free_variables(false);
91534+ memset(gr_usermode, 0, sizeof(struct gr_arg));
91535+ memset(gr_system_salt, 0, GR_SALT_LEN);
91536+ memset(gr_system_sum, 0, GR_SHA_LEN);
91537+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
91538+ } else if (gr_acl_is_enabled()) {
91539+ gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
91540+ error = -EPERM;
91541+ } else {
91542+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
91543+ error = -EAGAIN;
91544+ }
91545+ break;
91546+ case GR_ENABLE:
91547+ if (!gr_acl_is_enabled() && !(error2 = gracl_init(gr_usermode)))
91548+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
91549+ else {
91550+ if (gr_acl_is_enabled())
91551+ error = -EAGAIN;
91552+ else
91553+ error = error2;
91554+ gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
91555+ }
91556+ break;
91557+ case GR_OLDRELOAD:
91558+ oldmode = 1;
91559+ case GR_RELOAD:
91560+ if (!gr_acl_is_enabled()) {
91561+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
91562+ error = -EAGAIN;
91563+ } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
91564+ error2 = gracl_reload(gr_usermode, oldmode);
91565+ if (!error2)
91566+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
91567+ else {
91568+ gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
91569+ error = error2;
91570+ }
91571+ } else {
91572+ gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
91573+ error = -EPERM;
91574+ }
91575+ break;
91576+ case GR_SEGVMOD:
91577+ if (unlikely(!gr_acl_is_enabled())) {
91578+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
91579+ error = -EAGAIN;
91580+ break;
91581+ }
91582+
91583+ if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
91584+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
91585+ if (gr_usermode->segv_device && gr_usermode->segv_inode) {
91586+ struct acl_subject_label *segvacl;
91587+ segvacl =
91588+ lookup_acl_subj_label(gr_usermode->segv_inode,
91589+ gr_usermode->segv_device,
91590+ current->role);
91591+ if (segvacl) {
91592+ segvacl->crashes = 0;
91593+ segvacl->expires = 0;
91594+ }
91595+ } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
91596+ gr_remove_uid(gr_usermode->segv_uid);
91597+ }
91598+ } else {
91599+ gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
91600+ error = -EPERM;
91601+ }
91602+ break;
91603+ case GR_SPROLE:
91604+ case GR_SPROLEPAM:
91605+ if (unlikely(!gr_acl_is_enabled())) {
91606+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
91607+ error = -EAGAIN;
91608+ break;
91609+ }
91610+
91611+ if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
91612+ current->role->expires = 0;
91613+ current->role->auth_attempts = 0;
91614+ }
91615+
91616+ if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
91617+ time_after(current->role->expires, get_seconds())) {
91618+ error = -EBUSY;
91619+ goto out;
91620+ }
91621+
91622+ if (lookup_special_role_auth
91623+ (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
91624+ && ((!sprole_salt && !sprole_sum)
91625+ || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
91626+ char *p = "";
91627+ assign_special_role(gr_usermode->sp_role);
91628+ read_lock(&tasklist_lock);
91629+ if (current->real_parent)
91630+ p = current->real_parent->role->rolename;
91631+ read_unlock(&tasklist_lock);
91632+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
91633+ p, acl_sp_role_value);
91634+ } else {
91635+ gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
91636+ error = -EPERM;
91637+ if(!(current->role->auth_attempts++))
91638+ current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
91639+
91640+ goto out;
91641+ }
91642+ break;
91643+ case GR_UNSPROLE:
91644+ if (unlikely(!gr_acl_is_enabled())) {
91645+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
91646+ error = -EAGAIN;
91647+ break;
91648+ }
91649+
91650+ if (current->role->roletype & GR_ROLE_SPECIAL) {
91651+ char *p = "";
91652+ int i = 0;
91653+
91654+ read_lock(&tasklist_lock);
91655+ if (current->real_parent) {
91656+ p = current->real_parent->role->rolename;
91657+ i = current->real_parent->acl_role_id;
91658+ }
91659+ read_unlock(&tasklist_lock);
91660+
91661+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
91662+ gr_set_acls(1);
91663+ } else {
91664+ error = -EPERM;
91665+ goto out;
91666+ }
91667+ break;
91668+ default:
91669+ gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
91670+ error = -EINVAL;
91671+ break;
91672+ }
91673+
91674+ if (error != -EPERM)
91675+ goto out;
91676+
91677+ if(!(gr_auth_attempts++))
91678+ gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
91679+
91680+ out:
91681+ mutex_unlock(&gr_dev_mutex);
91682+
91683+ if (!error)
91684+ error = req_count;
91685+
91686+ return error;
91687+}
91688+
91689+int
91690+gr_set_acls(const int type)
91691+{
91692+ struct task_struct *task, *task2;
91693+ struct acl_role_label *role = current->role;
91694+ struct acl_subject_label *subj;
91695+ __u16 acl_role_id = current->acl_role_id;
91696+ const struct cred *cred;
91697+ int ret;
91698+
91699+ rcu_read_lock();
91700+ read_lock(&tasklist_lock);
91701+ read_lock(&grsec_exec_file_lock);
91702+ do_each_thread(task2, task) {
91703+ /* check to see if we're called from the exit handler,
91704+ if so, only replace ACLs that have inherited the admin
91705+ ACL */
91706+
91707+ if (type && (task->role != role ||
91708+ task->acl_role_id != acl_role_id))
91709+ continue;
91710+
91711+ task->acl_role_id = 0;
91712+ task->acl_sp_role = 0;
91713+ task->inherited = 0;
91714+
91715+ if (task->exec_file) {
91716+ cred = __task_cred(task);
91717+ task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
91718+ subj = __gr_get_subject_for_task(polstate, task, NULL, 1);
91719+ if (subj == NULL) {
91720+ ret = -EINVAL;
91721+ read_unlock(&grsec_exec_file_lock);
91722+ read_unlock(&tasklist_lock);
91723+ rcu_read_unlock();
91724+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
91725+ return ret;
91726+ }
91727+ __gr_apply_subject_to_task(polstate, task, subj);
91728+ } else {
91729+ // it's a kernel process
91730+ task->role = polstate->kernel_role;
91731+ task->acl = polstate->kernel_role->root_label;
91732+#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
91733+ task->acl->mode &= ~GR_PROCFIND;
91734+#endif
91735+ }
91736+ } while_each_thread(task2, task);
91737+ read_unlock(&grsec_exec_file_lock);
91738+ read_unlock(&tasklist_lock);
91739+ rcu_read_unlock();
91740+
91741+ return 0;
91742+}
91743diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
91744new file mode 100644
91745index 0000000..39645c9
91746--- /dev/null
91747+++ b/grsecurity/gracl_res.c
91748@@ -0,0 +1,68 @@
91749+#include <linux/kernel.h>
91750+#include <linux/sched.h>
91751+#include <linux/gracl.h>
91752+#include <linux/grinternal.h>
91753+
91754+static const char *restab_log[] = {
91755+ [RLIMIT_CPU] = "RLIMIT_CPU",
91756+ [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
91757+ [RLIMIT_DATA] = "RLIMIT_DATA",
91758+ [RLIMIT_STACK] = "RLIMIT_STACK",
91759+ [RLIMIT_CORE] = "RLIMIT_CORE",
91760+ [RLIMIT_RSS] = "RLIMIT_RSS",
91761+ [RLIMIT_NPROC] = "RLIMIT_NPROC",
91762+ [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
91763+ [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
91764+ [RLIMIT_AS] = "RLIMIT_AS",
91765+ [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
91766+ [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
91767+ [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
91768+ [RLIMIT_NICE] = "RLIMIT_NICE",
91769+ [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
91770+ [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
91771+ [GR_CRASH_RES] = "RLIMIT_CRASH"
91772+};
91773+
91774+void
91775+gr_log_resource(const struct task_struct *task,
91776+ const int res, const unsigned long wanted, const int gt)
91777+{
91778+ const struct cred *cred;
91779+ unsigned long rlim;
91780+
91781+ if (!gr_acl_is_enabled() && !grsec_resource_logging)
91782+ return;
91783+
91784+ // not yet supported resource
91785+ if (unlikely(!restab_log[res]))
91786+ return;
91787+
91788+ if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
91789+ rlim = task_rlimit_max(task, res);
91790+ else
91791+ rlim = task_rlimit(task, res);
91792+
91793+ if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
91794+ return;
91795+
91796+ rcu_read_lock();
91797+ cred = __task_cred(task);
91798+
91799+ if (res == RLIMIT_NPROC &&
91800+ (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
91801+ cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
91802+ goto out_rcu_unlock;
91803+ else if (res == RLIMIT_MEMLOCK &&
91804+ cap_raised(cred->cap_effective, CAP_IPC_LOCK))
91805+ goto out_rcu_unlock;
91806+ else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
91807+ goto out_rcu_unlock;
91808+ rcu_read_unlock();
91809+
91810+ gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
91811+
91812+ return;
91813+out_rcu_unlock:
91814+ rcu_read_unlock();
91815+ return;
91816+}
91817diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
91818new file mode 100644
91819index 0000000..21646aa
91820--- /dev/null
91821+++ b/grsecurity/gracl_segv.c
91822@@ -0,0 +1,304 @@
91823+#include <linux/kernel.h>
91824+#include <linux/mm.h>
91825+#include <asm/uaccess.h>
91826+#include <asm/errno.h>
91827+#include <asm/mman.h>
91828+#include <net/sock.h>
91829+#include <linux/file.h>
91830+#include <linux/fs.h>
91831+#include <linux/net.h>
91832+#include <linux/in.h>
91833+#include <linux/slab.h>
91834+#include <linux/types.h>
91835+#include <linux/sched.h>
91836+#include <linux/timer.h>
91837+#include <linux/gracl.h>
91838+#include <linux/grsecurity.h>
91839+#include <linux/grinternal.h>
91840+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
91841+#include <linux/magic.h>
91842+#include <linux/pagemap.h>
91843+#include "../fs/btrfs/async-thread.h"
91844+#include "../fs/btrfs/ctree.h"
91845+#include "../fs/btrfs/btrfs_inode.h"
91846+#endif
91847+
91848+static struct crash_uid *uid_set;
91849+static unsigned short uid_used;
91850+static DEFINE_SPINLOCK(gr_uid_lock);
91851+extern rwlock_t gr_inode_lock;
91852+extern struct acl_subject_label *
91853+ lookup_acl_subj_label(const u64 inode, const dev_t dev,
91854+ struct acl_role_label *role);
91855+
91856+int
91857+gr_init_uidset(void)
91858+{
91859+ uid_set =
91860+ kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
91861+ uid_used = 0;
91862+
91863+ return uid_set ? 1 : 0;
91864+}
91865+
91866+void
91867+gr_free_uidset(void)
91868+{
91869+ if (uid_set) {
91870+ struct crash_uid *tmpset;
91871+ spin_lock(&gr_uid_lock);
91872+ tmpset = uid_set;
91873+ uid_set = NULL;
91874+ uid_used = 0;
91875+ spin_unlock(&gr_uid_lock);
91876+ if (tmpset)
91877+ kfree(tmpset);
91878+ }
91879+
91880+ return;
91881+}
91882+
91883+int
91884+gr_find_uid(const uid_t uid)
91885+{
91886+ struct crash_uid *tmp = uid_set;
91887+ uid_t buid;
91888+ int low = 0, high = uid_used - 1, mid;
91889+
91890+ while (high >= low) {
91891+ mid = (low + high) >> 1;
91892+ buid = tmp[mid].uid;
91893+ if (buid == uid)
91894+ return mid;
91895+ if (buid > uid)
91896+ high = mid - 1;
91897+ if (buid < uid)
91898+ low = mid + 1;
91899+ }
91900+
91901+ return -1;
91902+}
91903+
91904+static void
91905+gr_insertsort(void)
91906+{
91907+ unsigned short i, j;
91908+ struct crash_uid index;
91909+
91910+ for (i = 1; i < uid_used; i++) {
91911+ index = uid_set[i];
91912+ j = i;
91913+ while ((j > 0) && uid_set[j - 1].uid > index.uid) {
91914+ uid_set[j] = uid_set[j - 1];
91915+ j--;
91916+ }
91917+ uid_set[j] = index;
91918+ }
91919+
91920+ return;
91921+}
91922+
91923+static void
91924+gr_insert_uid(const kuid_t kuid, const unsigned long expires)
91925+{
91926+ int loc;
91927+ uid_t uid = GR_GLOBAL_UID(kuid);
91928+
91929+ if (uid_used == GR_UIDTABLE_MAX)
91930+ return;
91931+
91932+ loc = gr_find_uid(uid);
91933+
91934+ if (loc >= 0) {
91935+ uid_set[loc].expires = expires;
91936+ return;
91937+ }
91938+
91939+ uid_set[uid_used].uid = uid;
91940+ uid_set[uid_used].expires = expires;
91941+ uid_used++;
91942+
91943+ gr_insertsort();
91944+
91945+ return;
91946+}
91947+
91948+void
91949+gr_remove_uid(const unsigned short loc)
91950+{
91951+ unsigned short i;
91952+
91953+ for (i = loc + 1; i < uid_used; i++)
91954+ uid_set[i - 1] = uid_set[i];
91955+
91956+ uid_used--;
91957+
91958+ return;
91959+}
91960+
91961+int
91962+gr_check_crash_uid(const kuid_t kuid)
91963+{
91964+ int loc;
91965+ int ret = 0;
91966+ uid_t uid;
91967+
91968+ if (unlikely(!gr_acl_is_enabled()))
91969+ return 0;
91970+
91971+ uid = GR_GLOBAL_UID(kuid);
91972+
91973+ spin_lock(&gr_uid_lock);
91974+ loc = gr_find_uid(uid);
91975+
91976+ if (loc < 0)
91977+ goto out_unlock;
91978+
91979+ if (time_before_eq(uid_set[loc].expires, get_seconds()))
91980+ gr_remove_uid(loc);
91981+ else
91982+ ret = 1;
91983+
91984+out_unlock:
91985+ spin_unlock(&gr_uid_lock);
91986+ return ret;
91987+}
91988+
91989+static int
91990+proc_is_setxid(const struct cred *cred)
91991+{
91992+ if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
91993+ !uid_eq(cred->uid, cred->fsuid))
91994+ return 1;
91995+ if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
91996+ !gid_eq(cred->gid, cred->fsgid))
91997+ return 1;
91998+
91999+ return 0;
92000+}
92001+
92002+extern int gr_fake_force_sig(int sig, struct task_struct *t);
92003+
92004+void
92005+gr_handle_crash(struct task_struct *task, const int sig)
92006+{
92007+ struct acl_subject_label *curr;
92008+ struct task_struct *tsk, *tsk2;
92009+ const struct cred *cred;
92010+ const struct cred *cred2;
92011+
92012+ if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
92013+ return;
92014+
92015+ if (unlikely(!gr_acl_is_enabled()))
92016+ return;
92017+
92018+ curr = task->acl;
92019+
92020+ if (!(curr->resmask & (1U << GR_CRASH_RES)))
92021+ return;
92022+
92023+ if (time_before_eq(curr->expires, get_seconds())) {
92024+ curr->expires = 0;
92025+ curr->crashes = 0;
92026+ }
92027+
92028+ curr->crashes++;
92029+
92030+ if (!curr->expires)
92031+ curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
92032+
92033+ if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
92034+ time_after(curr->expires, get_seconds())) {
92035+ rcu_read_lock();
92036+ cred = __task_cred(task);
92037+ if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
92038+ gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
92039+ spin_lock(&gr_uid_lock);
92040+ gr_insert_uid(cred->uid, curr->expires);
92041+ spin_unlock(&gr_uid_lock);
92042+ curr->expires = 0;
92043+ curr->crashes = 0;
92044+ read_lock(&tasklist_lock);
92045+ do_each_thread(tsk2, tsk) {
92046+ cred2 = __task_cred(tsk);
92047+ if (tsk != task && uid_eq(cred2->uid, cred->uid))
92048+ gr_fake_force_sig(SIGKILL, tsk);
92049+ } while_each_thread(tsk2, tsk);
92050+ read_unlock(&tasklist_lock);
92051+ } else {
92052+ gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
92053+ read_lock(&tasklist_lock);
92054+ read_lock(&grsec_exec_file_lock);
92055+ do_each_thread(tsk2, tsk) {
92056+ if (likely(tsk != task)) {
92057+ // if this thread has the same subject as the one that triggered
92058+ // RES_CRASH and it's the same binary, kill it
92059+ if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
92060+ gr_fake_force_sig(SIGKILL, tsk);
92061+ }
92062+ } while_each_thread(tsk2, tsk);
92063+ read_unlock(&grsec_exec_file_lock);
92064+ read_unlock(&tasklist_lock);
92065+ }
92066+ rcu_read_unlock();
92067+ }
92068+
92069+ return;
92070+}
92071+
92072+int
92073+gr_check_crash_exec(const struct file *filp)
92074+{
92075+ struct acl_subject_label *curr;
92076+ struct dentry *dentry;
92077+
92078+ if (unlikely(!gr_acl_is_enabled()))
92079+ return 0;
92080+
92081+ read_lock(&gr_inode_lock);
92082+ dentry = filp->f_path.dentry;
92083+ curr = lookup_acl_subj_label(gr_get_ino_from_dentry(dentry), gr_get_dev_from_dentry(dentry),
92084+ current->role);
92085+ read_unlock(&gr_inode_lock);
92086+
92087+ if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
92088+ (!curr->crashes && !curr->expires))
92089+ return 0;
92090+
92091+ if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
92092+ time_after(curr->expires, get_seconds()))
92093+ return 1;
92094+ else if (time_before_eq(curr->expires, get_seconds())) {
92095+ curr->crashes = 0;
92096+ curr->expires = 0;
92097+ }
92098+
92099+ return 0;
92100+}
92101+
92102+void
92103+gr_handle_alertkill(struct task_struct *task)
92104+{
92105+ struct acl_subject_label *curracl;
92106+ __u32 curr_ip;
92107+ struct task_struct *p, *p2;
92108+
92109+ if (unlikely(!gr_acl_is_enabled()))
92110+ return;
92111+
92112+ curracl = task->acl;
92113+ curr_ip = task->signal->curr_ip;
92114+
92115+ if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
92116+ read_lock(&tasklist_lock);
92117+ do_each_thread(p2, p) {
92118+ if (p->signal->curr_ip == curr_ip)
92119+ gr_fake_force_sig(SIGKILL, p);
92120+ } while_each_thread(p2, p);
92121+ read_unlock(&tasklist_lock);
92122+ } else if (curracl->mode & GR_KILLPROC)
92123+ gr_fake_force_sig(SIGKILL, task);
92124+
92125+ return;
92126+}
92127diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
92128new file mode 100644
92129index 0000000..6b0c9cc
92130--- /dev/null
92131+++ b/grsecurity/gracl_shm.c
92132@@ -0,0 +1,40 @@
92133+#include <linux/kernel.h>
92134+#include <linux/mm.h>
92135+#include <linux/sched.h>
92136+#include <linux/file.h>
92137+#include <linux/ipc.h>
92138+#include <linux/gracl.h>
92139+#include <linux/grsecurity.h>
92140+#include <linux/grinternal.h>
92141+
92142+int
92143+gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
92144+ const u64 shm_createtime, const kuid_t cuid, const int shmid)
92145+{
92146+ struct task_struct *task;
92147+
92148+ if (!gr_acl_is_enabled())
92149+ return 1;
92150+
92151+ rcu_read_lock();
92152+ read_lock(&tasklist_lock);
92153+
92154+ task = find_task_by_vpid(shm_cprid);
92155+
92156+ if (unlikely(!task))
92157+ task = find_task_by_vpid(shm_lapid);
92158+
92159+ if (unlikely(task && (time_before_eq64(task->start_time, shm_createtime) ||
92160+ (task_pid_nr(task) == shm_lapid)) &&
92161+ (task->acl->mode & GR_PROTSHM) &&
92162+ (task->acl != current->acl))) {
92163+ read_unlock(&tasklist_lock);
92164+ rcu_read_unlock();
92165+ gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
92166+ return 0;
92167+ }
92168+ read_unlock(&tasklist_lock);
92169+ rcu_read_unlock();
92170+
92171+ return 1;
92172+}
92173diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
92174new file mode 100644
92175index 0000000..bc0be01
92176--- /dev/null
92177+++ b/grsecurity/grsec_chdir.c
92178@@ -0,0 +1,19 @@
92179+#include <linux/kernel.h>
92180+#include <linux/sched.h>
92181+#include <linux/fs.h>
92182+#include <linux/file.h>
92183+#include <linux/grsecurity.h>
92184+#include <linux/grinternal.h>
92185+
92186+void
92187+gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
92188+{
92189+#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
92190+ if ((grsec_enable_chdir && grsec_enable_group &&
92191+ in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
92192+ !grsec_enable_group)) {
92193+ gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
92194+ }
92195+#endif
92196+ return;
92197+}
92198diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
92199new file mode 100644
92200index 0000000..652ab45
92201--- /dev/null
92202+++ b/grsecurity/grsec_chroot.c
92203@@ -0,0 +1,467 @@
92204+#include <linux/kernel.h>
92205+#include <linux/module.h>
92206+#include <linux/sched.h>
92207+#include <linux/file.h>
92208+#include <linux/fs.h>
92209+#include <linux/mount.h>
92210+#include <linux/types.h>
92211+#include "../fs/mount.h"
92212+#include <linux/grsecurity.h>
92213+#include <linux/grinternal.h>
92214+
92215+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
92216+int gr_init_ran;
92217+#endif
92218+
92219+void gr_inc_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt)
92220+{
92221+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
92222+ struct dentry *tmpd = dentry;
92223+
92224+ read_seqlock_excl(&mount_lock);
92225+ write_seqlock(&rename_lock);
92226+
92227+ while (tmpd != mnt->mnt_root) {
92228+ atomic_inc(&tmpd->chroot_refcnt);
92229+ tmpd = tmpd->d_parent;
92230+ }
92231+ atomic_inc(&tmpd->chroot_refcnt);
92232+
92233+ write_sequnlock(&rename_lock);
92234+ read_sequnlock_excl(&mount_lock);
92235+#endif
92236+}
92237+
92238+void gr_dec_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt)
92239+{
92240+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
92241+ struct dentry *tmpd = dentry;
92242+
92243+ read_seqlock_excl(&mount_lock);
92244+ write_seqlock(&rename_lock);
92245+
92246+ while (tmpd != mnt->mnt_root) {
92247+ atomic_dec(&tmpd->chroot_refcnt);
92248+ tmpd = tmpd->d_parent;
92249+ }
92250+ atomic_dec(&tmpd->chroot_refcnt);
92251+
92252+ write_sequnlock(&rename_lock);
92253+ read_sequnlock_excl(&mount_lock);
92254+#endif
92255+}
92256+
92257+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
92258+static struct dentry *get_closest_chroot(struct dentry *dentry)
92259+{
92260+ write_seqlock(&rename_lock);
92261+ do {
92262+ if (atomic_read(&dentry->chroot_refcnt)) {
92263+ write_sequnlock(&rename_lock);
92264+ return dentry;
92265+ }
92266+ dentry = dentry->d_parent;
92267+ } while (!IS_ROOT(dentry));
92268+ write_sequnlock(&rename_lock);
92269+ return NULL;
92270+}
92271+#endif
92272+
92273+int gr_bad_chroot_rename(struct dentry *olddentry, struct vfsmount *oldmnt,
92274+ struct dentry *newdentry, struct vfsmount *newmnt)
92275+{
92276+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
92277+ struct dentry *chroot;
92278+
92279+ if (unlikely(!grsec_enable_chroot_rename))
92280+ return 0;
92281+
92282+ if (likely(!proc_is_chrooted(current) && gr_is_global_root(current_uid())))
92283+ return 0;
92284+
92285+ chroot = get_closest_chroot(olddentry);
92286+
92287+ if (chroot == NULL)
92288+ return 0;
92289+
92290+ if (is_subdir(newdentry, chroot))
92291+ return 0;
92292+
92293+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_RENAME_MSG, olddentry, oldmnt);
92294+
92295+ return 1;
92296+#else
92297+ return 0;
92298+#endif
92299+}
92300+
92301+void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
92302+{
92303+#ifdef CONFIG_GRKERNSEC
92304+ if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
92305+ path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
92306+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
92307+ && gr_init_ran
92308+#endif
92309+ )
92310+ task->gr_is_chrooted = 1;
92311+ else {
92312+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
92313+ if (task_pid_nr(task) == 1 && !gr_init_ran)
92314+ gr_init_ran = 1;
92315+#endif
92316+ task->gr_is_chrooted = 0;
92317+ }
92318+
92319+ task->gr_chroot_dentry = path->dentry;
92320+#endif
92321+ return;
92322+}
92323+
92324+void gr_clear_chroot_entries(struct task_struct *task)
92325+{
92326+#ifdef CONFIG_GRKERNSEC
92327+ task->gr_is_chrooted = 0;
92328+ task->gr_chroot_dentry = NULL;
92329+#endif
92330+ return;
92331+}
92332+
92333+int
92334+gr_handle_chroot_unix(const pid_t pid)
92335+{
92336+#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
92337+ struct task_struct *p;
92338+
92339+ if (unlikely(!grsec_enable_chroot_unix))
92340+ return 1;
92341+
92342+ if (likely(!proc_is_chrooted(current)))
92343+ return 1;
92344+
92345+ rcu_read_lock();
92346+ read_lock(&tasklist_lock);
92347+ p = find_task_by_vpid_unrestricted(pid);
92348+ if (unlikely(p && !have_same_root(current, p))) {
92349+ read_unlock(&tasklist_lock);
92350+ rcu_read_unlock();
92351+ gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
92352+ return 0;
92353+ }
92354+ read_unlock(&tasklist_lock);
92355+ rcu_read_unlock();
92356+#endif
92357+ return 1;
92358+}
92359+
92360+int
92361+gr_handle_chroot_nice(void)
92362+{
92363+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
92364+ if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
92365+ gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
92366+ return -EPERM;
92367+ }
92368+#endif
92369+ return 0;
92370+}
92371+
92372+int
92373+gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
92374+{
92375+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
92376+ if (grsec_enable_chroot_nice && (niceval < task_nice(p))
92377+ && proc_is_chrooted(current)) {
92378+ gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
92379+ return -EACCES;
92380+ }
92381+#endif
92382+ return 0;
92383+}
92384+
92385+int
92386+gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
92387+{
92388+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
92389+ struct task_struct *p;
92390+ int ret = 0;
92391+ if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
92392+ return ret;
92393+
92394+ read_lock(&tasklist_lock);
92395+ do_each_pid_task(pid, type, p) {
92396+ if (!have_same_root(current, p)) {
92397+ ret = 1;
92398+ goto out;
92399+ }
92400+ } while_each_pid_task(pid, type, p);
92401+out:
92402+ read_unlock(&tasklist_lock);
92403+ return ret;
92404+#endif
92405+ return 0;
92406+}
92407+
92408+int
92409+gr_pid_is_chrooted(struct task_struct *p)
92410+{
92411+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
92412+ if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
92413+ return 0;
92414+
92415+ if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
92416+ !have_same_root(current, p)) {
92417+ return 1;
92418+ }
92419+#endif
92420+ return 0;
92421+}
92422+
92423+EXPORT_SYMBOL_GPL(gr_pid_is_chrooted);
92424+
92425+#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
92426+int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
92427+{
92428+ struct path path, currentroot;
92429+ int ret = 0;
92430+
92431+ path.dentry = (struct dentry *)u_dentry;
92432+ path.mnt = (struct vfsmount *)u_mnt;
92433+ get_fs_root(current->fs, &currentroot);
92434+ if (path_is_under(&path, &currentroot))
92435+ ret = 1;
92436+ path_put(&currentroot);
92437+
92438+ return ret;
92439+}
92440+#endif
92441+
92442+int
92443+gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
92444+{
92445+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
92446+ if (!grsec_enable_chroot_fchdir)
92447+ return 1;
92448+
92449+ if (!proc_is_chrooted(current))
92450+ return 1;
92451+ else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
92452+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
92453+ return 0;
92454+ }
92455+#endif
92456+ return 1;
92457+}
92458+
92459+int
92460+gr_chroot_fhandle(void)
92461+{
92462+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
92463+ if (!grsec_enable_chroot_fchdir)
92464+ return 1;
92465+
92466+ if (!proc_is_chrooted(current))
92467+ return 1;
92468+ else {
92469+ gr_log_noargs(GR_DONT_AUDIT, GR_CHROOT_FHANDLE_MSG);
92470+ return 0;
92471+ }
92472+#endif
92473+ return 1;
92474+}
92475+
92476+int
92477+gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
92478+ const u64 shm_createtime)
92479+{
92480+#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
92481+ struct task_struct *p;
92482+
92483+ if (unlikely(!grsec_enable_chroot_shmat))
92484+ return 1;
92485+
92486+ if (likely(!proc_is_chrooted(current)))
92487+ return 1;
92488+
92489+ rcu_read_lock();
92490+ read_lock(&tasklist_lock);
92491+
92492+ if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
92493+ if (time_before_eq64(p->start_time, shm_createtime)) {
92494+ if (have_same_root(current, p)) {
92495+ goto allow;
92496+ } else {
92497+ read_unlock(&tasklist_lock);
92498+ rcu_read_unlock();
92499+ gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
92500+ return 0;
92501+ }
92502+ }
92503+ /* creator exited, pid reuse, fall through to next check */
92504+ }
92505+ if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
92506+ if (unlikely(!have_same_root(current, p))) {
92507+ read_unlock(&tasklist_lock);
92508+ rcu_read_unlock();
92509+ gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
92510+ return 0;
92511+ }
92512+ }
92513+
92514+allow:
92515+ read_unlock(&tasklist_lock);
92516+ rcu_read_unlock();
92517+#endif
92518+ return 1;
92519+}
92520+
92521+void
92522+gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
92523+{
92524+#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
92525+ if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
92526+ gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
92527+#endif
92528+ return;
92529+}
92530+
92531+int
92532+gr_handle_chroot_mknod(const struct dentry *dentry,
92533+ const struct vfsmount *mnt, const int mode)
92534+{
92535+#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
92536+ if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
92537+ proc_is_chrooted(current)) {
92538+ gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
92539+ return -EPERM;
92540+ }
92541+#endif
92542+ return 0;
92543+}
92544+
92545+int
92546+gr_handle_chroot_mount(const struct dentry *dentry,
92547+ const struct vfsmount *mnt, const char *dev_name)
92548+{
92549+#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
92550+ if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
92551+ gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
92552+ return -EPERM;
92553+ }
92554+#endif
92555+ return 0;
92556+}
92557+
92558+int
92559+gr_handle_chroot_pivot(void)
92560+{
92561+#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
92562+ if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
92563+ gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
92564+ return -EPERM;
92565+ }
92566+#endif
92567+ return 0;
92568+}
92569+
92570+int
92571+gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
92572+{
92573+#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
92574+ if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
92575+ !gr_is_outside_chroot(dentry, mnt)) {
92576+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
92577+ return -EPERM;
92578+ }
92579+#endif
92580+ return 0;
92581+}
92582+
92583+extern const char *captab_log[];
92584+extern int captab_log_entries;
92585+
92586+int
92587+gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
92588+{
92589+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
92590+ if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
92591+ kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
92592+ if (cap_raised(chroot_caps, cap)) {
92593+ if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
92594+ gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
92595+ }
92596+ return 0;
92597+ }
92598+ }
92599+#endif
92600+ return 1;
92601+}
92602+
92603+int
92604+gr_chroot_is_capable(const int cap)
92605+{
92606+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
92607+ return gr_task_chroot_is_capable(current, current_cred(), cap);
92608+#endif
92609+ return 1;
92610+}
92611+
92612+int
92613+gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
92614+{
92615+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
92616+ if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
92617+ kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
92618+ if (cap_raised(chroot_caps, cap)) {
92619+ return 0;
92620+ }
92621+ }
92622+#endif
92623+ return 1;
92624+}
92625+
92626+int
92627+gr_chroot_is_capable_nolog(const int cap)
92628+{
92629+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
92630+ return gr_task_chroot_is_capable_nolog(current, cap);
92631+#endif
92632+ return 1;
92633+}
92634+
92635+int
92636+gr_handle_chroot_sysctl(const int op)
92637+{
92638+#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
92639+ if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
92640+ proc_is_chrooted(current))
92641+ return -EACCES;
92642+#endif
92643+ return 0;
92644+}
92645+
92646+void
92647+gr_handle_chroot_chdir(const struct path *path)
92648+{
92649+#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
92650+ if (grsec_enable_chroot_chdir)
92651+ set_fs_pwd(current->fs, path);
92652+#endif
92653+ return;
92654+}
92655+
92656+int
92657+gr_handle_chroot_chmod(const struct dentry *dentry,
92658+ const struct vfsmount *mnt, const int mode)
92659+{
92660+#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
92661+ /* allow chmod +s on directories, but not files */
92662+ if (grsec_enable_chroot_chmod && !d_is_dir(dentry) &&
92663+ ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
92664+ proc_is_chrooted(current)) {
92665+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
92666+ return -EPERM;
92667+ }
92668+#endif
92669+ return 0;
92670+}
92671diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
92672new file mode 100644
92673index 0000000..e723c08
92674--- /dev/null
92675+++ b/grsecurity/grsec_disabled.c
92676@@ -0,0 +1,445 @@
92677+#include <linux/kernel.h>
92678+#include <linux/module.h>
92679+#include <linux/sched.h>
92680+#include <linux/file.h>
92681+#include <linux/fs.h>
92682+#include <linux/kdev_t.h>
92683+#include <linux/net.h>
92684+#include <linux/in.h>
92685+#include <linux/ip.h>
92686+#include <linux/skbuff.h>
92687+#include <linux/sysctl.h>
92688+
92689+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
92690+void
92691+pax_set_initial_flags(struct linux_binprm *bprm)
92692+{
92693+ return;
92694+}
92695+#endif
92696+
92697+#ifdef CONFIG_SYSCTL
92698+__u32
92699+gr_handle_sysctl(const struct ctl_table * table, const int op)
92700+{
92701+ return 0;
92702+}
92703+#endif
92704+
92705+#ifdef CONFIG_TASKSTATS
92706+int gr_is_taskstats_denied(int pid)
92707+{
92708+ return 0;
92709+}
92710+#endif
92711+
92712+int
92713+gr_acl_is_enabled(void)
92714+{
92715+ return 0;
92716+}
92717+
92718+int
92719+gr_learn_cap(const struct task_struct *task, const struct cred *cred, const int cap)
92720+{
92721+ return 0;
92722+}
92723+
92724+void
92725+gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
92726+{
92727+ return;
92728+}
92729+
92730+int
92731+gr_handle_rawio(const struct inode *inode)
92732+{
92733+ return 0;
92734+}
92735+
92736+void
92737+gr_acl_handle_psacct(struct task_struct *task, const long code)
92738+{
92739+ return;
92740+}
92741+
92742+int
92743+gr_handle_ptrace(struct task_struct *task, const long request)
92744+{
92745+ return 0;
92746+}
92747+
92748+int
92749+gr_handle_proc_ptrace(struct task_struct *task)
92750+{
92751+ return 0;
92752+}
92753+
92754+int
92755+gr_set_acls(const int type)
92756+{
92757+ return 0;
92758+}
92759+
92760+int
92761+gr_check_hidden_task(const struct task_struct *tsk)
92762+{
92763+ return 0;
92764+}
92765+
92766+int
92767+gr_check_protected_task(const struct task_struct *task)
92768+{
92769+ return 0;
92770+}
92771+
92772+int
92773+gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
92774+{
92775+ return 0;
92776+}
92777+
92778+void
92779+gr_copy_label(struct task_struct *tsk)
92780+{
92781+ return;
92782+}
92783+
92784+void
92785+gr_set_pax_flags(struct task_struct *task)
92786+{
92787+ return;
92788+}
92789+
92790+int
92791+gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
92792+ const int unsafe_share)
92793+{
92794+ return 0;
92795+}
92796+
92797+void
92798+gr_handle_delete(const u64 ino, const dev_t dev)
92799+{
92800+ return;
92801+}
92802+
92803+void
92804+gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
92805+{
92806+ return;
92807+}
92808+
92809+void
92810+gr_handle_crash(struct task_struct *task, const int sig)
92811+{
92812+ return;
92813+}
92814+
92815+int
92816+gr_check_crash_exec(const struct file *filp)
92817+{
92818+ return 0;
92819+}
92820+
92821+int
92822+gr_check_crash_uid(const kuid_t uid)
92823+{
92824+ return 0;
92825+}
92826+
92827+void
92828+gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
92829+ struct dentry *old_dentry,
92830+ struct dentry *new_dentry,
92831+ struct vfsmount *mnt, const __u8 replace, unsigned int flags)
92832+{
92833+ return;
92834+}
92835+
92836+int
92837+gr_search_socket(const int family, const int type, const int protocol)
92838+{
92839+ return 1;
92840+}
92841+
92842+int
92843+gr_search_connectbind(const int mode, const struct socket *sock,
92844+ const struct sockaddr_in *addr)
92845+{
92846+ return 0;
92847+}
92848+
92849+void
92850+gr_handle_alertkill(struct task_struct *task)
92851+{
92852+ return;
92853+}
92854+
92855+__u32
92856+gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
92857+{
92858+ return 1;
92859+}
92860+
92861+__u32
92862+gr_acl_handle_hidden_file(const struct dentry * dentry,
92863+ const struct vfsmount * mnt)
92864+{
92865+ return 1;
92866+}
92867+
92868+__u32
92869+gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
92870+ int acc_mode)
92871+{
92872+ return 1;
92873+}
92874+
92875+__u32
92876+gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
92877+{
92878+ return 1;
92879+}
92880+
92881+__u32
92882+gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
92883+{
92884+ return 1;
92885+}
92886+
92887+int
92888+gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
92889+ unsigned int *vm_flags)
92890+{
92891+ return 1;
92892+}
92893+
92894+__u32
92895+gr_acl_handle_truncate(const struct dentry * dentry,
92896+ const struct vfsmount * mnt)
92897+{
92898+ return 1;
92899+}
92900+
92901+__u32
92902+gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
92903+{
92904+ return 1;
92905+}
92906+
92907+__u32
92908+gr_acl_handle_access(const struct dentry * dentry,
92909+ const struct vfsmount * mnt, const int fmode)
92910+{
92911+ return 1;
92912+}
92913+
92914+__u32
92915+gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
92916+ umode_t *mode)
92917+{
92918+ return 1;
92919+}
92920+
92921+__u32
92922+gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
92923+{
92924+ return 1;
92925+}
92926+
92927+__u32
92928+gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
92929+{
92930+ return 1;
92931+}
92932+
92933+__u32
92934+gr_acl_handle_removexattr(const struct dentry * dentry, const struct vfsmount * mnt)
92935+{
92936+ return 1;
92937+}
92938+
92939+void
92940+grsecurity_init(void)
92941+{
92942+ return;
92943+}
92944+
92945+umode_t gr_acl_umask(void)
92946+{
92947+ return 0;
92948+}
92949+
92950+__u32
92951+gr_acl_handle_mknod(const struct dentry * new_dentry,
92952+ const struct dentry * parent_dentry,
92953+ const struct vfsmount * parent_mnt,
92954+ const int mode)
92955+{
92956+ return 1;
92957+}
92958+
92959+__u32
92960+gr_acl_handle_mkdir(const struct dentry * new_dentry,
92961+ const struct dentry * parent_dentry,
92962+ const struct vfsmount * parent_mnt)
92963+{
92964+ return 1;
92965+}
92966+
92967+__u32
92968+gr_acl_handle_symlink(const struct dentry * new_dentry,
92969+ const struct dentry * parent_dentry,
92970+ const struct vfsmount * parent_mnt, const struct filename *from)
92971+{
92972+ return 1;
92973+}
92974+
92975+__u32
92976+gr_acl_handle_link(const struct dentry * new_dentry,
92977+ const struct dentry * parent_dentry,
92978+ const struct vfsmount * parent_mnt,
92979+ const struct dentry * old_dentry,
92980+ const struct vfsmount * old_mnt, const struct filename *to)
92981+{
92982+ return 1;
92983+}
92984+
92985+int
92986+gr_acl_handle_rename(const struct dentry *new_dentry,
92987+ const struct dentry *parent_dentry,
92988+ const struct vfsmount *parent_mnt,
92989+ const struct dentry *old_dentry,
92990+ const struct inode *old_parent_inode,
92991+ const struct vfsmount *old_mnt, const struct filename *newname,
92992+ unsigned int flags)
92993+{
92994+ return 0;
92995+}
92996+
92997+int
92998+gr_acl_handle_filldir(const struct file *file, const char *name,
92999+ const int namelen, const u64 ino)
93000+{
93001+ return 1;
93002+}
93003+
93004+int
93005+gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
93006+ const u64 shm_createtime, const kuid_t cuid, const int shmid)
93007+{
93008+ return 1;
93009+}
93010+
93011+int
93012+gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
93013+{
93014+ return 0;
93015+}
93016+
93017+int
93018+gr_search_accept(const struct socket *sock)
93019+{
93020+ return 0;
93021+}
93022+
93023+int
93024+gr_search_listen(const struct socket *sock)
93025+{
93026+ return 0;
93027+}
93028+
93029+int
93030+gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
93031+{
93032+ return 0;
93033+}
93034+
93035+__u32
93036+gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
93037+{
93038+ return 1;
93039+}
93040+
93041+__u32
93042+gr_acl_handle_creat(const struct dentry * dentry,
93043+ const struct dentry * p_dentry,
93044+ const struct vfsmount * p_mnt, int open_flags, int acc_mode,
93045+ const int imode)
93046+{
93047+ return 1;
93048+}
93049+
93050+void
93051+gr_acl_handle_exit(void)
93052+{
93053+ return;
93054+}
93055+
93056+int
93057+gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
93058+{
93059+ return 1;
93060+}
93061+
93062+void
93063+gr_set_role_label(const kuid_t uid, const kgid_t gid)
93064+{
93065+ return;
93066+}
93067+
93068+int
93069+gr_acl_handle_procpidmem(const struct task_struct *task)
93070+{
93071+ return 0;
93072+}
93073+
93074+int
93075+gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
93076+{
93077+ return 0;
93078+}
93079+
93080+int
93081+gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
93082+{
93083+ return 0;
93084+}
93085+
93086+int
93087+gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
93088+{
93089+ return 0;
93090+}
93091+
93092+int
93093+gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
93094+{
93095+ return 0;
93096+}
93097+
93098+int gr_acl_enable_at_secure(void)
93099+{
93100+ return 0;
93101+}
93102+
93103+dev_t gr_get_dev_from_dentry(struct dentry *dentry)
93104+{
93105+ return d_backing_inode(dentry)->i_sb->s_dev;
93106+}
93107+
93108+u64 gr_get_ino_from_dentry(struct dentry *dentry)
93109+{
93110+ return d_backing_inode(dentry)->i_ino;
93111+}
93112+
93113+void gr_put_exec_file(struct task_struct *task)
93114+{
93115+ return;
93116+}
93117+
93118+#ifdef CONFIG_SECURITY
93119+EXPORT_SYMBOL_GPL(gr_check_user_change);
93120+EXPORT_SYMBOL_GPL(gr_check_group_change);
93121+#endif
93122diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
93123new file mode 100644
93124index 0000000..fb7531e
93125--- /dev/null
93126+++ b/grsecurity/grsec_exec.c
93127@@ -0,0 +1,189 @@
93128+#include <linux/kernel.h>
93129+#include <linux/sched.h>
93130+#include <linux/file.h>
93131+#include <linux/binfmts.h>
93132+#include <linux/fs.h>
93133+#include <linux/types.h>
93134+#include <linux/grdefs.h>
93135+#include <linux/grsecurity.h>
93136+#include <linux/grinternal.h>
93137+#include <linux/capability.h>
93138+#include <linux/module.h>
93139+#include <linux/compat.h>
93140+
93141+#include <asm/uaccess.h>
93142+
93143+#ifdef CONFIG_GRKERNSEC_EXECLOG
93144+static char gr_exec_arg_buf[132];
93145+static DEFINE_MUTEX(gr_exec_arg_mutex);
93146+#endif
93147+
93148+struct user_arg_ptr {
93149+#ifdef CONFIG_COMPAT
93150+ bool is_compat;
93151+#endif
93152+ union {
93153+ const char __user *const __user *native;
93154+#ifdef CONFIG_COMPAT
93155+ const compat_uptr_t __user *compat;
93156+#endif
93157+ } ptr;
93158+};
93159+
93160+extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
93161+
93162+void
93163+gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
93164+{
93165+#ifdef CONFIG_GRKERNSEC_EXECLOG
93166+ char *grarg = gr_exec_arg_buf;
93167+ unsigned int i, x, execlen = 0;
93168+ char c;
93169+
93170+ if (!((grsec_enable_execlog && grsec_enable_group &&
93171+ in_group_p(grsec_audit_gid))
93172+ || (grsec_enable_execlog && !grsec_enable_group)))
93173+ return;
93174+
93175+ mutex_lock(&gr_exec_arg_mutex);
93176+ memset(grarg, 0, sizeof(gr_exec_arg_buf));
93177+
93178+ for (i = 0; i < bprm->argc && execlen < 128; i++) {
93179+ const char __user *p;
93180+ unsigned int len;
93181+
93182+ p = get_user_arg_ptr(argv, i);
93183+ if (IS_ERR(p))
93184+ goto log;
93185+
93186+ len = strnlen_user(p, 128 - execlen);
93187+ if (len > 128 - execlen)
93188+ len = 128 - execlen;
93189+ else if (len > 0)
93190+ len--;
93191+ if (copy_from_user(grarg + execlen, p, len))
93192+ goto log;
93193+
93194+ /* rewrite unprintable characters */
93195+ for (x = 0; x < len; x++) {
93196+ c = *(grarg + execlen + x);
93197+ if (c < 32 || c > 126)
93198+ *(grarg + execlen + x) = ' ';
93199+ }
93200+
93201+ execlen += len;
93202+ *(grarg + execlen) = ' ';
93203+ *(grarg + execlen + 1) = '\0';
93204+ execlen++;
93205+ }
93206+
93207+ log:
93208+ gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
93209+ bprm->file->f_path.mnt, grarg);
93210+ mutex_unlock(&gr_exec_arg_mutex);
93211+#endif
93212+ return;
93213+}
93214+
93215+#ifdef CONFIG_GRKERNSEC
93216+extern int gr_acl_is_capable(const int cap);
93217+extern int gr_acl_is_capable_nolog(const int cap);
93218+extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
93219+extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
93220+extern int gr_chroot_is_capable(const int cap);
93221+extern int gr_chroot_is_capable_nolog(const int cap);
93222+extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
93223+extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
93224+#endif
93225+
93226+const char *captab_log[] = {
93227+ "CAP_CHOWN",
93228+ "CAP_DAC_OVERRIDE",
93229+ "CAP_DAC_READ_SEARCH",
93230+ "CAP_FOWNER",
93231+ "CAP_FSETID",
93232+ "CAP_KILL",
93233+ "CAP_SETGID",
93234+ "CAP_SETUID",
93235+ "CAP_SETPCAP",
93236+ "CAP_LINUX_IMMUTABLE",
93237+ "CAP_NET_BIND_SERVICE",
93238+ "CAP_NET_BROADCAST",
93239+ "CAP_NET_ADMIN",
93240+ "CAP_NET_RAW",
93241+ "CAP_IPC_LOCK",
93242+ "CAP_IPC_OWNER",
93243+ "CAP_SYS_MODULE",
93244+ "CAP_SYS_RAWIO",
93245+ "CAP_SYS_CHROOT",
93246+ "CAP_SYS_PTRACE",
93247+ "CAP_SYS_PACCT",
93248+ "CAP_SYS_ADMIN",
93249+ "CAP_SYS_BOOT",
93250+ "CAP_SYS_NICE",
93251+ "CAP_SYS_RESOURCE",
93252+ "CAP_SYS_TIME",
93253+ "CAP_SYS_TTY_CONFIG",
93254+ "CAP_MKNOD",
93255+ "CAP_LEASE",
93256+ "CAP_AUDIT_WRITE",
93257+ "CAP_AUDIT_CONTROL",
93258+ "CAP_SETFCAP",
93259+ "CAP_MAC_OVERRIDE",
93260+ "CAP_MAC_ADMIN",
93261+ "CAP_SYSLOG",
93262+ "CAP_WAKE_ALARM",
93263+ "CAP_BLOCK_SUSPEND",
93264+ "CAP_AUDIT_READ"
93265+};
93266+
93267+int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
93268+
93269+int gr_is_capable(const int cap)
93270+{
93271+#ifdef CONFIG_GRKERNSEC
93272+ if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
93273+ return 1;
93274+ return 0;
93275+#else
93276+ return 1;
93277+#endif
93278+}
93279+
93280+int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
93281+{
93282+#ifdef CONFIG_GRKERNSEC
93283+ if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
93284+ return 1;
93285+ return 0;
93286+#else
93287+ return 1;
93288+#endif
93289+}
93290+
93291+int gr_is_capable_nolog(const int cap)
93292+{
93293+#ifdef CONFIG_GRKERNSEC
93294+ if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
93295+ return 1;
93296+ return 0;
93297+#else
93298+ return 1;
93299+#endif
93300+}
93301+
93302+int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
93303+{
93304+#ifdef CONFIG_GRKERNSEC
93305+ if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
93306+ return 1;
93307+ return 0;
93308+#else
93309+ return 1;
93310+#endif
93311+}
93312+
93313+EXPORT_SYMBOL_GPL(gr_is_capable);
93314+EXPORT_SYMBOL_GPL(gr_is_capable_nolog);
93315+EXPORT_SYMBOL_GPL(gr_task_is_capable);
93316+EXPORT_SYMBOL_GPL(gr_task_is_capable_nolog);
93317diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
93318new file mode 100644
93319index 0000000..cdec49b
93320--- /dev/null
93321+++ b/grsecurity/grsec_fifo.c
93322@@ -0,0 +1,26 @@
93323+#include <linux/kernel.h>
93324+#include <linux/sched.h>
93325+#include <linux/fs.h>
93326+#include <linux/file.h>
93327+#include <linux/grinternal.h>
93328+
93329+int
93330+gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
93331+ const struct dentry *dir, const int flag, const int acc_mode)
93332+{
93333+#ifdef CONFIG_GRKERNSEC_FIFO
93334+ const struct cred *cred = current_cred();
93335+ struct inode *inode = d_backing_inode(dentry);
93336+ struct inode *dir_inode = d_backing_inode(dir);
93337+
93338+ if (grsec_enable_fifo && S_ISFIFO(inode->i_mode) &&
93339+ !(flag & O_EXCL) && (dir_inode->i_mode & S_ISVTX) &&
93340+ !uid_eq(inode->i_uid, dir_inode->i_uid) &&
93341+ !uid_eq(cred->fsuid, inode->i_uid)) {
93342+ if (!inode_permission(inode, acc_mode))
93343+ gr_log_fs_int2(GR_DONT_AUDIT, GR_FIFO_MSG, dentry, mnt, GR_GLOBAL_UID(inode->i_uid), GR_GLOBAL_GID(inode->i_gid));
93344+ return -EACCES;
93345+ }
93346+#endif
93347+ return 0;
93348+}
93349diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
93350new file mode 100644
93351index 0000000..8ca18bf
93352--- /dev/null
93353+++ b/grsecurity/grsec_fork.c
93354@@ -0,0 +1,23 @@
93355+#include <linux/kernel.h>
93356+#include <linux/sched.h>
93357+#include <linux/grsecurity.h>
93358+#include <linux/grinternal.h>
93359+#include <linux/errno.h>
93360+
93361+void
93362+gr_log_forkfail(const int retval)
93363+{
93364+#ifdef CONFIG_GRKERNSEC_FORKFAIL
93365+ if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
93366+ switch (retval) {
93367+ case -EAGAIN:
93368+ gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
93369+ break;
93370+ case -ENOMEM:
93371+ gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
93372+ break;
93373+ }
93374+ }
93375+#endif
93376+ return;
93377+}
93378diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
93379new file mode 100644
93380index 0000000..a364c58
93381--- /dev/null
93382+++ b/grsecurity/grsec_init.c
93383@@ -0,0 +1,290 @@
93384+#include <linux/kernel.h>
93385+#include <linux/sched.h>
93386+#include <linux/mm.h>
93387+#include <linux/gracl.h>
93388+#include <linux/slab.h>
93389+#include <linux/vmalloc.h>
93390+#include <linux/percpu.h>
93391+#include <linux/module.h>
93392+
93393+int grsec_enable_ptrace_readexec __read_only;
93394+int grsec_enable_setxid __read_only;
93395+int grsec_enable_symlinkown __read_only;
93396+kgid_t grsec_symlinkown_gid __read_only;
93397+int grsec_enable_brute __read_only;
93398+int grsec_enable_link __read_only;
93399+int grsec_enable_dmesg __read_only;
93400+int grsec_enable_harden_ptrace __read_only;
93401+int grsec_enable_harden_ipc __read_only;
93402+int grsec_enable_fifo __read_only;
93403+int grsec_enable_execlog __read_only;
93404+int grsec_enable_signal __read_only;
93405+int grsec_enable_forkfail __read_only;
93406+int grsec_enable_audit_ptrace __read_only;
93407+int grsec_enable_time __read_only;
93408+int grsec_enable_group __read_only;
93409+kgid_t grsec_audit_gid __read_only;
93410+int grsec_enable_chdir __read_only;
93411+int grsec_enable_mount __read_only;
93412+int grsec_enable_rofs __read_only;
93413+int grsec_deny_new_usb __read_only;
93414+int grsec_enable_chroot_findtask __read_only;
93415+int grsec_enable_chroot_mount __read_only;
93416+int grsec_enable_chroot_shmat __read_only;
93417+int grsec_enable_chroot_fchdir __read_only;
93418+int grsec_enable_chroot_double __read_only;
93419+int grsec_enable_chroot_pivot __read_only;
93420+int grsec_enable_chroot_chdir __read_only;
93421+int grsec_enable_chroot_chmod __read_only;
93422+int grsec_enable_chroot_mknod __read_only;
93423+int grsec_enable_chroot_nice __read_only;
93424+int grsec_enable_chroot_execlog __read_only;
93425+int grsec_enable_chroot_caps __read_only;
93426+int grsec_enable_chroot_rename __read_only;
93427+int grsec_enable_chroot_sysctl __read_only;
93428+int grsec_enable_chroot_unix __read_only;
93429+int grsec_enable_tpe __read_only;
93430+kgid_t grsec_tpe_gid __read_only;
93431+int grsec_enable_blackhole __read_only;
93432+#ifdef CONFIG_IPV6_MODULE
93433+EXPORT_SYMBOL_GPL(grsec_enable_blackhole);
93434+#endif
93435+int grsec_lastack_retries __read_only;
93436+int grsec_enable_tpe_all __read_only;
93437+int grsec_enable_tpe_invert __read_only;
93438+int grsec_enable_socket_all __read_only;
93439+kgid_t grsec_socket_all_gid __read_only;
93440+int grsec_enable_socket_client __read_only;
93441+kgid_t grsec_socket_client_gid __read_only;
93442+int grsec_enable_socket_server __read_only;
93443+kgid_t grsec_socket_server_gid __read_only;
93444+int grsec_resource_logging __read_only;
93445+int grsec_disable_privio __read_only;
93446+int grsec_enable_log_rwxmaps __read_only;
93447+int grsec_lock __read_only;
93448+
93449+DEFINE_SPINLOCK(grsec_alert_lock);
93450+unsigned long grsec_alert_wtime = 0;
93451+unsigned long grsec_alert_fyet = 0;
93452+
93453+DEFINE_SPINLOCK(grsec_audit_lock);
93454+
93455+DEFINE_RWLOCK(grsec_exec_file_lock);
93456+
93457+char *gr_shared_page[4];
93458+
93459+char *gr_alert_log_fmt;
93460+char *gr_audit_log_fmt;
93461+char *gr_alert_log_buf;
93462+char *gr_audit_log_buf;
93463+
93464+extern struct gr_arg *gr_usermode;
93465+extern unsigned char *gr_system_salt;
93466+extern unsigned char *gr_system_sum;
93467+
93468+void __init
93469+grsecurity_init(void)
93470+{
93471+ int j;
93472+ /* create the per-cpu shared pages */
93473+
93474+#ifdef CONFIG_X86
93475+ memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
93476+#endif
93477+
93478+ for (j = 0; j < 4; j++) {
93479+ gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
93480+ if (gr_shared_page[j] == NULL) {
93481+ panic("Unable to allocate grsecurity shared page");
93482+ return;
93483+ }
93484+ }
93485+
93486+ /* allocate log buffers */
93487+ gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
93488+ if (!gr_alert_log_fmt) {
93489+ panic("Unable to allocate grsecurity alert log format buffer");
93490+ return;
93491+ }
93492+ gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
93493+ if (!gr_audit_log_fmt) {
93494+ panic("Unable to allocate grsecurity audit log format buffer");
93495+ return;
93496+ }
93497+ gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
93498+ if (!gr_alert_log_buf) {
93499+ panic("Unable to allocate grsecurity alert log buffer");
93500+ return;
93501+ }
93502+ gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
93503+ if (!gr_audit_log_buf) {
93504+ panic("Unable to allocate grsecurity audit log buffer");
93505+ return;
93506+ }
93507+
93508+ /* allocate memory for authentication structure */
93509+ gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
93510+ gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
93511+ gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
93512+
93513+ if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
93514+ panic("Unable to allocate grsecurity authentication structure");
93515+ return;
93516+ }
93517+
93518+#ifdef CONFIG_GRKERNSEC_IO
93519+#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
93520+ grsec_disable_privio = 1;
93521+#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
93522+ grsec_disable_privio = 1;
93523+#else
93524+ grsec_disable_privio = 0;
93525+#endif
93526+#endif
93527+
93528+#ifdef CONFIG_GRKERNSEC_TPE_INVERT
93529+ /* for backward compatibility, tpe_invert always defaults to on if
93530+ enabled in the kernel
93531+ */
93532+ grsec_enable_tpe_invert = 1;
93533+#endif
93534+
93535+#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
93536+#ifndef CONFIG_GRKERNSEC_SYSCTL
93537+ grsec_lock = 1;
93538+#endif
93539+
93540+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
93541+ grsec_enable_log_rwxmaps = 1;
93542+#endif
93543+#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
93544+ grsec_enable_group = 1;
93545+ grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
93546+#endif
93547+#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
93548+ grsec_enable_ptrace_readexec = 1;
93549+#endif
93550+#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
93551+ grsec_enable_chdir = 1;
93552+#endif
93553+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
93554+ grsec_enable_harden_ptrace = 1;
93555+#endif
93556+#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
93557+ grsec_enable_harden_ipc = 1;
93558+#endif
93559+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
93560+ grsec_enable_mount = 1;
93561+#endif
93562+#ifdef CONFIG_GRKERNSEC_LINK
93563+ grsec_enable_link = 1;
93564+#endif
93565+#ifdef CONFIG_GRKERNSEC_BRUTE
93566+ grsec_enable_brute = 1;
93567+#endif
93568+#ifdef CONFIG_GRKERNSEC_DMESG
93569+ grsec_enable_dmesg = 1;
93570+#endif
93571+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93572+ grsec_enable_blackhole = 1;
93573+ grsec_lastack_retries = 4;
93574+#endif
93575+#ifdef CONFIG_GRKERNSEC_FIFO
93576+ grsec_enable_fifo = 1;
93577+#endif
93578+#ifdef CONFIG_GRKERNSEC_EXECLOG
93579+ grsec_enable_execlog = 1;
93580+#endif
93581+#ifdef CONFIG_GRKERNSEC_SETXID
93582+ grsec_enable_setxid = 1;
93583+#endif
93584+#ifdef CONFIG_GRKERNSEC_SIGNAL
93585+ grsec_enable_signal = 1;
93586+#endif
93587+#ifdef CONFIG_GRKERNSEC_FORKFAIL
93588+ grsec_enable_forkfail = 1;
93589+#endif
93590+#ifdef CONFIG_GRKERNSEC_TIME
93591+ grsec_enable_time = 1;
93592+#endif
93593+#ifdef CONFIG_GRKERNSEC_RESLOG
93594+ grsec_resource_logging = 1;
93595+#endif
93596+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
93597+ grsec_enable_chroot_findtask = 1;
93598+#endif
93599+#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
93600+ grsec_enable_chroot_unix = 1;
93601+#endif
93602+#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
93603+ grsec_enable_chroot_mount = 1;
93604+#endif
93605+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
93606+ grsec_enable_chroot_fchdir = 1;
93607+#endif
93608+#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
93609+ grsec_enable_chroot_shmat = 1;
93610+#endif
93611+#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
93612+ grsec_enable_audit_ptrace = 1;
93613+#endif
93614+#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
93615+ grsec_enable_chroot_double = 1;
93616+#endif
93617+#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
93618+ grsec_enable_chroot_pivot = 1;
93619+#endif
93620+#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
93621+ grsec_enable_chroot_chdir = 1;
93622+#endif
93623+#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
93624+ grsec_enable_chroot_chmod = 1;
93625+#endif
93626+#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
93627+ grsec_enable_chroot_mknod = 1;
93628+#endif
93629+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
93630+ grsec_enable_chroot_nice = 1;
93631+#endif
93632+#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
93633+ grsec_enable_chroot_execlog = 1;
93634+#endif
93635+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
93636+ grsec_enable_chroot_caps = 1;
93637+#endif
93638+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
93639+ grsec_enable_chroot_rename = 1;
93640+#endif
93641+#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
93642+ grsec_enable_chroot_sysctl = 1;
93643+#endif
93644+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
93645+ grsec_enable_symlinkown = 1;
93646+ grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
93647+#endif
93648+#ifdef CONFIG_GRKERNSEC_TPE
93649+ grsec_enable_tpe = 1;
93650+ grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
93651+#ifdef CONFIG_GRKERNSEC_TPE_ALL
93652+ grsec_enable_tpe_all = 1;
93653+#endif
93654+#endif
93655+#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
93656+ grsec_enable_socket_all = 1;
93657+ grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
93658+#endif
93659+#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
93660+ grsec_enable_socket_client = 1;
93661+ grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
93662+#endif
93663+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
93664+ grsec_enable_socket_server = 1;
93665+ grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
93666+#endif
93667+#endif
93668+#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
93669+ grsec_deny_new_usb = 1;
93670+#endif
93671+
93672+ return;
93673+}
93674diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
93675new file mode 100644
93676index 0000000..1773300
93677--- /dev/null
93678+++ b/grsecurity/grsec_ipc.c
93679@@ -0,0 +1,48 @@
93680+#include <linux/kernel.h>
93681+#include <linux/mm.h>
93682+#include <linux/sched.h>
93683+#include <linux/file.h>
93684+#include <linux/ipc.h>
93685+#include <linux/ipc_namespace.h>
93686+#include <linux/grsecurity.h>
93687+#include <linux/grinternal.h>
93688+
93689+int
93690+gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
93691+{
93692+#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
93693+ int write;
93694+ int orig_granted_mode;
93695+ kuid_t euid;
93696+ kgid_t egid;
93697+
93698+ if (!grsec_enable_harden_ipc)
93699+ return 1;
93700+
93701+ euid = current_euid();
93702+ egid = current_egid();
93703+
93704+ write = requested_mode & 00002;
93705+ orig_granted_mode = ipcp->mode;
93706+
93707+ if (uid_eq(euid, ipcp->cuid) || uid_eq(euid, ipcp->uid))
93708+ orig_granted_mode >>= 6;
93709+ else {
93710+ /* if likely wrong permissions, lock to user */
93711+ if (orig_granted_mode & 0007)
93712+ orig_granted_mode = 0;
93713+ /* otherwise do a egid-only check */
93714+ else if (gid_eq(egid, ipcp->cgid) || gid_eq(egid, ipcp->gid))
93715+ orig_granted_mode >>= 3;
93716+ /* otherwise, no access */
93717+ else
93718+ orig_granted_mode = 0;
93719+ }
93720+ if (!(requested_mode & ~granted_mode & 0007) && (requested_mode & ~orig_granted_mode & 0007) &&
93721+ !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
93722+ gr_log_str_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", GR_GLOBAL_UID(ipcp->cuid));
93723+ return 0;
93724+ }
93725+#endif
93726+ return 1;
93727+}
93728diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
93729new file mode 100644
93730index 0000000..84c44a0
93731--- /dev/null
93732+++ b/grsecurity/grsec_link.c
93733@@ -0,0 +1,65 @@
93734+#include <linux/kernel.h>
93735+#include <linux/sched.h>
93736+#include <linux/fs.h>
93737+#include <linux/file.h>
93738+#include <linux/grinternal.h>
93739+
93740+int gr_get_symlinkown_enabled(void)
93741+{
93742+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
93743+ if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid))
93744+ return 1;
93745+#endif
93746+ return 0;
93747+}
93748+
93749+int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
93750+{
93751+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
93752+ const struct inode *link_inode = d_backing_inode(link->dentry);
93753+
93754+ if (target && !uid_eq(link_inode->i_uid, target->i_uid)) {
93755+ 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));
93756+ return 1;
93757+ }
93758+#endif
93759+ return 0;
93760+}
93761+
93762+int
93763+gr_handle_follow_link(const struct dentry *dentry, const struct vfsmount *mnt)
93764+{
93765+#ifdef CONFIG_GRKERNSEC_LINK
93766+ struct inode *inode = d_backing_inode(dentry);
93767+ struct inode *parent = d_backing_inode(dentry->d_parent);
93768+ const struct cred *cred = current_cred();
93769+
93770+ if (grsec_enable_link && d_is_symlink(dentry) &&
93771+ (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
93772+ (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
93773+ gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, GR_GLOBAL_UID(inode->i_uid), GR_GLOBAL_GID(inode->i_gid));
93774+ return -EACCES;
93775+ }
93776+#endif
93777+ return 0;
93778+}
93779+
93780+int
93781+gr_handle_hardlink(const struct dentry *dentry,
93782+ const struct vfsmount *mnt,
93783+ const struct filename *to)
93784+{
93785+#ifdef CONFIG_GRKERNSEC_LINK
93786+ struct inode *inode = d_backing_inode(dentry);
93787+ const struct cred *cred = current_cred();
93788+
93789+ if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
93790+ (!d_is_reg(dentry) || is_privileged_binary(dentry) ||
93791+ (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
93792+ !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
93793+ 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);
93794+ return -EPERM;
93795+ }
93796+#endif
93797+ return 0;
93798+}
93799diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
93800new file mode 100644
93801index 0000000..a24b338
93802--- /dev/null
93803+++ b/grsecurity/grsec_log.c
93804@@ -0,0 +1,340 @@
93805+#include <linux/kernel.h>
93806+#include <linux/sched.h>
93807+#include <linux/file.h>
93808+#include <linux/tty.h>
93809+#include <linux/fs.h>
93810+#include <linux/mm.h>
93811+#include <linux/grinternal.h>
93812+
93813+#ifdef CONFIG_TREE_PREEMPT_RCU
93814+#define DISABLE_PREEMPT() preempt_disable()
93815+#define ENABLE_PREEMPT() preempt_enable()
93816+#else
93817+#define DISABLE_PREEMPT()
93818+#define ENABLE_PREEMPT()
93819+#endif
93820+
93821+#define BEGIN_LOCKS(x) \
93822+ DISABLE_PREEMPT(); \
93823+ rcu_read_lock(); \
93824+ read_lock(&tasklist_lock); \
93825+ read_lock(&grsec_exec_file_lock); \
93826+ if (x != GR_DO_AUDIT) \
93827+ spin_lock(&grsec_alert_lock); \
93828+ else \
93829+ spin_lock(&grsec_audit_lock)
93830+
93831+#define END_LOCKS(x) \
93832+ if (x != GR_DO_AUDIT) \
93833+ spin_unlock(&grsec_alert_lock); \
93834+ else \
93835+ spin_unlock(&grsec_audit_lock); \
93836+ read_unlock(&grsec_exec_file_lock); \
93837+ read_unlock(&tasklist_lock); \
93838+ rcu_read_unlock(); \
93839+ ENABLE_PREEMPT(); \
93840+ if (x == GR_DONT_AUDIT) \
93841+ gr_handle_alertkill(current)
93842+
93843+enum {
93844+ FLOODING,
93845+ NO_FLOODING
93846+};
93847+
93848+extern char *gr_alert_log_fmt;
93849+extern char *gr_audit_log_fmt;
93850+extern char *gr_alert_log_buf;
93851+extern char *gr_audit_log_buf;
93852+
93853+static int gr_log_start(int audit)
93854+{
93855+ char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
93856+ char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
93857+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
93858+#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
93859+ unsigned long curr_secs = get_seconds();
93860+
93861+ if (audit == GR_DO_AUDIT)
93862+ goto set_fmt;
93863+
93864+ if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
93865+ grsec_alert_wtime = curr_secs;
93866+ grsec_alert_fyet = 0;
93867+ } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
93868+ && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
93869+ grsec_alert_fyet++;
93870+ } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
93871+ grsec_alert_wtime = curr_secs;
93872+ grsec_alert_fyet++;
93873+ printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
93874+ return FLOODING;
93875+ }
93876+ else return FLOODING;
93877+
93878+set_fmt:
93879+#endif
93880+ memset(buf, 0, PAGE_SIZE);
93881+ if (current->signal->curr_ip && gr_acl_is_enabled()) {
93882+ sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
93883+ snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
93884+ } else if (current->signal->curr_ip) {
93885+ sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
93886+ snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
93887+ } else if (gr_acl_is_enabled()) {
93888+ sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
93889+ snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
93890+ } else {
93891+ sprintf(fmt, "%s%s", loglevel, "grsec: ");
93892+ strcpy(buf, fmt);
93893+ }
93894+
93895+ return NO_FLOODING;
93896+}
93897+
93898+static void gr_log_middle(int audit, const char *msg, va_list ap)
93899+ __attribute__ ((format (printf, 2, 0)));
93900+
93901+static void gr_log_middle(int audit, const char *msg, va_list ap)
93902+{
93903+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
93904+ unsigned int len = strlen(buf);
93905+
93906+ vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
93907+
93908+ return;
93909+}
93910+
93911+static void gr_log_middle_varargs(int audit, const char *msg, ...)
93912+ __attribute__ ((format (printf, 2, 3)));
93913+
93914+static void gr_log_middle_varargs(int audit, const char *msg, ...)
93915+{
93916+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
93917+ unsigned int len = strlen(buf);
93918+ va_list ap;
93919+
93920+ va_start(ap, msg);
93921+ vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
93922+ va_end(ap);
93923+
93924+ return;
93925+}
93926+
93927+static void gr_log_end(int audit, int append_default)
93928+{
93929+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
93930+ if (append_default) {
93931+ struct task_struct *task = current;
93932+ struct task_struct *parent = task->real_parent;
93933+ const struct cred *cred = __task_cred(task);
93934+ const struct cred *pcred = __task_cred(parent);
93935+ unsigned int len = strlen(buf);
93936+
93937+ 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));
93938+ }
93939+
93940+ printk("%s\n", buf);
93941+
93942+ return;
93943+}
93944+
93945+void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
93946+{
93947+ int logtype;
93948+ char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
93949+ char *str1 = NULL, *str2 = NULL, *str3 = NULL;
93950+ void *voidptr = NULL;
93951+ int num1 = 0, num2 = 0;
93952+ unsigned long ulong1 = 0, ulong2 = 0;
93953+ struct dentry *dentry = NULL;
93954+ struct vfsmount *mnt = NULL;
93955+ struct file *file = NULL;
93956+ struct task_struct *task = NULL;
93957+ struct vm_area_struct *vma = NULL;
93958+ const struct cred *cred, *pcred;
93959+ va_list ap;
93960+
93961+ BEGIN_LOCKS(audit);
93962+ logtype = gr_log_start(audit);
93963+ if (logtype == FLOODING) {
93964+ END_LOCKS(audit);
93965+ return;
93966+ }
93967+ va_start(ap, argtypes);
93968+ switch (argtypes) {
93969+ case GR_TTYSNIFF:
93970+ task = va_arg(ap, struct task_struct *);
93971+ 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));
93972+ break;
93973+ case GR_SYSCTL_HIDDEN:
93974+ str1 = va_arg(ap, char *);
93975+ gr_log_middle_varargs(audit, msg, result, str1);
93976+ break;
93977+ case GR_RBAC:
93978+ dentry = va_arg(ap, struct dentry *);
93979+ mnt = va_arg(ap, struct vfsmount *);
93980+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
93981+ break;
93982+ case GR_RBAC_STR:
93983+ dentry = va_arg(ap, struct dentry *);
93984+ mnt = va_arg(ap, struct vfsmount *);
93985+ str1 = va_arg(ap, char *);
93986+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
93987+ break;
93988+ case GR_STR_RBAC:
93989+ str1 = va_arg(ap, char *);
93990+ dentry = va_arg(ap, struct dentry *);
93991+ mnt = va_arg(ap, struct vfsmount *);
93992+ gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
93993+ break;
93994+ case GR_RBAC_MODE2:
93995+ dentry = va_arg(ap, struct dentry *);
93996+ mnt = va_arg(ap, struct vfsmount *);
93997+ str1 = va_arg(ap, char *);
93998+ str2 = va_arg(ap, char *);
93999+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
94000+ break;
94001+ case GR_RBAC_MODE3:
94002+ dentry = va_arg(ap, struct dentry *);
94003+ mnt = va_arg(ap, struct vfsmount *);
94004+ str1 = va_arg(ap, char *);
94005+ str2 = va_arg(ap, char *);
94006+ str3 = va_arg(ap, char *);
94007+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
94008+ break;
94009+ case GR_FILENAME:
94010+ dentry = va_arg(ap, struct dentry *);
94011+ mnt = va_arg(ap, struct vfsmount *);
94012+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
94013+ break;
94014+ case GR_STR_FILENAME:
94015+ str1 = va_arg(ap, char *);
94016+ dentry = va_arg(ap, struct dentry *);
94017+ mnt = va_arg(ap, struct vfsmount *);
94018+ gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
94019+ break;
94020+ case GR_FILENAME_STR:
94021+ dentry = va_arg(ap, struct dentry *);
94022+ mnt = va_arg(ap, struct vfsmount *);
94023+ str1 = va_arg(ap, char *);
94024+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
94025+ break;
94026+ case GR_FILENAME_TWO_INT:
94027+ dentry = va_arg(ap, struct dentry *);
94028+ mnt = va_arg(ap, struct vfsmount *);
94029+ num1 = va_arg(ap, int);
94030+ num2 = va_arg(ap, int);
94031+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
94032+ break;
94033+ case GR_FILENAME_TWO_INT_STR:
94034+ dentry = va_arg(ap, struct dentry *);
94035+ mnt = va_arg(ap, struct vfsmount *);
94036+ num1 = va_arg(ap, int);
94037+ num2 = va_arg(ap, int);
94038+ str1 = va_arg(ap, char *);
94039+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
94040+ break;
94041+ case GR_TEXTREL:
94042+ str1 = va_arg(ap, char *);
94043+ file = va_arg(ap, struct file *);
94044+ ulong1 = va_arg(ap, unsigned long);
94045+ ulong2 = va_arg(ap, unsigned long);
94046+ gr_log_middle_varargs(audit, msg, str1, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
94047+ break;
94048+ case GR_PTRACE:
94049+ task = va_arg(ap, struct task_struct *);
94050+ 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));
94051+ break;
94052+ case GR_RESOURCE:
94053+ task = va_arg(ap, struct task_struct *);
94054+ cred = __task_cred(task);
94055+ pcred = __task_cred(task->real_parent);
94056+ ulong1 = va_arg(ap, unsigned long);
94057+ str1 = va_arg(ap, char *);
94058+ ulong2 = va_arg(ap, unsigned long);
94059+ 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));
94060+ break;
94061+ case GR_CAP:
94062+ task = va_arg(ap, struct task_struct *);
94063+ cred = __task_cred(task);
94064+ pcred = __task_cred(task->real_parent);
94065+ str1 = va_arg(ap, char *);
94066+ 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));
94067+ break;
94068+ case GR_SIG:
94069+ str1 = va_arg(ap, char *);
94070+ voidptr = va_arg(ap, void *);
94071+ gr_log_middle_varargs(audit, msg, str1, voidptr);
94072+ break;
94073+ case GR_SIG2:
94074+ task = va_arg(ap, struct task_struct *);
94075+ cred = __task_cred(task);
94076+ pcred = __task_cred(task->real_parent);
94077+ num1 = va_arg(ap, int);
94078+ 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));
94079+ break;
94080+ case GR_CRASH1:
94081+ task = va_arg(ap, struct task_struct *);
94082+ cred = __task_cred(task);
94083+ pcred = __task_cred(task->real_parent);
94084+ ulong1 = va_arg(ap, unsigned long);
94085+ 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);
94086+ break;
94087+ case GR_CRASH2:
94088+ task = va_arg(ap, struct task_struct *);
94089+ cred = __task_cred(task);
94090+ pcred = __task_cred(task->real_parent);
94091+ ulong1 = va_arg(ap, unsigned long);
94092+ 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);
94093+ break;
94094+ case GR_RWXMAP:
94095+ file = va_arg(ap, struct file *);
94096+ gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
94097+ break;
94098+ case GR_RWXMAPVMA:
94099+ vma = va_arg(ap, struct vm_area_struct *);
94100+ if (vma->vm_file)
94101+ str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
94102+ else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
94103+ str1 = "<stack>";
94104+ else if (vma->vm_start <= current->mm->brk &&
94105+ vma->vm_end >= current->mm->start_brk)
94106+ str1 = "<heap>";
94107+ else
94108+ str1 = "<anonymous mapping>";
94109+ gr_log_middle_varargs(audit, msg, str1);
94110+ break;
94111+ case GR_PSACCT:
94112+ {
94113+ unsigned int wday, cday;
94114+ __u8 whr, chr;
94115+ __u8 wmin, cmin;
94116+ __u8 wsec, csec;
94117+
94118+ task = va_arg(ap, struct task_struct *);
94119+ wday = va_arg(ap, unsigned int);
94120+ cday = va_arg(ap, unsigned int);
94121+ whr = va_arg(ap, int);
94122+ chr = va_arg(ap, int);
94123+ wmin = va_arg(ap, int);
94124+ cmin = va_arg(ap, int);
94125+ wsec = va_arg(ap, int);
94126+ csec = va_arg(ap, int);
94127+ ulong1 = va_arg(ap, unsigned long);
94128+ cred = __task_cred(task);
94129+ pcred = __task_cred(task->real_parent);
94130+
94131+ 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));
94132+ }
94133+ break;
94134+ default:
94135+ gr_log_middle(audit, msg, ap);
94136+ }
94137+ va_end(ap);
94138+ // these don't need DEFAULTSECARGS printed on the end
94139+ if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
94140+ gr_log_end(audit, 0);
94141+ else
94142+ gr_log_end(audit, 1);
94143+ END_LOCKS(audit);
94144+}
94145diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
94146new file mode 100644
94147index 0000000..0e39d8c7
94148--- /dev/null
94149+++ b/grsecurity/grsec_mem.c
94150@@ -0,0 +1,48 @@
94151+#include <linux/kernel.h>
94152+#include <linux/sched.h>
94153+#include <linux/mm.h>
94154+#include <linux/mman.h>
94155+#include <linux/module.h>
94156+#include <linux/grinternal.h>
94157+
94158+void gr_handle_msr_write(void)
94159+{
94160+ gr_log_noargs(GR_DONT_AUDIT, GR_MSRWRITE_MSG);
94161+ return;
94162+}
94163+EXPORT_SYMBOL_GPL(gr_handle_msr_write);
94164+
94165+void
94166+gr_handle_ioperm(void)
94167+{
94168+ gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
94169+ return;
94170+}
94171+
94172+void
94173+gr_handle_iopl(void)
94174+{
94175+ gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
94176+ return;
94177+}
94178+
94179+void
94180+gr_handle_mem_readwrite(u64 from, u64 to)
94181+{
94182+ gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
94183+ return;
94184+}
94185+
94186+void
94187+gr_handle_vm86(void)
94188+{
94189+ gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
94190+ return;
94191+}
94192+
94193+void
94194+gr_log_badprocpid(const char *entry)
94195+{
94196+ gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
94197+ return;
94198+}
94199diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
94200new file mode 100644
94201index 0000000..fe02bf4
94202--- /dev/null
94203+++ b/grsecurity/grsec_mount.c
94204@@ -0,0 +1,65 @@
94205+#include <linux/kernel.h>
94206+#include <linux/sched.h>
94207+#include <linux/mount.h>
94208+#include <linux/major.h>
94209+#include <linux/grsecurity.h>
94210+#include <linux/grinternal.h>
94211+
94212+void
94213+gr_log_remount(const char *devname, const int retval)
94214+{
94215+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
94216+ if (grsec_enable_mount && (retval >= 0))
94217+ gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
94218+#endif
94219+ return;
94220+}
94221+
94222+void
94223+gr_log_unmount(const char *devname, const int retval)
94224+{
94225+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
94226+ if (grsec_enable_mount && (retval >= 0))
94227+ gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
94228+#endif
94229+ return;
94230+}
94231+
94232+void
94233+gr_log_mount(const char *from, struct path *to, const int retval)
94234+{
94235+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
94236+ if (grsec_enable_mount && (retval >= 0))
94237+ gr_log_str_fs(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to->dentry, to->mnt);
94238+#endif
94239+ return;
94240+}
94241+
94242+int
94243+gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
94244+{
94245+#ifdef CONFIG_GRKERNSEC_ROFS
94246+ if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
94247+ gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
94248+ return -EPERM;
94249+ } else
94250+ return 0;
94251+#endif
94252+ return 0;
94253+}
94254+
94255+int
94256+gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
94257+{
94258+#ifdef CONFIG_GRKERNSEC_ROFS
94259+ struct inode *inode = d_backing_inode(dentry);
94260+
94261+ if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
94262+ inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR))) {
94263+ gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
94264+ return -EPERM;
94265+ } else
94266+ return 0;
94267+#endif
94268+ return 0;
94269+}
94270diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
94271new file mode 100644
94272index 0000000..2ad7b96
94273--- /dev/null
94274+++ b/grsecurity/grsec_pax.c
94275@@ -0,0 +1,47 @@
94276+#include <linux/kernel.h>
94277+#include <linux/sched.h>
94278+#include <linux/mm.h>
94279+#include <linux/file.h>
94280+#include <linux/grinternal.h>
94281+#include <linux/grsecurity.h>
94282+
94283+void
94284+gr_log_textrel(struct vm_area_struct * vma, bool is_textrel_rw)
94285+{
94286+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
94287+ if (grsec_enable_log_rwxmaps)
94288+ gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG,
94289+ is_textrel_rw ? "executable to writable" : "writable to executable",
94290+ vma->vm_file, vma->vm_start, vma->vm_pgoff);
94291+#endif
94292+ return;
94293+}
94294+
94295+void gr_log_ptgnustack(struct file *file)
94296+{
94297+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
94298+ if (grsec_enable_log_rwxmaps)
94299+ gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
94300+#endif
94301+ return;
94302+}
94303+
94304+void
94305+gr_log_rwxmmap(struct file *file)
94306+{
94307+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
94308+ if (grsec_enable_log_rwxmaps)
94309+ gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
94310+#endif
94311+ return;
94312+}
94313+
94314+void
94315+gr_log_rwxmprotect(struct vm_area_struct *vma)
94316+{
94317+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
94318+ if (grsec_enable_log_rwxmaps)
94319+ gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
94320+#endif
94321+ return;
94322+}
94323diff --git a/grsecurity/grsec_proc.c b/grsecurity/grsec_proc.c
94324new file mode 100644
94325index 0000000..2005a3a
94326--- /dev/null
94327+++ b/grsecurity/grsec_proc.c
94328@@ -0,0 +1,20 @@
94329+#include <linux/kernel.h>
94330+#include <linux/sched.h>
94331+#include <linux/grsecurity.h>
94332+#include <linux/grinternal.h>
94333+
94334+int gr_proc_is_restricted(void)
94335+{
94336+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
94337+ const struct cred *cred = current_cred();
94338+#endif
94339+
94340+#ifdef CONFIG_GRKERNSEC_PROC_USER
94341+ if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
94342+ return -EACCES;
94343+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
94344+ if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
94345+ return -EACCES;
94346+#endif
94347+ return 0;
94348+}
94349diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
94350new file mode 100644
94351index 0000000..304c518
94352--- /dev/null
94353+++ b/grsecurity/grsec_ptrace.c
94354@@ -0,0 +1,30 @@
94355+#include <linux/kernel.h>
94356+#include <linux/sched.h>
94357+#include <linux/grinternal.h>
94358+#include <linux/security.h>
94359+
94360+void
94361+gr_audit_ptrace(struct task_struct *task)
94362+{
94363+#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
94364+ if (grsec_enable_audit_ptrace)
94365+ gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
94366+#endif
94367+ return;
94368+}
94369+
94370+int
94371+gr_ptrace_readexec(struct file *file, int unsafe_flags)
94372+{
94373+#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
94374+ const struct dentry *dentry = file->f_path.dentry;
94375+ const struct vfsmount *mnt = file->f_path.mnt;
94376+
94377+ if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
94378+ (inode_permission(d_backing_inode(dentry), MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
94379+ gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
94380+ return -EACCES;
94381+ }
94382+#endif
94383+ return 0;
94384+}
94385diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
94386new file mode 100644
94387index 0000000..3860c7e
94388--- /dev/null
94389+++ b/grsecurity/grsec_sig.c
94390@@ -0,0 +1,236 @@
94391+#include <linux/kernel.h>
94392+#include <linux/sched.h>
94393+#include <linux/fs.h>
94394+#include <linux/delay.h>
94395+#include <linux/grsecurity.h>
94396+#include <linux/grinternal.h>
94397+#include <linux/hardirq.h>
94398+
94399+char *signames[] = {
94400+ [SIGSEGV] = "Segmentation fault",
94401+ [SIGILL] = "Illegal instruction",
94402+ [SIGABRT] = "Abort",
94403+ [SIGBUS] = "Invalid alignment/Bus error"
94404+};
94405+
94406+void
94407+gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
94408+{
94409+#ifdef CONFIG_GRKERNSEC_SIGNAL
94410+ if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
94411+ (sig == SIGABRT) || (sig == SIGBUS))) {
94412+ if (task_pid_nr(t) == task_pid_nr(current)) {
94413+ gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
94414+ } else {
94415+ gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
94416+ }
94417+ }
94418+#endif
94419+ return;
94420+}
94421+
94422+int
94423+gr_handle_signal(const struct task_struct *p, const int sig)
94424+{
94425+#ifdef CONFIG_GRKERNSEC
94426+ /* ignore the 0 signal for protected task checks */
94427+ if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
94428+ gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
94429+ return -EPERM;
94430+ } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
94431+ return -EPERM;
94432+ }
94433+#endif
94434+ return 0;
94435+}
94436+
94437+#ifdef CONFIG_GRKERNSEC
94438+extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
94439+
94440+int gr_fake_force_sig(int sig, struct task_struct *t)
94441+{
94442+ unsigned long int flags;
94443+ int ret, blocked, ignored;
94444+ struct k_sigaction *action;
94445+
94446+ spin_lock_irqsave(&t->sighand->siglock, flags);
94447+ action = &t->sighand->action[sig-1];
94448+ ignored = action->sa.sa_handler == SIG_IGN;
94449+ blocked = sigismember(&t->blocked, sig);
94450+ if (blocked || ignored) {
94451+ action->sa.sa_handler = SIG_DFL;
94452+ if (blocked) {
94453+ sigdelset(&t->blocked, sig);
94454+ recalc_sigpending_and_wake(t);
94455+ }
94456+ }
94457+ if (action->sa.sa_handler == SIG_DFL)
94458+ t->signal->flags &= ~SIGNAL_UNKILLABLE;
94459+ ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
94460+
94461+ spin_unlock_irqrestore(&t->sighand->siglock, flags);
94462+
94463+ return ret;
94464+}
94465+#endif
94466+
94467+#define GR_USER_BAN_TIME (15 * 60)
94468+#define GR_DAEMON_BRUTE_TIME (30 * 60)
94469+
94470+void gr_handle_brute_attach(int dumpable)
94471+{
94472+#ifdef CONFIG_GRKERNSEC_BRUTE
94473+ struct task_struct *p = current;
94474+ kuid_t uid = GLOBAL_ROOT_UID;
94475+ int daemon = 0;
94476+
94477+ if (!grsec_enable_brute)
94478+ return;
94479+
94480+ rcu_read_lock();
94481+ read_lock(&tasklist_lock);
94482+ read_lock(&grsec_exec_file_lock);
94483+ if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
94484+ p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
94485+ p->real_parent->brute = 1;
94486+ daemon = 1;
94487+ } else {
94488+ const struct cred *cred = __task_cred(p), *cred2;
94489+ struct task_struct *tsk, *tsk2;
94490+
94491+ if (dumpable != SUID_DUMP_USER && gr_is_global_nonroot(cred->uid)) {
94492+ struct user_struct *user;
94493+
94494+ uid = cred->uid;
94495+
94496+ /* this is put upon execution past expiration */
94497+ user = find_user(uid);
94498+ if (user == NULL)
94499+ goto unlock;
94500+ user->suid_banned = 1;
94501+ user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
94502+ if (user->suid_ban_expires == ~0UL)
94503+ user->suid_ban_expires--;
94504+
94505+ /* only kill other threads of the same binary, from the same user */
94506+ do_each_thread(tsk2, tsk) {
94507+ cred2 = __task_cred(tsk);
94508+ if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
94509+ gr_fake_force_sig(SIGKILL, tsk);
94510+ } while_each_thread(tsk2, tsk);
94511+ }
94512+ }
94513+unlock:
94514+ read_unlock(&grsec_exec_file_lock);
94515+ read_unlock(&tasklist_lock);
94516+ rcu_read_unlock();
94517+
94518+ if (gr_is_global_nonroot(uid))
94519+ 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);
94520+ else if (daemon)
94521+ gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
94522+
94523+#endif
94524+ return;
94525+}
94526+
94527+void gr_handle_brute_check(void)
94528+{
94529+#ifdef CONFIG_GRKERNSEC_BRUTE
94530+ struct task_struct *p = current;
94531+
94532+ if (unlikely(p->brute)) {
94533+ if (!grsec_enable_brute)
94534+ p->brute = 0;
94535+ else if (time_before(get_seconds(), p->brute_expires))
94536+ msleep(30 * 1000);
94537+ }
94538+#endif
94539+ return;
94540+}
94541+
94542+void gr_handle_kernel_exploit(void)
94543+{
94544+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
94545+ const struct cred *cred;
94546+ struct task_struct *tsk, *tsk2;
94547+ struct user_struct *user;
94548+ kuid_t uid;
94549+
94550+ if (in_irq() || in_serving_softirq() || in_nmi())
94551+ panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
94552+
94553+ uid = current_uid();
94554+
94555+ if (gr_is_global_root(uid))
94556+ panic("grsec: halting the system due to suspicious kernel crash caused by root");
94557+ else {
94558+ /* kill all the processes of this user, hold a reference
94559+ to their creds struct, and prevent them from creating
94560+ another process until system reset
94561+ */
94562+ printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
94563+ GR_GLOBAL_UID(uid));
94564+ /* we intentionally leak this ref */
94565+ user = get_uid(current->cred->user);
94566+ if (user)
94567+ user->kernel_banned = 1;
94568+
94569+ /* kill all processes of this user */
94570+ read_lock(&tasklist_lock);
94571+ do_each_thread(tsk2, tsk) {
94572+ cred = __task_cred(tsk);
94573+ if (uid_eq(cred->uid, uid))
94574+ gr_fake_force_sig(SIGKILL, tsk);
94575+ } while_each_thread(tsk2, tsk);
94576+ read_unlock(&tasklist_lock);
94577+ }
94578+#endif
94579+}
94580+
94581+#ifdef CONFIG_GRKERNSEC_BRUTE
94582+static bool suid_ban_expired(struct user_struct *user)
94583+{
94584+ if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
94585+ user->suid_banned = 0;
94586+ user->suid_ban_expires = 0;
94587+ free_uid(user);
94588+ return true;
94589+ }
94590+
94591+ return false;
94592+}
94593+#endif
94594+
94595+int gr_process_kernel_exec_ban(void)
94596+{
94597+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
94598+ if (unlikely(current->cred->user->kernel_banned))
94599+ return -EPERM;
94600+#endif
94601+ return 0;
94602+}
94603+
94604+int gr_process_kernel_setuid_ban(struct user_struct *user)
94605+{
94606+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
94607+ if (unlikely(user->kernel_banned))
94608+ gr_fake_force_sig(SIGKILL, current);
94609+#endif
94610+ return 0;
94611+}
94612+
94613+int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
94614+{
94615+#ifdef CONFIG_GRKERNSEC_BRUTE
94616+ struct user_struct *user = current->cred->user;
94617+ if (unlikely(user->suid_banned)) {
94618+ if (suid_ban_expired(user))
94619+ return 0;
94620+ /* disallow execution of suid binaries only */
94621+ else if (!uid_eq(bprm->cred->euid, current->cred->uid))
94622+ return -EPERM;
94623+ }
94624+#endif
94625+ return 0;
94626+}
94627diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
94628new file mode 100644
94629index 0000000..a523bd2
94630--- /dev/null
94631+++ b/grsecurity/grsec_sock.c
94632@@ -0,0 +1,244 @@
94633+#include <linux/kernel.h>
94634+#include <linux/module.h>
94635+#include <linux/sched.h>
94636+#include <linux/file.h>
94637+#include <linux/net.h>
94638+#include <linux/in.h>
94639+#include <linux/ip.h>
94640+#include <net/sock.h>
94641+#include <net/inet_sock.h>
94642+#include <linux/grsecurity.h>
94643+#include <linux/grinternal.h>
94644+#include <linux/gracl.h>
94645+
94646+extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
94647+extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
94648+
94649+EXPORT_SYMBOL_GPL(gr_search_udp_recvmsg);
94650+EXPORT_SYMBOL_GPL(gr_search_udp_sendmsg);
94651+
94652+#ifdef CONFIG_UNIX_MODULE
94653+EXPORT_SYMBOL_GPL(gr_acl_handle_unix);
94654+EXPORT_SYMBOL_GPL(gr_acl_handle_mknod);
94655+EXPORT_SYMBOL_GPL(gr_handle_chroot_unix);
94656+EXPORT_SYMBOL_GPL(gr_handle_create);
94657+#endif
94658+
94659+#ifdef CONFIG_GRKERNSEC
94660+#define gr_conn_table_size 32749
94661+struct conn_table_entry {
94662+ struct conn_table_entry *next;
94663+ struct signal_struct *sig;
94664+};
94665+
94666+struct conn_table_entry *gr_conn_table[gr_conn_table_size];
94667+DEFINE_SPINLOCK(gr_conn_table_lock);
94668+
94669+extern const char * gr_socktype_to_name(unsigned char type);
94670+extern const char * gr_proto_to_name(unsigned char proto);
94671+extern const char * gr_sockfamily_to_name(unsigned char family);
94672+
94673+static int
94674+conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
94675+{
94676+ return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
94677+}
94678+
94679+static int
94680+conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
94681+ __u16 sport, __u16 dport)
94682+{
94683+ if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
94684+ sig->gr_sport == sport && sig->gr_dport == dport))
94685+ return 1;
94686+ else
94687+ return 0;
94688+}
94689+
94690+static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
94691+{
94692+ struct conn_table_entry **match;
94693+ unsigned int index;
94694+
94695+ index = conn_hash(sig->gr_saddr, sig->gr_daddr,
94696+ sig->gr_sport, sig->gr_dport,
94697+ gr_conn_table_size);
94698+
94699+ newent->sig = sig;
94700+
94701+ match = &gr_conn_table[index];
94702+ newent->next = *match;
94703+ *match = newent;
94704+
94705+ return;
94706+}
94707+
94708+static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
94709+{
94710+ struct conn_table_entry *match, *last = NULL;
94711+ unsigned int index;
94712+
94713+ index = conn_hash(sig->gr_saddr, sig->gr_daddr,
94714+ sig->gr_sport, sig->gr_dport,
94715+ gr_conn_table_size);
94716+
94717+ match = gr_conn_table[index];
94718+ while (match && !conn_match(match->sig,
94719+ sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
94720+ sig->gr_dport)) {
94721+ last = match;
94722+ match = match->next;
94723+ }
94724+
94725+ if (match) {
94726+ if (last)
94727+ last->next = match->next;
94728+ else
94729+ gr_conn_table[index] = NULL;
94730+ kfree(match);
94731+ }
94732+
94733+ return;
94734+}
94735+
94736+static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
94737+ __u16 sport, __u16 dport)
94738+{
94739+ struct conn_table_entry *match;
94740+ unsigned int index;
94741+
94742+ index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
94743+
94744+ match = gr_conn_table[index];
94745+ while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
94746+ match = match->next;
94747+
94748+ if (match)
94749+ return match->sig;
94750+ else
94751+ return NULL;
94752+}
94753+
94754+#endif
94755+
94756+void gr_update_task_in_ip_table(const struct inet_sock *inet)
94757+{
94758+#ifdef CONFIG_GRKERNSEC
94759+ struct signal_struct *sig = current->signal;
94760+ struct conn_table_entry *newent;
94761+
94762+ newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
94763+ if (newent == NULL)
94764+ return;
94765+ /* no bh lock needed since we are called with bh disabled */
94766+ spin_lock(&gr_conn_table_lock);
94767+ gr_del_task_from_ip_table_nolock(sig);
94768+ sig->gr_saddr = inet->inet_rcv_saddr;
94769+ sig->gr_daddr = inet->inet_daddr;
94770+ sig->gr_sport = inet->inet_sport;
94771+ sig->gr_dport = inet->inet_dport;
94772+ gr_add_to_task_ip_table_nolock(sig, newent);
94773+ spin_unlock(&gr_conn_table_lock);
94774+#endif
94775+ return;
94776+}
94777+
94778+void gr_del_task_from_ip_table(struct task_struct *task)
94779+{
94780+#ifdef CONFIG_GRKERNSEC
94781+ spin_lock_bh(&gr_conn_table_lock);
94782+ gr_del_task_from_ip_table_nolock(task->signal);
94783+ spin_unlock_bh(&gr_conn_table_lock);
94784+#endif
94785+ return;
94786+}
94787+
94788+void
94789+gr_attach_curr_ip(const struct sock *sk)
94790+{
94791+#ifdef CONFIG_GRKERNSEC
94792+ struct signal_struct *p, *set;
94793+ const struct inet_sock *inet = inet_sk(sk);
94794+
94795+ if (unlikely(sk->sk_protocol != IPPROTO_TCP))
94796+ return;
94797+
94798+ set = current->signal;
94799+
94800+ spin_lock_bh(&gr_conn_table_lock);
94801+ p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
94802+ inet->inet_dport, inet->inet_sport);
94803+ if (unlikely(p != NULL)) {
94804+ set->curr_ip = p->curr_ip;
94805+ set->used_accept = 1;
94806+ gr_del_task_from_ip_table_nolock(p);
94807+ spin_unlock_bh(&gr_conn_table_lock);
94808+ return;
94809+ }
94810+ spin_unlock_bh(&gr_conn_table_lock);
94811+
94812+ set->curr_ip = inet->inet_daddr;
94813+ set->used_accept = 1;
94814+#endif
94815+ return;
94816+}
94817+
94818+int
94819+gr_handle_sock_all(const int family, const int type, const int protocol)
94820+{
94821+#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
94822+ if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
94823+ (family != AF_UNIX)) {
94824+ if (family == AF_INET)
94825+ gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
94826+ else
94827+ gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
94828+ return -EACCES;
94829+ }
94830+#endif
94831+ return 0;
94832+}
94833+
94834+int
94835+gr_handle_sock_server(const struct sockaddr *sck)
94836+{
94837+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
94838+ if (grsec_enable_socket_server &&
94839+ in_group_p(grsec_socket_server_gid) &&
94840+ sck && (sck->sa_family != AF_UNIX) &&
94841+ (sck->sa_family != AF_LOCAL)) {
94842+ gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
94843+ return -EACCES;
94844+ }
94845+#endif
94846+ return 0;
94847+}
94848+
94849+int
94850+gr_handle_sock_server_other(const struct sock *sck)
94851+{
94852+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
94853+ if (grsec_enable_socket_server &&
94854+ in_group_p(grsec_socket_server_gid) &&
94855+ sck && (sck->sk_family != AF_UNIX) &&
94856+ (sck->sk_family != AF_LOCAL)) {
94857+ gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
94858+ return -EACCES;
94859+ }
94860+#endif
94861+ return 0;
94862+}
94863+
94864+int
94865+gr_handle_sock_client(const struct sockaddr *sck)
94866+{
94867+#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
94868+ if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
94869+ sck && (sck->sa_family != AF_UNIX) &&
94870+ (sck->sa_family != AF_LOCAL)) {
94871+ gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
94872+ return -EACCES;
94873+ }
94874+#endif
94875+ return 0;
94876+}
94877diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
94878new file mode 100644
94879index 0000000..aaec43c
94880--- /dev/null
94881+++ b/grsecurity/grsec_sysctl.c
94882@@ -0,0 +1,488 @@
94883+#include <linux/kernel.h>
94884+#include <linux/sched.h>
94885+#include <linux/sysctl.h>
94886+#include <linux/grsecurity.h>
94887+#include <linux/grinternal.h>
94888+
94889+int
94890+gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
94891+{
94892+#ifdef CONFIG_GRKERNSEC_SYSCTL
94893+ if (dirname == NULL || name == NULL)
94894+ return 0;
94895+ if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
94896+ gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
94897+ return -EACCES;
94898+ }
94899+#endif
94900+ return 0;
94901+}
94902+
94903+#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
94904+static int __maybe_unused __read_only one = 1;
94905+#endif
94906+
94907+#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
94908+ defined(CONFIG_GRKERNSEC_DENYUSB)
94909+struct ctl_table grsecurity_table[] = {
94910+#ifdef CONFIG_GRKERNSEC_SYSCTL
94911+#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
94912+#ifdef CONFIG_GRKERNSEC_IO
94913+ {
94914+ .procname = "disable_priv_io",
94915+ .data = &grsec_disable_privio,
94916+ .maxlen = sizeof(int),
94917+ .mode = 0600,
94918+ .proc_handler = &proc_dointvec_secure,
94919+ },
94920+#endif
94921+#endif
94922+#ifdef CONFIG_GRKERNSEC_LINK
94923+ {
94924+ .procname = "linking_restrictions",
94925+ .data = &grsec_enable_link,
94926+ .maxlen = sizeof(int),
94927+ .mode = 0600,
94928+ .proc_handler = &proc_dointvec_secure,
94929+ },
94930+#endif
94931+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
94932+ {
94933+ .procname = "enforce_symlinksifowner",
94934+ .data = &grsec_enable_symlinkown,
94935+ .maxlen = sizeof(int),
94936+ .mode = 0600,
94937+ .proc_handler = &proc_dointvec_secure,
94938+ },
94939+ {
94940+ .procname = "symlinkown_gid",
94941+ .data = &grsec_symlinkown_gid,
94942+ .maxlen = sizeof(int),
94943+ .mode = 0600,
94944+ .proc_handler = &proc_dointvec_secure,
94945+ },
94946+#endif
94947+#ifdef CONFIG_GRKERNSEC_BRUTE
94948+ {
94949+ .procname = "deter_bruteforce",
94950+ .data = &grsec_enable_brute,
94951+ .maxlen = sizeof(int),
94952+ .mode = 0600,
94953+ .proc_handler = &proc_dointvec_secure,
94954+ },
94955+#endif
94956+#ifdef CONFIG_GRKERNSEC_FIFO
94957+ {
94958+ .procname = "fifo_restrictions",
94959+ .data = &grsec_enable_fifo,
94960+ .maxlen = sizeof(int),
94961+ .mode = 0600,
94962+ .proc_handler = &proc_dointvec_secure,
94963+ },
94964+#endif
94965+#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
94966+ {
94967+ .procname = "ptrace_readexec",
94968+ .data = &grsec_enable_ptrace_readexec,
94969+ .maxlen = sizeof(int),
94970+ .mode = 0600,
94971+ .proc_handler = &proc_dointvec_secure,
94972+ },
94973+#endif
94974+#ifdef CONFIG_GRKERNSEC_SETXID
94975+ {
94976+ .procname = "consistent_setxid",
94977+ .data = &grsec_enable_setxid,
94978+ .maxlen = sizeof(int),
94979+ .mode = 0600,
94980+ .proc_handler = &proc_dointvec_secure,
94981+ },
94982+#endif
94983+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94984+ {
94985+ .procname = "ip_blackhole",
94986+ .data = &grsec_enable_blackhole,
94987+ .maxlen = sizeof(int),
94988+ .mode = 0600,
94989+ .proc_handler = &proc_dointvec_secure,
94990+ },
94991+ {
94992+ .procname = "lastack_retries",
94993+ .data = &grsec_lastack_retries,
94994+ .maxlen = sizeof(int),
94995+ .mode = 0600,
94996+ .proc_handler = &proc_dointvec_secure,
94997+ },
94998+#endif
94999+#ifdef CONFIG_GRKERNSEC_EXECLOG
95000+ {
95001+ .procname = "exec_logging",
95002+ .data = &grsec_enable_execlog,
95003+ .maxlen = sizeof(int),
95004+ .mode = 0600,
95005+ .proc_handler = &proc_dointvec_secure,
95006+ },
95007+#endif
95008+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
95009+ {
95010+ .procname = "rwxmap_logging",
95011+ .data = &grsec_enable_log_rwxmaps,
95012+ .maxlen = sizeof(int),
95013+ .mode = 0600,
95014+ .proc_handler = &proc_dointvec_secure,
95015+ },
95016+#endif
95017+#ifdef CONFIG_GRKERNSEC_SIGNAL
95018+ {
95019+ .procname = "signal_logging",
95020+ .data = &grsec_enable_signal,
95021+ .maxlen = sizeof(int),
95022+ .mode = 0600,
95023+ .proc_handler = &proc_dointvec_secure,
95024+ },
95025+#endif
95026+#ifdef CONFIG_GRKERNSEC_FORKFAIL
95027+ {
95028+ .procname = "forkfail_logging",
95029+ .data = &grsec_enable_forkfail,
95030+ .maxlen = sizeof(int),
95031+ .mode = 0600,
95032+ .proc_handler = &proc_dointvec_secure,
95033+ },
95034+#endif
95035+#ifdef CONFIG_GRKERNSEC_TIME
95036+ {
95037+ .procname = "timechange_logging",
95038+ .data = &grsec_enable_time,
95039+ .maxlen = sizeof(int),
95040+ .mode = 0600,
95041+ .proc_handler = &proc_dointvec_secure,
95042+ },
95043+#endif
95044+#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
95045+ {
95046+ .procname = "chroot_deny_shmat",
95047+ .data = &grsec_enable_chroot_shmat,
95048+ .maxlen = sizeof(int),
95049+ .mode = 0600,
95050+ .proc_handler = &proc_dointvec_secure,
95051+ },
95052+#endif
95053+#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
95054+ {
95055+ .procname = "chroot_deny_unix",
95056+ .data = &grsec_enable_chroot_unix,
95057+ .maxlen = sizeof(int),
95058+ .mode = 0600,
95059+ .proc_handler = &proc_dointvec_secure,
95060+ },
95061+#endif
95062+#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
95063+ {
95064+ .procname = "chroot_deny_mount",
95065+ .data = &grsec_enable_chroot_mount,
95066+ .maxlen = sizeof(int),
95067+ .mode = 0600,
95068+ .proc_handler = &proc_dointvec_secure,
95069+ },
95070+#endif
95071+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
95072+ {
95073+ .procname = "chroot_deny_fchdir",
95074+ .data = &grsec_enable_chroot_fchdir,
95075+ .maxlen = sizeof(int),
95076+ .mode = 0600,
95077+ .proc_handler = &proc_dointvec_secure,
95078+ },
95079+#endif
95080+#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
95081+ {
95082+ .procname = "chroot_deny_chroot",
95083+ .data = &grsec_enable_chroot_double,
95084+ .maxlen = sizeof(int),
95085+ .mode = 0600,
95086+ .proc_handler = &proc_dointvec_secure,
95087+ },
95088+#endif
95089+#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
95090+ {
95091+ .procname = "chroot_deny_pivot",
95092+ .data = &grsec_enable_chroot_pivot,
95093+ .maxlen = sizeof(int),
95094+ .mode = 0600,
95095+ .proc_handler = &proc_dointvec_secure,
95096+ },
95097+#endif
95098+#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
95099+ {
95100+ .procname = "chroot_enforce_chdir",
95101+ .data = &grsec_enable_chroot_chdir,
95102+ .maxlen = sizeof(int),
95103+ .mode = 0600,
95104+ .proc_handler = &proc_dointvec_secure,
95105+ },
95106+#endif
95107+#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
95108+ {
95109+ .procname = "chroot_deny_chmod",
95110+ .data = &grsec_enable_chroot_chmod,
95111+ .maxlen = sizeof(int),
95112+ .mode = 0600,
95113+ .proc_handler = &proc_dointvec_secure,
95114+ },
95115+#endif
95116+#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
95117+ {
95118+ .procname = "chroot_deny_mknod",
95119+ .data = &grsec_enable_chroot_mknod,
95120+ .maxlen = sizeof(int),
95121+ .mode = 0600,
95122+ .proc_handler = &proc_dointvec_secure,
95123+ },
95124+#endif
95125+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
95126+ {
95127+ .procname = "chroot_restrict_nice",
95128+ .data = &grsec_enable_chroot_nice,
95129+ .maxlen = sizeof(int),
95130+ .mode = 0600,
95131+ .proc_handler = &proc_dointvec_secure,
95132+ },
95133+#endif
95134+#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
95135+ {
95136+ .procname = "chroot_execlog",
95137+ .data = &grsec_enable_chroot_execlog,
95138+ .maxlen = sizeof(int),
95139+ .mode = 0600,
95140+ .proc_handler = &proc_dointvec_secure,
95141+ },
95142+#endif
95143+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
95144+ {
95145+ .procname = "chroot_caps",
95146+ .data = &grsec_enable_chroot_caps,
95147+ .maxlen = sizeof(int),
95148+ .mode = 0600,
95149+ .proc_handler = &proc_dointvec_secure,
95150+ },
95151+#endif
95152+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
95153+ {
95154+ .procname = "chroot_deny_bad_rename",
95155+ .data = &grsec_enable_chroot_rename,
95156+ .maxlen = sizeof(int),
95157+ .mode = 0600,
95158+ .proc_handler = &proc_dointvec_secure,
95159+ },
95160+#endif
95161+#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
95162+ {
95163+ .procname = "chroot_deny_sysctl",
95164+ .data = &grsec_enable_chroot_sysctl,
95165+ .maxlen = sizeof(int),
95166+ .mode = 0600,
95167+ .proc_handler = &proc_dointvec_secure,
95168+ },
95169+#endif
95170+#ifdef CONFIG_GRKERNSEC_TPE
95171+ {
95172+ .procname = "tpe",
95173+ .data = &grsec_enable_tpe,
95174+ .maxlen = sizeof(int),
95175+ .mode = 0600,
95176+ .proc_handler = &proc_dointvec_secure,
95177+ },
95178+ {
95179+ .procname = "tpe_gid",
95180+ .data = &grsec_tpe_gid,
95181+ .maxlen = sizeof(int),
95182+ .mode = 0600,
95183+ .proc_handler = &proc_dointvec_secure,
95184+ },
95185+#endif
95186+#ifdef CONFIG_GRKERNSEC_TPE_INVERT
95187+ {
95188+ .procname = "tpe_invert",
95189+ .data = &grsec_enable_tpe_invert,
95190+ .maxlen = sizeof(int),
95191+ .mode = 0600,
95192+ .proc_handler = &proc_dointvec_secure,
95193+ },
95194+#endif
95195+#ifdef CONFIG_GRKERNSEC_TPE_ALL
95196+ {
95197+ .procname = "tpe_restrict_all",
95198+ .data = &grsec_enable_tpe_all,
95199+ .maxlen = sizeof(int),
95200+ .mode = 0600,
95201+ .proc_handler = &proc_dointvec_secure,
95202+ },
95203+#endif
95204+#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
95205+ {
95206+ .procname = "socket_all",
95207+ .data = &grsec_enable_socket_all,
95208+ .maxlen = sizeof(int),
95209+ .mode = 0600,
95210+ .proc_handler = &proc_dointvec_secure,
95211+ },
95212+ {
95213+ .procname = "socket_all_gid",
95214+ .data = &grsec_socket_all_gid,
95215+ .maxlen = sizeof(int),
95216+ .mode = 0600,
95217+ .proc_handler = &proc_dointvec_secure,
95218+ },
95219+#endif
95220+#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
95221+ {
95222+ .procname = "socket_client",
95223+ .data = &grsec_enable_socket_client,
95224+ .maxlen = sizeof(int),
95225+ .mode = 0600,
95226+ .proc_handler = &proc_dointvec_secure,
95227+ },
95228+ {
95229+ .procname = "socket_client_gid",
95230+ .data = &grsec_socket_client_gid,
95231+ .maxlen = sizeof(int),
95232+ .mode = 0600,
95233+ .proc_handler = &proc_dointvec_secure,
95234+ },
95235+#endif
95236+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
95237+ {
95238+ .procname = "socket_server",
95239+ .data = &grsec_enable_socket_server,
95240+ .maxlen = sizeof(int),
95241+ .mode = 0600,
95242+ .proc_handler = &proc_dointvec_secure,
95243+ },
95244+ {
95245+ .procname = "socket_server_gid",
95246+ .data = &grsec_socket_server_gid,
95247+ .maxlen = sizeof(int),
95248+ .mode = 0600,
95249+ .proc_handler = &proc_dointvec_secure,
95250+ },
95251+#endif
95252+#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
95253+ {
95254+ .procname = "audit_group",
95255+ .data = &grsec_enable_group,
95256+ .maxlen = sizeof(int),
95257+ .mode = 0600,
95258+ .proc_handler = &proc_dointvec_secure,
95259+ },
95260+ {
95261+ .procname = "audit_gid",
95262+ .data = &grsec_audit_gid,
95263+ .maxlen = sizeof(int),
95264+ .mode = 0600,
95265+ .proc_handler = &proc_dointvec_secure,
95266+ },
95267+#endif
95268+#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
95269+ {
95270+ .procname = "audit_chdir",
95271+ .data = &grsec_enable_chdir,
95272+ .maxlen = sizeof(int),
95273+ .mode = 0600,
95274+ .proc_handler = &proc_dointvec_secure,
95275+ },
95276+#endif
95277+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
95278+ {
95279+ .procname = "audit_mount",
95280+ .data = &grsec_enable_mount,
95281+ .maxlen = sizeof(int),
95282+ .mode = 0600,
95283+ .proc_handler = &proc_dointvec_secure,
95284+ },
95285+#endif
95286+#ifdef CONFIG_GRKERNSEC_DMESG
95287+ {
95288+ .procname = "dmesg",
95289+ .data = &grsec_enable_dmesg,
95290+ .maxlen = sizeof(int),
95291+ .mode = 0600,
95292+ .proc_handler = &proc_dointvec_secure,
95293+ },
95294+#endif
95295+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
95296+ {
95297+ .procname = "chroot_findtask",
95298+ .data = &grsec_enable_chroot_findtask,
95299+ .maxlen = sizeof(int),
95300+ .mode = 0600,
95301+ .proc_handler = &proc_dointvec_secure,
95302+ },
95303+#endif
95304+#ifdef CONFIG_GRKERNSEC_RESLOG
95305+ {
95306+ .procname = "resource_logging",
95307+ .data = &grsec_resource_logging,
95308+ .maxlen = sizeof(int),
95309+ .mode = 0600,
95310+ .proc_handler = &proc_dointvec_secure,
95311+ },
95312+#endif
95313+#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
95314+ {
95315+ .procname = "audit_ptrace",
95316+ .data = &grsec_enable_audit_ptrace,
95317+ .maxlen = sizeof(int),
95318+ .mode = 0600,
95319+ .proc_handler = &proc_dointvec_secure,
95320+ },
95321+#endif
95322+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
95323+ {
95324+ .procname = "harden_ptrace",
95325+ .data = &grsec_enable_harden_ptrace,
95326+ .maxlen = sizeof(int),
95327+ .mode = 0600,
95328+ .proc_handler = &proc_dointvec_secure,
95329+ },
95330+#endif
95331+#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
95332+ {
95333+ .procname = "harden_ipc",
95334+ .data = &grsec_enable_harden_ipc,
95335+ .maxlen = sizeof(int),
95336+ .mode = 0600,
95337+ .proc_handler = &proc_dointvec_secure,
95338+ },
95339+#endif
95340+ {
95341+ .procname = "grsec_lock",
95342+ .data = &grsec_lock,
95343+ .maxlen = sizeof(int),
95344+ .mode = 0600,
95345+ .proc_handler = &proc_dointvec_secure,
95346+ },
95347+#endif
95348+#ifdef CONFIG_GRKERNSEC_ROFS
95349+ {
95350+ .procname = "romount_protect",
95351+ .data = &grsec_enable_rofs,
95352+ .maxlen = sizeof(int),
95353+ .mode = 0600,
95354+ .proc_handler = &proc_dointvec_minmax_secure,
95355+ .extra1 = &one,
95356+ .extra2 = &one,
95357+ },
95358+#endif
95359+#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
95360+ {
95361+ .procname = "deny_new_usb",
95362+ .data = &grsec_deny_new_usb,
95363+ .maxlen = sizeof(int),
95364+ .mode = 0600,
95365+ .proc_handler = &proc_dointvec_secure,
95366+ },
95367+#endif
95368+ { }
95369+};
95370+#endif
95371diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
95372new file mode 100644
95373index 0000000..61b514e
95374--- /dev/null
95375+++ b/grsecurity/grsec_time.c
95376@@ -0,0 +1,16 @@
95377+#include <linux/kernel.h>
95378+#include <linux/sched.h>
95379+#include <linux/grinternal.h>
95380+#include <linux/module.h>
95381+
95382+void
95383+gr_log_timechange(void)
95384+{
95385+#ifdef CONFIG_GRKERNSEC_TIME
95386+ if (grsec_enable_time)
95387+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
95388+#endif
95389+ return;
95390+}
95391+
95392+EXPORT_SYMBOL_GPL(gr_log_timechange);
95393diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
95394new file mode 100644
95395index 0000000..9786671
95396--- /dev/null
95397+++ b/grsecurity/grsec_tpe.c
95398@@ -0,0 +1,78 @@
95399+#include <linux/kernel.h>
95400+#include <linux/sched.h>
95401+#include <linux/file.h>
95402+#include <linux/fs.h>
95403+#include <linux/grinternal.h>
95404+
95405+extern int gr_acl_tpe_check(void);
95406+
95407+int
95408+gr_tpe_allow(const struct file *file)
95409+{
95410+#ifdef CONFIG_GRKERNSEC
95411+ struct inode *inode = d_backing_inode(file->f_path.dentry->d_parent);
95412+ struct inode *file_inode = d_backing_inode(file->f_path.dentry);
95413+ const struct cred *cred = current_cred();
95414+ char *msg = NULL;
95415+ char *msg2 = NULL;
95416+
95417+ // never restrict root
95418+ if (gr_is_global_root(cred->uid))
95419+ return 1;
95420+
95421+ if (grsec_enable_tpe) {
95422+#ifdef CONFIG_GRKERNSEC_TPE_INVERT
95423+ if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
95424+ msg = "not being in trusted group";
95425+ else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
95426+ msg = "being in untrusted group";
95427+#else
95428+ if (in_group_p(grsec_tpe_gid))
95429+ msg = "being in untrusted group";
95430+#endif
95431+ }
95432+ if (!msg && gr_acl_tpe_check())
95433+ msg = "being in untrusted role";
95434+
95435+ // not in any affected group/role
95436+ if (!msg)
95437+ goto next_check;
95438+
95439+ if (gr_is_global_nonroot(inode->i_uid))
95440+ msg2 = "file in non-root-owned directory";
95441+ else if (inode->i_mode & S_IWOTH)
95442+ msg2 = "file in world-writable directory";
95443+ else if (inode->i_mode & S_IWGRP)
95444+ msg2 = "file in group-writable directory";
95445+ else if (file_inode->i_mode & S_IWOTH)
95446+ msg2 = "file is world-writable";
95447+
95448+ if (msg && msg2) {
95449+ char fullmsg[70] = {0};
95450+ snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
95451+ gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
95452+ return 0;
95453+ }
95454+ msg = NULL;
95455+next_check:
95456+#ifdef CONFIG_GRKERNSEC_TPE_ALL
95457+ if (!grsec_enable_tpe || !grsec_enable_tpe_all)
95458+ return 1;
95459+
95460+ if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
95461+ msg = "directory not owned by user";
95462+ else if (inode->i_mode & S_IWOTH)
95463+ msg = "file in world-writable directory";
95464+ else if (inode->i_mode & S_IWGRP)
95465+ msg = "file in group-writable directory";
95466+ else if (file_inode->i_mode & S_IWOTH)
95467+ msg = "file is world-writable";
95468+
95469+ if (msg) {
95470+ gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
95471+ return 0;
95472+ }
95473+#endif
95474+#endif
95475+ return 1;
95476+}
95477diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
95478new file mode 100644
95479index 0000000..ae02d8e
95480--- /dev/null
95481+++ b/grsecurity/grsec_usb.c
95482@@ -0,0 +1,15 @@
95483+#include <linux/kernel.h>
95484+#include <linux/grinternal.h>
95485+#include <linux/module.h>
95486+
95487+int gr_handle_new_usb(void)
95488+{
95489+#ifdef CONFIG_GRKERNSEC_DENYUSB
95490+ if (grsec_deny_new_usb) {
95491+ printk(KERN_ALERT "grsec: denied insert of new USB device\n");
95492+ return 1;
95493+ }
95494+#endif
95495+ return 0;
95496+}
95497+EXPORT_SYMBOL_GPL(gr_handle_new_usb);
95498diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
95499new file mode 100644
95500index 0000000..158b330
95501--- /dev/null
95502+++ b/grsecurity/grsum.c
95503@@ -0,0 +1,64 @@
95504+#include <linux/err.h>
95505+#include <linux/kernel.h>
95506+#include <linux/sched.h>
95507+#include <linux/mm.h>
95508+#include <linux/scatterlist.h>
95509+#include <linux/crypto.h>
95510+#include <linux/gracl.h>
95511+
95512+
95513+#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
95514+#error "crypto and sha256 must be built into the kernel"
95515+#endif
95516+
95517+int
95518+chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
95519+{
95520+ struct crypto_hash *tfm;
95521+ struct hash_desc desc;
95522+ struct scatterlist sg[2];
95523+ unsigned char temp_sum[GR_SHA_LEN] __attribute__((aligned(__alignof__(unsigned long))));
95524+ unsigned long *tmpsumptr = (unsigned long *)temp_sum;
95525+ unsigned long *sumptr = (unsigned long *)sum;
95526+ int cryptres;
95527+ int retval = 1;
95528+ volatile int mismatched = 0;
95529+ volatile int dummy = 0;
95530+ unsigned int i;
95531+
95532+ tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
95533+ if (IS_ERR(tfm)) {
95534+ /* should never happen, since sha256 should be built in */
95535+ memset(entry->pw, 0, GR_PW_LEN);
95536+ return 1;
95537+ }
95538+
95539+ sg_init_table(sg, 2);
95540+ sg_set_buf(&sg[0], salt, GR_SALT_LEN);
95541+ sg_set_buf(&sg[1], entry->pw, strlen(entry->pw));
95542+
95543+ desc.tfm = tfm;
95544+ desc.flags = 0;
95545+
95546+ cryptres = crypto_hash_digest(&desc, sg, GR_SALT_LEN + strlen(entry->pw),
95547+ temp_sum);
95548+
95549+ memset(entry->pw, 0, GR_PW_LEN);
95550+
95551+ if (cryptres)
95552+ goto out;
95553+
95554+ for (i = 0; i < GR_SHA_LEN/sizeof(tmpsumptr[0]); i++)
95555+ if (sumptr[i] != tmpsumptr[i])
95556+ mismatched = 1;
95557+ else
95558+ dummy = 1; // waste a cycle
95559+
95560+ if (!mismatched)
95561+ retval = dummy - 1;
95562+
95563+out:
95564+ crypto_free_hash(tfm);
95565+
95566+ return retval;
95567+}
95568diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
95569index 5bdab6b..9ae82fe 100644
95570--- a/include/asm-generic/4level-fixup.h
95571+++ b/include/asm-generic/4level-fixup.h
95572@@ -14,8 +14,10 @@
95573 #define pmd_alloc(mm, pud, address) \
95574 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
95575 NULL: pmd_offset(pud, address))
95576+#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
95577
95578 #define pud_alloc(mm, pgd, address) (pgd)
95579+#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
95580 #define pud_offset(pgd, start) (pgd)
95581 #define pud_none(pud) 0
95582 #define pud_bad(pud) 0
95583diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
95584index b7babf0..1e4b4f1 100644
95585--- a/include/asm-generic/atomic-long.h
95586+++ b/include/asm-generic/atomic-long.h
95587@@ -22,6 +22,12 @@
95588
95589 typedef atomic64_t atomic_long_t;
95590
95591+#ifdef CONFIG_PAX_REFCOUNT
95592+typedef atomic64_unchecked_t atomic_long_unchecked_t;
95593+#else
95594+typedef atomic64_t atomic_long_unchecked_t;
95595+#endif
95596+
95597 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
95598
95599 static inline long atomic_long_read(atomic_long_t *l)
95600@@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
95601 return (long)atomic64_read(v);
95602 }
95603
95604+#ifdef CONFIG_PAX_REFCOUNT
95605+static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
95606+{
95607+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95608+
95609+ return (long)atomic64_read_unchecked(v);
95610+}
95611+#endif
95612+
95613 static inline void atomic_long_set(atomic_long_t *l, long i)
95614 {
95615 atomic64_t *v = (atomic64_t *)l;
95616@@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
95617 atomic64_set(v, i);
95618 }
95619
95620+#ifdef CONFIG_PAX_REFCOUNT
95621+static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
95622+{
95623+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95624+
95625+ atomic64_set_unchecked(v, i);
95626+}
95627+#endif
95628+
95629 static inline void atomic_long_inc(atomic_long_t *l)
95630 {
95631 atomic64_t *v = (atomic64_t *)l;
95632@@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
95633 atomic64_inc(v);
95634 }
95635
95636+#ifdef CONFIG_PAX_REFCOUNT
95637+static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
95638+{
95639+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95640+
95641+ atomic64_inc_unchecked(v);
95642+}
95643+#endif
95644+
95645 static inline void atomic_long_dec(atomic_long_t *l)
95646 {
95647 atomic64_t *v = (atomic64_t *)l;
95648@@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
95649 atomic64_dec(v);
95650 }
95651
95652+#ifdef CONFIG_PAX_REFCOUNT
95653+static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
95654+{
95655+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95656+
95657+ atomic64_dec_unchecked(v);
95658+}
95659+#endif
95660+
95661 static inline void atomic_long_add(long i, atomic_long_t *l)
95662 {
95663 atomic64_t *v = (atomic64_t *)l;
95664@@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
95665 atomic64_add(i, v);
95666 }
95667
95668+#ifdef CONFIG_PAX_REFCOUNT
95669+static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
95670+{
95671+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95672+
95673+ atomic64_add_unchecked(i, v);
95674+}
95675+#endif
95676+
95677 static inline void atomic_long_sub(long i, atomic_long_t *l)
95678 {
95679 atomic64_t *v = (atomic64_t *)l;
95680@@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
95681 atomic64_sub(i, v);
95682 }
95683
95684+#ifdef CONFIG_PAX_REFCOUNT
95685+static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
95686+{
95687+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95688+
95689+ atomic64_sub_unchecked(i, v);
95690+}
95691+#endif
95692+
95693 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
95694 {
95695 atomic64_t *v = (atomic64_t *)l;
95696@@ -94,13 +154,22 @@ static inline int atomic_long_add_negative(long i, atomic_long_t *l)
95697 return atomic64_add_negative(i, v);
95698 }
95699
95700-static inline long atomic_long_add_return(long i, atomic_long_t *l)
95701+static inline long __intentional_overflow(-1) atomic_long_add_return(long i, atomic_long_t *l)
95702 {
95703 atomic64_t *v = (atomic64_t *)l;
95704
95705 return (long)atomic64_add_return(i, v);
95706 }
95707
95708+#ifdef CONFIG_PAX_REFCOUNT
95709+static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
95710+{
95711+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95712+
95713+ return (long)atomic64_add_return_unchecked(i, v);
95714+}
95715+#endif
95716+
95717 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
95718 {
95719 atomic64_t *v = (atomic64_t *)l;
95720@@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
95721 return (long)atomic64_inc_return(v);
95722 }
95723
95724+#ifdef CONFIG_PAX_REFCOUNT
95725+static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
95726+{
95727+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95728+
95729+ return (long)atomic64_inc_return_unchecked(v);
95730+}
95731+#endif
95732+
95733 static inline long atomic_long_dec_return(atomic_long_t *l)
95734 {
95735 atomic64_t *v = (atomic64_t *)l;
95736@@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
95737
95738 typedef atomic_t atomic_long_t;
95739
95740+#ifdef CONFIG_PAX_REFCOUNT
95741+typedef atomic_unchecked_t atomic_long_unchecked_t;
95742+#else
95743+typedef atomic_t atomic_long_unchecked_t;
95744+#endif
95745+
95746 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
95747 static inline long atomic_long_read(atomic_long_t *l)
95748 {
95749@@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
95750 return (long)atomic_read(v);
95751 }
95752
95753+#ifdef CONFIG_PAX_REFCOUNT
95754+static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
95755+{
95756+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95757+
95758+ return (long)atomic_read_unchecked(v);
95759+}
95760+#endif
95761+
95762 static inline void atomic_long_set(atomic_long_t *l, long i)
95763 {
95764 atomic_t *v = (atomic_t *)l;
95765@@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
95766 atomic_set(v, i);
95767 }
95768
95769+#ifdef CONFIG_PAX_REFCOUNT
95770+static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
95771+{
95772+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95773+
95774+ atomic_set_unchecked(v, i);
95775+}
95776+#endif
95777+
95778 static inline void atomic_long_inc(atomic_long_t *l)
95779 {
95780 atomic_t *v = (atomic_t *)l;
95781@@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
95782 atomic_inc(v);
95783 }
95784
95785+#ifdef CONFIG_PAX_REFCOUNT
95786+static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
95787+{
95788+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95789+
95790+ atomic_inc_unchecked(v);
95791+}
95792+#endif
95793+
95794 static inline void atomic_long_dec(atomic_long_t *l)
95795 {
95796 atomic_t *v = (atomic_t *)l;
95797@@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
95798 atomic_dec(v);
95799 }
95800
95801+#ifdef CONFIG_PAX_REFCOUNT
95802+static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
95803+{
95804+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95805+
95806+ atomic_dec_unchecked(v);
95807+}
95808+#endif
95809+
95810 static inline void atomic_long_add(long i, atomic_long_t *l)
95811 {
95812 atomic_t *v = (atomic_t *)l;
95813@@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
95814 atomic_add(i, v);
95815 }
95816
95817+#ifdef CONFIG_PAX_REFCOUNT
95818+static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
95819+{
95820+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95821+
95822+ atomic_add_unchecked(i, v);
95823+}
95824+#endif
95825+
95826 static inline void atomic_long_sub(long i, atomic_long_t *l)
95827 {
95828 atomic_t *v = (atomic_t *)l;
95829@@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
95830 atomic_sub(i, v);
95831 }
95832
95833+#ifdef CONFIG_PAX_REFCOUNT
95834+static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
95835+{
95836+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95837+
95838+ atomic_sub_unchecked(i, v);
95839+}
95840+#endif
95841+
95842 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
95843 {
95844 atomic_t *v = (atomic_t *)l;
95845@@ -211,13 +349,23 @@ static inline int atomic_long_add_negative(long i, atomic_long_t *l)
95846 return atomic_add_negative(i, v);
95847 }
95848
95849-static inline long atomic_long_add_return(long i, atomic_long_t *l)
95850+static inline long __intentional_overflow(-1) atomic_long_add_return(long i, atomic_long_t *l)
95851 {
95852 atomic_t *v = (atomic_t *)l;
95853
95854 return (long)atomic_add_return(i, v);
95855 }
95856
95857+#ifdef CONFIG_PAX_REFCOUNT
95858+static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
95859+{
95860+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95861+
95862+ return (long)atomic_add_return_unchecked(i, v);
95863+}
95864+
95865+#endif
95866+
95867 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
95868 {
95869 atomic_t *v = (atomic_t *)l;
95870@@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
95871 return (long)atomic_inc_return(v);
95872 }
95873
95874+#ifdef CONFIG_PAX_REFCOUNT
95875+static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
95876+{
95877+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95878+
95879+ return (long)atomic_inc_return_unchecked(v);
95880+}
95881+#endif
95882+
95883 static inline long atomic_long_dec_return(atomic_long_t *l)
95884 {
95885 atomic_t *v = (atomic_t *)l;
95886@@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
95887
95888 #endif /* BITS_PER_LONG == 64 */
95889
95890+#ifdef CONFIG_PAX_REFCOUNT
95891+static inline void pax_refcount_needs_these_functions(void)
95892+{
95893+ atomic_read_unchecked((atomic_unchecked_t *)NULL);
95894+ atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
95895+ atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
95896+ atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
95897+ atomic_inc_unchecked((atomic_unchecked_t *)NULL);
95898+ (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
95899+ atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
95900+ atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
95901+ atomic_dec_unchecked((atomic_unchecked_t *)NULL);
95902+ atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
95903+ (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
95904+#ifdef CONFIG_X86
95905+ atomic_clear_mask_unchecked(0, NULL);
95906+ atomic_set_mask_unchecked(0, NULL);
95907+#endif
95908+
95909+ atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
95910+ atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
95911+ atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
95912+ atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
95913+ atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
95914+ atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
95915+ atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
95916+ atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
95917+}
95918+#else
95919+#define atomic_read_unchecked(v) atomic_read(v)
95920+#define atomic_set_unchecked(v, i) atomic_set((v), (i))
95921+#define atomic_add_unchecked(i, v) atomic_add((i), (v))
95922+#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
95923+#define atomic_inc_unchecked(v) atomic_inc(v)
95924+#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
95925+#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
95926+#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
95927+#define atomic_dec_unchecked(v) atomic_dec(v)
95928+#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
95929+#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
95930+#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
95931+#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
95932+
95933+#define atomic_long_read_unchecked(v) atomic_long_read(v)
95934+#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
95935+#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
95936+#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
95937+#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
95938+#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
95939+#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
95940+#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
95941+#endif
95942+
95943 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
95944diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
95945index 30ad9c8..c70c170 100644
95946--- a/include/asm-generic/atomic64.h
95947+++ b/include/asm-generic/atomic64.h
95948@@ -16,6 +16,8 @@ typedef struct {
95949 long long counter;
95950 } atomic64_t;
95951
95952+typedef atomic64_t atomic64_unchecked_t;
95953+
95954 #define ATOMIC64_INIT(i) { (i) }
95955
95956 extern long long atomic64_read(const atomic64_t *v);
95957@@ -51,4 +53,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
95958 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
95959 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
95960
95961+#define atomic64_read_unchecked(v) atomic64_read(v)
95962+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
95963+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
95964+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
95965+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
95966+#define atomic64_inc_unchecked(v) atomic64_inc(v)
95967+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
95968+#define atomic64_dec_unchecked(v) atomic64_dec(v)
95969+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
95970+
95971 #endif /* _ASM_GENERIC_ATOMIC64_H */
95972diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h
95973index 55e3abc..104e2a1 100644
95974--- a/include/asm-generic/barrier.h
95975+++ b/include/asm-generic/barrier.h
95976@@ -108,7 +108,7 @@
95977 do { \
95978 compiletime_assert_atomic_type(*p); \
95979 smp_mb(); \
95980- ACCESS_ONCE(*p) = (v); \
95981+ ACCESS_ONCE_RW(*p) = (v); \
95982 } while (0)
95983
95984 #define smp_load_acquire(p) \
95985diff --git a/include/asm-generic/bitops/__fls.h b/include/asm-generic/bitops/__fls.h
95986index a60a7cc..0fe12f2 100644
95987--- a/include/asm-generic/bitops/__fls.h
95988+++ b/include/asm-generic/bitops/__fls.h
95989@@ -9,7 +9,7 @@
95990 *
95991 * Undefined if no set bit exists, so code should check against 0 first.
95992 */
95993-static __always_inline unsigned long __fls(unsigned long word)
95994+static __always_inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
95995 {
95996 int num = BITS_PER_LONG - 1;
95997
95998diff --git a/include/asm-generic/bitops/fls.h b/include/asm-generic/bitops/fls.h
95999index 0576d1f..dad6c71 100644
96000--- a/include/asm-generic/bitops/fls.h
96001+++ b/include/asm-generic/bitops/fls.h
96002@@ -9,7 +9,7 @@
96003 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
96004 */
96005
96006-static __always_inline int fls(int x)
96007+static __always_inline int __intentional_overflow(-1) fls(int x)
96008 {
96009 int r = 32;
96010
96011diff --git a/include/asm-generic/bitops/fls64.h b/include/asm-generic/bitops/fls64.h
96012index b097cf8..3d40e14 100644
96013--- a/include/asm-generic/bitops/fls64.h
96014+++ b/include/asm-generic/bitops/fls64.h
96015@@ -15,7 +15,7 @@
96016 * at position 64.
96017 */
96018 #if BITS_PER_LONG == 32
96019-static __always_inline int fls64(__u64 x)
96020+static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
96021 {
96022 __u32 h = x >> 32;
96023 if (h)
96024@@ -23,7 +23,7 @@ static __always_inline int fls64(__u64 x)
96025 return fls(x);
96026 }
96027 #elif BITS_PER_LONG == 64
96028-static __always_inline int fls64(__u64 x)
96029+static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
96030 {
96031 if (x == 0)
96032 return 0;
96033diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
96034index 630dd23..8c1dcb6b 100644
96035--- a/include/asm-generic/bug.h
96036+++ b/include/asm-generic/bug.h
96037@@ -62,13 +62,13 @@ struct bug_entry {
96038 * to provide better diagnostics.
96039 */
96040 #ifndef __WARN_TAINT
96041-extern __printf(3, 4)
96042+extern __printf(3, 4) __nocapture(1, 3, 4)
96043 void warn_slowpath_fmt(const char *file, const int line,
96044 const char *fmt, ...);
96045-extern __printf(4, 5)
96046+extern __printf(4, 5) __nocapture(1, 4, 5)
96047 void warn_slowpath_fmt_taint(const char *file, const int line, unsigned taint,
96048 const char *fmt, ...);
96049-extern void warn_slowpath_null(const char *file, const int line);
96050+extern __nocapture(1) void warn_slowpath_null(const char *file, const int line);
96051 #define WANT_WARN_ON_SLOWPATH
96052 #define __WARN() warn_slowpath_null(__FILE__, __LINE__)
96053 #define __WARN_printf(arg...) warn_slowpath_fmt(__FILE__, __LINE__, arg)
96054diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
96055index 1bfcfe5..e04c5c9 100644
96056--- a/include/asm-generic/cache.h
96057+++ b/include/asm-generic/cache.h
96058@@ -6,7 +6,7 @@
96059 * cache lines need to provide their own cache.h.
96060 */
96061
96062-#define L1_CACHE_SHIFT 5
96063-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
96064+#define L1_CACHE_SHIFT 5UL
96065+#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
96066
96067 #endif /* __ASM_GENERIC_CACHE_H */
96068diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
96069index 0d68a1e..b74a761 100644
96070--- a/include/asm-generic/emergency-restart.h
96071+++ b/include/asm-generic/emergency-restart.h
96072@@ -1,7 +1,7 @@
96073 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
96074 #define _ASM_GENERIC_EMERGENCY_RESTART_H
96075
96076-static inline void machine_emergency_restart(void)
96077+static inline __noreturn void machine_emergency_restart(void)
96078 {
96079 machine_restart(NULL);
96080 }
96081diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
96082index 90f99c7..00ce236 100644
96083--- a/include/asm-generic/kmap_types.h
96084+++ b/include/asm-generic/kmap_types.h
96085@@ -2,9 +2,9 @@
96086 #define _ASM_GENERIC_KMAP_TYPES_H
96087
96088 #ifdef __WITH_KM_FENCE
96089-# define KM_TYPE_NR 41
96090+# define KM_TYPE_NR 42
96091 #else
96092-# define KM_TYPE_NR 20
96093+# define KM_TYPE_NR 21
96094 #endif
96095
96096 #endif
96097diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
96098index 9ceb03b..62b0b8f 100644
96099--- a/include/asm-generic/local.h
96100+++ b/include/asm-generic/local.h
96101@@ -23,24 +23,37 @@ typedef struct
96102 atomic_long_t a;
96103 } local_t;
96104
96105+typedef struct {
96106+ atomic_long_unchecked_t a;
96107+} local_unchecked_t;
96108+
96109 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
96110
96111 #define local_read(l) atomic_long_read(&(l)->a)
96112+#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
96113 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
96114+#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
96115 #define local_inc(l) atomic_long_inc(&(l)->a)
96116+#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
96117 #define local_dec(l) atomic_long_dec(&(l)->a)
96118+#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
96119 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
96120+#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
96121 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
96122+#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
96123
96124 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
96125 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
96126 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
96127 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
96128 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
96129+#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
96130 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
96131 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
96132+#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
96133
96134 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
96135+#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
96136 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
96137 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
96138 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
96139diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
96140index 725612b..9cc513a 100644
96141--- a/include/asm-generic/pgtable-nopmd.h
96142+++ b/include/asm-generic/pgtable-nopmd.h
96143@@ -1,14 +1,19 @@
96144 #ifndef _PGTABLE_NOPMD_H
96145 #define _PGTABLE_NOPMD_H
96146
96147-#ifndef __ASSEMBLY__
96148-
96149 #include <asm-generic/pgtable-nopud.h>
96150
96151-struct mm_struct;
96152-
96153 #define __PAGETABLE_PMD_FOLDED
96154
96155+#define PMD_SHIFT PUD_SHIFT
96156+#define PTRS_PER_PMD 1
96157+#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
96158+#define PMD_MASK (~(PMD_SIZE-1))
96159+
96160+#ifndef __ASSEMBLY__
96161+
96162+struct mm_struct;
96163+
96164 /*
96165 * Having the pmd type consist of a pud gets the size right, and allows
96166 * us to conceptually access the pud entry that this pmd is folded into
96167@@ -16,11 +21,6 @@ struct mm_struct;
96168 */
96169 typedef struct { pud_t pud; } pmd_t;
96170
96171-#define PMD_SHIFT PUD_SHIFT
96172-#define PTRS_PER_PMD 1
96173-#define PMD_SIZE (1UL << PMD_SHIFT)
96174-#define PMD_MASK (~(PMD_SIZE-1))
96175-
96176 /*
96177 * The "pud_xxx()" functions here are trivial for a folded two-level
96178 * setup: the pmd is never bad, and a pmd always exists (as it's folded
96179diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
96180index 810431d..0ec4804f 100644
96181--- a/include/asm-generic/pgtable-nopud.h
96182+++ b/include/asm-generic/pgtable-nopud.h
96183@@ -1,10 +1,15 @@
96184 #ifndef _PGTABLE_NOPUD_H
96185 #define _PGTABLE_NOPUD_H
96186
96187-#ifndef __ASSEMBLY__
96188-
96189 #define __PAGETABLE_PUD_FOLDED
96190
96191+#define PUD_SHIFT PGDIR_SHIFT
96192+#define PTRS_PER_PUD 1
96193+#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
96194+#define PUD_MASK (~(PUD_SIZE-1))
96195+
96196+#ifndef __ASSEMBLY__
96197+
96198 /*
96199 * Having the pud type consist of a pgd gets the size right, and allows
96200 * us to conceptually access the pgd entry that this pud is folded into
96201@@ -12,11 +17,6 @@
96202 */
96203 typedef struct { pgd_t pgd; } pud_t;
96204
96205-#define PUD_SHIFT PGDIR_SHIFT
96206-#define PTRS_PER_PUD 1
96207-#define PUD_SIZE (1UL << PUD_SHIFT)
96208-#define PUD_MASK (~(PUD_SIZE-1))
96209-
96210 /*
96211 * The "pgd_xxx()" functions here are trivial for a folded two-level
96212 * setup: the pud is never bad, and a pud always exists (as it's folded
96213@@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
96214 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
96215
96216 #define pgd_populate(mm, pgd, pud) do { } while (0)
96217+#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
96218 /*
96219 * (puds are folded into pgds so this doesn't get actually called,
96220 * but the define is needed for a generic inline function.)
96221diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
96222index 29c57b2..da571a2 100644
96223--- a/include/asm-generic/pgtable.h
96224+++ b/include/asm-generic/pgtable.h
96225@@ -715,6 +715,22 @@ static inline int pmd_protnone(pmd_t pmd)
96226 }
96227 #endif /* CONFIG_NUMA_BALANCING */
96228
96229+#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
96230+#ifdef CONFIG_PAX_KERNEXEC
96231+#error KERNEXEC requires pax_open_kernel
96232+#else
96233+static inline unsigned long pax_open_kernel(void) { return 0; }
96234+#endif
96235+#endif
96236+
96237+#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
96238+#ifdef CONFIG_PAX_KERNEXEC
96239+#error KERNEXEC requires pax_close_kernel
96240+#else
96241+static inline unsigned long pax_close_kernel(void) { return 0; }
96242+#endif
96243+#endif
96244+
96245 #endif /* CONFIG_MMU */
96246
96247 #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
96248diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
96249index b58fd66..6cfae67 100644
96250--- a/include/asm-generic/sections.h
96251+++ b/include/asm-generic/sections.h
96252@@ -30,6 +30,7 @@ extern char _data[], _sdata[], _edata[];
96253 extern char __bss_start[], __bss_stop[];
96254 extern char __init_begin[], __init_end[];
96255 extern char _sinittext[], _einittext[];
96256+extern char _sinitdata[], _einitdata[];
96257 extern char _end[];
96258 extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[];
96259 extern char __kprobes_text_start[], __kprobes_text_end[];
96260diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
96261index 72d8803..cb9749c 100644
96262--- a/include/asm-generic/uaccess.h
96263+++ b/include/asm-generic/uaccess.h
96264@@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
96265 return __clear_user(to, n);
96266 }
96267
96268+#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
96269+#ifdef CONFIG_PAX_MEMORY_UDEREF
96270+#error UDEREF requires pax_open_userland
96271+#else
96272+static inline unsigned long pax_open_userland(void) { return 0; }
96273+#endif
96274+#endif
96275+
96276+#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
96277+#ifdef CONFIG_PAX_MEMORY_UDEREF
96278+#error UDEREF requires pax_close_userland
96279+#else
96280+static inline unsigned long pax_close_userland(void) { return 0; }
96281+#endif
96282+#endif
96283+
96284 #endif /* __ASM_GENERIC_UACCESS_H */
96285diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
96286index 8bd374d..2665ce3 100644
96287--- a/include/asm-generic/vmlinux.lds.h
96288+++ b/include/asm-generic/vmlinux.lds.h
96289@@ -246,6 +246,7 @@
96290 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
96291 VMLINUX_SYMBOL(__start_rodata) = .; \
96292 *(.rodata) *(.rodata.*) \
96293+ *(.data..read_only) \
96294 *(__vermagic) /* Kernel version magic */ \
96295 . = ALIGN(8); \
96296 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
96297@@ -504,6 +505,7 @@
96298 KERNEL_CTORS() \
96299 MCOUNT_REC() \
96300 *(.init.rodata) \
96301+ *(.init.rodata.*) \
96302 FTRACE_EVENTS() \
96303 TRACE_SYSCALLS() \
96304 KPROBE_BLACKLIST() \
96305@@ -525,6 +527,8 @@
96306
96307 #define EXIT_DATA \
96308 *(.exit.data) \
96309+ *(.exit.rodata) \
96310+ *(.exit.rodata.*) \
96311 MEM_DISCARD(exit.data) \
96312 MEM_DISCARD(exit.rodata)
96313
96314@@ -741,17 +745,18 @@
96315 * section in the linker script will go there too. @phdr should have
96316 * a leading colon.
96317 *
96318- * Note that this macros defines __per_cpu_load as an absolute symbol.
96319+ * Note that this macros defines per_cpu_load as an absolute symbol.
96320 * If there is no need to put the percpu section at a predetermined
96321 * address, use PERCPU_SECTION.
96322 */
96323 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
96324- VMLINUX_SYMBOL(__per_cpu_load) = .; \
96325- .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
96326+ per_cpu_load = .; \
96327+ .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
96328 - LOAD_OFFSET) { \
96329+ VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
96330 PERCPU_INPUT(cacheline) \
96331 } phdr \
96332- . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
96333+ . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
96334
96335 /**
96336 * PERCPU_SECTION - define output section for percpu area, simple version
96337@@ -813,12 +818,14 @@
96338
96339 #define INIT_DATA_SECTION(initsetup_align) \
96340 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \
96341+ VMLINUX_SYMBOL(_sinitdata) = .; \
96342 INIT_DATA \
96343 INIT_SETUP(initsetup_align) \
96344 INIT_CALLS \
96345 CON_INITCALL \
96346 SECURITY_INITCALL \
96347 INIT_RAM_FS \
96348+ VMLINUX_SYMBOL(_einitdata) = .; \
96349 }
96350
96351 #define BSS_SECTION(sbss_align, bss_align, stop_align) \
96352diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
96353index d4ebf6e..ca4bd35 100644
96354--- a/include/crypto/algapi.h
96355+++ b/include/crypto/algapi.h
96356@@ -35,7 +35,7 @@ struct crypto_type {
96357 unsigned int maskclear;
96358 unsigned int maskset;
96359 unsigned int tfmsize;
96360-};
96361+} __do_const;
96362
96363 struct crypto_instance {
96364 struct crypto_alg alg;
96365diff --git a/include/drm/drmP.h b/include/drm/drmP.h
96366index 5aa5197..e4ca348 100644
96367--- a/include/drm/drmP.h
96368+++ b/include/drm/drmP.h
96369@@ -59,6 +59,7 @@
96370
96371 #include <asm/mman.h>
96372 #include <asm/pgalloc.h>
96373+#include <asm/local.h>
96374 #include <asm/uaccess.h>
96375
96376 #include <uapi/drm/drm.h>
96377@@ -137,17 +138,18 @@ void drm_err(const char *format, ...);
96378 /*@{*/
96379
96380 /* driver capabilities and requirements mask */
96381-#define DRIVER_USE_AGP 0x1
96382-#define DRIVER_PCI_DMA 0x8
96383-#define DRIVER_SG 0x10
96384-#define DRIVER_HAVE_DMA 0x20
96385-#define DRIVER_HAVE_IRQ 0x40
96386-#define DRIVER_IRQ_SHARED 0x80
96387-#define DRIVER_GEM 0x1000
96388-#define DRIVER_MODESET 0x2000
96389-#define DRIVER_PRIME 0x4000
96390-#define DRIVER_RENDER 0x8000
96391-#define DRIVER_ATOMIC 0x10000
96392+#define DRIVER_USE_AGP 0x1
96393+#define DRIVER_PCI_DMA 0x8
96394+#define DRIVER_SG 0x10
96395+#define DRIVER_HAVE_DMA 0x20
96396+#define DRIVER_HAVE_IRQ 0x40
96397+#define DRIVER_IRQ_SHARED 0x80
96398+#define DRIVER_GEM 0x1000
96399+#define DRIVER_MODESET 0x2000
96400+#define DRIVER_PRIME 0x4000
96401+#define DRIVER_RENDER 0x8000
96402+#define DRIVER_ATOMIC 0x10000
96403+#define DRIVER_KMS_LEGACY_CONTEXT 0x20000
96404
96405 /***********************************************************************/
96406 /** \name Macros to make printk easier */
96407@@ -233,10 +235,12 @@ void drm_err(const char *format, ...);
96408 * \param cmd command.
96409 * \param arg argument.
96410 */
96411-typedef int drm_ioctl_t(struct drm_device *dev, void *data,
96412+typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
96413+ struct drm_file *file_priv);
96414+typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
96415 struct drm_file *file_priv);
96416
96417-typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
96418+typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
96419 unsigned long arg);
96420
96421 #define DRM_IOCTL_NR(n) _IOC_NR(n)
96422@@ -252,9 +256,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
96423 struct drm_ioctl_desc {
96424 unsigned int cmd;
96425 int flags;
96426- drm_ioctl_t *func;
96427+ drm_ioctl_t func;
96428 const char *name;
96429-};
96430+} __do_const;
96431
96432 /**
96433 * Creates a driver or general drm_ioctl_desc array entry for the given
96434@@ -647,7 +651,8 @@ struct drm_info_list {
96435 int (*show)(struct seq_file*, void*); /** show callback */
96436 u32 driver_features; /**< Required driver features for this entry */
96437 void *data;
96438-};
96439+} __do_const;
96440+typedef struct drm_info_list __no_const drm_info_list_no_const;
96441
96442 /**
96443 * debugfs node structure. This structure represents a debugfs file.
96444@@ -735,7 +740,7 @@ struct drm_device {
96445
96446 /** \name Usage Counters */
96447 /*@{ */
96448- int open_count; /**< Outstanding files open, protected by drm_global_mutex. */
96449+ local_t open_count; /**< Outstanding files open, protected by drm_global_mutex. */
96450 spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */
96451 int buf_use; /**< Buffers in use -- cannot alloc */
96452 atomic_t buf_alloc; /**< Buffer allocation in progress */
96453diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
96454index 918aa68..f162a8a 100644
96455--- a/include/drm/drm_crtc_helper.h
96456+++ b/include/drm/drm_crtc_helper.h
96457@@ -161,7 +161,7 @@ struct drm_encoder_helper_funcs {
96458 int (*atomic_check)(struct drm_encoder *encoder,
96459 struct drm_crtc_state *crtc_state,
96460 struct drm_connector_state *conn_state);
96461-};
96462+} __no_const;
96463
96464 /**
96465 * struct drm_connector_helper_funcs - helper operations for connectors
96466diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
96467index 0de6290..2a2c125 100644
96468--- a/include/drm/drm_mm.h
96469+++ b/include/drm/drm_mm.h
96470@@ -297,7 +297,7 @@ void drm_mm_remove_node(struct drm_mm_node *node);
96471 void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new);
96472 void drm_mm_init(struct drm_mm *mm,
96473 u64 start,
96474- u64 size);
96475+ u64 size) __intentional_overflow(3);
96476 void drm_mm_takedown(struct drm_mm *mm);
96477 bool drm_mm_clean(struct drm_mm *mm);
96478
96479diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
96480index 17c4456..da0c5eb 100644
96481--- a/include/drm/i915_pciids.h
96482+++ b/include/drm/i915_pciids.h
96483@@ -37,7 +37,7 @@
96484 */
96485 #define INTEL_VGA_DEVICE(id, info) { \
96486 0x8086, id, \
96487- ~0, ~0, \
96488+ PCI_ANY_ID, PCI_ANY_ID, \
96489 0x030000, 0xff0000, \
96490 (unsigned long) info }
96491
96492diff --git a/include/drm/intel-gtt.h b/include/drm/intel-gtt.h
96493index b08bdad..21e6054 100644
96494--- a/include/drm/intel-gtt.h
96495+++ b/include/drm/intel-gtt.h
96496@@ -3,8 +3,8 @@
96497 #ifndef _DRM_INTEL_GTT_H
96498 #define _DRM_INTEL_GTT_H
96499
96500-void intel_gtt_get(size_t *gtt_total, size_t *stolen_size,
96501- phys_addr_t *mappable_base, unsigned long *mappable_end);
96502+void intel_gtt_get(uint64_t *gtt_total, uint64_t *stolen_size,
96503+ uint64_t *mappable_base, uint64_t *mappable_end);
96504
96505 int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
96506 struct agp_bridge_data *bridge);
96507diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
96508index 72dcbe8..8db58d7 100644
96509--- a/include/drm/ttm/ttm_memory.h
96510+++ b/include/drm/ttm/ttm_memory.h
96511@@ -48,7 +48,7 @@
96512
96513 struct ttm_mem_shrink {
96514 int (*do_shrink) (struct ttm_mem_shrink *);
96515-};
96516+} __no_const;
96517
96518 /**
96519 * struct ttm_mem_global - Global memory accounting structure.
96520diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h
96521index 49a8284..9643967 100644
96522--- a/include/drm/ttm/ttm_page_alloc.h
96523+++ b/include/drm/ttm/ttm_page_alloc.h
96524@@ -80,6 +80,7 @@ void ttm_dma_page_alloc_fini(void);
96525 */
96526 extern int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data);
96527
96528+struct device;
96529 extern int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev);
96530 extern void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev);
96531
96532diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
96533index 4b840e8..155d235 100644
96534--- a/include/keys/asymmetric-subtype.h
96535+++ b/include/keys/asymmetric-subtype.h
96536@@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
96537 /* Verify the signature on a key of this subtype (optional) */
96538 int (*verify_signature)(const struct key *key,
96539 const struct public_key_signature *sig);
96540-};
96541+} __do_const;
96542
96543 /**
96544 * asymmetric_key_subtype - Get the subtype from an asymmetric key
96545diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
96546index c1da539..1dcec55 100644
96547--- a/include/linux/atmdev.h
96548+++ b/include/linux/atmdev.h
96549@@ -28,7 +28,7 @@ struct compat_atm_iobuf {
96550 #endif
96551
96552 struct k_atm_aal_stats {
96553-#define __HANDLE_ITEM(i) atomic_t i
96554+#define __HANDLE_ITEM(i) atomic_unchecked_t i
96555 __AAL_STAT_ITEMS
96556 #undef __HANDLE_ITEM
96557 };
96558@@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
96559 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
96560 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
96561 struct module *owner;
96562-};
96563+} __do_const ;
96564
96565 struct atmphy_ops {
96566 int (*start)(struct atm_dev *dev);
96567diff --git a/include/linux/atomic.h b/include/linux/atomic.h
96568index 5b08a85..60922fb 100644
96569--- a/include/linux/atomic.h
96570+++ b/include/linux/atomic.h
96571@@ -12,7 +12,7 @@
96572 * Atomically adds @a to @v, so long as @v was not already @u.
96573 * Returns non-zero if @v was not @u, and zero otherwise.
96574 */
96575-static inline int atomic_add_unless(atomic_t *v, int a, int u)
96576+static inline int __intentional_overflow(-1) atomic_add_unless(atomic_t *v, int a, int u)
96577 {
96578 return __atomic_add_unless(v, a, u) != u;
96579 }
96580diff --git a/include/linux/audit.h b/include/linux/audit.h
96581index c2e7e3a..8bfc0e1 100644
96582--- a/include/linux/audit.h
96583+++ b/include/linux/audit.h
96584@@ -223,7 +223,7 @@ static inline void audit_ptrace(struct task_struct *t)
96585 extern unsigned int audit_serial(void);
96586 extern int auditsc_get_stamp(struct audit_context *ctx,
96587 struct timespec *t, unsigned int *serial);
96588-extern int audit_set_loginuid(kuid_t loginuid);
96589+extern int __intentional_overflow(-1) audit_set_loginuid(kuid_t loginuid);
96590
96591 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
96592 {
96593diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
96594index 576e463..28fd926 100644
96595--- a/include/linux/binfmts.h
96596+++ b/include/linux/binfmts.h
96597@@ -44,7 +44,7 @@ struct linux_binprm {
96598 unsigned interp_flags;
96599 unsigned interp_data;
96600 unsigned long loader, exec;
96601-};
96602+} __randomize_layout;
96603
96604 #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
96605 #define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT)
96606@@ -77,8 +77,10 @@ struct linux_binfmt {
96607 int (*load_binary)(struct linux_binprm *);
96608 int (*load_shlib)(struct file *);
96609 int (*core_dump)(struct coredump_params *cprm);
96610+ void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
96611+ void (*handle_mmap)(struct file *);
96612 unsigned long min_coredump; /* minimal dump size */
96613-};
96614+} __do_const __randomize_layout;
96615
96616 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
96617
96618diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
96619index ea17cca..dd56e56 100644
96620--- a/include/linux/bitmap.h
96621+++ b/include/linux/bitmap.h
96622@@ -295,7 +295,7 @@ static inline int bitmap_full(const unsigned long *src, unsigned int nbits)
96623 return find_first_zero_bit(src, nbits) == nbits;
96624 }
96625
96626-static inline int bitmap_weight(const unsigned long *src, unsigned int nbits)
96627+static inline int __intentional_overflow(-1) bitmap_weight(const unsigned long *src, unsigned int nbits)
96628 {
96629 if (small_const_nbits(nbits))
96630 return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
96631diff --git a/include/linux/bitops.h b/include/linux/bitops.h
96632index 297f5bd..5892caa 100644
96633--- a/include/linux/bitops.h
96634+++ b/include/linux/bitops.h
96635@@ -75,7 +75,7 @@ static __inline__ int get_count_order(unsigned int count)
96636 return order;
96637 }
96638
96639-static inline unsigned long hweight_long(unsigned long w)
96640+static inline unsigned long __intentional_overflow(-1) hweight_long(unsigned long w)
96641 {
96642 return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
96643 }
96644@@ -105,7 +105,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift)
96645 * @word: value to rotate
96646 * @shift: bits to roll
96647 */
96648-static inline __u32 rol32(__u32 word, unsigned int shift)
96649+static inline __u32 __intentional_overflow(-1) rol32(__u32 word, unsigned int shift)
96650 {
96651 return (word << shift) | (word >> (32 - shift));
96652 }
96653@@ -115,7 +115,7 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
96654 * @word: value to rotate
96655 * @shift: bits to roll
96656 */
96657-static inline __u32 ror32(__u32 word, unsigned int shift)
96658+static inline __u32 __intentional_overflow(-1) ror32(__u32 word, unsigned int shift)
96659 {
96660 return (word >> shift) | (word << (32 - shift));
96661 }
96662@@ -171,7 +171,7 @@ static inline __s32 sign_extend32(__u32 value, int index)
96663 return (__s32)(value << shift) >> shift;
96664 }
96665
96666-static inline unsigned fls_long(unsigned long l)
96667+static inline unsigned __intentional_overflow(-1) fls_long(unsigned long l)
96668 {
96669 if (sizeof(l) == 4)
96670 return fls(l);
96671diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
96672index d4068c1..77159a1 100644
96673--- a/include/linux/blkdev.h
96674+++ b/include/linux/blkdev.h
96675@@ -1567,7 +1567,7 @@ struct block_device_operations {
96676 /* this callback is with swap_lock and sometimes page table lock held */
96677 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
96678 struct module *owner;
96679-};
96680+} __do_const;
96681
96682 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
96683 unsigned long);
96684diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
96685index afc1343..9735539 100644
96686--- a/include/linux/blktrace_api.h
96687+++ b/include/linux/blktrace_api.h
96688@@ -25,7 +25,7 @@ struct blk_trace {
96689 struct dentry *dropped_file;
96690 struct dentry *msg_file;
96691 struct list_head running_list;
96692- atomic_t dropped;
96693+ atomic_unchecked_t dropped;
96694 };
96695
96696 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
96697diff --git a/include/linux/cache.h b/include/linux/cache.h
96698index 17e7e82..1d7da26 100644
96699--- a/include/linux/cache.h
96700+++ b/include/linux/cache.h
96701@@ -16,6 +16,14 @@
96702 #define __read_mostly
96703 #endif
96704
96705+#ifndef __read_only
96706+#ifdef CONFIG_PAX_KERNEXEC
96707+#error KERNEXEC requires __read_only
96708+#else
96709+#define __read_only __read_mostly
96710+#endif
96711+#endif
96712+
96713 #ifndef ____cacheline_aligned
96714 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
96715 #endif
96716diff --git a/include/linux/capability.h b/include/linux/capability.h
96717index af9f0b9..71a5e5c 100644
96718--- a/include/linux/capability.h
96719+++ b/include/linux/capability.h
96720@@ -237,15 +237,28 @@ static inline bool capable(int cap)
96721 {
96722 return true;
96723 }
96724+static inline bool capable_nolog(int cap)
96725+{
96726+ return true;
96727+}
96728 static inline bool ns_capable(struct user_namespace *ns, int cap)
96729 {
96730 return true;
96731 }
96732+static inline bool ns_capable_nolog(struct user_namespace *ns, int cap)
96733+{
96734+ return true;
96735+}
96736 #endif /* CONFIG_MULTIUSER */
96737 extern bool capable_wrt_inode_uidgid(const struct inode *inode, int cap);
96738+extern bool capable_wrt_inode_uidgid_nolog(const struct inode *inode, int cap);
96739 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
96740+extern bool capable_nolog(int cap);
96741+extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
96742
96743 /* audit system wants to get cap info from files as well */
96744 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
96745
96746+extern int is_privileged_binary(const struct dentry *dentry);
96747+
96748 #endif /* !_LINUX_CAPABILITY_H */
96749diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
96750index 8609d57..86e4d79 100644
96751--- a/include/linux/cdrom.h
96752+++ b/include/linux/cdrom.h
96753@@ -87,7 +87,6 @@ struct cdrom_device_ops {
96754
96755 /* driver specifications */
96756 const int capability; /* capability flags */
96757- int n_minors; /* number of active minor devices */
96758 /* handle uniform packets for scsi type devices (scsi,atapi) */
96759 int (*generic_packet) (struct cdrom_device_info *,
96760 struct packet_command *);
96761diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
96762index bda5ec0b4..51d8ea1 100644
96763--- a/include/linux/cleancache.h
96764+++ b/include/linux/cleancache.h
96765@@ -35,7 +35,7 @@ struct cleancache_ops {
96766 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
96767 void (*invalidate_inode)(int, struct cleancache_filekey);
96768 void (*invalidate_fs)(int);
96769-};
96770+} __no_const;
96771
96772 extern int cleancache_register_ops(struct cleancache_ops *ops);
96773 extern void __cleancache_init_fs(struct super_block *);
96774diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
96775index 78842f4..7e7f81f 100644
96776--- a/include/linux/clk-provider.h
96777+++ b/include/linux/clk-provider.h
96778@@ -196,6 +196,7 @@ struct clk_ops {
96779 void (*init)(struct clk_hw *hw);
96780 int (*debug_init)(struct clk_hw *hw, struct dentry *dentry);
96781 };
96782+typedef struct clk_ops __no_const clk_ops_no_const;
96783
96784 /**
96785 * struct clk_init_data - holds init data that's common to all clocks and is
96786diff --git a/include/linux/compat.h b/include/linux/compat.h
96787index a76c917..63b52db 100644
96788--- a/include/linux/compat.h
96789+++ b/include/linux/compat.h
96790@@ -316,7 +316,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
96791 compat_size_t __user *len_ptr);
96792
96793 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
96794-asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
96795+asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
96796 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
96797 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
96798 compat_ssize_t msgsz, int msgflg);
96799@@ -325,7 +325,7 @@ asmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp,
96800 long compat_sys_msgctl(int first, int second, void __user *uptr);
96801 long compat_sys_shmctl(int first, int second, void __user *uptr);
96802 long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
96803- unsigned nsems, const struct compat_timespec __user *timeout);
96804+ compat_long_t nsems, const struct compat_timespec __user *timeout);
96805 asmlinkage long compat_sys_keyctl(u32 option,
96806 u32 arg2, u32 arg3, u32 arg4, u32 arg5);
96807 asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
96808@@ -439,7 +439,7 @@ extern int compat_ptrace_request(struct task_struct *child,
96809 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
96810 compat_ulong_t addr, compat_ulong_t data);
96811 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
96812- compat_long_t addr, compat_long_t data);
96813+ compat_ulong_t addr, compat_ulong_t data);
96814
96815 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, compat_size_t);
96816 /*
96817diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
96818index dfaa7b3..c8a6a2e 100644
96819--- a/include/linux/compiler-gcc.h
96820+++ b/include/linux/compiler-gcc.h
96821@@ -116,8 +116,8 @@
96822 */
96823 #define __pure __attribute__((pure))
96824 #define __aligned(x) __attribute__((aligned(x)))
96825-#define __printf(a, b) __attribute__((format(printf, a, b)))
96826-#define __scanf(a, b) __attribute__((format(scanf, a, b)))
96827+#define __printf(a, b) __attribute__((format(printf, a, b))) __nocapture(a, b)
96828+#define __scanf(a, b) __attribute__((format(scanf, a, b))) __nocapture(a, b)
96829 #define __attribute_const__ __attribute__((__const__))
96830 #define __maybe_unused __attribute__((unused))
96831 #define __always_unused __attribute__((unused))
96832@@ -184,9 +184,38 @@
96833 # define __compiletime_warning(message) __attribute__((warning(message)))
96834 # define __compiletime_error(message) __attribute__((error(message)))
96835 #endif /* __CHECKER__ */
96836+
96837+#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
96838+#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
96839+#define __bos0(ptr) __bos((ptr), 0)
96840+#define __bos1(ptr) __bos((ptr), 1)
96841 #endif /* GCC_VERSION >= 40300 */
96842
96843 #if GCC_VERSION >= 40500
96844+
96845+#ifdef RANDSTRUCT_PLUGIN
96846+#define __randomize_layout __attribute__((randomize_layout))
96847+#define __no_randomize_layout __attribute__((no_randomize_layout))
96848+#endif
96849+
96850+#ifdef CONSTIFY_PLUGIN
96851+#define __no_const __attribute__((no_const))
96852+#define __do_const __attribute__((do_const))
96853+#endif
96854+
96855+#ifdef SIZE_OVERFLOW_PLUGIN
96856+#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
96857+#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
96858+#endif
96859+
96860+#ifdef LATENT_ENTROPY_PLUGIN
96861+#define __latent_entropy __attribute__((latent_entropy))
96862+#endif
96863+
96864+#ifdef INITIFY_PLUGIN
96865+#define __nocapture(...) __attribute__((nocapture(__VA_ARGS__)))
96866+#endif
96867+
96868 /*
96869 * Mark a position in code as unreachable. This can be used to
96870 * suppress control flow warnings after asm blocks that transfer
96871@@ -237,6 +266,10 @@
96872 #define KASAN_ABI_VERSION 3
96873 #endif
96874
96875+#if GCC_VERSION >= 50000
96876+#define CC_HAVE_BUILTIN_OVERFLOW
96877+#endif
96878+
96879 #endif /* gcc version >= 40000 specific checks */
96880
96881 #if !defined(__noclone)
96882diff --git a/include/linux/compiler.h b/include/linux/compiler.h
96883index e08a6ae..2e5e776 100644
96884--- a/include/linux/compiler.h
96885+++ b/include/linux/compiler.h
96886@@ -5,11 +5,14 @@
96887
96888 #ifdef __CHECKER__
96889 # define __user __attribute__((noderef, address_space(1)))
96890+# define __force_user __force __user
96891 # define __kernel __attribute__((address_space(0)))
96892+# define __force_kernel __force __kernel
96893 # define __safe __attribute__((safe))
96894 # define __force __attribute__((force))
96895 # define __nocast __attribute__((nocast))
96896 # define __iomem __attribute__((noderef, address_space(2)))
96897+# define __force_iomem __force __iomem
96898 # define __must_hold(x) __attribute__((context(x,1,1)))
96899 # define __acquires(x) __attribute__((context(x,0,1)))
96900 # define __releases(x) __attribute__((context(x,1,0)))
96901@@ -17,21 +20,39 @@
96902 # define __release(x) __context__(x,-1)
96903 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
96904 # define __percpu __attribute__((noderef, address_space(3)))
96905+# define __force_percpu __force __percpu
96906 # define __pmem __attribute__((noderef, address_space(5)))
96907+# define __force_pmem __force __pmem
96908 #ifdef CONFIG_SPARSE_RCU_POINTER
96909 # define __rcu __attribute__((noderef, address_space(4)))
96910+# define __force_rcu __force __rcu
96911 #else
96912 # define __rcu
96913+# define __force_rcu
96914 #endif
96915 extern void __chk_user_ptr(const volatile void __user *);
96916 extern void __chk_io_ptr(const volatile void __iomem *);
96917 #else
96918-# define __user
96919-# define __kernel
96920+# ifdef CHECKER_PLUGIN
96921+//# define __user
96922+//# define __force_user
96923+//# define __kernel
96924+//# define __force_kernel
96925+# else
96926+# ifdef STRUCTLEAK_PLUGIN
96927+# define __user __attribute__((user))
96928+# else
96929+# define __user
96930+# endif
96931+# define __force_user
96932+# define __kernel
96933+# define __force_kernel
96934+# endif
96935 # define __safe
96936 # define __force
96937 # define __nocast
96938 # define __iomem
96939+# define __force_iomem
96940 # define __chk_user_ptr(x) (void)0
96941 # define __chk_io_ptr(x) (void)0
96942 # define __builtin_warning(x, y...) (1)
96943@@ -42,8 +63,11 @@ extern void __chk_io_ptr(const volatile void __iomem *);
96944 # define __release(x) (void)0
96945 # define __cond_lock(x,c) (c)
96946 # define __percpu
96947+# define __force_percpu
96948 # define __rcu
96949+# define __force_rcu
96950 # define __pmem
96951+# define __force_pmem
96952 #endif
96953
96954 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
96955@@ -201,27 +225,27 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
96956 static __always_inline void __read_once_size(const volatile void *p, void *res, int size)
96957 {
96958 switch (size) {
96959- case 1: *(__u8 *)res = *(volatile __u8 *)p; break;
96960- case 2: *(__u16 *)res = *(volatile __u16 *)p; break;
96961- case 4: *(__u32 *)res = *(volatile __u32 *)p; break;
96962- case 8: *(__u64 *)res = *(volatile __u64 *)p; break;
96963+ case 1: *(__u8 *)res = *(const volatile __u8 *)p; break;
96964+ case 2: *(__u16 *)res = *(const volatile __u16 *)p; break;
96965+ case 4: *(__u32 *)res = *(const volatile __u32 *)p; break;
96966+ case 8: *(__u64 *)res = *(const volatile __u64 *)p; break;
96967 default:
96968 barrier();
96969- __builtin_memcpy((void *)res, (const void *)p, size);
96970+ __builtin_memcpy(res, (const void *)p, size);
96971 barrier();
96972 }
96973 }
96974
96975-static __always_inline void __write_once_size(volatile void *p, void *res, int size)
96976+static __always_inline void __write_once_size(volatile void *p, const void *res, int size)
96977 {
96978 switch (size) {
96979- case 1: *(volatile __u8 *)p = *(__u8 *)res; break;
96980- case 2: *(volatile __u16 *)p = *(__u16 *)res; break;
96981- case 4: *(volatile __u32 *)p = *(__u32 *)res; break;
96982- case 8: *(volatile __u64 *)p = *(__u64 *)res; break;
96983+ case 1: *(volatile __u8 *)p = *(const __u8 *)res; break;
96984+ case 2: *(volatile __u16 *)p = *(const __u16 *)res; break;
96985+ case 4: *(volatile __u32 *)p = *(const __u32 *)res; break;
96986+ case 8: *(volatile __u64 *)p = *(const __u64 *)res; break;
96987 default:
96988 barrier();
96989- __builtin_memcpy((void *)p, (const void *)res, size);
96990+ __builtin_memcpy((void *)p, res, size);
96991 barrier();
96992 }
96993 }
96994@@ -370,6 +394,38 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
96995 # define __attribute_const__ /* unimplemented */
96996 #endif
96997
96998+#ifndef __randomize_layout
96999+# define __randomize_layout
97000+#endif
97001+
97002+#ifndef __no_randomize_layout
97003+# define __no_randomize_layout
97004+#endif
97005+
97006+#ifndef __no_const
97007+# define __no_const
97008+#endif
97009+
97010+#ifndef __do_const
97011+# define __do_const
97012+#endif
97013+
97014+#ifndef __size_overflow
97015+# define __size_overflow(...)
97016+#endif
97017+
97018+#ifndef __intentional_overflow
97019+# define __intentional_overflow(...)
97020+#endif
97021+
97022+#ifndef __latent_entropy
97023+# define __latent_entropy
97024+#endif
97025+
97026+#ifndef __nocapture
97027+# define __nocapture(...)
97028+#endif
97029+
97030 /*
97031 * Tell gcc if a function is cold. The compiler will assume any path
97032 * directly leading to the call is unlikely.
97033@@ -379,6 +435,22 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
97034 #define __cold
97035 #endif
97036
97037+#ifndef __alloc_size
97038+#define __alloc_size(...)
97039+#endif
97040+
97041+#ifndef __bos
97042+#define __bos(ptr, arg)
97043+#endif
97044+
97045+#ifndef __bos0
97046+#define __bos0(ptr)
97047+#endif
97048+
97049+#ifndef __bos1
97050+#define __bos1(ptr)
97051+#endif
97052+
97053 /* Simple shorthand for a section definition */
97054 #ifndef __section
97055 # define __section(S) __attribute__ ((__section__(#S)))
97056@@ -393,6 +465,8 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
97057 # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
97058 #endif
97059
97060+#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))
97061+
97062 /* Is this type a native word size -- useful for atomic operations */
97063 #ifndef __native_word
97064 # define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
97065@@ -472,8 +546,9 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
97066 */
97067 #define __ACCESS_ONCE(x) ({ \
97068 __maybe_unused typeof(x) __var = (__force typeof(x)) 0; \
97069- (volatile typeof(x) *)&(x); })
97070+ (volatile const typeof(x) *)&(x); })
97071 #define ACCESS_ONCE(x) (*__ACCESS_ONCE(x))
97072+#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
97073
97074 /**
97075 * lockless_dereference() - safely load a pointer for later dereference
97076diff --git a/include/linux/configfs.h b/include/linux/configfs.h
97077index 63a36e8..26b0825 100644
97078--- a/include/linux/configfs.h
97079+++ b/include/linux/configfs.h
97080@@ -125,7 +125,7 @@ struct configfs_attribute {
97081 const char *ca_name;
97082 struct module *ca_owner;
97083 umode_t ca_mode;
97084-};
97085+} __do_const;
97086
97087 /*
97088 * Users often need to create attribute structures for their configurable
97089diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
97090index bde1e56..168de74 100644
97091--- a/include/linux/cpufreq.h
97092+++ b/include/linux/cpufreq.h
97093@@ -211,6 +211,7 @@ struct global_attr {
97094 ssize_t (*store)(struct kobject *a, struct attribute *b,
97095 const char *c, size_t count);
97096 };
97097+typedef struct global_attr __no_const global_attr_no_const;
97098
97099 #define define_one_global_ro(_name) \
97100 static struct global_attr _name = \
97101@@ -282,7 +283,7 @@ struct cpufreq_driver {
97102 bool boost_supported;
97103 bool boost_enabled;
97104 int (*set_boost)(int state);
97105-};
97106+} __do_const;
97107
97108 /* flags */
97109 #define CPUFREQ_STICKY (1 << 0) /* driver isn't removed even if
97110diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
97111index d075d34..3b6734a 100644
97112--- a/include/linux/cpuidle.h
97113+++ b/include/linux/cpuidle.h
97114@@ -59,7 +59,8 @@ struct cpuidle_state {
97115 void (*enter_freeze) (struct cpuidle_device *dev,
97116 struct cpuidle_driver *drv,
97117 int index);
97118-};
97119+} __do_const;
97120+typedef struct cpuidle_state __no_const cpuidle_state_no_const;
97121
97122 /* Idle State Flags */
97123 #define CPUIDLE_FLAG_COUPLED (0x02) /* state applies to multiple cpus */
97124@@ -235,7 +236,7 @@ struct cpuidle_governor {
97125 void (*reflect) (struct cpuidle_device *dev, int index);
97126
97127 struct module *owner;
97128-};
97129+} __do_const;
97130
97131 #ifdef CONFIG_CPU_IDLE
97132 extern int cpuidle_register_governor(struct cpuidle_governor *gov);
97133diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
97134index 59915ea..81ebec0 100644
97135--- a/include/linux/cpumask.h
97136+++ b/include/linux/cpumask.h
97137@@ -127,17 +127,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
97138 }
97139
97140 /* Valid inputs for n are -1 and 0. */
97141-static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
97142+static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
97143 {
97144 return n+1;
97145 }
97146
97147-static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
97148+static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
97149 {
97150 return n+1;
97151 }
97152
97153-static inline unsigned int cpumask_next_and(int n,
97154+static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
97155 const struct cpumask *srcp,
97156 const struct cpumask *andp)
97157 {
97158@@ -181,7 +181,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
97159 *
97160 * Returns >= nr_cpu_ids if no further cpus set.
97161 */
97162-static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
97163+static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
97164 {
97165 /* -1 is a legal arg here. */
97166 if (n != -1)
97167@@ -196,7 +196,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
97168 *
97169 * Returns >= nr_cpu_ids if no further cpus unset.
97170 */
97171-static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
97172+static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
97173 {
97174 /* -1 is a legal arg here. */
97175 if (n != -1)
97176@@ -204,7 +204,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
97177 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
97178 }
97179
97180-int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
97181+int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
97182 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
97183 unsigned int cpumask_local_spread(unsigned int i, int node);
97184
97185@@ -471,7 +471,7 @@ static inline bool cpumask_full(const struct cpumask *srcp)
97186 * cpumask_weight - Count of bits in *srcp
97187 * @srcp: the cpumask to count bits (< nr_cpu_ids) in.
97188 */
97189-static inline unsigned int cpumask_weight(const struct cpumask *srcp)
97190+static inline unsigned int __intentional_overflow(-1) cpumask_weight(const struct cpumask *srcp)
97191 {
97192 return bitmap_weight(cpumask_bits(srcp), nr_cpumask_bits);
97193 }
97194diff --git a/include/linux/cred.h b/include/linux/cred.h
97195index 8b6c083..51cb9f5 100644
97196--- a/include/linux/cred.h
97197+++ b/include/linux/cred.h
97198@@ -35,7 +35,7 @@ struct group_info {
97199 int nblocks;
97200 kgid_t small_block[NGROUPS_SMALL];
97201 kgid_t *blocks[0];
97202-};
97203+} __randomize_layout;
97204
97205 /**
97206 * get_group_info - Get a reference to a group info structure
97207@@ -152,7 +152,7 @@ struct cred {
97208 struct user_namespace *user_ns; /* user_ns the caps and keyrings are relative to. */
97209 struct group_info *group_info; /* supplementary groups for euid/fsgid */
97210 struct rcu_head rcu; /* RCU deletion hook */
97211-};
97212+} __randomize_layout;
97213
97214 extern void __put_cred(struct cred *);
97215 extern void exit_creds(struct task_struct *);
97216@@ -210,6 +210,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
97217 static inline void validate_process_creds(void)
97218 {
97219 }
97220+static inline void validate_task_creds(struct task_struct *task)
97221+{
97222+}
97223 #endif
97224
97225 /**
97226@@ -347,6 +350,7 @@ static inline void put_cred(const struct cred *_cred)
97227
97228 #define task_uid(task) (task_cred_xxx((task), uid))
97229 #define task_euid(task) (task_cred_xxx((task), euid))
97230+#define task_securebits(task) (task_cred_xxx((task), securebits))
97231
97232 #define current_cred_xxx(xxx) \
97233 ({ \
97234diff --git a/include/linux/crypto.h b/include/linux/crypto.h
97235index 81ef938..9ec0fdb 100644
97236--- a/include/linux/crypto.h
97237+++ b/include/linux/crypto.h
97238@@ -569,7 +569,7 @@ struct cipher_tfm {
97239 const u8 *key, unsigned int keylen);
97240 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
97241 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
97242-};
97243+} __no_const;
97244
97245 struct hash_tfm {
97246 int (*init)(struct hash_desc *desc);
97247@@ -590,7 +590,7 @@ struct compress_tfm {
97248 int (*cot_decompress)(struct crypto_tfm *tfm,
97249 const u8 *src, unsigned int slen,
97250 u8 *dst, unsigned int *dlen);
97251-};
97252+} __no_const;
97253
97254 #define crt_ablkcipher crt_u.ablkcipher
97255 #define crt_blkcipher crt_u.blkcipher
97256diff --git a/include/linux/ctype.h b/include/linux/ctype.h
97257index 653589e..4ef254a 100644
97258--- a/include/linux/ctype.h
97259+++ b/include/linux/ctype.h
97260@@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
97261 * Fast implementation of tolower() for internal usage. Do not use in your
97262 * code.
97263 */
97264-static inline char _tolower(const char c)
97265+static inline unsigned char _tolower(const unsigned char c)
97266 {
97267 return c | 0x20;
97268 }
97269diff --git a/include/linux/dcache.h b/include/linux/dcache.h
97270index d67ae11..9ec20d2 100644
97271--- a/include/linux/dcache.h
97272+++ b/include/linux/dcache.h
97273@@ -123,6 +123,9 @@ struct dentry {
97274 unsigned long d_time; /* used by d_revalidate */
97275 void *d_fsdata; /* fs-specific data */
97276
97277+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
97278+ atomic_t chroot_refcnt; /* tracks use of directory in chroot */
97279+#endif
97280 struct list_head d_lru; /* LRU list */
97281 struct list_head d_child; /* child of parent list */
97282 struct list_head d_subdirs; /* our children */
97283@@ -133,7 +136,7 @@ struct dentry {
97284 struct hlist_node d_alias; /* inode alias list */
97285 struct rcu_head d_rcu;
97286 } d_u;
97287-};
97288+} __randomize_layout;
97289
97290 /*
97291 * dentry->d_lock spinlock nesting subclasses:
97292@@ -321,7 +324,7 @@ extern struct dentry *__d_lookup_rcu(const struct dentry *parent,
97293
97294 static inline unsigned d_count(const struct dentry *dentry)
97295 {
97296- return dentry->d_lockref.count;
97297+ return __lockref_read(&dentry->d_lockref);
97298 }
97299
97300 /*
97301@@ -350,7 +353,7 @@ extern char *dentry_path(struct dentry *, char *, int);
97302 static inline struct dentry *dget_dlock(struct dentry *dentry)
97303 {
97304 if (dentry)
97305- dentry->d_lockref.count++;
97306+ __lockref_inc(&dentry->d_lockref);
97307 return dentry;
97308 }
97309
97310diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
97311index 7925bf0..d5143d2 100644
97312--- a/include/linux/decompress/mm.h
97313+++ b/include/linux/decompress/mm.h
97314@@ -77,7 +77,7 @@ static void free(void *where)
97315 * warnings when not needed (indeed large_malloc / large_free are not
97316 * needed by inflate */
97317
97318-#define malloc(a) kmalloc(a, GFP_KERNEL)
97319+#define malloc(a) kmalloc((a), GFP_KERNEL)
97320 #define free(a) kfree(a)
97321
97322 #define large_malloc(a) vmalloc(a)
97323diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
97324index ce447f0..83c66bd 100644
97325--- a/include/linux/devfreq.h
97326+++ b/include/linux/devfreq.h
97327@@ -114,7 +114,7 @@ struct devfreq_governor {
97328 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
97329 int (*event_handler)(struct devfreq *devfreq,
97330 unsigned int event, void *data);
97331-};
97332+} __do_const;
97333
97334 /**
97335 * struct devfreq - Device devfreq structure
97336diff --git a/include/linux/device.h b/include/linux/device.h
97337index a2b4ea7..b07dddd 100644
97338--- a/include/linux/device.h
97339+++ b/include/linux/device.h
97340@@ -342,7 +342,7 @@ struct subsys_interface {
97341 struct list_head node;
97342 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
97343 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
97344-};
97345+} __do_const;
97346
97347 int subsys_interface_register(struct subsys_interface *sif);
97348 void subsys_interface_unregister(struct subsys_interface *sif);
97349@@ -538,7 +538,7 @@ struct device_type {
97350 void (*release)(struct device *dev);
97351
97352 const struct dev_pm_ops *pm;
97353-};
97354+} __do_const;
97355
97356 /* interface for exporting device attributes */
97357 struct device_attribute {
97358@@ -548,11 +548,12 @@ struct device_attribute {
97359 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
97360 const char *buf, size_t count);
97361 };
97362+typedef struct device_attribute __no_const device_attribute_no_const;
97363
97364 struct dev_ext_attribute {
97365 struct device_attribute attr;
97366 void *var;
97367-};
97368+} __do_const;
97369
97370 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
97371 char *buf);
97372diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
97373index ac07ff0..edff186 100644
97374--- a/include/linux/dma-mapping.h
97375+++ b/include/linux/dma-mapping.h
97376@@ -64,7 +64,7 @@ struct dma_map_ops {
97377 u64 (*get_required_mask)(struct device *dev);
97378 #endif
97379 int is_phys;
97380-};
97381+} __do_const;
97382
97383 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
97384
97385diff --git a/include/linux/efi.h b/include/linux/efi.h
97386index 85ef051..2714c3b 100644
97387--- a/include/linux/efi.h
97388+++ b/include/linux/efi.h
97389@@ -1073,6 +1073,7 @@ struct efivar_operations {
97390 efi_set_variable_nonblocking_t *set_variable_nonblocking;
97391 efi_query_variable_store_t *query_variable_store;
97392 };
97393+typedef struct efivar_operations __no_const efivar_operations_no_const;
97394
97395 struct efivars {
97396 /*
97397diff --git a/include/linux/elf.h b/include/linux/elf.h
97398index 20fa8d8..3d0dd18 100644
97399--- a/include/linux/elf.h
97400+++ b/include/linux/elf.h
97401@@ -29,6 +29,7 @@ extern Elf32_Dyn _DYNAMIC [];
97402 #define elf_note elf32_note
97403 #define elf_addr_t Elf32_Off
97404 #define Elf_Half Elf32_Half
97405+#define elf_dyn Elf32_Dyn
97406
97407 #else
97408
97409@@ -39,6 +40,7 @@ extern Elf64_Dyn _DYNAMIC [];
97410 #define elf_note elf64_note
97411 #define elf_addr_t Elf64_Off
97412 #define Elf_Half Elf64_Half
97413+#define elf_dyn Elf64_Dyn
97414
97415 #endif
97416
97417diff --git a/include/linux/err.h b/include/linux/err.h
97418index a729120..6ede2c9 100644
97419--- a/include/linux/err.h
97420+++ b/include/linux/err.h
97421@@ -20,12 +20,12 @@
97422
97423 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
97424
97425-static inline void * __must_check ERR_PTR(long error)
97426+static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
97427 {
97428 return (void *) error;
97429 }
97430
97431-static inline long __must_check PTR_ERR(__force const void *ptr)
97432+static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
97433 {
97434 return (long) ptr;
97435 }
97436diff --git a/include/linux/extcon.h b/include/linux/extcon.h
97437index b16d929..d389bf1 100644
97438--- a/include/linux/extcon.h
97439+++ b/include/linux/extcon.h
97440@@ -120,7 +120,7 @@ struct extcon_dev {
97441 /* /sys/class/extcon/.../mutually_exclusive/... */
97442 struct attribute_group attr_g_muex;
97443 struct attribute **attrs_muex;
97444- struct device_attribute *d_attrs_muex;
97445+ device_attribute_no_const *d_attrs_muex;
97446 };
97447
97448 /**
97449diff --git a/include/linux/fb.h b/include/linux/fb.h
97450index 043f328..180ccbf 100644
97451--- a/include/linux/fb.h
97452+++ b/include/linux/fb.h
97453@@ -305,7 +305,8 @@ struct fb_ops {
97454 /* called at KDB enter and leave time to prepare the console */
97455 int (*fb_debug_enter)(struct fb_info *info);
97456 int (*fb_debug_leave)(struct fb_info *info);
97457-};
97458+} __do_const;
97459+typedef struct fb_ops __no_const fb_ops_no_const;
97460
97461 #ifdef CONFIG_FB_TILEBLITTING
97462 #define FB_TILE_CURSOR_NONE 0
97463diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
97464index fbb8874..15c61e7 100644
97465--- a/include/linux/fdtable.h
97466+++ b/include/linux/fdtable.h
97467@@ -103,7 +103,7 @@ struct files_struct *get_files_struct(struct task_struct *);
97468 void put_files_struct(struct files_struct *fs);
97469 void reset_files_struct(struct files_struct *);
97470 int unshare_files(struct files_struct **);
97471-struct files_struct *dup_fd(struct files_struct *, int *);
97472+struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
97473 void do_close_on_exec(struct files_struct *);
97474 int iterate_fd(struct files_struct *, unsigned,
97475 int (*)(const void *, struct file *, unsigned),
97476diff --git a/include/linux/fs.h b/include/linux/fs.h
97477index 84b783f..b31767d 100644
97478--- a/include/linux/fs.h
97479+++ b/include/linux/fs.h
97480@@ -439,7 +439,7 @@ struct address_space {
97481 spinlock_t private_lock; /* for use by the address_space */
97482 struct list_head private_list; /* ditto */
97483 void *private_data; /* ditto */
97484-} __attribute__((aligned(sizeof(long))));
97485+} __attribute__((aligned(sizeof(long)))) __randomize_layout;
97486 /*
97487 * On most architectures that alignment is already the case; but
97488 * must be enforced here for CRIS, to let the least significant bit
97489@@ -482,7 +482,7 @@ struct block_device {
97490 int bd_fsfreeze_count;
97491 /* Mutex for freeze */
97492 struct mutex bd_fsfreeze_mutex;
97493-};
97494+} __randomize_layout;
97495
97496 /*
97497 * Radix-tree tags, for tagging dirty and writeback pages within the pagecache
97498@@ -677,7 +677,7 @@ struct inode {
97499 #endif
97500
97501 void *i_private; /* fs or device private pointer */
97502-};
97503+} __randomize_layout;
97504
97505 static inline int inode_unhashed(struct inode *inode)
97506 {
97507@@ -872,7 +872,7 @@ struct file {
97508 struct list_head f_tfile_llink;
97509 #endif /* #ifdef CONFIG_EPOLL */
97510 struct address_space *f_mapping;
97511-} __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */
97512+} __attribute__((aligned(4))) __randomize_layout; /* lest something weird decides that 2 is OK */
97513
97514 struct file_handle {
97515 __u32 handle_bytes;
97516@@ -1001,7 +1001,7 @@ struct file_lock {
97517 int state; /* state of grant or error if -ve */
97518 } afs;
97519 } fl_u;
97520-};
97521+} __randomize_layout;
97522
97523 struct file_lock_context {
97524 spinlock_t flc_lock;
97525@@ -1380,7 +1380,7 @@ struct super_block {
97526 * Indicates how deep in a filesystem stack this SB is
97527 */
97528 int s_stack_depth;
97529-};
97530+} __randomize_layout;
97531
97532 extern struct timespec current_fs_time(struct super_block *sb);
97533
97534@@ -1632,7 +1632,8 @@ struct file_operations {
97535 #ifndef CONFIG_MMU
97536 unsigned (*mmap_capabilities)(struct file *);
97537 #endif
97538-};
97539+} __do_const __randomize_layout;
97540+typedef struct file_operations __no_const file_operations_no_const;
97541
97542 struct inode_operations {
97543 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
97544@@ -2341,7 +2342,7 @@ extern int register_chrdev_region(dev_t, unsigned, const char *);
97545 extern int __register_chrdev(unsigned int major, unsigned int baseminor,
97546 unsigned int count, const char *name,
97547 const struct file_operations *fops);
97548-extern void __unregister_chrdev(unsigned int major, unsigned int baseminor,
97549+extern __nocapture(4) void __unregister_chrdev(unsigned int major, unsigned int baseminor,
97550 unsigned int count, const char *name);
97551 extern void unregister_chrdev_region(dev_t, unsigned);
97552 extern void chrdev_show(struct seq_file *,off_t);
97553@@ -3041,4 +3042,14 @@ static inline bool dir_relax(struct inode *inode)
97554 return !IS_DEADDIR(inode);
97555 }
97556
97557+static inline bool is_sidechannel_device(const struct inode *inode)
97558+{
97559+#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
97560+ umode_t mode = inode->i_mode;
97561+ return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
97562+#else
97563+ return false;
97564+#endif
97565+}
97566+
97567 #endif /* _LINUX_FS_H */
97568diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
97569index 0efc3e6..fd23610 100644
97570--- a/include/linux/fs_struct.h
97571+++ b/include/linux/fs_struct.h
97572@@ -6,13 +6,13 @@
97573 #include <linux/seqlock.h>
97574
97575 struct fs_struct {
97576- int users;
97577+ atomic_t users;
97578 spinlock_t lock;
97579 seqcount_t seq;
97580 int umask;
97581 int in_exec;
97582 struct path root, pwd;
97583-};
97584+} __randomize_layout;
97585
97586 extern struct kmem_cache *fs_cachep;
97587
97588diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
97589index 604e152..5954d0d 100644
97590--- a/include/linux/fscache-cache.h
97591+++ b/include/linux/fscache-cache.h
97592@@ -117,7 +117,7 @@ struct fscache_operation {
97593 fscache_operation_release_t release;
97594 };
97595
97596-extern atomic_t fscache_op_debug_id;
97597+extern atomic_unchecked_t fscache_op_debug_id;
97598 extern void fscache_op_work_func(struct work_struct *work);
97599
97600 extern void fscache_enqueue_operation(struct fscache_operation *);
97601diff --git a/include/linux/fscache.h b/include/linux/fscache.h
97602index 115bb81..e7b812b 100644
97603--- a/include/linux/fscache.h
97604+++ b/include/linux/fscache.h
97605@@ -152,7 +152,7 @@ struct fscache_cookie_def {
97606 * - this is mandatory for any object that may have data
97607 */
97608 void (*now_uncached)(void *cookie_netfs_data);
97609-};
97610+} __do_const;
97611
97612 /*
97613 * fscache cached network filesystem type
97614diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
97615index 7ee1774..72505b8 100644
97616--- a/include/linux/fsnotify.h
97617+++ b/include/linux/fsnotify.h
97618@@ -197,6 +197,9 @@ static inline void fsnotify_access(struct file *file)
97619 struct inode *inode = file_inode(file);
97620 __u32 mask = FS_ACCESS;
97621
97622+ if (is_sidechannel_device(inode))
97623+ return;
97624+
97625 if (S_ISDIR(inode->i_mode))
97626 mask |= FS_ISDIR;
97627
97628@@ -215,6 +218,9 @@ static inline void fsnotify_modify(struct file *file)
97629 struct inode *inode = file_inode(file);
97630 __u32 mask = FS_MODIFY;
97631
97632+ if (is_sidechannel_device(inode))
97633+ return;
97634+
97635 if (S_ISDIR(inode->i_mode))
97636 mask |= FS_ISDIR;
97637
97638@@ -317,7 +323,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
97639 */
97640 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
97641 {
97642- return kstrdup(name, GFP_KERNEL);
97643+ return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
97644 }
97645
97646 /*
97647diff --git a/include/linux/genhd.h b/include/linux/genhd.h
97648index ec274e0..e678159 100644
97649--- a/include/linux/genhd.h
97650+++ b/include/linux/genhd.h
97651@@ -194,7 +194,7 @@ struct gendisk {
97652 struct kobject *slave_dir;
97653
97654 struct timer_rand_state *random;
97655- atomic_t sync_io; /* RAID */
97656+ atomic_unchecked_t sync_io; /* RAID */
97657 struct disk_events *ev;
97658 #ifdef CONFIG_BLK_DEV_INTEGRITY
97659 struct blk_integrity *integrity;
97660@@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
97661 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
97662
97663 /* drivers/char/random.c */
97664-extern void add_disk_randomness(struct gendisk *disk);
97665+extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
97666 extern void rand_initialize_disk(struct gendisk *disk);
97667
97668 static inline sector_t get_start_sect(struct block_device *bdev)
97669diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
97670index 667c311..abac2a7 100644
97671--- a/include/linux/genl_magic_func.h
97672+++ b/include/linux/genl_magic_func.h
97673@@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
97674 },
97675
97676 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
97677-static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
97678+static struct genl_ops ZZZ_genl_ops[] = {
97679 #include GENL_MAGIC_INCLUDE_FILE
97680 };
97681
97682diff --git a/include/linux/gfp.h b/include/linux/gfp.h
97683index ad35f30..30b1916 100644
97684--- a/include/linux/gfp.h
97685+++ b/include/linux/gfp.h
97686@@ -35,6 +35,13 @@ struct vm_area_struct;
97687 #define ___GFP_NO_KSWAPD 0x400000u
97688 #define ___GFP_OTHER_NODE 0x800000u
97689 #define ___GFP_WRITE 0x1000000u
97690+
97691+#ifdef CONFIG_PAX_USERCOPY_SLABS
97692+#define ___GFP_USERCOPY 0x2000000u
97693+#else
97694+#define ___GFP_USERCOPY 0
97695+#endif
97696+
97697 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
97698
97699 /*
97700@@ -94,6 +101,7 @@ struct vm_area_struct;
97701 #define __GFP_NO_KSWAPD ((__force gfp_t)___GFP_NO_KSWAPD)
97702 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
97703 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
97704+#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
97705
97706 /*
97707 * This may seem redundant, but it's a way of annotating false positives vs.
97708@@ -101,7 +109,7 @@ struct vm_area_struct;
97709 */
97710 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
97711
97712-#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
97713+#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
97714 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
97715
97716 /* This equals 0, but use constants in case they ever change */
97717@@ -146,6 +154,8 @@ struct vm_area_struct;
97718 /* 4GB DMA on some platforms */
97719 #define GFP_DMA32 __GFP_DMA32
97720
97721+#define GFP_USERCOPY __GFP_USERCOPY
97722+
97723 /* Convert GFP flags to their corresponding migrate type */
97724 static inline int gfpflags_to_migratetype(const gfp_t gfp_flags)
97725 {
97726diff --git a/include/linux/gracl.h b/include/linux/gracl.h
97727new file mode 100644
97728index 0000000..91858e4
97729--- /dev/null
97730+++ b/include/linux/gracl.h
97731@@ -0,0 +1,342 @@
97732+#ifndef GR_ACL_H
97733+#define GR_ACL_H
97734+
97735+#include <linux/grdefs.h>
97736+#include <linux/resource.h>
97737+#include <linux/capability.h>
97738+#include <linux/dcache.h>
97739+#include <asm/resource.h>
97740+
97741+/* Major status information */
97742+
97743+#define GR_VERSION "grsecurity 3.1"
97744+#define GRSECURITY_VERSION 0x3100
97745+
97746+enum {
97747+ GR_SHUTDOWN = 0,
97748+ GR_ENABLE = 1,
97749+ GR_SPROLE = 2,
97750+ GR_OLDRELOAD = 3,
97751+ GR_SEGVMOD = 4,
97752+ GR_STATUS = 5,
97753+ GR_UNSPROLE = 6,
97754+ GR_PASSSET = 7,
97755+ GR_SPROLEPAM = 8,
97756+ GR_RELOAD = 9,
97757+};
97758+
97759+/* Password setup definitions
97760+ * kernel/grhash.c */
97761+enum {
97762+ GR_PW_LEN = 128,
97763+ GR_SALT_LEN = 16,
97764+ GR_SHA_LEN = 32,
97765+};
97766+
97767+enum {
97768+ GR_SPROLE_LEN = 64,
97769+};
97770+
97771+enum {
97772+ GR_NO_GLOB = 0,
97773+ GR_REG_GLOB,
97774+ GR_CREATE_GLOB
97775+};
97776+
97777+#define GR_NLIMITS 32
97778+
97779+/* Begin Data Structures */
97780+
97781+struct sprole_pw {
97782+ unsigned char *rolename;
97783+ unsigned char salt[GR_SALT_LEN];
97784+ unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
97785+};
97786+
97787+struct name_entry {
97788+ __u32 key;
97789+ u64 inode;
97790+ dev_t device;
97791+ char *name;
97792+ __u16 len;
97793+ __u8 deleted;
97794+ struct name_entry *prev;
97795+ struct name_entry *next;
97796+};
97797+
97798+struct inodev_entry {
97799+ struct name_entry *nentry;
97800+ struct inodev_entry *prev;
97801+ struct inodev_entry *next;
97802+};
97803+
97804+struct acl_role_db {
97805+ struct acl_role_label **r_hash;
97806+ __u32 r_size;
97807+};
97808+
97809+struct inodev_db {
97810+ struct inodev_entry **i_hash;
97811+ __u32 i_size;
97812+};
97813+
97814+struct name_db {
97815+ struct name_entry **n_hash;
97816+ __u32 n_size;
97817+};
97818+
97819+struct crash_uid {
97820+ uid_t uid;
97821+ unsigned long expires;
97822+};
97823+
97824+struct gr_hash_struct {
97825+ void **table;
97826+ void **nametable;
97827+ void *first;
97828+ __u32 table_size;
97829+ __u32 used_size;
97830+ int type;
97831+};
97832+
97833+/* Userspace Grsecurity ACL data structures */
97834+
97835+struct acl_subject_label {
97836+ char *filename;
97837+ u64 inode;
97838+ dev_t device;
97839+ __u32 mode;
97840+ kernel_cap_t cap_mask;
97841+ kernel_cap_t cap_lower;
97842+ kernel_cap_t cap_invert_audit;
97843+
97844+ struct rlimit res[GR_NLIMITS];
97845+ __u32 resmask;
97846+
97847+ __u8 user_trans_type;
97848+ __u8 group_trans_type;
97849+ uid_t *user_transitions;
97850+ gid_t *group_transitions;
97851+ __u16 user_trans_num;
97852+ __u16 group_trans_num;
97853+
97854+ __u32 sock_families[2];
97855+ __u32 ip_proto[8];
97856+ __u32 ip_type;
97857+ struct acl_ip_label **ips;
97858+ __u32 ip_num;
97859+ __u32 inaddr_any_override;
97860+
97861+ __u32 crashes;
97862+ unsigned long expires;
97863+
97864+ struct acl_subject_label *parent_subject;
97865+ struct gr_hash_struct *hash;
97866+ struct acl_subject_label *prev;
97867+ struct acl_subject_label *next;
97868+
97869+ struct acl_object_label **obj_hash;
97870+ __u32 obj_hash_size;
97871+ __u16 pax_flags;
97872+};
97873+
97874+struct role_allowed_ip {
97875+ __u32 addr;
97876+ __u32 netmask;
97877+
97878+ struct role_allowed_ip *prev;
97879+ struct role_allowed_ip *next;
97880+};
97881+
97882+struct role_transition {
97883+ char *rolename;
97884+
97885+ struct role_transition *prev;
97886+ struct role_transition *next;
97887+};
97888+
97889+struct acl_role_label {
97890+ char *rolename;
97891+ uid_t uidgid;
97892+ __u16 roletype;
97893+
97894+ __u16 auth_attempts;
97895+ unsigned long expires;
97896+
97897+ struct acl_subject_label *root_label;
97898+ struct gr_hash_struct *hash;
97899+
97900+ struct acl_role_label *prev;
97901+ struct acl_role_label *next;
97902+
97903+ struct role_transition *transitions;
97904+ struct role_allowed_ip *allowed_ips;
97905+ uid_t *domain_children;
97906+ __u16 domain_child_num;
97907+
97908+ umode_t umask;
97909+
97910+ struct acl_subject_label **subj_hash;
97911+ __u32 subj_hash_size;
97912+};
97913+
97914+struct user_acl_role_db {
97915+ struct acl_role_label **r_table;
97916+ __u32 num_pointers; /* Number of allocations to track */
97917+ __u32 num_roles; /* Number of roles */
97918+ __u32 num_domain_children; /* Number of domain children */
97919+ __u32 num_subjects; /* Number of subjects */
97920+ __u32 num_objects; /* Number of objects */
97921+};
97922+
97923+struct acl_object_label {
97924+ char *filename;
97925+ u64 inode;
97926+ dev_t device;
97927+ __u32 mode;
97928+
97929+ struct acl_subject_label *nested;
97930+ struct acl_object_label *globbed;
97931+
97932+ /* next two structures not used */
97933+
97934+ struct acl_object_label *prev;
97935+ struct acl_object_label *next;
97936+};
97937+
97938+struct acl_ip_label {
97939+ char *iface;
97940+ __u32 addr;
97941+ __u32 netmask;
97942+ __u16 low, high;
97943+ __u8 mode;
97944+ __u32 type;
97945+ __u32 proto[8];
97946+
97947+ /* next two structures not used */
97948+
97949+ struct acl_ip_label *prev;
97950+ struct acl_ip_label *next;
97951+};
97952+
97953+struct gr_arg {
97954+ struct user_acl_role_db role_db;
97955+ unsigned char pw[GR_PW_LEN];
97956+ unsigned char salt[GR_SALT_LEN];
97957+ unsigned char sum[GR_SHA_LEN];
97958+ unsigned char sp_role[GR_SPROLE_LEN];
97959+ struct sprole_pw *sprole_pws;
97960+ dev_t segv_device;
97961+ u64 segv_inode;
97962+ uid_t segv_uid;
97963+ __u16 num_sprole_pws;
97964+ __u16 mode;
97965+};
97966+
97967+struct gr_arg_wrapper {
97968+ struct gr_arg *arg;
97969+ __u32 version;
97970+ __u32 size;
97971+};
97972+
97973+struct subject_map {
97974+ struct acl_subject_label *user;
97975+ struct acl_subject_label *kernel;
97976+ struct subject_map *prev;
97977+ struct subject_map *next;
97978+};
97979+
97980+struct acl_subj_map_db {
97981+ struct subject_map **s_hash;
97982+ __u32 s_size;
97983+};
97984+
97985+struct gr_policy_state {
97986+ struct sprole_pw **acl_special_roles;
97987+ __u16 num_sprole_pws;
97988+ struct acl_role_label *kernel_role;
97989+ struct acl_role_label *role_list;
97990+ struct acl_role_label *default_role;
97991+ struct acl_role_db acl_role_set;
97992+ struct acl_subj_map_db subj_map_set;
97993+ struct name_db name_set;
97994+ struct inodev_db inodev_set;
97995+};
97996+
97997+struct gr_alloc_state {
97998+ unsigned long alloc_stack_next;
97999+ unsigned long alloc_stack_size;
98000+ void **alloc_stack;
98001+};
98002+
98003+struct gr_reload_state {
98004+ struct gr_policy_state oldpolicy;
98005+ struct gr_alloc_state oldalloc;
98006+ struct gr_policy_state newpolicy;
98007+ struct gr_alloc_state newalloc;
98008+ struct gr_policy_state *oldpolicy_ptr;
98009+ struct gr_alloc_state *oldalloc_ptr;
98010+ unsigned char oldmode;
98011+};
98012+
98013+/* End Data Structures Section */
98014+
98015+/* Hash functions generated by empirical testing by Brad Spengler
98016+ Makes good use of the low bits of the inode. Generally 0-1 times
98017+ in loop for successful match. 0-3 for unsuccessful match.
98018+ Shift/add algorithm with modulus of table size and an XOR*/
98019+
98020+static __inline__ unsigned int
98021+gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
98022+{
98023+ return ((((uid + type) << (16 + type)) ^ uid) % sz);
98024+}
98025+
98026+ static __inline__ unsigned int
98027+gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
98028+{
98029+ return ((const unsigned long)userp % sz);
98030+}
98031+
98032+static __inline__ unsigned int
98033+gr_fhash(const u64 ino, const dev_t dev, const unsigned int sz)
98034+{
98035+ unsigned int rem;
98036+ div_u64_rem((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9)), sz, &rem);
98037+ return rem;
98038+}
98039+
98040+static __inline__ unsigned int
98041+gr_nhash(const char *name, const __u16 len, const unsigned int sz)
98042+{
98043+ return full_name_hash((const unsigned char *)name, len) % sz;
98044+}
98045+
98046+#define FOR_EACH_SUBJECT_START(role,subj,iter) \
98047+ subj = NULL; \
98048+ iter = 0; \
98049+ while (iter < role->subj_hash_size) { \
98050+ if (subj == NULL) \
98051+ subj = role->subj_hash[iter]; \
98052+ if (subj == NULL) { \
98053+ iter++; \
98054+ continue; \
98055+ }
98056+
98057+#define FOR_EACH_SUBJECT_END(subj,iter) \
98058+ subj = subj->next; \
98059+ if (subj == NULL) \
98060+ iter++; \
98061+ }
98062+
98063+
98064+#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
98065+ subj = role->hash->first; \
98066+ while (subj != NULL) {
98067+
98068+#define FOR_EACH_NESTED_SUBJECT_END(subj) \
98069+ subj = subj->next; \
98070+ }
98071+
98072+#endif
98073+
98074diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
98075new file mode 100644
98076index 0000000..af64092
98077--- /dev/null
98078+++ b/include/linux/gracl_compat.h
98079@@ -0,0 +1,156 @@
98080+#ifndef GR_ACL_COMPAT_H
98081+#define GR_ACL_COMPAT_H
98082+
98083+#include <linux/resource.h>
98084+#include <asm/resource.h>
98085+
98086+struct sprole_pw_compat {
98087+ compat_uptr_t rolename;
98088+ unsigned char salt[GR_SALT_LEN];
98089+ unsigned char sum[GR_SHA_LEN];
98090+};
98091+
98092+struct gr_hash_struct_compat {
98093+ compat_uptr_t table;
98094+ compat_uptr_t nametable;
98095+ compat_uptr_t first;
98096+ __u32 table_size;
98097+ __u32 used_size;
98098+ int type;
98099+};
98100+
98101+struct acl_subject_label_compat {
98102+ compat_uptr_t filename;
98103+ compat_u64 inode;
98104+ __u32 device;
98105+ __u32 mode;
98106+ kernel_cap_t cap_mask;
98107+ kernel_cap_t cap_lower;
98108+ kernel_cap_t cap_invert_audit;
98109+
98110+ struct compat_rlimit res[GR_NLIMITS];
98111+ __u32 resmask;
98112+
98113+ __u8 user_trans_type;
98114+ __u8 group_trans_type;
98115+ compat_uptr_t user_transitions;
98116+ compat_uptr_t group_transitions;
98117+ __u16 user_trans_num;
98118+ __u16 group_trans_num;
98119+
98120+ __u32 sock_families[2];
98121+ __u32 ip_proto[8];
98122+ __u32 ip_type;
98123+ compat_uptr_t ips;
98124+ __u32 ip_num;
98125+ __u32 inaddr_any_override;
98126+
98127+ __u32 crashes;
98128+ compat_ulong_t expires;
98129+
98130+ compat_uptr_t parent_subject;
98131+ compat_uptr_t hash;
98132+ compat_uptr_t prev;
98133+ compat_uptr_t next;
98134+
98135+ compat_uptr_t obj_hash;
98136+ __u32 obj_hash_size;
98137+ __u16 pax_flags;
98138+};
98139+
98140+struct role_allowed_ip_compat {
98141+ __u32 addr;
98142+ __u32 netmask;
98143+
98144+ compat_uptr_t prev;
98145+ compat_uptr_t next;
98146+};
98147+
98148+struct role_transition_compat {
98149+ compat_uptr_t rolename;
98150+
98151+ compat_uptr_t prev;
98152+ compat_uptr_t next;
98153+};
98154+
98155+struct acl_role_label_compat {
98156+ compat_uptr_t rolename;
98157+ uid_t uidgid;
98158+ __u16 roletype;
98159+
98160+ __u16 auth_attempts;
98161+ compat_ulong_t expires;
98162+
98163+ compat_uptr_t root_label;
98164+ compat_uptr_t hash;
98165+
98166+ compat_uptr_t prev;
98167+ compat_uptr_t next;
98168+
98169+ compat_uptr_t transitions;
98170+ compat_uptr_t allowed_ips;
98171+ compat_uptr_t domain_children;
98172+ __u16 domain_child_num;
98173+
98174+ umode_t umask;
98175+
98176+ compat_uptr_t subj_hash;
98177+ __u32 subj_hash_size;
98178+};
98179+
98180+struct user_acl_role_db_compat {
98181+ compat_uptr_t r_table;
98182+ __u32 num_pointers;
98183+ __u32 num_roles;
98184+ __u32 num_domain_children;
98185+ __u32 num_subjects;
98186+ __u32 num_objects;
98187+};
98188+
98189+struct acl_object_label_compat {
98190+ compat_uptr_t filename;
98191+ compat_u64 inode;
98192+ __u32 device;
98193+ __u32 mode;
98194+
98195+ compat_uptr_t nested;
98196+ compat_uptr_t globbed;
98197+
98198+ compat_uptr_t prev;
98199+ compat_uptr_t next;
98200+};
98201+
98202+struct acl_ip_label_compat {
98203+ compat_uptr_t iface;
98204+ __u32 addr;
98205+ __u32 netmask;
98206+ __u16 low, high;
98207+ __u8 mode;
98208+ __u32 type;
98209+ __u32 proto[8];
98210+
98211+ compat_uptr_t prev;
98212+ compat_uptr_t next;
98213+};
98214+
98215+struct gr_arg_compat {
98216+ struct user_acl_role_db_compat role_db;
98217+ unsigned char pw[GR_PW_LEN];
98218+ unsigned char salt[GR_SALT_LEN];
98219+ unsigned char sum[GR_SHA_LEN];
98220+ unsigned char sp_role[GR_SPROLE_LEN];
98221+ compat_uptr_t sprole_pws;
98222+ __u32 segv_device;
98223+ compat_u64 segv_inode;
98224+ uid_t segv_uid;
98225+ __u16 num_sprole_pws;
98226+ __u16 mode;
98227+};
98228+
98229+struct gr_arg_wrapper_compat {
98230+ compat_uptr_t arg;
98231+ __u32 version;
98232+ __u32 size;
98233+};
98234+
98235+#endif
98236diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
98237new file mode 100644
98238index 0000000..323ecf2
98239--- /dev/null
98240+++ b/include/linux/gralloc.h
98241@@ -0,0 +1,9 @@
98242+#ifndef __GRALLOC_H
98243+#define __GRALLOC_H
98244+
98245+void acl_free_all(void);
98246+int acl_alloc_stack_init(unsigned long size);
98247+void *acl_alloc(unsigned long len);
98248+void *acl_alloc_num(unsigned long num, unsigned long len);
98249+
98250+#endif
98251diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
98252new file mode 100644
98253index 0000000..be66033
98254--- /dev/null
98255+++ b/include/linux/grdefs.h
98256@@ -0,0 +1,140 @@
98257+#ifndef GRDEFS_H
98258+#define GRDEFS_H
98259+
98260+/* Begin grsecurity status declarations */
98261+
98262+enum {
98263+ GR_READY = 0x01,
98264+ GR_STATUS_INIT = 0x00 // disabled state
98265+};
98266+
98267+/* Begin ACL declarations */
98268+
98269+/* Role flags */
98270+
98271+enum {
98272+ GR_ROLE_USER = 0x0001,
98273+ GR_ROLE_GROUP = 0x0002,
98274+ GR_ROLE_DEFAULT = 0x0004,
98275+ GR_ROLE_SPECIAL = 0x0008,
98276+ GR_ROLE_AUTH = 0x0010,
98277+ GR_ROLE_NOPW = 0x0020,
98278+ GR_ROLE_GOD = 0x0040,
98279+ GR_ROLE_LEARN = 0x0080,
98280+ GR_ROLE_TPE = 0x0100,
98281+ GR_ROLE_DOMAIN = 0x0200,
98282+ GR_ROLE_PAM = 0x0400,
98283+ GR_ROLE_PERSIST = 0x0800
98284+};
98285+
98286+/* ACL Subject and Object mode flags */
98287+enum {
98288+ GR_DELETED = 0x80000000
98289+};
98290+
98291+/* ACL Object-only mode flags */
98292+enum {
98293+ GR_READ = 0x00000001,
98294+ GR_APPEND = 0x00000002,
98295+ GR_WRITE = 0x00000004,
98296+ GR_EXEC = 0x00000008,
98297+ GR_FIND = 0x00000010,
98298+ GR_INHERIT = 0x00000020,
98299+ GR_SETID = 0x00000040,
98300+ GR_CREATE = 0x00000080,
98301+ GR_DELETE = 0x00000100,
98302+ GR_LINK = 0x00000200,
98303+ GR_AUDIT_READ = 0x00000400,
98304+ GR_AUDIT_APPEND = 0x00000800,
98305+ GR_AUDIT_WRITE = 0x00001000,
98306+ GR_AUDIT_EXEC = 0x00002000,
98307+ GR_AUDIT_FIND = 0x00004000,
98308+ GR_AUDIT_INHERIT= 0x00008000,
98309+ GR_AUDIT_SETID = 0x00010000,
98310+ GR_AUDIT_CREATE = 0x00020000,
98311+ GR_AUDIT_DELETE = 0x00040000,
98312+ GR_AUDIT_LINK = 0x00080000,
98313+ GR_PTRACERD = 0x00100000,
98314+ GR_NOPTRACE = 0x00200000,
98315+ GR_SUPPRESS = 0x00400000,
98316+ GR_NOLEARN = 0x00800000,
98317+ GR_INIT_TRANSFER= 0x01000000
98318+};
98319+
98320+#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
98321+ GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
98322+ GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
98323+
98324+/* ACL subject-only mode flags */
98325+enum {
98326+ GR_KILL = 0x00000001,
98327+ GR_VIEW = 0x00000002,
98328+ GR_PROTECTED = 0x00000004,
98329+ GR_LEARN = 0x00000008,
98330+ GR_OVERRIDE = 0x00000010,
98331+ /* just a placeholder, this mode is only used in userspace */
98332+ GR_DUMMY = 0x00000020,
98333+ GR_PROTSHM = 0x00000040,
98334+ GR_KILLPROC = 0x00000080,
98335+ GR_KILLIPPROC = 0x00000100,
98336+ /* just a placeholder, this mode is only used in userspace */
98337+ GR_NOTROJAN = 0x00000200,
98338+ GR_PROTPROCFD = 0x00000400,
98339+ GR_PROCACCT = 0x00000800,
98340+ GR_RELAXPTRACE = 0x00001000,
98341+ //GR_NESTED = 0x00002000,
98342+ GR_INHERITLEARN = 0x00004000,
98343+ GR_PROCFIND = 0x00008000,
98344+ GR_POVERRIDE = 0x00010000,
98345+ GR_KERNELAUTH = 0x00020000,
98346+ GR_ATSECURE = 0x00040000,
98347+ GR_SHMEXEC = 0x00080000
98348+};
98349+
98350+enum {
98351+ GR_PAX_ENABLE_SEGMEXEC = 0x0001,
98352+ GR_PAX_ENABLE_PAGEEXEC = 0x0002,
98353+ GR_PAX_ENABLE_MPROTECT = 0x0004,
98354+ GR_PAX_ENABLE_RANDMMAP = 0x0008,
98355+ GR_PAX_ENABLE_EMUTRAMP = 0x0010,
98356+ GR_PAX_DISABLE_SEGMEXEC = 0x0100,
98357+ GR_PAX_DISABLE_PAGEEXEC = 0x0200,
98358+ GR_PAX_DISABLE_MPROTECT = 0x0400,
98359+ GR_PAX_DISABLE_RANDMMAP = 0x0800,
98360+ GR_PAX_DISABLE_EMUTRAMP = 0x1000,
98361+};
98362+
98363+enum {
98364+ GR_ID_USER = 0x01,
98365+ GR_ID_GROUP = 0x02,
98366+};
98367+
98368+enum {
98369+ GR_ID_ALLOW = 0x01,
98370+ GR_ID_DENY = 0x02,
98371+};
98372+
98373+#define GR_CRASH_RES 31
98374+#define GR_UIDTABLE_MAX 500
98375+
98376+/* begin resource learning section */
98377+enum {
98378+ GR_RLIM_CPU_BUMP = 60,
98379+ GR_RLIM_FSIZE_BUMP = 50000,
98380+ GR_RLIM_DATA_BUMP = 10000,
98381+ GR_RLIM_STACK_BUMP = 1000,
98382+ GR_RLIM_CORE_BUMP = 10000,
98383+ GR_RLIM_RSS_BUMP = 500000,
98384+ GR_RLIM_NPROC_BUMP = 1,
98385+ GR_RLIM_NOFILE_BUMP = 5,
98386+ GR_RLIM_MEMLOCK_BUMP = 50000,
98387+ GR_RLIM_AS_BUMP = 500000,
98388+ GR_RLIM_LOCKS_BUMP = 2,
98389+ GR_RLIM_SIGPENDING_BUMP = 5,
98390+ GR_RLIM_MSGQUEUE_BUMP = 10000,
98391+ GR_RLIM_NICE_BUMP = 1,
98392+ GR_RLIM_RTPRIO_BUMP = 1,
98393+ GR_RLIM_RTTIME_BUMP = 1000000
98394+};
98395+
98396+#endif
98397diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
98398new file mode 100644
98399index 0000000..6245f9e
98400--- /dev/null
98401+++ b/include/linux/grinternal.h
98402@@ -0,0 +1,230 @@
98403+#ifndef __GRINTERNAL_H
98404+#define __GRINTERNAL_H
98405+
98406+#ifdef CONFIG_GRKERNSEC
98407+
98408+#include <linux/fs.h>
98409+#include <linux/mnt_namespace.h>
98410+#include <linux/nsproxy.h>
98411+#include <linux/gracl.h>
98412+#include <linux/grdefs.h>
98413+#include <linux/grmsg.h>
98414+
98415+void gr_add_learn_entry(const char *fmt, ...)
98416+ __attribute__ ((format (printf, 1, 2)));
98417+__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
98418+ const struct vfsmount *mnt);
98419+__u32 gr_check_create(const struct dentry *new_dentry,
98420+ const struct dentry *parent,
98421+ const struct vfsmount *mnt, const __u32 mode);
98422+int gr_check_protected_task(const struct task_struct *task);
98423+__u32 to_gr_audit(const __u32 reqmode);
98424+int gr_set_acls(const int type);
98425+int gr_acl_is_enabled(void);
98426+char gr_roletype_to_char(void);
98427+
98428+void gr_handle_alertkill(struct task_struct *task);
98429+char *gr_to_filename(const struct dentry *dentry,
98430+ const struct vfsmount *mnt);
98431+char *gr_to_filename1(const struct dentry *dentry,
98432+ const struct vfsmount *mnt);
98433+char *gr_to_filename2(const struct dentry *dentry,
98434+ const struct vfsmount *mnt);
98435+char *gr_to_filename3(const struct dentry *dentry,
98436+ const struct vfsmount *mnt);
98437+
98438+extern int grsec_enable_ptrace_readexec;
98439+extern int grsec_enable_harden_ptrace;
98440+extern int grsec_enable_link;
98441+extern int grsec_enable_fifo;
98442+extern int grsec_enable_execve;
98443+extern int grsec_enable_shm;
98444+extern int grsec_enable_execlog;
98445+extern int grsec_enable_signal;
98446+extern int grsec_enable_audit_ptrace;
98447+extern int grsec_enable_forkfail;
98448+extern int grsec_enable_time;
98449+extern int grsec_enable_rofs;
98450+extern int grsec_deny_new_usb;
98451+extern int grsec_enable_chroot_shmat;
98452+extern int grsec_enable_chroot_mount;
98453+extern int grsec_enable_chroot_double;
98454+extern int grsec_enable_chroot_pivot;
98455+extern int grsec_enable_chroot_chdir;
98456+extern int grsec_enable_chroot_chmod;
98457+extern int grsec_enable_chroot_mknod;
98458+extern int grsec_enable_chroot_fchdir;
98459+extern int grsec_enable_chroot_nice;
98460+extern int grsec_enable_chroot_execlog;
98461+extern int grsec_enable_chroot_caps;
98462+extern int grsec_enable_chroot_rename;
98463+extern int grsec_enable_chroot_sysctl;
98464+extern int grsec_enable_chroot_unix;
98465+extern int grsec_enable_symlinkown;
98466+extern kgid_t grsec_symlinkown_gid;
98467+extern int grsec_enable_tpe;
98468+extern kgid_t grsec_tpe_gid;
98469+extern int grsec_enable_tpe_all;
98470+extern int grsec_enable_tpe_invert;
98471+extern int grsec_enable_socket_all;
98472+extern kgid_t grsec_socket_all_gid;
98473+extern int grsec_enable_socket_client;
98474+extern kgid_t grsec_socket_client_gid;
98475+extern int grsec_enable_socket_server;
98476+extern kgid_t grsec_socket_server_gid;
98477+extern kgid_t grsec_audit_gid;
98478+extern int grsec_enable_group;
98479+extern int grsec_enable_log_rwxmaps;
98480+extern int grsec_enable_mount;
98481+extern int grsec_enable_chdir;
98482+extern int grsec_resource_logging;
98483+extern int grsec_enable_blackhole;
98484+extern int grsec_lastack_retries;
98485+extern int grsec_enable_brute;
98486+extern int grsec_enable_harden_ipc;
98487+extern int grsec_lock;
98488+
98489+extern spinlock_t grsec_alert_lock;
98490+extern unsigned long grsec_alert_wtime;
98491+extern unsigned long grsec_alert_fyet;
98492+
98493+extern spinlock_t grsec_audit_lock;
98494+
98495+extern rwlock_t grsec_exec_file_lock;
98496+
98497+#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
98498+ gr_to_filename2((tsk)->exec_file->f_path.dentry, \
98499+ (tsk)->exec_file->f_path.mnt) : "/")
98500+
98501+#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
98502+ gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
98503+ (tsk)->real_parent->exec_file->f_path.mnt) : "/")
98504+
98505+#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
98506+ gr_to_filename((tsk)->exec_file->f_path.dentry, \
98507+ (tsk)->exec_file->f_path.mnt) : "/")
98508+
98509+#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
98510+ gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
98511+ (tsk)->real_parent->exec_file->f_path.mnt) : "/")
98512+
98513+#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
98514+
98515+#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
98516+
98517+static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
98518+{
98519+ if (file1 && file2) {
98520+ const struct inode *inode1 = file1->f_path.dentry->d_inode;
98521+ const struct inode *inode2 = file2->f_path.dentry->d_inode;
98522+ if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
98523+ return true;
98524+ }
98525+
98526+ return false;
98527+}
98528+
98529+#define GR_CHROOT_CAPS {{ \
98530+ CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
98531+ CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
98532+ CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
98533+ CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
98534+ CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
98535+ CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
98536+ CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
98537+
98538+#define security_learn(normal_msg,args...) \
98539+({ \
98540+ read_lock(&grsec_exec_file_lock); \
98541+ gr_add_learn_entry(normal_msg "\n", ## args); \
98542+ read_unlock(&grsec_exec_file_lock); \
98543+})
98544+
98545+enum {
98546+ GR_DO_AUDIT,
98547+ GR_DONT_AUDIT,
98548+ /* used for non-audit messages that we shouldn't kill the task on */
98549+ GR_DONT_AUDIT_GOOD
98550+};
98551+
98552+enum {
98553+ GR_TTYSNIFF,
98554+ GR_RBAC,
98555+ GR_RBAC_STR,
98556+ GR_STR_RBAC,
98557+ GR_RBAC_MODE2,
98558+ GR_RBAC_MODE3,
98559+ GR_FILENAME,
98560+ GR_SYSCTL_HIDDEN,
98561+ GR_NOARGS,
98562+ GR_ONE_INT,
98563+ GR_ONE_INT_TWO_STR,
98564+ GR_ONE_STR,
98565+ GR_STR_INT,
98566+ GR_TWO_STR_INT,
98567+ GR_TWO_INT,
98568+ GR_TWO_U64,
98569+ GR_THREE_INT,
98570+ GR_FIVE_INT_TWO_STR,
98571+ GR_TWO_STR,
98572+ GR_THREE_STR,
98573+ GR_FOUR_STR,
98574+ GR_STR_FILENAME,
98575+ GR_FILENAME_STR,
98576+ GR_FILENAME_TWO_INT,
98577+ GR_FILENAME_TWO_INT_STR,
98578+ GR_TEXTREL,
98579+ GR_PTRACE,
98580+ GR_RESOURCE,
98581+ GR_CAP,
98582+ GR_SIG,
98583+ GR_SIG2,
98584+ GR_CRASH1,
98585+ GR_CRASH2,
98586+ GR_PSACCT,
98587+ GR_RWXMAP,
98588+ GR_RWXMAPVMA
98589+};
98590+
98591+#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
98592+#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
98593+#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
98594+#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
98595+#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
98596+#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
98597+#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)
98598+#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
98599+#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
98600+#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
98601+#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
98602+#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
98603+#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
98604+#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
98605+#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
98606+#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
98607+#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)
98608+#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
98609+#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
98610+#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
98611+#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
98612+#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
98613+#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
98614+#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
98615+#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)
98616+#define gr_log_textrel_ulong_ulong(audit, msg, str, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, str, file, ulong1, ulong2)
98617+#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
98618+#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
98619+#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
98620+#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
98621+#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
98622+#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
98623+#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
98624+#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)
98625+#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
98626+#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
98627+
98628+void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
98629+
98630+#endif
98631+
98632+#endif
98633diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
98634new file mode 100644
98635index 0000000..3092b3c
98636--- /dev/null
98637+++ b/include/linux/grmsg.h
98638@@ -0,0 +1,118 @@
98639+#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"
98640+#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"
98641+#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
98642+#define GR_STOPMOD_MSG "denied modification of module state by "
98643+#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
98644+#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
98645+#define GR_IOPERM_MSG "denied use of ioperm() by "
98646+#define GR_IOPL_MSG "denied use of iopl() by "
98647+#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
98648+#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
98649+#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
98650+#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
98651+#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
98652+#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"
98653+#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"
98654+#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
98655+#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
98656+#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
98657+#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
98658+#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
98659+#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
98660+#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
98661+#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
98662+#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
98663+#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
98664+#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
98665+#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
98666+#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
98667+#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
98668+#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
98669+#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
98670+#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
98671+#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
98672+#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
98673+#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
98674+#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
98675+#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
98676+#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
98677+#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
98678+#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
98679+#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
98680+#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
98681+#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
98682+#define GR_CHROOT_RENAME_MSG "denied bad rename of %.950s out of a chroot by "
98683+#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
98684+#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
98685+#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
98686+#define GR_CHROOT_FHANDLE_MSG "denied use of file handles inside chroot by "
98687+#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
98688+#define GR_SETXATTR_ACL_MSG "%s setting extended attribute of %.950s by "
98689+#define GR_REMOVEXATTR_ACL_MSG "%s removing extended attribute of %.950s by "
98690+#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
98691+#define GR_INITF_ACL_MSG "init_variables() failed %s by "
98692+#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"
98693+#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
98694+#define GR_SHUTS_ACL_MSG "shutdown auth success for "
98695+#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
98696+#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
98697+#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
98698+#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
98699+#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
98700+#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
98701+#define GR_ENABLEF_ACL_MSG "unable to load %s for "
98702+#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
98703+#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
98704+#define GR_RELOADF_ACL_MSG "failed reload of %s for "
98705+#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
98706+#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
98707+#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
98708+#define GR_SPROLEF_ACL_MSG "special role %s failure for "
98709+#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
98710+#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
98711+#define GR_INVMODE_ACL_MSG "invalid mode %d by "
98712+#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
98713+#define GR_FAILFORK_MSG "failed fork with errno %s by "
98714+#define GR_NICE_CHROOT_MSG "denied priority change by "
98715+#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
98716+#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
98717+#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
98718+#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
98719+#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
98720+#define GR_TIME_MSG "time set by "
98721+#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
98722+#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
98723+#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
98724+#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
98725+#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
98726+#define GR_BIND_MSG "denied bind() by "
98727+#define GR_CONNECT_MSG "denied connect() by "
98728+#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
98729+#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
98730+#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"
98731+#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
98732+#define GR_CAP_ACL_MSG "use of %s denied for "
98733+#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
98734+#define GR_CAP_ACL_MSG2 "use of %s permitted for "
98735+#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
98736+#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
98737+#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
98738+#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
98739+#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
98740+#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
98741+#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
98742+#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
98743+#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
98744+#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
98745+#define GR_TEXTREL_AUDIT_MSG "allowed %s text relocation transition in %.950s, VMA:0x%08lx 0x%08lx by "
98746+#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
98747+#define GR_VM86_MSG "denied use of vm86 by "
98748+#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
98749+#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
98750+#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
98751+#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
98752+#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
98753+#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 "
98754+#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 "
98755+#define GR_IPC_DENIED_MSG "denied %s of overly-permissive IPC object with creator uid %u by "
98756+#define GR_MSRWRITE_MSG "denied write to CPU MSR by "
98757diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
98758new file mode 100644
98759index 0000000..0ea4a82
98760--- /dev/null
98761+++ b/include/linux/grsecurity.h
98762@@ -0,0 +1,255 @@
98763+#ifndef GR_SECURITY_H
98764+#define GR_SECURITY_H
98765+#include <linux/fs.h>
98766+#include <linux/fs_struct.h>
98767+#include <linux/binfmts.h>
98768+#include <linux/gracl.h>
98769+
98770+/* notify of brain-dead configs */
98771+#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_GRKERNSEC_KMEM)
98772+#error "CONFIG_DEBUG_FS being enabled is a security risk when CONFIG_GRKERNSEC_KMEM is enabled"
98773+#endif
98774+#if defined(CONFIG_PROC_PAGE_MONITOR) && defined(CONFIG_GRKERNSEC)
98775+#error "CONFIG_PROC_PAGE_MONITOR is a security risk"
98776+#endif
98777+#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
98778+#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
98779+#endif
98780+#if defined(CONFIG_GRKERNSEC_PROC) && !defined(CONFIG_GRKERNSEC_PROC_USER) && !defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
98781+#error "CONFIG_GRKERNSEC_PROC enabled, but neither CONFIG_GRKERNSEC_PROC_USER nor CONFIG_GRKERNSEC_PROC_USERGROUP enabled"
98782+#endif
98783+#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
98784+#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
98785+#endif
98786+#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
98787+#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
98788+#endif
98789+#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
98790+#error "CONFIG_PAX enabled, but no PaX options are enabled."
98791+#endif
98792+
98793+int gr_handle_new_usb(void);
98794+
98795+void gr_handle_brute_attach(int dumpable);
98796+void gr_handle_brute_check(void);
98797+void gr_handle_kernel_exploit(void);
98798+
98799+char gr_roletype_to_char(void);
98800+
98801+int gr_proc_is_restricted(void);
98802+
98803+int gr_acl_enable_at_secure(void);
98804+
98805+int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
98806+int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
98807+
98808+int gr_learn_cap(const struct task_struct *task, const struct cred *cred, const int cap);
98809+
98810+void gr_del_task_from_ip_table(struct task_struct *p);
98811+
98812+int gr_pid_is_chrooted(struct task_struct *p);
98813+int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
98814+int gr_handle_chroot_nice(void);
98815+int gr_handle_chroot_sysctl(const int op);
98816+int gr_handle_chroot_setpriority(struct task_struct *p,
98817+ const int niceval);
98818+int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
98819+int gr_chroot_fhandle(void);
98820+int gr_handle_chroot_chroot(const struct dentry *dentry,
98821+ const struct vfsmount *mnt);
98822+void gr_handle_chroot_chdir(const struct path *path);
98823+int gr_handle_chroot_chmod(const struct dentry *dentry,
98824+ const struct vfsmount *mnt, const int mode);
98825+int gr_handle_chroot_mknod(const struct dentry *dentry,
98826+ const struct vfsmount *mnt, const int mode);
98827+int gr_handle_chroot_mount(const struct dentry *dentry,
98828+ const struct vfsmount *mnt,
98829+ const char *dev_name);
98830+int gr_handle_chroot_pivot(void);
98831+int gr_handle_chroot_unix(const pid_t pid);
98832+
98833+int gr_handle_rawio(const struct inode *inode);
98834+
98835+void gr_handle_ioperm(void);
98836+void gr_handle_iopl(void);
98837+void gr_handle_msr_write(void);
98838+
98839+umode_t gr_acl_umask(void);
98840+
98841+int gr_tpe_allow(const struct file *file);
98842+
98843+void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
98844+void gr_clear_chroot_entries(struct task_struct *task);
98845+
98846+void gr_log_forkfail(const int retval);
98847+void gr_log_timechange(void);
98848+void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
98849+void gr_log_chdir(const struct dentry *dentry,
98850+ const struct vfsmount *mnt);
98851+void gr_log_chroot_exec(const struct dentry *dentry,
98852+ const struct vfsmount *mnt);
98853+void gr_log_remount(const char *devname, const int retval);
98854+void gr_log_unmount(const char *devname, const int retval);
98855+void gr_log_mount(const char *from, struct path *to, const int retval);
98856+void gr_log_textrel(struct vm_area_struct *vma, bool is_textrel_rw);
98857+void gr_log_ptgnustack(struct file *file);
98858+void gr_log_rwxmmap(struct file *file);
98859+void gr_log_rwxmprotect(struct vm_area_struct *vma);
98860+
98861+int gr_handle_follow_link(const struct dentry *dentry,
98862+ const struct vfsmount *mnt);
98863+int gr_handle_fifo(const struct dentry *dentry,
98864+ const struct vfsmount *mnt,
98865+ const struct dentry *dir, const int flag,
98866+ const int acc_mode);
98867+int gr_handle_hardlink(const struct dentry *dentry,
98868+ const struct vfsmount *mnt,
98869+ const struct filename *to);
98870+
98871+int gr_is_capable(const int cap);
98872+int gr_is_capable_nolog(const int cap);
98873+int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
98874+int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
98875+
98876+void gr_copy_label(struct task_struct *tsk);
98877+void gr_handle_crash(struct task_struct *task, const int sig);
98878+int gr_handle_signal(const struct task_struct *p, const int sig);
98879+int gr_check_crash_uid(const kuid_t uid);
98880+int gr_check_protected_task(const struct task_struct *task);
98881+int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
98882+int gr_acl_handle_mmap(const struct file *file,
98883+ const unsigned long prot);
98884+int gr_acl_handle_mprotect(const struct file *file,
98885+ const unsigned long prot);
98886+int gr_check_hidden_task(const struct task_struct *tsk);
98887+__u32 gr_acl_handle_truncate(const struct dentry *dentry,
98888+ const struct vfsmount *mnt);
98889+__u32 gr_acl_handle_utime(const struct dentry *dentry,
98890+ const struct vfsmount *mnt);
98891+__u32 gr_acl_handle_access(const struct dentry *dentry,
98892+ const struct vfsmount *mnt, const int fmode);
98893+__u32 gr_acl_handle_chmod(const struct dentry *dentry,
98894+ const struct vfsmount *mnt, umode_t *mode);
98895+__u32 gr_acl_handle_chown(const struct dentry *dentry,
98896+ const struct vfsmount *mnt);
98897+__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
98898+ const struct vfsmount *mnt);
98899+__u32 gr_acl_handle_removexattr(const struct dentry *dentry,
98900+ const struct vfsmount *mnt);
98901+int gr_handle_ptrace(struct task_struct *task, const long request);
98902+int gr_handle_proc_ptrace(struct task_struct *task);
98903+__u32 gr_acl_handle_execve(const struct dentry *dentry,
98904+ const struct vfsmount *mnt);
98905+int gr_check_crash_exec(const struct file *filp);
98906+int gr_acl_is_enabled(void);
98907+void gr_set_role_label(struct task_struct *task, const kuid_t uid,
98908+ const kgid_t gid);
98909+int gr_set_proc_label(const struct dentry *dentry,
98910+ const struct vfsmount *mnt,
98911+ const int unsafe_flags);
98912+__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
98913+ const struct vfsmount *mnt);
98914+__u32 gr_acl_handle_open(const struct dentry *dentry,
98915+ const struct vfsmount *mnt, int acc_mode);
98916+__u32 gr_acl_handle_creat(const struct dentry *dentry,
98917+ const struct dentry *p_dentry,
98918+ const struct vfsmount *p_mnt,
98919+ int open_flags, int acc_mode, const int imode);
98920+void gr_handle_create(const struct dentry *dentry,
98921+ const struct vfsmount *mnt);
98922+void gr_handle_proc_create(const struct dentry *dentry,
98923+ const struct inode *inode);
98924+__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
98925+ const struct dentry *parent_dentry,
98926+ const struct vfsmount *parent_mnt,
98927+ const int mode);
98928+__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
98929+ const struct dentry *parent_dentry,
98930+ const struct vfsmount *parent_mnt);
98931+__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
98932+ const struct vfsmount *mnt);
98933+void gr_handle_delete(const u64 ino, const dev_t dev);
98934+__u32 gr_acl_handle_unlink(const struct dentry *dentry,
98935+ const struct vfsmount *mnt);
98936+__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
98937+ const struct dentry *parent_dentry,
98938+ const struct vfsmount *parent_mnt,
98939+ const struct filename *from);
98940+__u32 gr_acl_handle_link(const struct dentry *new_dentry,
98941+ const struct dentry *parent_dentry,
98942+ const struct vfsmount *parent_mnt,
98943+ const struct dentry *old_dentry,
98944+ const struct vfsmount *old_mnt, const struct filename *to);
98945+int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
98946+int gr_acl_handle_rename(struct dentry *new_dentry,
98947+ struct dentry *parent_dentry,
98948+ const struct vfsmount *parent_mnt,
98949+ struct dentry *old_dentry,
98950+ struct inode *old_parent_inode,
98951+ struct vfsmount *old_mnt, const struct filename *newname, unsigned int flags);
98952+void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
98953+ struct dentry *old_dentry,
98954+ struct dentry *new_dentry,
98955+ struct vfsmount *mnt, const __u8 replace, unsigned int flags);
98956+__u32 gr_check_link(const struct dentry *new_dentry,
98957+ const struct dentry *parent_dentry,
98958+ const struct vfsmount *parent_mnt,
98959+ const struct dentry *old_dentry,
98960+ const struct vfsmount *old_mnt);
98961+int gr_acl_handle_filldir(const struct file *file, const char *name,
98962+ const unsigned int namelen, const u64 ino);
98963+
98964+__u32 gr_acl_handle_unix(const struct dentry *dentry,
98965+ const struct vfsmount *mnt);
98966+void gr_acl_handle_exit(void);
98967+void gr_acl_handle_psacct(struct task_struct *task, const long code);
98968+int gr_acl_handle_procpidmem(const struct task_struct *task);
98969+int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
98970+int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
98971+void gr_audit_ptrace(struct task_struct *task);
98972+dev_t gr_get_dev_from_dentry(struct dentry *dentry);
98973+u64 gr_get_ino_from_dentry(struct dentry *dentry);
98974+void gr_put_exec_file(struct task_struct *task);
98975+
98976+int gr_get_symlinkown_enabled(void);
98977+
98978+int gr_ptrace_readexec(struct file *file, int unsafe_flags);
98979+
98980+void gr_inc_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt);
98981+void gr_dec_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt);
98982+int gr_bad_chroot_rename(struct dentry *olddentry, struct vfsmount *oldmnt,
98983+ struct dentry *newdentry, struct vfsmount *newmnt);
98984+
98985+#ifdef CONFIG_GRKERNSEC_RESLOG
98986+extern void gr_log_resource(const struct task_struct *task, const int res,
98987+ const unsigned long wanted, const int gt);
98988+#else
98989+static inline void gr_log_resource(const struct task_struct *task, const int res,
98990+ const unsigned long wanted, const int gt)
98991+{
98992+}
98993+#endif
98994+
98995+#ifdef CONFIG_GRKERNSEC
98996+void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
98997+void gr_handle_vm86(void);
98998+void gr_handle_mem_readwrite(u64 from, u64 to);
98999+
99000+void gr_log_badprocpid(const char *entry);
99001+
99002+extern int grsec_enable_dmesg;
99003+extern int grsec_disable_privio;
99004+
99005+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
99006+extern kgid_t grsec_proc_gid;
99007+#endif
99008+
99009+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
99010+extern int grsec_enable_chroot_findtask;
99011+#endif
99012+#ifdef CONFIG_GRKERNSEC_SETXID
99013+extern int grsec_enable_setxid;
99014+#endif
99015+#endif
99016+
99017+#endif
99018diff --git a/include/linux/grsock.h b/include/linux/grsock.h
99019new file mode 100644
99020index 0000000..e7ffaaf
99021--- /dev/null
99022+++ b/include/linux/grsock.h
99023@@ -0,0 +1,19 @@
99024+#ifndef __GRSOCK_H
99025+#define __GRSOCK_H
99026+
99027+extern void gr_attach_curr_ip(const struct sock *sk);
99028+extern int gr_handle_sock_all(const int family, const int type,
99029+ const int protocol);
99030+extern int gr_handle_sock_server(const struct sockaddr *sck);
99031+extern int gr_handle_sock_server_other(const struct sock *sck);
99032+extern int gr_handle_sock_client(const struct sockaddr *sck);
99033+extern int gr_search_connect(struct socket * sock,
99034+ struct sockaddr_in * addr);
99035+extern int gr_search_bind(struct socket * sock,
99036+ struct sockaddr_in * addr);
99037+extern int gr_search_listen(struct socket * sock);
99038+extern int gr_search_accept(struct socket * sock);
99039+extern int gr_search_socket(const int domain, const int type,
99040+ const int protocol);
99041+
99042+#endif
99043diff --git a/include/linux/highmem.h b/include/linux/highmem.h
99044index 6aefcd0..98b81dc 100644
99045--- a/include/linux/highmem.h
99046+++ b/include/linux/highmem.h
99047@@ -191,6 +191,18 @@ static inline void clear_highpage(struct page *page)
99048 kunmap_atomic(kaddr);
99049 }
99050
99051+static inline void sanitize_highpage(struct page *page)
99052+{
99053+ void *kaddr;
99054+ unsigned long flags;
99055+
99056+ local_irq_save(flags);
99057+ kaddr = kmap_atomic(page);
99058+ clear_page(kaddr);
99059+ kunmap_atomic(kaddr);
99060+ local_irq_restore(flags);
99061+}
99062+
99063 static inline void zero_user_segments(struct page *page,
99064 unsigned start1, unsigned end1,
99065 unsigned start2, unsigned end2)
99066diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
99067index 1c7b89a..7dda400 100644
99068--- a/include/linux/hwmon-sysfs.h
99069+++ b/include/linux/hwmon-sysfs.h
99070@@ -25,7 +25,8 @@
99071 struct sensor_device_attribute{
99072 struct device_attribute dev_attr;
99073 int index;
99074-};
99075+} __do_const;
99076+typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
99077 #define to_sensor_dev_attr(_dev_attr) \
99078 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
99079
99080@@ -41,7 +42,8 @@ struct sensor_device_attribute_2 {
99081 struct device_attribute dev_attr;
99082 u8 index;
99083 u8 nr;
99084-};
99085+} __do_const;
99086+typedef struct sensor_device_attribute_2 __no_const sensor_device_attribute_2_no_const;
99087 #define to_sensor_dev_attr_2(_dev_attr) \
99088 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
99089
99090diff --git a/include/linux/i2c.h b/include/linux/i2c.h
99091index e83a738..8b323fa 100644
99092--- a/include/linux/i2c.h
99093+++ b/include/linux/i2c.h
99094@@ -409,6 +409,7 @@ struct i2c_algorithm {
99095 int (*unreg_slave)(struct i2c_client *client);
99096 #endif
99097 };
99098+typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
99099
99100 /**
99101 * struct i2c_bus_recovery_info - I2C bus recovery information
99102diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
99103index b49cf92..0c29072 100644
99104--- a/include/linux/if_pppox.h
99105+++ b/include/linux/if_pppox.h
99106@@ -78,7 +78,7 @@ struct pppox_proto {
99107 int (*ioctl)(struct socket *sock, unsigned int cmd,
99108 unsigned long arg);
99109 struct module *owner;
99110-};
99111+} __do_const;
99112
99113 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
99114 extern void unregister_pppox_proto(int proto_num);
99115diff --git a/include/linux/init.h b/include/linux/init.h
99116index b449f37..61005b3 100644
99117--- a/include/linux/init.h
99118+++ b/include/linux/init.h
99119@@ -37,9 +37,17 @@
99120 * section.
99121 */
99122
99123+#define add_init_latent_entropy __latent_entropy
99124+
99125+#ifdef CONFIG_MEMORY_HOTPLUG
99126+#define add_meminit_latent_entropy
99127+#else
99128+#define add_meminit_latent_entropy __latent_entropy
99129+#endif
99130+
99131 /* These are for everybody (although not all archs will actually
99132 discard it in modules) */
99133-#define __init __section(.init.text) __cold notrace
99134+#define __init __section(.init.text) __cold notrace add_init_latent_entropy
99135 #define __initdata __section(.init.data)
99136 #define __initconst __constsection(.init.rodata)
99137 #define __exitdata __section(.exit.data)
99138@@ -92,7 +100,7 @@
99139 #define __exit __section(.exit.text) __exitused __cold notrace
99140
99141 /* Used for MEMORY_HOTPLUG */
99142-#define __meminit __section(.meminit.text) __cold notrace
99143+#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
99144 #define __meminitdata __section(.meminit.data)
99145 #define __meminitconst __constsection(.meminit.rodata)
99146 #define __memexit __section(.memexit.text) __exitused __cold notrace
99147diff --git a/include/linux/init_task.h b/include/linux/init_task.h
99148index bb9b075..ecac42c 100644
99149--- a/include/linux/init_task.h
99150+++ b/include/linux/init_task.h
99151@@ -157,6 +157,12 @@ extern struct task_group root_task_group;
99152
99153 #define INIT_TASK_COMM "swapper"
99154
99155+#ifdef CONFIG_X86
99156+#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
99157+#else
99158+#define INIT_TASK_THREAD_INFO
99159+#endif
99160+
99161 #ifdef CONFIG_RT_MUTEXES
99162 # define INIT_RT_MUTEXES(tsk) \
99163 .pi_waiters = RB_ROOT, \
99164@@ -223,6 +229,7 @@ extern struct task_group root_task_group;
99165 RCU_POINTER_INITIALIZER(cred, &init_cred), \
99166 .comm = INIT_TASK_COMM, \
99167 .thread = INIT_THREAD, \
99168+ INIT_TASK_THREAD_INFO \
99169 .fs = &init_fs, \
99170 .files = &init_files, \
99171 .signal = &init_signals, \
99172diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
99173index be7e75c..09bec77 100644
99174--- a/include/linux/interrupt.h
99175+++ b/include/linux/interrupt.h
99176@@ -433,8 +433,8 @@ extern const char * const softirq_to_name[NR_SOFTIRQS];
99177
99178 struct softirq_action
99179 {
99180- void (*action)(struct softirq_action *);
99181-};
99182+ void (*action)(void);
99183+} __no_const;
99184
99185 asmlinkage void do_softirq(void);
99186 asmlinkage void __do_softirq(void);
99187@@ -448,7 +448,7 @@ static inline void do_softirq_own_stack(void)
99188 }
99189 #endif
99190
99191-extern void open_softirq(int nr, void (*action)(struct softirq_action *));
99192+extern void open_softirq(int nr, void (*action)(void));
99193 extern void softirq_init(void);
99194 extern void __raise_softirq_irqoff(unsigned int nr);
99195
99196diff --git a/include/linux/iommu.h b/include/linux/iommu.h
99197index f9c1b6d..db7d6f5 100644
99198--- a/include/linux/iommu.h
99199+++ b/include/linux/iommu.h
99200@@ -192,7 +192,7 @@ struct iommu_ops {
99201
99202 unsigned long pgsize_bitmap;
99203 void *priv;
99204-};
99205+} __do_const;
99206
99207 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
99208 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
99209diff --git a/include/linux/ioport.h b/include/linux/ioport.h
99210index 388e3ae..d7e45a1 100644
99211--- a/include/linux/ioport.h
99212+++ b/include/linux/ioport.h
99213@@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
99214 int adjust_resource(struct resource *res, resource_size_t start,
99215 resource_size_t size);
99216 resource_size_t resource_alignment(struct resource *res);
99217-static inline resource_size_t resource_size(const struct resource *res)
99218+static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
99219 {
99220 return res->end - res->start + 1;
99221 }
99222diff --git a/include/linux/ipc.h b/include/linux/ipc.h
99223index 9d84942..12d5bdf 100644
99224--- a/include/linux/ipc.h
99225+++ b/include/linux/ipc.h
99226@@ -19,8 +19,8 @@ struct kern_ipc_perm
99227 kuid_t cuid;
99228 kgid_t cgid;
99229 umode_t mode;
99230- unsigned long seq;
99231+ unsigned long seq __intentional_overflow(-1);
99232 void *security;
99233-};
99234+} __randomize_layout;
99235
99236 #endif /* _LINUX_IPC_H */
99237diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
99238index 1eee6bc..9cf4912 100644
99239--- a/include/linux/ipc_namespace.h
99240+++ b/include/linux/ipc_namespace.h
99241@@ -60,7 +60,7 @@ struct ipc_namespace {
99242 struct user_namespace *user_ns;
99243
99244 struct ns_common ns;
99245-};
99246+} __randomize_layout;
99247
99248 extern struct ipc_namespace init_ipc_ns;
99249 extern atomic_t nr_ipc_ns;
99250diff --git a/include/linux/irq.h b/include/linux/irq.h
99251index 51744bc..e902653 100644
99252--- a/include/linux/irq.h
99253+++ b/include/linux/irq.h
99254@@ -383,7 +383,10 @@ struct irq_chip {
99255 int (*irq_set_vcpu_affinity)(struct irq_data *data, void *vcpu_info);
99256
99257 unsigned long flags;
99258-};
99259+} __do_const;
99260+#ifndef _LINUX_IRQDOMAIN_H
99261+typedef struct irq_chip __no_const irq_chip_no_const;
99262+#endif
99263
99264 /*
99265 * irq_chip specific flags
99266diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
99267index fcea4e4..cff381d 100644
99268--- a/include/linux/irqdesc.h
99269+++ b/include/linux/irqdesc.h
99270@@ -59,7 +59,7 @@ struct irq_desc {
99271 unsigned int irq_count; /* For detecting broken IRQs */
99272 unsigned long last_unhandled; /* Aging timer for unhandled count */
99273 unsigned int irqs_unhandled;
99274- atomic_t threads_handled;
99275+ atomic_unchecked_t threads_handled;
99276 int threads_handled_last;
99277 raw_spinlock_t lock;
99278 struct cpumask *percpu_enabled;
99279diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
99280index 744ac0e..382b1a6 100644
99281--- a/include/linux/irqdomain.h
99282+++ b/include/linux/irqdomain.h
99283@@ -40,6 +40,9 @@ struct device_node;
99284 struct irq_domain;
99285 struct of_device_id;
99286 struct irq_chip;
99287+#ifndef _LINUX_IRQ_H
99288+typedef struct irq_chip __no_const irq_chip_no_const;
99289+#endif
99290 struct irq_data;
99291
99292 /* Number of irqs reserved for a legacy isa controller */
99293diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
99294index 535fd3b..e5c356e 100644
99295--- a/include/linux/jiffies.h
99296+++ b/include/linux/jiffies.h
99297@@ -284,19 +284,19 @@ extern unsigned long preset_lpj;
99298 extern unsigned int jiffies_to_msecs(const unsigned long j);
99299 extern unsigned int jiffies_to_usecs(const unsigned long j);
99300
99301-static inline u64 jiffies_to_nsecs(const unsigned long j)
99302+static inline u64 __intentional_overflow(-1) jiffies_to_nsecs(const unsigned long j)
99303 {
99304 return (u64)jiffies_to_usecs(j) * NSEC_PER_USEC;
99305 }
99306
99307-extern unsigned long __msecs_to_jiffies(const unsigned int m);
99308+extern unsigned long __msecs_to_jiffies(const unsigned int m) __intentional_overflow(-1);
99309 #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
99310 /*
99311 * HZ is equal to or smaller than 1000, and 1000 is a nice round
99312 * multiple of HZ, divide with the factor between them, but round
99313 * upwards:
99314 */
99315-static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99316+static inline unsigned long __intentional_overflow(-1) _msecs_to_jiffies(const unsigned int m)
99317 {
99318 return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ);
99319 }
99320@@ -307,7 +307,7 @@ static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99321 *
99322 * But first make sure the multiplication result cannot overflow:
99323 */
99324-static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99325+static inline unsigned long __intentional_overflow(-1) _msecs_to_jiffies(const unsigned int m)
99326 {
99327 if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
99328 return MAX_JIFFY_OFFSET;
99329@@ -318,7 +318,7 @@ static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99330 * Generic case - multiply, round and divide. But first check that if
99331 * we are doing a net multiplication, that we wouldn't overflow:
99332 */
99333-static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99334+static inline unsigned long __intentional_overflow(-1) _msecs_to_jiffies(const unsigned int m)
99335 {
99336 if (HZ > MSEC_PER_SEC && m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
99337 return MAX_JIFFY_OFFSET;
99338@@ -362,21 +362,19 @@ static inline unsigned long msecs_to_jiffies(const unsigned int m)
99339 }
99340 }
99341
99342-extern unsigned long __usecs_to_jiffies(const unsigned int u);
99343+extern unsigned long __usecs_to_jiffies(const unsigned int u) __intentional_overflow(-1);
99344 #if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ)
99345-static inline unsigned long _usecs_to_jiffies(const unsigned int u)
99346+static inline unsigned long __intentional_overflow(-1) _usecs_to_jiffies(const unsigned int u)
99347 {
99348 return (u + (USEC_PER_SEC / HZ) - 1) / (USEC_PER_SEC / HZ);
99349 }
99350 #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC)
99351-static inline unsigned long _usecs_to_jiffies(const unsigned int u)
99352+static inline unsigned long __intentional_overflow(-1) _usecs_to_jiffies(const unsigned int u)
99353 {
99354 return u * (HZ / USEC_PER_SEC);
99355 }
99356-static inline unsigned long _usecs_to_jiffies(const unsigned int u)
99357-{
99358 #else
99359-static inline unsigned long _usecs_to_jiffies(const unsigned int u)
99360+static inline unsigned long __intentional_overflow(-1) _usecs_to_jiffies(const unsigned int u)
99361 {
99362 return (USEC_TO_HZ_MUL32 * u + USEC_TO_HZ_ADJ32)
99363 >> USEC_TO_HZ_SHR32;
99364diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
99365index 6883e19..e854fcb 100644
99366--- a/include/linux/kallsyms.h
99367+++ b/include/linux/kallsyms.h
99368@@ -15,7 +15,8 @@
99369
99370 struct module;
99371
99372-#ifdef CONFIG_KALLSYMS
99373+#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
99374+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
99375 /* Lookup the address for a symbol. Returns 0 if not found. */
99376 unsigned long kallsyms_lookup_name(const char *name);
99377
99378@@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
99379 /* Stupid that this does nothing, but I didn't create this mess. */
99380 #define __print_symbol(fmt, addr)
99381 #endif /*CONFIG_KALLSYMS*/
99382+#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
99383+ arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
99384+extern unsigned long kallsyms_lookup_name(const char *name);
99385+extern void __print_symbol(const char *fmt, unsigned long address);
99386+extern int sprint_backtrace(char *buffer, unsigned long address);
99387+extern int sprint_symbol(char *buffer, unsigned long address);
99388+extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
99389+const char *kallsyms_lookup(unsigned long addr,
99390+ unsigned long *symbolsize,
99391+ unsigned long *offset,
99392+ char **modname, char *namebuf);
99393+extern int kallsyms_lookup_size_offset(unsigned long addr,
99394+ unsigned long *symbolsize,
99395+ unsigned long *offset);
99396+#endif
99397
99398 /* This macro allows us to keep printk typechecking */
99399 static __printf(1, 2)
99400diff --git a/include/linux/key-type.h b/include/linux/key-type.h
99401index ff9f1d3..6712be5 100644
99402--- a/include/linux/key-type.h
99403+++ b/include/linux/key-type.h
99404@@ -152,7 +152,7 @@ struct key_type {
99405 /* internal fields */
99406 struct list_head link; /* link in types list */
99407 struct lock_class_key lock_class; /* key->sem lock class */
99408-};
99409+} __do_const;
99410
99411 extern struct key_type key_type_keyring;
99412
99413diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
99414index e465bb1..19f605fd 100644
99415--- a/include/linux/kgdb.h
99416+++ b/include/linux/kgdb.h
99417@@ -52,7 +52,7 @@ extern int kgdb_connected;
99418 extern int kgdb_io_module_registered;
99419
99420 extern atomic_t kgdb_setting_breakpoint;
99421-extern atomic_t kgdb_cpu_doing_single_step;
99422+extern atomic_unchecked_t kgdb_cpu_doing_single_step;
99423
99424 extern struct task_struct *kgdb_usethread;
99425 extern struct task_struct *kgdb_contthread;
99426@@ -254,7 +254,7 @@ struct kgdb_arch {
99427 void (*correct_hw_break)(void);
99428
99429 void (*enable_nmi)(bool on);
99430-};
99431+} __do_const;
99432
99433 /**
99434 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
99435@@ -279,7 +279,7 @@ struct kgdb_io {
99436 void (*pre_exception) (void);
99437 void (*post_exception) (void);
99438 int is_console;
99439-};
99440+} __do_const;
99441
99442 extern struct kgdb_arch arch_kgdb_ops;
99443
99444diff --git a/include/linux/kmemleak.h b/include/linux/kmemleak.h
99445index d0a1f99..0bd8b7c 100644
99446--- a/include/linux/kmemleak.h
99447+++ b/include/linux/kmemleak.h
99448@@ -27,7 +27,7 @@
99449
99450 extern void kmemleak_init(void) __ref;
99451 extern void kmemleak_alloc(const void *ptr, size_t size, int min_count,
99452- gfp_t gfp) __ref;
99453+ gfp_t gfp) __ref __size_overflow(2);
99454 extern void kmemleak_alloc_percpu(const void __percpu *ptr, size_t size,
99455 gfp_t gfp) __ref;
99456 extern void kmemleak_free(const void *ptr) __ref;
99457@@ -63,7 +63,7 @@ static inline void kmemleak_erase(void **ptr)
99458 static inline void kmemleak_init(void)
99459 {
99460 }
99461-static inline void kmemleak_alloc(const void *ptr, size_t size, int min_count,
99462+static inline void __size_overflow(2) kmemleak_alloc(const void *ptr, size_t size, int min_count,
99463 gfp_t gfp)
99464 {
99465 }
99466diff --git a/include/linux/kmod.h b/include/linux/kmod.h
99467index 0555cc6..40116ce 100644
99468--- a/include/linux/kmod.h
99469+++ b/include/linux/kmod.h
99470@@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
99471 * usually useless though. */
99472 extern __printf(2, 3)
99473 int __request_module(bool wait, const char *name, ...);
99474+extern __printf(3, 4)
99475+int ___request_module(bool wait, char *param_name, const char *name, ...);
99476 #define request_module(mod...) __request_module(true, mod)
99477 #define request_module_nowait(mod...) __request_module(false, mod)
99478 #define try_then_request_module(x, mod...) \
99479@@ -57,6 +59,9 @@ struct subprocess_info {
99480 struct work_struct work;
99481 struct completion *complete;
99482 char *path;
99483+#ifdef CONFIG_GRKERNSEC
99484+ char *origpath;
99485+#endif
99486 char **argv;
99487 char **envp;
99488 int wait;
99489diff --git a/include/linux/kobject.h b/include/linux/kobject.h
99490index 637f670..3d69945 100644
99491--- a/include/linux/kobject.h
99492+++ b/include/linux/kobject.h
99493@@ -119,7 +119,7 @@ struct kobj_type {
99494 struct attribute **default_attrs;
99495 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
99496 const void *(*namespace)(struct kobject *kobj);
99497-};
99498+} __do_const;
99499
99500 struct kobj_uevent_env {
99501 char *argv[3];
99502@@ -143,6 +143,7 @@ struct kobj_attribute {
99503 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
99504 const char *buf, size_t count);
99505 };
99506+typedef struct kobj_attribute __no_const kobj_attribute_no_const;
99507
99508 extern const struct sysfs_ops kobj_sysfs_ops;
99509
99510@@ -170,7 +171,7 @@ struct kset {
99511 spinlock_t list_lock;
99512 struct kobject kobj;
99513 const struct kset_uevent_ops *uevent_ops;
99514-};
99515+} __randomize_layout;
99516
99517 extern void kset_init(struct kset *kset);
99518 extern int __must_check kset_register(struct kset *kset);
99519diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
99520index df32d25..fb52e27 100644
99521--- a/include/linux/kobject_ns.h
99522+++ b/include/linux/kobject_ns.h
99523@@ -44,7 +44,7 @@ struct kobj_ns_type_operations {
99524 const void *(*netlink_ns)(struct sock *sk);
99525 const void *(*initial_ns)(void);
99526 void (*drop_ns)(void *);
99527-};
99528+} __do_const;
99529
99530 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
99531 int kobj_ns_type_registered(enum kobj_ns_type type);
99532diff --git a/include/linux/kref.h b/include/linux/kref.h
99533index 484604d..0f6c5b6 100644
99534--- a/include/linux/kref.h
99535+++ b/include/linux/kref.h
99536@@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
99537 static inline int kref_sub(struct kref *kref, unsigned int count,
99538 void (*release)(struct kref *kref))
99539 {
99540- WARN_ON(release == NULL);
99541+ BUG_ON(release == NULL);
99542
99543 if (atomic_sub_and_test((int) count, &kref->refcount)) {
99544 release(kref);
99545diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
99546index 05e99b8..484b1f97 100644
99547--- a/include/linux/kvm_host.h
99548+++ b/include/linux/kvm_host.h
99549@@ -468,7 +468,7 @@ static inline void kvm_irqfd_exit(void)
99550 {
99551 }
99552 #endif
99553-int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
99554+int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
99555 struct module *module);
99556 void kvm_exit(void);
99557
99558@@ -678,7 +678,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
99559 struct kvm_guest_debug *dbg);
99560 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
99561
99562-int kvm_arch_init(void *opaque);
99563+int kvm_arch_init(const void *opaque);
99564 void kvm_arch_exit(void);
99565
99566 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
99567diff --git a/include/linux/libata.h b/include/linux/libata.h
99568index c9cfbcd..46986db 100644
99569--- a/include/linux/libata.h
99570+++ b/include/linux/libata.h
99571@@ -990,7 +990,7 @@ struct ata_port_operations {
99572 * fields must be pointers.
99573 */
99574 const struct ata_port_operations *inherits;
99575-};
99576+} __do_const;
99577
99578 struct ata_port_info {
99579 unsigned long flags;
99580diff --git a/include/linux/linkage.h b/include/linux/linkage.h
99581index a6a42dd..6c5ebce 100644
99582--- a/include/linux/linkage.h
99583+++ b/include/linux/linkage.h
99584@@ -36,6 +36,7 @@
99585 #endif
99586
99587 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
99588+#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
99589 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
99590
99591 /*
99592diff --git a/include/linux/list.h b/include/linux/list.h
99593index feb773c..98f3075 100644
99594--- a/include/linux/list.h
99595+++ b/include/linux/list.h
99596@@ -113,6 +113,19 @@ extern void __list_del_entry(struct list_head *entry);
99597 extern void list_del(struct list_head *entry);
99598 #endif
99599
99600+extern void __pax_list_add(struct list_head *new,
99601+ struct list_head *prev,
99602+ struct list_head *next);
99603+static inline void pax_list_add(struct list_head *new, struct list_head *head)
99604+{
99605+ __pax_list_add(new, head, head->next);
99606+}
99607+static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
99608+{
99609+ __pax_list_add(new, head->prev, head);
99610+}
99611+extern void pax_list_del(struct list_head *entry);
99612+
99613 /**
99614 * list_replace - replace old entry by new one
99615 * @old : the element to be replaced
99616@@ -146,6 +159,8 @@ static inline void list_del_init(struct list_head *entry)
99617 INIT_LIST_HEAD(entry);
99618 }
99619
99620+extern void pax_list_del_init(struct list_head *entry);
99621+
99622 /**
99623 * list_move - delete from one list and add as another's head
99624 * @list: the entry to move
99625diff --git a/include/linux/lockref.h b/include/linux/lockref.h
99626index b10b122..d37b3de 100644
99627--- a/include/linux/lockref.h
99628+++ b/include/linux/lockref.h
99629@@ -28,7 +28,7 @@ struct lockref {
99630 #endif
99631 struct {
99632 spinlock_t lock;
99633- int count;
99634+ atomic_t count;
99635 };
99636 };
99637 };
99638@@ -43,9 +43,29 @@ extern void lockref_mark_dead(struct lockref *);
99639 extern int lockref_get_not_dead(struct lockref *);
99640
99641 /* Must be called under spinlock for reliable results */
99642-static inline int __lockref_is_dead(const struct lockref *l)
99643+static inline int __lockref_is_dead(const struct lockref *lockref)
99644 {
99645- return ((int)l->count < 0);
99646+ return atomic_read(&lockref->count) < 0;
99647+}
99648+
99649+static inline int __lockref_read(const struct lockref *lockref)
99650+{
99651+ return atomic_read(&lockref->count);
99652+}
99653+
99654+static inline void __lockref_set(struct lockref *lockref, int count)
99655+{
99656+ atomic_set(&lockref->count, count);
99657+}
99658+
99659+static inline void __lockref_inc(struct lockref *lockref)
99660+{
99661+ atomic_inc(&lockref->count);
99662+}
99663+
99664+static inline void __lockref_dec(struct lockref *lockref)
99665+{
99666+ atomic_dec(&lockref->count);
99667 }
99668
99669 #endif /* __LINUX_LOCKREF_H */
99670diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
99671index 9429f05..a5d5425 100644
99672--- a/include/linux/lsm_hooks.h
99673+++ b/include/linux/lsm_hooks.h
99674@@ -1824,7 +1824,7 @@ struct security_hook_heads {
99675 struct list_head audit_rule_match;
99676 struct list_head audit_rule_free;
99677 #endif /* CONFIG_AUDIT */
99678-};
99679+} __randomize_layout;
99680
99681 /*
99682 * Security module hook list structure.
99683@@ -1834,7 +1834,7 @@ struct security_hook_list {
99684 struct list_head list;
99685 struct list_head *head;
99686 union security_list_options hook;
99687-};
99688+} __randomize_layout;
99689
99690 /*
99691 * Initializing a security_hook_list structure takes
99692diff --git a/include/linux/math64.h b/include/linux/math64.h
99693index c45c089..298841c 100644
99694--- a/include/linux/math64.h
99695+++ b/include/linux/math64.h
99696@@ -15,7 +15,7 @@
99697 * This is commonly provided by 32bit archs to provide an optimized 64bit
99698 * divide.
99699 */
99700-static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
99701+static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
99702 {
99703 *remainder = dividend % divisor;
99704 return dividend / divisor;
99705@@ -42,7 +42,7 @@ static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
99706 /**
99707 * div64_u64 - unsigned 64bit divide with 64bit divisor
99708 */
99709-static inline u64 div64_u64(u64 dividend, u64 divisor)
99710+static inline u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
99711 {
99712 return dividend / divisor;
99713 }
99714@@ -61,7 +61,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
99715 #define div64_ul(x, y) div_u64((x), (y))
99716
99717 #ifndef div_u64_rem
99718-static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
99719+static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
99720 {
99721 *remainder = do_div(dividend, divisor);
99722 return dividend;
99723@@ -77,7 +77,7 @@ extern u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder);
99724 #endif
99725
99726 #ifndef div64_u64
99727-extern u64 div64_u64(u64 dividend, u64 divisor);
99728+extern u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor);
99729 #endif
99730
99731 #ifndef div64_s64
99732@@ -94,7 +94,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
99733 * divide.
99734 */
99735 #ifndef div_u64
99736-static inline u64 div_u64(u64 dividend, u32 divisor)
99737+static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
99738 {
99739 u32 remainder;
99740 return div_u64_rem(dividend, divisor, &remainder);
99741diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
99742index 3d385c8..deacb6a 100644
99743--- a/include/linux/mempolicy.h
99744+++ b/include/linux/mempolicy.h
99745@@ -91,6 +91,10 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
99746 }
99747
99748 #define vma_policy(vma) ((vma)->vm_policy)
99749+static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
99750+{
99751+ vma->vm_policy = pol;
99752+}
99753
99754 static inline void mpol_get(struct mempolicy *pol)
99755 {
99756@@ -229,6 +233,9 @@ static inline void mpol_free_shared_policy(struct shared_policy *p)
99757 }
99758
99759 #define vma_policy(vma) NULL
99760+static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
99761+{
99762+}
99763
99764 static inline int
99765 vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
99766diff --git a/include/linux/mm.h b/include/linux/mm.h
99767index 2b05068..c58989c 100644
99768--- a/include/linux/mm.h
99769+++ b/include/linux/mm.h
99770@@ -136,6 +136,11 @@ extern unsigned int kobjsize(const void *objp);
99771
99772 #define VM_DONTCOPY 0x00020000 /* Do not copy this vma on fork */
99773 #define VM_DONTEXPAND 0x00040000 /* Cannot expand with mremap() */
99774+
99775+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
99776+#define VM_PAGEEXEC 0x00080000 /* vma->vm_page_prot needs special handling */
99777+#endif
99778+
99779 #define VM_ACCOUNT 0x00100000 /* Is a VM accounted object */
99780 #define VM_NORESERVE 0x00200000 /* should the VM suppress accounting */
99781 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
99782@@ -258,8 +263,8 @@ struct vm_operations_struct {
99783 /* called by access_process_vm when get_user_pages() fails, typically
99784 * for use by special VMAs that can switch between memory and hardware
99785 */
99786- int (*access)(struct vm_area_struct *vma, unsigned long addr,
99787- void *buf, int len, int write);
99788+ ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
99789+ void *buf, size_t len, int write);
99790
99791 /* Called by the /proc/PID/maps code to ask the vma whether it
99792 * has a special name. Returning non-NULL will also cause this
99793@@ -297,6 +302,7 @@ struct vm_operations_struct {
99794 struct page *(*find_special_page)(struct vm_area_struct *vma,
99795 unsigned long addr);
99796 };
99797+typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
99798
99799 struct mmu_gather;
99800 struct inode;
99801@@ -1181,8 +1187,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
99802 unsigned long *pfn);
99803 int follow_phys(struct vm_area_struct *vma, unsigned long address,
99804 unsigned int flags, unsigned long *prot, resource_size_t *phys);
99805-int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
99806- void *buf, int len, int write);
99807+ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
99808+ void *buf, size_t len, int write);
99809
99810 static inline void unmap_shared_mapping_range(struct address_space *mapping,
99811 loff_t const holebegin, loff_t const holelen)
99812@@ -1222,9 +1228,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
99813 }
99814 #endif
99815
99816-extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
99817-extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
99818- void *buf, int len, int write);
99819+extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
99820+extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
99821+ void *buf, size_t len, int write);
99822
99823 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
99824 unsigned long start, unsigned long nr_pages,
99825@@ -1272,34 +1278,6 @@ int clear_page_dirty_for_io(struct page *page);
99826
99827 int get_cmdline(struct task_struct *task, char *buffer, int buflen);
99828
99829-/* Is the vma a continuation of the stack vma above it? */
99830-static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
99831-{
99832- return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
99833-}
99834-
99835-static inline int stack_guard_page_start(struct vm_area_struct *vma,
99836- unsigned long addr)
99837-{
99838- return (vma->vm_flags & VM_GROWSDOWN) &&
99839- (vma->vm_start == addr) &&
99840- !vma_growsdown(vma->vm_prev, addr);
99841-}
99842-
99843-/* Is the vma a continuation of the stack vma below it? */
99844-static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
99845-{
99846- return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
99847-}
99848-
99849-static inline int stack_guard_page_end(struct vm_area_struct *vma,
99850- unsigned long addr)
99851-{
99852- return (vma->vm_flags & VM_GROWSUP) &&
99853- (vma->vm_end == addr) &&
99854- !vma_growsup(vma->vm_next, addr);
99855-}
99856-
99857 extern struct task_struct *task_of_stack(struct task_struct *task,
99858 struct vm_area_struct *vma, bool in_group);
99859
99860@@ -1422,8 +1400,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
99861 {
99862 return 0;
99863 }
99864+
99865+static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
99866+ unsigned long address)
99867+{
99868+ return 0;
99869+}
99870 #else
99871 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
99872+int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
99873 #endif
99874
99875 #if defined(__PAGETABLE_PMD_FOLDED) || !defined(CONFIG_MMU)
99876@@ -1433,6 +1418,12 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
99877 return 0;
99878 }
99879
99880+static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
99881+ unsigned long address)
99882+{
99883+ return 0;
99884+}
99885+
99886 static inline void mm_nr_pmds_init(struct mm_struct *mm) {}
99887
99888 static inline unsigned long mm_nr_pmds(struct mm_struct *mm)
99889@@ -1445,6 +1436,7 @@ static inline void mm_dec_nr_pmds(struct mm_struct *mm) {}
99890
99891 #else
99892 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
99893+int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
99894
99895 static inline void mm_nr_pmds_init(struct mm_struct *mm)
99896 {
99897@@ -1482,11 +1474,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
99898 NULL: pud_offset(pgd, address);
99899 }
99900
99901+static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
99902+{
99903+ return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
99904+ NULL: pud_offset(pgd, address);
99905+}
99906+
99907 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
99908 {
99909 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
99910 NULL: pmd_offset(pud, address);
99911 }
99912+
99913+static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
99914+{
99915+ return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
99916+ NULL: pmd_offset(pud, address);
99917+}
99918 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
99919
99920 #if USE_SPLIT_PTE_PTLOCKS
99921@@ -1867,12 +1871,23 @@ extern struct vm_area_struct *copy_vma(struct vm_area_struct **,
99922 bool *need_rmap_locks);
99923 extern void exit_mmap(struct mm_struct *);
99924
99925+#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
99926+extern void gr_learn_resource(const struct task_struct *task, const int res,
99927+ const unsigned long wanted, const int gt);
99928+#else
99929+static inline void gr_learn_resource(const struct task_struct *task, const int res,
99930+ const unsigned long wanted, const int gt)
99931+{
99932+}
99933+#endif
99934+
99935 static inline int check_data_rlimit(unsigned long rlim,
99936 unsigned long new,
99937 unsigned long start,
99938 unsigned long end_data,
99939 unsigned long start_data)
99940 {
99941+ gr_learn_resource(current, RLIMIT_DATA, (new - start) + (end_data - start_data), 1);
99942 if (rlim < RLIM_INFINITY) {
99943 if (((new - start) + (end_data - start_data)) > rlim)
99944 return -ENOSPC;
99945@@ -1905,6 +1920,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
99946 unsigned long len, unsigned long prot, unsigned long flags,
99947 unsigned long pgoff, unsigned long *populate);
99948 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
99949+extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
99950
99951 #ifdef CONFIG_MMU
99952 extern int __mm_populate(unsigned long addr, unsigned long len,
99953@@ -1933,10 +1949,11 @@ struct vm_unmapped_area_info {
99954 unsigned long high_limit;
99955 unsigned long align_mask;
99956 unsigned long align_offset;
99957+ unsigned long threadstack_offset;
99958 };
99959
99960-extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
99961-extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
99962+extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
99963+extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
99964
99965 /*
99966 * Search for an unmapped address range.
99967@@ -1948,7 +1965,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
99968 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
99969 */
99970 static inline unsigned long
99971-vm_unmapped_area(struct vm_unmapped_area_info *info)
99972+vm_unmapped_area(const struct vm_unmapped_area_info *info)
99973 {
99974 if (info->flags & VM_UNMAPPED_AREA_TOPDOWN)
99975 return unmapped_area_topdown(info);
99976@@ -2010,6 +2027,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
99977 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
99978 struct vm_area_struct **pprev);
99979
99980+extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
99981+extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
99982+extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
99983+
99984 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
99985 NULL if none. Assume start_addr < end_addr. */
99986 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
99987@@ -2039,10 +2060,10 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
99988 }
99989
99990 #ifdef CONFIG_MMU
99991-pgprot_t vm_get_page_prot(unsigned long vm_flags);
99992+pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
99993 void vma_set_page_prot(struct vm_area_struct *vma);
99994 #else
99995-static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
99996+static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
99997 {
99998 return __pgprot(0);
99999 }
100000@@ -2104,6 +2125,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
100001 static inline void vm_stat_account(struct mm_struct *mm,
100002 unsigned long flags, struct file *file, long pages)
100003 {
100004+
100005+#ifdef CONFIG_PAX_RANDMMAP
100006+ if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
100007+#endif
100008+
100009 mm->total_vm += pages;
100010 }
100011 #endif /* CONFIG_PROC_FS */
100012@@ -2207,7 +2233,7 @@ extern int get_hwpoison_page(struct page *page);
100013 extern int sysctl_memory_failure_early_kill;
100014 extern int sysctl_memory_failure_recovery;
100015 extern void shake_page(struct page *p, int access);
100016-extern atomic_long_t num_poisoned_pages;
100017+extern atomic_long_unchecked_t num_poisoned_pages;
100018 extern int soft_offline_page(struct page *page, int flags);
100019
100020
100021@@ -2292,5 +2318,11 @@ void __init setup_nr_node_ids(void);
100022 static inline void setup_nr_node_ids(void) {}
100023 #endif
100024
100025+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
100026+extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
100027+#else
100028+static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
100029+#endif
100030+
100031 #endif /* __KERNEL__ */
100032 #endif /* _LINUX_MM_H */
100033diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
100034index 1554957..0973bc5 100644
100035--- a/include/linux/mm_types.h
100036+++ b/include/linux/mm_types.h
100037@@ -322,7 +322,9 @@ struct vm_area_struct {
100038 #ifdef CONFIG_NUMA
100039 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
100040 #endif
100041-};
100042+
100043+ struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
100044+} __randomize_layout;
100045
100046 struct core_thread {
100047 struct task_struct *task;
100048@@ -475,7 +477,25 @@ struct mm_struct {
100049 /* address of the bounds directory */
100050 void __user *bd_addr;
100051 #endif
100052-};
100053+
100054+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
100055+ unsigned long pax_flags;
100056+#endif
100057+
100058+#ifdef CONFIG_PAX_DLRESOLVE
100059+ unsigned long call_dl_resolve;
100060+#endif
100061+
100062+#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
100063+ unsigned long call_syscall;
100064+#endif
100065+
100066+#ifdef CONFIG_PAX_ASLR
100067+ unsigned long delta_mmap; /* randomized offset */
100068+ unsigned long delta_stack; /* randomized offset */
100069+#endif
100070+
100071+} __randomize_layout;
100072
100073 static inline void mm_init_cpumask(struct mm_struct *mm)
100074 {
100075diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
100076index 3ba327a..85cd5ce 100644
100077--- a/include/linux/mmiotrace.h
100078+++ b/include/linux/mmiotrace.h
100079@@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
100080 /* Called from ioremap.c */
100081 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
100082 void __iomem *addr);
100083-extern void mmiotrace_iounmap(volatile void __iomem *addr);
100084+extern void mmiotrace_iounmap(const volatile void __iomem *addr);
100085
100086 /* For anyone to insert markers. Remember trailing newline. */
100087 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
100088@@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
100089 {
100090 }
100091
100092-static inline void mmiotrace_iounmap(volatile void __iomem *addr)
100093+static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
100094 {
100095 }
100096
100097diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
100098index 754c259..7b65ac6 100644
100099--- a/include/linux/mmzone.h
100100+++ b/include/linux/mmzone.h
100101@@ -526,7 +526,7 @@ struct zone {
100102
100103 ZONE_PADDING(_pad3_)
100104 /* Zone statistics */
100105- atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
100106+ atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
100107 } ____cacheline_internodealigned_in_smp;
100108
100109 enum zone_flags {
100110diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
100111index 34f25b7..0586069 100644
100112--- a/include/linux/mod_devicetable.h
100113+++ b/include/linux/mod_devicetable.h
100114@@ -139,7 +139,7 @@ struct usb_device_id {
100115 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
100116 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
100117
100118-#define HID_ANY_ID (~0)
100119+#define HID_ANY_ID (~0U)
100120 #define HID_BUS_ANY 0xffff
100121 #define HID_GROUP_ANY 0x0000
100122
100123@@ -472,7 +472,7 @@ struct dmi_system_id {
100124 const char *ident;
100125 struct dmi_strmatch matches[4];
100126 void *driver_data;
100127-};
100128+} __do_const;
100129 /*
100130 * struct dmi_device_id appears during expansion of
100131 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
100132diff --git a/include/linux/module.h b/include/linux/module.h
100133index 3a19c79..dea8c47 100644
100134--- a/include/linux/module.h
100135+++ b/include/linux/module.h
100136@@ -19,9 +19,11 @@
100137 #include <linux/jump_label.h>
100138 #include <linux/export.h>
100139 #include <linux/rbtree_latch.h>
100140+#include <linux/fs.h>
100141
100142 #include <linux/percpu.h>
100143 #include <asm/module.h>
100144+#include <asm/pgtable.h>
100145
100146 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
100147 #define MODULE_SIG_STRING "~Module signature appended~\n"
100148@@ -44,7 +46,7 @@ struct module_kobject {
100149 struct kobject *drivers_dir;
100150 struct module_param_attrs *mp;
100151 struct completion *kobj_completion;
100152-};
100153+} __randomize_layout;
100154
100155 struct module_attribute {
100156 struct attribute attr;
100157@@ -56,12 +58,13 @@ struct module_attribute {
100158 int (*test)(struct module *);
100159 void (*free)(struct module *);
100160 };
100161+typedef struct module_attribute __no_const module_attribute_no_const;
100162
100163 struct module_version_attribute {
100164 struct module_attribute mattr;
100165 const char *module_name;
100166 const char *version;
100167-} __attribute__ ((__aligned__(sizeof(void *))));
100168+} __do_const __attribute__ ((__aligned__(sizeof(void *))));
100169
100170 extern ssize_t __modver_version_show(struct module_attribute *,
100171 struct module_kobject *, char *);
100172@@ -313,7 +316,7 @@ struct module {
100173
100174 /* Sysfs stuff. */
100175 struct module_kobject mkobj;
100176- struct module_attribute *modinfo_attrs;
100177+ module_attribute_no_const *modinfo_attrs;
100178 const char *version;
100179 const char *srcversion;
100180 struct kobject *holders_dir;
100181@@ -370,20 +373,21 @@ struct module {
100182 * If this is non-NULL, vfree() after init() returns.
100183 *
100184 * Cacheline align here, such that:
100185- * module_init, module_core, init_size, core_size,
100186+ * module_init_*, module_core_*, init_size_*, core_size_*,
100187 * init_text_size, core_text_size and mtn_core::{mod,node[0]}
100188 * are on the same cacheline.
100189 */
100190- void *module_init ____cacheline_aligned;
100191+ void *module_init_rw ____cacheline_aligned;
100192+ void *module_init_rx;
100193
100194 /* Here is the actual code + data, vfree'd on unload. */
100195- void *module_core;
100196+ void *module_core_rx, *module_core_rw;
100197
100198 /* Here are the sizes of the init and core sections */
100199- unsigned int init_size, core_size;
100200+ unsigned int init_size_rw, core_size_rw;
100201
100202 /* The size of the executable code in each section. */
100203- unsigned int init_text_size, core_text_size;
100204+ unsigned int init_size_rx, core_size_rx;
100205
100206 #ifdef CONFIG_MODULES_TREE_LOOKUP
100207 /*
100208@@ -391,13 +395,12 @@ struct module {
100209 * above entries such that a regular lookup will only touch one
100210 * cacheline.
100211 */
100212- struct mod_tree_node mtn_core;
100213- struct mod_tree_node mtn_init;
100214+ struct mod_tree_node mtn_core_rw;
100215+ struct mod_tree_node mtn_core_rx;
100216+ struct mod_tree_node mtn_init_rw;
100217+ struct mod_tree_node mtn_init_rx;
100218 #endif
100219
100220- /* Size of RO sections of the module (text+rodata) */
100221- unsigned int init_ro_size, core_ro_size;
100222-
100223 /* Arch-specific module values */
100224 struct mod_arch_specific arch;
100225
100226@@ -454,6 +457,10 @@ struct module {
100227 unsigned int num_trace_events;
100228 struct trace_enum_map **trace_enums;
100229 unsigned int num_trace_enums;
100230+ struct file_operations trace_id;
100231+ struct file_operations trace_enable;
100232+ struct file_operations trace_format;
100233+ struct file_operations trace_filter;
100234 #endif
100235 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
100236 unsigned int num_ftrace_callsites;
100237@@ -481,7 +488,8 @@ struct module {
100238 ctor_fn_t *ctors;
100239 unsigned int num_ctors;
100240 #endif
100241-} ____cacheline_aligned;
100242+} ____cacheline_aligned __randomize_layout;
100243+
100244 #ifndef MODULE_ARCH_INIT
100245 #define MODULE_ARCH_INIT {}
100246 #endif
100247@@ -502,18 +510,48 @@ bool is_module_address(unsigned long addr);
100248 bool is_module_percpu_address(unsigned long addr);
100249 bool is_module_text_address(unsigned long addr);
100250
100251+static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
100252+{
100253+
100254+#ifdef CONFIG_PAX_KERNEXEC
100255+ if (ktla_ktva(addr) >= (unsigned long)start &&
100256+ ktla_ktva(addr) < (unsigned long)start + size)
100257+ return 1;
100258+#endif
100259+
100260+ return ((void *)addr >= start && (void *)addr < start + size);
100261+}
100262+
100263+static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
100264+{
100265+ return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
100266+}
100267+
100268+static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
100269+{
100270+ return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
100271+}
100272+
100273+static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
100274+{
100275+ return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
100276+}
100277+
100278+static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
100279+{
100280+ return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
100281+}
100282+
100283 static inline bool within_module_core(unsigned long addr,
100284 const struct module *mod)
100285 {
100286- return (unsigned long)mod->module_core <= addr &&
100287- addr < (unsigned long)mod->module_core + mod->core_size;
100288+ return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
100289 }
100290
100291 static inline bool within_module_init(unsigned long addr,
100292 const struct module *mod)
100293 {
100294- return (unsigned long)mod->module_init <= addr &&
100295- addr < (unsigned long)mod->module_init + mod->init_size;
100296+ return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
100297 }
100298
100299 static inline bool within_module(unsigned long addr, const struct module *mod)
100300diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
100301index 4d0cb9b..3169ac7 100644
100302--- a/include/linux/moduleloader.h
100303+++ b/include/linux/moduleloader.h
100304@@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
100305 sections. Returns NULL on failure. */
100306 void *module_alloc(unsigned long size);
100307
100308+#ifdef CONFIG_PAX_KERNEXEC
100309+void *module_alloc_exec(unsigned long size);
100310+#else
100311+#define module_alloc_exec(x) module_alloc(x)
100312+#endif
100313+
100314 /* Free memory returned from module_alloc. */
100315 void module_memfree(void *module_region);
100316
100317+#ifdef CONFIG_PAX_KERNEXEC
100318+void module_memfree_exec(void *module_region);
100319+#else
100320+#define module_memfree_exec(x) module_memfree((x))
100321+#endif
100322+
100323 /*
100324 * Apply the given relocation to the (simplified) ELF. Return -error
100325 * or 0.
100326@@ -45,8 +57,10 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
100327 unsigned int relsec,
100328 struct module *me)
100329 {
100330+#ifdef CONFIG_MODULES
100331 printk(KERN_ERR "module %s: REL relocation unsupported\n",
100332 module_name(me));
100333+#endif
100334 return -ENOEXEC;
100335 }
100336 #endif
100337@@ -68,8 +82,10 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
100338 unsigned int relsec,
100339 struct module *me)
100340 {
100341+#ifdef CONFIG_MODULES
100342 printk(KERN_ERR "module %s: REL relocation unsupported\n",
100343 module_name(me));
100344+#endif
100345 return -ENOEXEC;
100346 }
100347 #endif
100348diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
100349index c12f214..3ef907f 100644
100350--- a/include/linux/moduleparam.h
100351+++ b/include/linux/moduleparam.h
100352@@ -289,7 +289,7 @@ static inline void kernel_param_unlock(struct module *mod)
100353 * @len is usually just sizeof(string).
100354 */
100355 #define module_param_string(name, string, len, perm) \
100356- static const struct kparam_string __param_string_##name \
100357+ static const struct kparam_string __param_string_##name __used \
100358 = { len, string }; \
100359 __module_param_call(MODULE_PARAM_PREFIX, name, \
100360 &param_ops_string, \
100361@@ -440,7 +440,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
100362 */
100363 #define module_param_array_named(name, array, type, nump, perm) \
100364 param_check_##type(name, &(array)[0]); \
100365- static const struct kparam_array __param_arr_##name \
100366+ static const struct kparam_array __param_arr_##name __used \
100367 = { .max = ARRAY_SIZE(array), .num = nump, \
100368 .ops = &param_ops_##type, \
100369 .elemsize = sizeof(array[0]), .elem = array }; \
100370diff --git a/include/linux/mount.h b/include/linux/mount.h
100371index f822c3c..958ca0a 100644
100372--- a/include/linux/mount.h
100373+++ b/include/linux/mount.h
100374@@ -67,7 +67,7 @@ struct vfsmount {
100375 struct dentry *mnt_root; /* root of the mounted tree */
100376 struct super_block *mnt_sb; /* pointer to superblock */
100377 int mnt_flags;
100378-};
100379+} __randomize_layout;
100380
100381 struct file; /* forward dec */
100382 struct path;
100383diff --git a/include/linux/net.h b/include/linux/net.h
100384index 04aa068..8a24df5 100644
100385--- a/include/linux/net.h
100386+++ b/include/linux/net.h
100387@@ -189,7 +189,7 @@ struct net_proto_family {
100388 int (*create)(struct net *net, struct socket *sock,
100389 int protocol, int kern);
100390 struct module *owner;
100391-};
100392+} __do_const;
100393
100394 struct iovec;
100395 struct kvec;
100396diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
100397index e20979d..3c7827b 100644
100398--- a/include/linux/netdevice.h
100399+++ b/include/linux/netdevice.h
100400@@ -1212,6 +1212,7 @@ struct net_device_ops {
100401 u32 maxrate);
100402 int (*ndo_get_iflink)(const struct net_device *dev);
100403 };
100404+typedef struct net_device_ops __no_const net_device_ops_no_const;
100405
100406 /**
100407 * enum net_device_priv_flags - &struct net_device priv_flags
100408@@ -1519,7 +1520,7 @@ struct net_device {
100409 unsigned long base_addr;
100410 int irq;
100411
100412- atomic_t carrier_changes;
100413+ atomic_unchecked_t carrier_changes;
100414
100415 /*
100416 * Some hardware also needs these fields (state,dev_list,
100417@@ -1558,8 +1559,8 @@ struct net_device {
100418
100419 struct net_device_stats stats;
100420
100421- atomic_long_t rx_dropped;
100422- atomic_long_t tx_dropped;
100423+ atomic_long_unchecked_t rx_dropped;
100424+ atomic_long_unchecked_t tx_dropped;
100425
100426 #ifdef CONFIG_WIRELESS_EXT
100427 const struct iw_handler_def * wireless_handlers;
100428diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
100429index 00050df..0bc7081 100644
100430--- a/include/linux/netfilter.h
100431+++ b/include/linux/netfilter.h
100432@@ -115,7 +115,7 @@ struct nf_sockopt_ops {
100433 #endif
100434 /* Use the module struct to lock set/get code in place */
100435 struct module *owner;
100436-};
100437+} __do_const;
100438
100439 /* Function to register/unregister hook points. */
100440 int nf_register_hook(struct nf_hook_ops *reg);
100441diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
100442index e955d47..04a5338 100644
100443--- a/include/linux/netfilter/nfnetlink.h
100444+++ b/include/linux/netfilter/nfnetlink.h
100445@@ -19,7 +19,7 @@ struct nfnl_callback {
100446 const struct nlattr * const cda[]);
100447 const struct nla_policy *policy; /* netlink attribute policy */
100448 const u_int16_t attr_count; /* number of nlattr's */
100449-};
100450+} __do_const;
100451
100452 struct nfnetlink_subsystem {
100453 const char *name;
100454diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
100455new file mode 100644
100456index 0000000..33f4af8
100457--- /dev/null
100458+++ b/include/linux/netfilter/xt_gradm.h
100459@@ -0,0 +1,9 @@
100460+#ifndef _LINUX_NETFILTER_XT_GRADM_H
100461+#define _LINUX_NETFILTER_XT_GRADM_H 1
100462+
100463+struct xt_gradm_mtinfo {
100464+ __u16 flags;
100465+ __u16 invflags;
100466+};
100467+
100468+#endif
100469diff --git a/include/linux/nls.h b/include/linux/nls.h
100470index 520681b..2b7fabb 100644
100471--- a/include/linux/nls.h
100472+++ b/include/linux/nls.h
100473@@ -31,7 +31,7 @@ struct nls_table {
100474 const unsigned char *charset2upper;
100475 struct module *owner;
100476 struct nls_table *next;
100477-};
100478+} __do_const;
100479
100480 /* this value hold the maximum octet of charset */
100481 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
100482@@ -46,7 +46,7 @@ enum utf16_endian {
100483 /* nls_base.c */
100484 extern int __register_nls(struct nls_table *, struct module *);
100485 extern int unregister_nls(struct nls_table *);
100486-extern struct nls_table *load_nls(char *);
100487+extern struct nls_table *load_nls(const char *);
100488 extern void unload_nls(struct nls_table *);
100489 extern struct nls_table *load_nls_default(void);
100490 #define register_nls(nls) __register_nls((nls), THIS_MODULE)
100491diff --git a/include/linux/notifier.h b/include/linux/notifier.h
100492index d14a4c3..a078786 100644
100493--- a/include/linux/notifier.h
100494+++ b/include/linux/notifier.h
100495@@ -54,7 +54,8 @@ struct notifier_block {
100496 notifier_fn_t notifier_call;
100497 struct notifier_block __rcu *next;
100498 int priority;
100499-};
100500+} __do_const;
100501+typedef struct notifier_block __no_const notifier_block_no_const;
100502
100503 struct atomic_notifier_head {
100504 spinlock_t lock;
100505diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
100506index b2a0f15..4d7da32 100644
100507--- a/include/linux/oprofile.h
100508+++ b/include/linux/oprofile.h
100509@@ -138,9 +138,9 @@ int oprofilefs_create_ulong(struct dentry * root,
100510 int oprofilefs_create_ro_ulong(struct dentry * root,
100511 char const * name, ulong * val);
100512
100513-/** Create a file for read-only access to an atomic_t. */
100514+/** Create a file for read-only access to an atomic_unchecked_t. */
100515 int oprofilefs_create_ro_atomic(struct dentry * root,
100516- char const * name, atomic_t * val);
100517+ char const * name, atomic_unchecked_t * val);
100518
100519 /** create a directory */
100520 struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name);
100521diff --git a/include/linux/overflow-arith.h b/include/linux/overflow-arith.h
100522new file mode 100644
100523index 0000000..e12ccf8
100524--- /dev/null
100525+++ b/include/linux/overflow-arith.h
100526@@ -0,0 +1,18 @@
100527+#pragma once
100528+
100529+#include <linux/kernel.h>
100530+
100531+#ifdef CC_HAVE_BUILTIN_OVERFLOW
100532+
100533+#define overflow_usub __builtin_usub_overflow
100534+
100535+#else
100536+
100537+static inline bool overflow_usub(unsigned int a, unsigned int b,
100538+ unsigned int *res)
100539+{
100540+ *res = a - b;
100541+ return *res > a ? true : false;
100542+}
100543+
100544+#endif
100545diff --git a/include/linux/padata.h b/include/linux/padata.h
100546index 4386946..f50c615 100644
100547--- a/include/linux/padata.h
100548+++ b/include/linux/padata.h
100549@@ -129,7 +129,7 @@ struct parallel_data {
100550 struct padata_serial_queue __percpu *squeue;
100551 atomic_t reorder_objects;
100552 atomic_t refcnt;
100553- atomic_t seq_nr;
100554+ atomic_unchecked_t seq_nr;
100555 struct padata_cpumask cpumask;
100556 spinlock_t lock ____cacheline_aligned;
100557 unsigned int processed;
100558diff --git a/include/linux/path.h b/include/linux/path.h
100559index d137218..be0c176 100644
100560--- a/include/linux/path.h
100561+++ b/include/linux/path.h
100562@@ -1,13 +1,15 @@
100563 #ifndef _LINUX_PATH_H
100564 #define _LINUX_PATH_H
100565
100566+#include <linux/compiler.h>
100567+
100568 struct dentry;
100569 struct vfsmount;
100570
100571 struct path {
100572 struct vfsmount *mnt;
100573 struct dentry *dentry;
100574-};
100575+} __randomize_layout;
100576
100577 extern void path_get(const struct path *);
100578 extern void path_put(const struct path *);
100579diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
100580index 8c78950..0d74ed9 100644
100581--- a/include/linux/pci_hotplug.h
100582+++ b/include/linux/pci_hotplug.h
100583@@ -71,7 +71,8 @@ struct hotplug_slot_ops {
100584 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
100585 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
100586 int (*reset_slot) (struct hotplug_slot *slot, int probe);
100587-};
100588+} __do_const;
100589+typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
100590
100591 /**
100592 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
100593diff --git a/include/linux/percpu.h b/include/linux/percpu.h
100594index caebf2a..4c3ae9d 100644
100595--- a/include/linux/percpu.h
100596+++ b/include/linux/percpu.h
100597@@ -34,7 +34,7 @@
100598 * preallocate for this. Keep PERCPU_DYNAMIC_RESERVE equal to or
100599 * larger than PERCPU_DYNAMIC_EARLY_SIZE.
100600 */
100601-#define PERCPU_DYNAMIC_EARLY_SLOTS 128
100602+#define PERCPU_DYNAMIC_EARLY_SLOTS 256
100603 #define PERCPU_DYNAMIC_EARLY_SIZE (12 << 10)
100604
100605 /*
100606diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
100607index 2027809..c9cd38e 100644
100608--- a/include/linux/perf_event.h
100609+++ b/include/linux/perf_event.h
100610@@ -384,8 +384,8 @@ struct perf_event {
100611
100612 enum perf_event_active_state state;
100613 unsigned int attach_state;
100614- local64_t count;
100615- atomic64_t child_count;
100616+ local64_t count; /* PaX: fix it one day */
100617+ atomic64_unchecked_t child_count;
100618
100619 /*
100620 * These are the total time in nanoseconds that the event
100621@@ -436,8 +436,8 @@ struct perf_event {
100622 * These accumulate total time (in nanoseconds) that children
100623 * events have been enabled and running, respectively.
100624 */
100625- atomic64_t child_total_time_enabled;
100626- atomic64_t child_total_time_running;
100627+ atomic64_unchecked_t child_total_time_enabled;
100628+ atomic64_unchecked_t child_total_time_running;
100629
100630 /*
100631 * Protect attach/detach and child_list:
100632@@ -859,7 +859,7 @@ static inline void perf_event_task_sched_out(struct task_struct *prev,
100633
100634 static inline u64 __perf_event_count(struct perf_event *event)
100635 {
100636- return local64_read(&event->count) + atomic64_read(&event->child_count);
100637+ return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
100638 }
100639
100640 extern void perf_event_mmap(struct vm_area_struct *vma);
100641@@ -883,7 +883,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
100642 entry->ip[entry->nr++] = ip;
100643 }
100644
100645-extern int sysctl_perf_event_paranoid;
100646+extern int sysctl_perf_event_legitimately_concerned;
100647 extern int sysctl_perf_event_mlock;
100648 extern int sysctl_perf_event_sample_rate;
100649 extern int sysctl_perf_cpu_time_max_percent;
100650@@ -898,19 +898,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
100651 loff_t *ppos);
100652
100653
100654+static inline bool perf_paranoid_any(void)
100655+{
100656+ return sysctl_perf_event_legitimately_concerned > 2;
100657+}
100658+
100659 static inline bool perf_paranoid_tracepoint_raw(void)
100660 {
100661- return sysctl_perf_event_paranoid > -1;
100662+ return sysctl_perf_event_legitimately_concerned > -1;
100663 }
100664
100665 static inline bool perf_paranoid_cpu(void)
100666 {
100667- return sysctl_perf_event_paranoid > 0;
100668+ return sysctl_perf_event_legitimately_concerned > 0;
100669 }
100670
100671 static inline bool perf_paranoid_kernel(void)
100672 {
100673- return sysctl_perf_event_paranoid > 1;
100674+ return sysctl_perf_event_legitimately_concerned > 1;
100675 }
100676
100677 extern void perf_event_init(void);
100678@@ -1066,7 +1071,7 @@ struct perf_pmu_events_attr {
100679 struct device_attribute attr;
100680 u64 id;
100681 const char *event_str;
100682-};
100683+} __do_const;
100684
100685 ssize_t perf_event_sysfs_show(struct device *dev, struct device_attribute *attr,
100686 char *page);
100687diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
100688index 918b117..7af374b7 100644
100689--- a/include/linux/pid_namespace.h
100690+++ b/include/linux/pid_namespace.h
100691@@ -45,7 +45,7 @@ struct pid_namespace {
100692 int hide_pid;
100693 int reboot; /* group exit code if this pidns was rebooted */
100694 struct ns_common ns;
100695-};
100696+} __randomize_layout;
100697
100698 extern struct pid_namespace init_pid_ns;
100699
100700diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
100701index eb8b8ac..62649e1 100644
100702--- a/include/linux/pipe_fs_i.h
100703+++ b/include/linux/pipe_fs_i.h
100704@@ -47,10 +47,10 @@ struct pipe_inode_info {
100705 struct mutex mutex;
100706 wait_queue_head_t wait;
100707 unsigned int nrbufs, curbuf, buffers;
100708- unsigned int readers;
100709- unsigned int writers;
100710- unsigned int files;
100711- unsigned int waiting_writers;
100712+ atomic_t readers;
100713+ atomic_t writers;
100714+ atomic_t files;
100715+ atomic_t waiting_writers;
100716 unsigned int r_counter;
100717 unsigned int w_counter;
100718 struct page *tmp_page;
100719diff --git a/include/linux/pm.h b/include/linux/pm.h
100720index 35d599e..c604209 100644
100721--- a/include/linux/pm.h
100722+++ b/include/linux/pm.h
100723@@ -630,6 +630,7 @@ struct dev_pm_domain {
100724 void (*sync)(struct device *dev);
100725 void (*dismiss)(struct device *dev);
100726 };
100727+typedef struct dev_pm_domain __no_const dev_pm_domain_no_const;
100728
100729 /*
100730 * The PM_EVENT_ messages are also used by drivers implementing the legacy
100731diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
100732index 681ccb0..a90e0b7 100644
100733--- a/include/linux/pm_domain.h
100734+++ b/include/linux/pm_domain.h
100735@@ -39,11 +39,11 @@ struct gpd_dev_ops {
100736 int (*save_state)(struct device *dev);
100737 int (*restore_state)(struct device *dev);
100738 bool (*active_wakeup)(struct device *dev);
100739-};
100740+} __no_const;
100741
100742 struct gpd_cpuidle_data {
100743 unsigned int saved_exit_latency;
100744- struct cpuidle_state *idle_state;
100745+ cpuidle_state_no_const *idle_state;
100746 };
100747
100748 struct generic_pm_domain {
100749diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
100750index 30e84d4..22278b4 100644
100751--- a/include/linux/pm_runtime.h
100752+++ b/include/linux/pm_runtime.h
100753@@ -115,7 +115,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
100754
100755 static inline void pm_runtime_mark_last_busy(struct device *dev)
100756 {
100757- ACCESS_ONCE(dev->power.last_busy) = jiffies;
100758+ ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
100759 }
100760
100761 static inline bool pm_runtime_is_irq_safe(struct device *dev)
100762diff --git a/include/linux/pnp.h b/include/linux/pnp.h
100763index 5df733b..d55f252 100644
100764--- a/include/linux/pnp.h
100765+++ b/include/linux/pnp.h
100766@@ -298,7 +298,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
100767 struct pnp_fixup {
100768 char id[7];
100769 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
100770-};
100771+} __do_const;
100772
100773 /* config parameters */
100774 #define PNP_CONFIG_NORMAL 0x0001
100775diff --git a/include/linux/poison.h b/include/linux/poison.h
100776index 2110a81..13a11bb 100644
100777--- a/include/linux/poison.h
100778+++ b/include/linux/poison.h
100779@@ -19,8 +19,8 @@
100780 * under normal circumstances, used to verify that nobody uses
100781 * non-initialized list entries.
100782 */
100783-#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
100784-#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
100785+#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
100786+#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
100787
100788 /********** include/linux/timer.h **********/
100789 /*
100790diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
100791index d8b187c3..9a9257a 100644
100792--- a/include/linux/power/smartreflex.h
100793+++ b/include/linux/power/smartreflex.h
100794@@ -238,7 +238,7 @@ struct omap_sr_class_data {
100795 int (*notify)(struct omap_sr *sr, u32 status);
100796 u8 notify_flags;
100797 u8 class_type;
100798-};
100799+} __do_const;
100800
100801 /**
100802 * struct omap_sr_nvalue_table - Smartreflex n-target value info
100803diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
100804index 4ea1d37..80f4b33 100644
100805--- a/include/linux/ppp-comp.h
100806+++ b/include/linux/ppp-comp.h
100807@@ -84,7 +84,7 @@ struct compressor {
100808 struct module *owner;
100809 /* Extra skb space needed by the compressor algorithm */
100810 unsigned int comp_extra;
100811-};
100812+} __do_const;
100813
100814 /*
100815 * The return value from decompress routine is the length of the
100816diff --git a/include/linux/preempt.h b/include/linux/preempt.h
100817index bea8dd8..534a23d 100644
100818--- a/include/linux/preempt.h
100819+++ b/include/linux/preempt.h
100820@@ -140,11 +140,16 @@ extern void preempt_count_sub(int val);
100821 #define preempt_count_dec_and_test() __preempt_count_dec_and_test()
100822 #endif
100823
100824+#define raw_preempt_count_add(val) __preempt_count_add(val)
100825+#define raw_preempt_count_sub(val) __preempt_count_sub(val)
100826+
100827 #define __preempt_count_inc() __preempt_count_add(1)
100828 #define __preempt_count_dec() __preempt_count_sub(1)
100829
100830 #define preempt_count_inc() preempt_count_add(1)
100831+#define raw_preempt_count_inc() raw_preempt_count_add(1)
100832 #define preempt_count_dec() preempt_count_sub(1)
100833+#define raw_preempt_count_dec() raw_preempt_count_sub(1)
100834
100835 #define preempt_active_enter() \
100836 do { \
100837@@ -166,6 +171,12 @@ do { \
100838 barrier(); \
100839 } while (0)
100840
100841+#define raw_preempt_disable() \
100842+do { \
100843+ raw_preempt_count_inc(); \
100844+ barrier(); \
100845+} while (0)
100846+
100847 #define sched_preempt_enable_no_resched() \
100848 do { \
100849 barrier(); \
100850@@ -174,6 +185,12 @@ do { \
100851
100852 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
100853
100854+#define raw_preempt_enable_no_resched() \
100855+do { \
100856+ barrier(); \
100857+ raw_preempt_count_dec(); \
100858+} while (0)
100859+
100860 #define preemptible() (preempt_count() == 0 && !irqs_disabled())
100861
100862 #ifdef CONFIG_PREEMPT
100863@@ -234,8 +251,10 @@ do { \
100864 * region.
100865 */
100866 #define preempt_disable() barrier()
100867+#define raw_preempt_disable() barrier()
100868 #define sched_preempt_enable_no_resched() barrier()
100869 #define preempt_enable_no_resched() barrier()
100870+#define raw_preempt_enable_no_resched() barrier()
100871 #define preempt_enable() barrier()
100872 #define preempt_check_resched() do { } while (0)
100873
100874@@ -250,11 +269,13 @@ do { \
100875 /*
100876 * Modules have no business playing preemption tricks.
100877 */
100878+#ifndef CONFIG_PAX_KERNEXEC
100879 #undef sched_preempt_enable_no_resched
100880 #undef preempt_enable_no_resched
100881 #undef preempt_enable_no_resched_notrace
100882 #undef preempt_check_resched
100883 #endif
100884+#endif
100885
100886 #define preempt_set_need_resched() \
100887 do { \
100888diff --git a/include/linux/printk.h b/include/linux/printk.h
100889index a6298b2..57fe982 100644
100890--- a/include/linux/printk.h
100891+++ b/include/linux/printk.h
100892@@ -123,6 +123,7 @@ void early_printk(const char *s, ...) { }
100893 #endif
100894
100895 typedef __printf(1, 0) int (*printk_func_t)(const char *fmt, va_list args);
100896+extern int kptr_restrict;
100897
100898 #ifdef CONFIG_PRINTK
100899 asmlinkage __printf(5, 0)
100900@@ -158,7 +159,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
100901
100902 extern int printk_delay_msec;
100903 extern int dmesg_restrict;
100904-extern int kptr_restrict;
100905
100906 extern void wake_up_klogd(void);
100907
100908diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
100909index b97bf2e..f14c92d4 100644
100910--- a/include/linux/proc_fs.h
100911+++ b/include/linux/proc_fs.h
100912@@ -17,8 +17,11 @@ extern void proc_flush_task(struct task_struct *);
100913 extern struct proc_dir_entry *proc_symlink(const char *,
100914 struct proc_dir_entry *, const char *);
100915 extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);
100916+extern struct proc_dir_entry *proc_mkdir_restrict(const char *, struct proc_dir_entry *);
100917 extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
100918 struct proc_dir_entry *, void *);
100919+extern struct proc_dir_entry *proc_mkdir_data_restrict(const char *, umode_t,
100920+ struct proc_dir_entry *, void *);
100921 extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t,
100922 struct proc_dir_entry *);
100923
100924@@ -34,6 +37,19 @@ static inline struct proc_dir_entry *proc_create(
100925 return proc_create_data(name, mode, parent, proc_fops, NULL);
100926 }
100927
100928+static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
100929+ struct proc_dir_entry *parent, const struct file_operations *proc_fops)
100930+{
100931+#ifdef CONFIG_GRKERNSEC_PROC_USER
100932+ return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
100933+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
100934+ return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
100935+#else
100936+ return proc_create_data(name, mode, parent, proc_fops, NULL);
100937+#endif
100938+}
100939+
100940+
100941 extern void proc_set_size(struct proc_dir_entry *, loff_t);
100942 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
100943 extern void *PDE_DATA(const struct inode *);
100944@@ -56,8 +72,12 @@ static inline struct proc_dir_entry *proc_symlink(const char *name,
100945 struct proc_dir_entry *parent,const char *dest) { return NULL;}
100946 static inline struct proc_dir_entry *proc_mkdir(const char *name,
100947 struct proc_dir_entry *parent) {return NULL;}
100948+static inline struct proc_dir_entry *proc_mkdir_restrict(const char *name,
100949+ struct proc_dir_entry *parent) { return NULL; }
100950 static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
100951 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
100952+static inline struct proc_dir_entry *proc_mkdir_data_restrict(const char *name,
100953+ umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
100954 static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
100955 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
100956 #define proc_create(name, mode, parent, proc_fops) ({NULL;})
100957@@ -79,7 +99,7 @@ struct net;
100958 static inline struct proc_dir_entry *proc_net_mkdir(
100959 struct net *net, const char *name, struct proc_dir_entry *parent)
100960 {
100961- return proc_mkdir_data(name, 0, parent, net);
100962+ return proc_mkdir_data_restrict(name, 0, parent, net);
100963 }
100964
100965 #endif /* _LINUX_PROC_FS_H */
100966diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
100967index 42dfc61..8113a99 100644
100968--- a/include/linux/proc_ns.h
100969+++ b/include/linux/proc_ns.h
100970@@ -16,7 +16,7 @@ struct proc_ns_operations {
100971 struct ns_common *(*get)(struct task_struct *task);
100972 void (*put)(struct ns_common *ns);
100973 int (*install)(struct nsproxy *nsproxy, struct ns_common *ns);
100974-};
100975+} __do_const __randomize_layout;
100976
100977 extern const struct proc_ns_operations netns_operations;
100978 extern const struct proc_ns_operations utsns_operations;
100979diff --git a/include/linux/quota.h b/include/linux/quota.h
100980index b2505ac..5f7ab55 100644
100981--- a/include/linux/quota.h
100982+++ b/include/linux/quota.h
100983@@ -76,7 +76,7 @@ struct kqid { /* Type in which we store the quota identifier */
100984
100985 extern bool qid_eq(struct kqid left, struct kqid right);
100986 extern bool qid_lt(struct kqid left, struct kqid right);
100987-extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
100988+extern qid_t from_kqid(struct user_namespace *to, struct kqid qid) __intentional_overflow(-1);
100989 extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
100990 extern bool qid_valid(struct kqid qid);
100991
100992diff --git a/include/linux/random.h b/include/linux/random.h
100993index e651874..a872186 100644
100994--- a/include/linux/random.h
100995+++ b/include/linux/random.h
100996@@ -16,9 +16,19 @@ struct random_ready_callback {
100997 };
100998
100999 extern void add_device_randomness(const void *, unsigned int);
101000+
101001+static inline void add_latent_entropy(void)
101002+{
101003+
101004+#ifdef LATENT_ENTROPY_PLUGIN
101005+ add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
101006+#endif
101007+
101008+}
101009+
101010 extern void add_input_randomness(unsigned int type, unsigned int code,
101011- unsigned int value);
101012-extern void add_interrupt_randomness(int irq, int irq_flags);
101013+ unsigned int value) __latent_entropy;
101014+extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
101015
101016 extern void get_random_bytes(void *buf, int nbytes);
101017 extern int add_random_ready_callback(struct random_ready_callback *rdy);
101018@@ -46,6 +56,11 @@ struct rnd_state {
101019 u32 prandom_u32_state(struct rnd_state *state);
101020 void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes);
101021
101022+static inline unsigned long __intentional_overflow(-1) pax_get_random_long(void)
101023+{
101024+ return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
101025+}
101026+
101027 /**
101028 * prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro)
101029 * @ep_ro: right open interval endpoint
101030@@ -58,7 +73,7 @@ void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes);
101031 *
101032 * Returns: pseudo-random number in interval [0, ep_ro)
101033 */
101034-static inline u32 prandom_u32_max(u32 ep_ro)
101035+static inline u32 __intentional_overflow(-1) prandom_u32_max(u32 ep_ro)
101036 {
101037 return (u32)(((u64) prandom_u32() * ep_ro) >> 32);
101038 }
101039diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
101040index 14d7b83..a1edf56 100644
101041--- a/include/linux/rbtree_augmented.h
101042+++ b/include/linux/rbtree_augmented.h
101043@@ -90,7 +90,9 @@ rbname ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new) \
101044 old->rbaugmented = rbcompute(old); \
101045 } \
101046 rbstatic const struct rb_augment_callbacks rbname = { \
101047- rbname ## _propagate, rbname ## _copy, rbname ## _rotate \
101048+ .propagate = rbname ## _propagate, \
101049+ .copy = rbname ## _copy, \
101050+ .rotate = rbname ## _rotate \
101051 };
101052
101053
101054diff --git a/include/linux/rculist.h b/include/linux/rculist.h
101055index 17c6b1f..a65e3f8 100644
101056--- a/include/linux/rculist.h
101057+++ b/include/linux/rculist.h
101058@@ -59,6 +59,9 @@ void __list_add_rcu(struct list_head *new,
101059 struct list_head *prev, struct list_head *next);
101060 #endif
101061
101062+void __pax_list_add_rcu(struct list_head *new,
101063+ struct list_head *prev, struct list_head *next);
101064+
101065 /**
101066 * list_add_rcu - add a new entry to rcu-protected list
101067 * @new: new entry to be added
101068@@ -80,6 +83,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
101069 __list_add_rcu(new, head, head->next);
101070 }
101071
101072+static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
101073+{
101074+ __pax_list_add_rcu(new, head, head->next);
101075+}
101076+
101077 /**
101078 * list_add_tail_rcu - add a new entry to rcu-protected list
101079 * @new: new entry to be added
101080@@ -102,6 +110,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
101081 __list_add_rcu(new, head->prev, head);
101082 }
101083
101084+static inline void pax_list_add_tail_rcu(struct list_head *new,
101085+ struct list_head *head)
101086+{
101087+ __pax_list_add_rcu(new, head->prev, head);
101088+}
101089+
101090 /**
101091 * list_del_rcu - deletes entry from list without re-initialization
101092 * @entry: the element to delete from the list.
101093@@ -132,6 +146,8 @@ static inline void list_del_rcu(struct list_head *entry)
101094 entry->prev = LIST_POISON2;
101095 }
101096
101097+extern void pax_list_del_rcu(struct list_head *entry);
101098+
101099 /**
101100 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
101101 * @n: the element to delete from the hash list.
101102diff --git a/include/linux/reboot.h b/include/linux/reboot.h
101103index a7ff409..03e2fa8 100644
101104--- a/include/linux/reboot.h
101105+++ b/include/linux/reboot.h
101106@@ -47,9 +47,9 @@ extern void do_kernel_restart(char *cmd);
101107 */
101108
101109 extern void migrate_to_reboot_cpu(void);
101110-extern void machine_restart(char *cmd);
101111-extern void machine_halt(void);
101112-extern void machine_power_off(void);
101113+extern void machine_restart(char *cmd) __noreturn;
101114+extern void machine_halt(void) __noreturn;
101115+extern void machine_power_off(void) __noreturn;
101116
101117 extern void machine_shutdown(void);
101118 struct pt_regs;
101119@@ -60,9 +60,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
101120 */
101121
101122 extern void kernel_restart_prepare(char *cmd);
101123-extern void kernel_restart(char *cmd);
101124-extern void kernel_halt(void);
101125-extern void kernel_power_off(void);
101126+extern void kernel_restart(char *cmd) __noreturn;
101127+extern void kernel_halt(void) __noreturn;
101128+extern void kernel_power_off(void) __noreturn;
101129
101130 extern int C_A_D; /* for sysctl */
101131 void ctrl_alt_del(void);
101132@@ -77,7 +77,7 @@ extern void orderly_reboot(void);
101133 * Emergency restart, callable from an interrupt handler.
101134 */
101135
101136-extern void emergency_restart(void);
101137+extern void emergency_restart(void) __noreturn;
101138 #include <asm/emergency-restart.h>
101139
101140 #endif /* _LINUX_REBOOT_H */
101141diff --git a/include/linux/regset.h b/include/linux/regset.h
101142index 8e0c9fe..ac4d221 100644
101143--- a/include/linux/regset.h
101144+++ b/include/linux/regset.h
101145@@ -161,7 +161,8 @@ struct user_regset {
101146 unsigned int align;
101147 unsigned int bias;
101148 unsigned int core_note_type;
101149-};
101150+} __do_const;
101151+typedef struct user_regset __no_const user_regset_no_const;
101152
101153 /**
101154 * struct user_regset_view - available regsets
101155diff --git a/include/linux/relay.h b/include/linux/relay.h
101156index d7c8359..818daf5 100644
101157--- a/include/linux/relay.h
101158+++ b/include/linux/relay.h
101159@@ -157,7 +157,7 @@ struct rchan_callbacks
101160 * The callback should return 0 if successful, negative if not.
101161 */
101162 int (*remove_buf_file)(struct dentry *dentry);
101163-};
101164+} __no_const;
101165
101166 /*
101167 * CONFIG_RELAY kernel API, kernel/relay.c
101168diff --git a/include/linux/rio.h b/include/linux/rio.h
101169index cde976e..ebd6033 100644
101170--- a/include/linux/rio.h
101171+++ b/include/linux/rio.h
101172@@ -358,7 +358,7 @@ struct rio_ops {
101173 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
101174 u64 rstart, u32 size, u32 flags);
101175 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
101176-};
101177+} __no_const;
101178
101179 #define RIO_RESOURCE_MEM 0x00000100
101180 #define RIO_RESOURCE_DOORBELL 0x00000200
101181diff --git a/include/linux/rmap.h b/include/linux/rmap.h
101182index c89c53a..aa0a65a 100644
101183--- a/include/linux/rmap.h
101184+++ b/include/linux/rmap.h
101185@@ -146,8 +146,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
101186 void anon_vma_init(void); /* create anon_vma_cachep */
101187 int anon_vma_prepare(struct vm_area_struct *);
101188 void unlink_anon_vmas(struct vm_area_struct *);
101189-int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
101190-int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
101191+int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
101192+int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
101193
101194 static inline void anon_vma_merge(struct vm_area_struct *vma,
101195 struct vm_area_struct *next)
101196diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
101197index 9b1ef0c..9fa3feb 100644
101198--- a/include/linux/scatterlist.h
101199+++ b/include/linux/scatterlist.h
101200@@ -1,6 +1,7 @@
101201 #ifndef _LINUX_SCATTERLIST_H
101202 #define _LINUX_SCATTERLIST_H
101203
101204+#include <linux/sched.h>
101205 #include <linux/string.h>
101206 #include <linux/types.h>
101207 #include <linux/bug.h>
101208@@ -136,10 +137,17 @@ static inline struct page *sg_page(struct scatterlist *sg)
101209 static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
101210 unsigned int buflen)
101211 {
101212+ const void *realbuf = buf;
101213+
101214+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
101215+ if (object_starts_on_stack(buf))
101216+ realbuf = buf - current->stack + current->lowmem_stack;
101217+#endif
101218+
101219 #ifdef CONFIG_DEBUG_SG
101220- BUG_ON(!virt_addr_valid(buf));
101221+ BUG_ON(!virt_addr_valid(realbuf));
101222 #endif
101223- sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
101224+ sg_set_page(sg, virt_to_page(realbuf), buflen, offset_in_page(realbuf));
101225 }
101226
101227 /*
101228diff --git a/include/linux/sched.h b/include/linux/sched.h
101229index bfca8aa..c8b327c 100644
101230--- a/include/linux/sched.h
101231+++ b/include/linux/sched.h
101232@@ -7,7 +7,7 @@
101233
101234
101235 struct sched_param {
101236- int sched_priority;
101237+ unsigned int sched_priority;
101238 };
101239
101240 #include <asm/param.h> /* for HZ */
101241@@ -134,6 +134,7 @@ struct perf_event_context;
101242 struct blk_plug;
101243 struct filename;
101244 struct nameidata;
101245+struct linux_binprm;
101246
101247 #define VMACACHE_BITS 2
101248 #define VMACACHE_SIZE (1U << VMACACHE_BITS)
101249@@ -436,6 +437,19 @@ struct nsproxy;
101250 struct user_namespace;
101251
101252 #ifdef CONFIG_MMU
101253+
101254+#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
101255+extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
101256+#else
101257+static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
101258+{
101259+ return 0;
101260+}
101261+#endif
101262+
101263+extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
101264+extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
101265+
101266 extern void arch_pick_mmap_layout(struct mm_struct *mm);
101267 extern unsigned long
101268 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
101269@@ -749,6 +763,17 @@ struct signal_struct {
101270 #ifdef CONFIG_TASKSTATS
101271 struct taskstats *stats;
101272 #endif
101273+
101274+#ifdef CONFIG_GRKERNSEC
101275+ u32 curr_ip;
101276+ u32 saved_ip;
101277+ u32 gr_saddr;
101278+ u32 gr_daddr;
101279+ u16 gr_sport;
101280+ u16 gr_dport;
101281+ u8 used_accept:1;
101282+#endif
101283+
101284 #ifdef CONFIG_AUDIT
101285 unsigned audit_tty;
101286 unsigned audit_tty_log_passwd;
101287@@ -775,7 +800,7 @@ struct signal_struct {
101288 struct mutex cred_guard_mutex; /* guard against foreign influences on
101289 * credential calculations
101290 * (notably. ptrace) */
101291-};
101292+} __randomize_layout;
101293
101294 /*
101295 * Bits in flags field of signal_struct.
101296@@ -828,6 +853,14 @@ struct user_struct {
101297 struct key *session_keyring; /* UID's default session keyring */
101298 #endif
101299
101300+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
101301+ unsigned char kernel_banned;
101302+#endif
101303+#ifdef CONFIG_GRKERNSEC_BRUTE
101304+ unsigned char suid_banned;
101305+ unsigned long suid_ban_expires;
101306+#endif
101307+
101308 /* Hash table maintenance information */
101309 struct hlist_node uidhash_node;
101310 kuid_t uid;
101311@@ -835,7 +868,7 @@ struct user_struct {
101312 #ifdef CONFIG_PERF_EVENTS
101313 atomic_long_t locked_vm;
101314 #endif
101315-};
101316+} __randomize_layout;
101317
101318 extern int uids_sysfs_init(void);
101319
101320@@ -1356,6 +1389,9 @@ enum perf_event_task_context {
101321 struct task_struct {
101322 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
101323 void *stack;
101324+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
101325+ void *lowmem_stack;
101326+#endif
101327 atomic_t usage;
101328 unsigned int flags; /* per process flags, defined below */
101329 unsigned int ptrace;
101330@@ -1488,8 +1524,8 @@ struct task_struct {
101331 struct list_head thread_node;
101332
101333 struct completion *vfork_done; /* for vfork() */
101334- int __user *set_child_tid; /* CLONE_CHILD_SETTID */
101335- int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
101336+ pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
101337+ pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
101338
101339 cputime_t utime, stime, utimescaled, stimescaled;
101340 cputime_t gtime;
101341@@ -1514,11 +1550,6 @@ struct task_struct {
101342 struct task_cputime cputime_expires;
101343 struct list_head cpu_timers[3];
101344
101345-/* process credentials */
101346- const struct cred __rcu *real_cred; /* objective and real subjective task
101347- * credentials (COW) */
101348- const struct cred __rcu *cred; /* effective (overridable) subjective task
101349- * credentials (COW) */
101350 char comm[TASK_COMM_LEN]; /* executable name excluding path
101351 - access with [gs]et_task_comm (which lock
101352 it with task_lock())
101353@@ -1610,6 +1641,10 @@ struct task_struct {
101354 gfp_t lockdep_reclaim_gfp;
101355 #endif
101356
101357+/* process credentials */
101358+ const struct cred __rcu *real_cred; /* objective and real subjective task
101359+ * credentials (COW) */
101360+
101361 /* journalling filesystem info */
101362 void *journal_info;
101363
101364@@ -1648,6 +1683,10 @@ struct task_struct {
101365 /* cg_list protected by css_set_lock and tsk->alloc_lock */
101366 struct list_head cg_list;
101367 #endif
101368+
101369+ const struct cred __rcu *cred; /* effective (overridable) subjective task
101370+ * credentials (COW) */
101371+
101372 #ifdef CONFIG_FUTEX
101373 struct robust_list_head __user *robust_list;
101374 #ifdef CONFIG_COMPAT
101375@@ -1759,7 +1798,7 @@ struct task_struct {
101376 * Number of functions that haven't been traced
101377 * because of depth overrun.
101378 */
101379- atomic_t trace_overrun;
101380+ atomic_unchecked_t trace_overrun;
101381 /* Pause for the tracing */
101382 atomic_t tracing_graph_pause;
101383 #endif
101384@@ -1788,22 +1827,91 @@ struct task_struct {
101385 unsigned long task_state_change;
101386 #endif
101387 int pagefault_disabled;
101388+
101389+#ifdef CONFIG_GRKERNSEC
101390+ /* grsecurity */
101391+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
101392+ u64 exec_id;
101393+#endif
101394+#ifdef CONFIG_GRKERNSEC_SETXID
101395+ const struct cred *delayed_cred;
101396+#endif
101397+ struct dentry *gr_chroot_dentry;
101398+ struct acl_subject_label *acl;
101399+ struct acl_subject_label *tmpacl;
101400+ struct acl_role_label *role;
101401+ struct file *exec_file;
101402+ unsigned long brute_expires;
101403+ u16 acl_role_id;
101404+ u8 inherited;
101405+ /* is this the task that authenticated to the special role */
101406+ u8 acl_sp_role;
101407+ u8 is_writable;
101408+ u8 brute;
101409+ u8 gr_is_chrooted;
101410+#endif
101411+
101412+/* thread_info moved to task_struct */
101413+#ifdef CONFIG_X86
101414+ struct thread_info tinfo;
101415+#endif
101416 /* CPU-specific state of this task */
101417 struct thread_struct thread;
101418-/*
101419- * WARNING: on x86, 'thread_struct' contains a variable-sized
101420- * structure. It *MUST* be at the end of 'task_struct'.
101421- *
101422- * Do not put anything below here!
101423- */
101424-};
101425+} __randomize_layout;
101426
101427 #ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT
101428-extern int arch_task_struct_size __read_mostly;
101429+extern size_t arch_task_struct_size __read_mostly;
101430 #else
101431 # define arch_task_struct_size (sizeof(struct task_struct))
101432 #endif
101433
101434+#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
101435+#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
101436+#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
101437+#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
101438+/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
101439+#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
101440+
101441+#ifdef CONFIG_PAX_SOFTMODE
101442+extern int pax_softmode;
101443+#endif
101444+
101445+extern int pax_check_flags(unsigned long *);
101446+#define PAX_PARSE_FLAGS_FALLBACK (~0UL)
101447+
101448+/* if tsk != current then task_lock must be held on it */
101449+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
101450+static inline unsigned long pax_get_flags(struct task_struct *tsk)
101451+{
101452+ if (likely(tsk->mm))
101453+ return tsk->mm->pax_flags;
101454+ else
101455+ return 0UL;
101456+}
101457+
101458+/* if tsk != current then task_lock must be held on it */
101459+static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
101460+{
101461+ if (likely(tsk->mm)) {
101462+ tsk->mm->pax_flags = flags;
101463+ return 0;
101464+ }
101465+ return -EINVAL;
101466+}
101467+#endif
101468+
101469+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
101470+extern void pax_set_initial_flags(struct linux_binprm *bprm);
101471+#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
101472+extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
101473+#endif
101474+
101475+struct path;
101476+extern char *pax_get_path(const struct path *path, char *buf, int buflen);
101477+extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
101478+extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
101479+extern void pax_report_refcount_overflow(struct pt_regs *regs);
101480+
101481 /* Future-safe accessor for struct task_struct's cpus_allowed. */
101482 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
101483
101484@@ -1885,7 +1993,7 @@ struct pid_namespace;
101485 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
101486 struct pid_namespace *ns);
101487
101488-static inline pid_t task_pid_nr(struct task_struct *tsk)
101489+static inline pid_t task_pid_nr(const struct task_struct *tsk)
101490 {
101491 return tsk->pid;
101492 }
101493@@ -2253,6 +2361,25 @@ extern u64 sched_clock_cpu(int cpu);
101494
101495 extern void sched_clock_init(void);
101496
101497+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
101498+static inline void populate_stack(void)
101499+{
101500+ struct task_struct *curtask = current;
101501+ int c;
101502+ int *ptr = curtask->stack;
101503+ int *end = curtask->stack + THREAD_SIZE;
101504+
101505+ while (ptr < end) {
101506+ c = *(volatile int *)ptr;
101507+ ptr += PAGE_SIZE/sizeof(int);
101508+ }
101509+}
101510+#else
101511+static inline void populate_stack(void)
101512+{
101513+}
101514+#endif
101515+
101516 #ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
101517 static inline void sched_clock_tick(void)
101518 {
101519@@ -2381,7 +2508,9 @@ extern void set_curr_task(int cpu, struct task_struct *p);
101520 void yield(void);
101521
101522 union thread_union {
101523+#ifndef CONFIG_X86
101524 struct thread_info thread_info;
101525+#endif
101526 unsigned long stack[THREAD_SIZE/sizeof(long)];
101527 };
101528
101529@@ -2414,6 +2543,7 @@ extern struct pid_namespace init_pid_ns;
101530 */
101531
101532 extern struct task_struct *find_task_by_vpid(pid_t nr);
101533+extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
101534 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
101535 struct pid_namespace *ns);
101536
101537@@ -2591,7 +2721,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
101538 extern void exit_itimers(struct signal_struct *);
101539 extern void flush_itimer_signals(void);
101540
101541-extern void do_group_exit(int);
101542+extern __noreturn void do_group_exit(int);
101543
101544 extern int do_execve(struct filename *,
101545 const char __user * const __user *,
101546@@ -2796,9 +2926,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
101547 #define task_stack_end_corrupted(task) \
101548 (*(end_of_stack(task)) != STACK_END_MAGIC)
101549
101550-static inline int object_is_on_stack(void *obj)
101551+static inline int object_starts_on_stack(const void *obj)
101552 {
101553- void *stack = task_stack_page(current);
101554+ const void *stack = task_stack_page(current);
101555
101556 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
101557 }
101558diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
101559index c9e4731..c716293 100644
101560--- a/include/linux/sched/sysctl.h
101561+++ b/include/linux/sched/sysctl.h
101562@@ -34,6 +34,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
101563 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
101564
101565 extern int sysctl_max_map_count;
101566+extern unsigned long sysctl_heap_stack_gap;
101567
101568 extern unsigned int sysctl_sched_latency;
101569 extern unsigned int sysctl_sched_min_granularity;
101570diff --git a/include/linux/security.h b/include/linux/security.h
101571index 2f4c1f7..5bc05d7 100644
101572--- a/include/linux/security.h
101573+++ b/include/linux/security.h
101574@@ -28,6 +28,7 @@
101575 #include <linux/err.h>
101576 #include <linux/string.h>
101577 #include <linux/mm.h>
101578+#include <linux/grsecurity.h>
101579
101580 struct linux_binprm;
101581 struct cred;
101582diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
101583index dc368b8..e895209 100644
101584--- a/include/linux/semaphore.h
101585+++ b/include/linux/semaphore.h
101586@@ -37,7 +37,7 @@ static inline void sema_init(struct semaphore *sem, int val)
101587 }
101588
101589 extern void down(struct semaphore *sem);
101590-extern int __must_check down_interruptible(struct semaphore *sem);
101591+extern int __must_check down_interruptible(struct semaphore *sem) __intentional_overflow(-1);
101592 extern int __must_check down_killable(struct semaphore *sem);
101593 extern int __must_check down_trylock(struct semaphore *sem);
101594 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
101595diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
101596index d4c7271..abf5706 100644
101597--- a/include/linux/seq_file.h
101598+++ b/include/linux/seq_file.h
101599@@ -27,6 +27,9 @@ struct seq_file {
101600 struct mutex lock;
101601 const struct seq_operations *op;
101602 int poll_event;
101603+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
101604+ u64 exec_id;
101605+#endif
101606 #ifdef CONFIG_USER_NS
101607 struct user_namespace *user_ns;
101608 #endif
101609@@ -39,6 +42,7 @@ struct seq_operations {
101610 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
101611 int (*show) (struct seq_file *m, void *v);
101612 };
101613+typedef struct seq_operations __no_const seq_operations_no_const;
101614
101615 #define SEQ_SKIP 1
101616
101617@@ -111,6 +115,7 @@ void seq_pad(struct seq_file *m, char c);
101618
101619 char *mangle_path(char *s, const char *p, const char *esc);
101620 int seq_open(struct file *, const struct seq_operations *);
101621+int seq_open_restrict(struct file *, const struct seq_operations *);
101622 ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
101623 loff_t seq_lseek(struct file *, loff_t, int);
101624 int seq_release(struct inode *, struct file *);
101625@@ -129,6 +134,7 @@ int seq_path_root(struct seq_file *m, const struct path *path,
101626 const struct path *root, const char *esc);
101627
101628 int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
101629+int single_open_restrict(struct file *, int (*)(struct seq_file *, void *), void *);
101630 int single_open_size(struct file *, int (*)(struct seq_file *, void *), void *, size_t);
101631 int single_release(struct inode *, struct file *);
101632 void *__seq_open_private(struct file *, const struct seq_operations *, int);
101633diff --git a/include/linux/shm.h b/include/linux/shm.h
101634index 6fb8016..2cf60e7 100644
101635--- a/include/linux/shm.h
101636+++ b/include/linux/shm.h
101637@@ -22,7 +22,11 @@ struct shmid_kernel /* private to the kernel */
101638 /* The task created the shm object. NULL if the task is dead. */
101639 struct task_struct *shm_creator;
101640 struct list_head shm_clist; /* list by creator */
101641-};
101642+#ifdef CONFIG_GRKERNSEC
101643+ u64 shm_createtime;
101644+ pid_t shm_lapid;
101645+#endif
101646+} __randomize_layout;
101647
101648 /* shm_mode upper byte flags */
101649 #define SHM_DEST 01000 /* segment will be destroyed on last detach */
101650diff --git a/include/linux/signal.h b/include/linux/signal.h
101651index ab1e039..ad4229e 100644
101652--- a/include/linux/signal.h
101653+++ b/include/linux/signal.h
101654@@ -289,7 +289,7 @@ static inline void allow_signal(int sig)
101655 * know it'll be handled, so that they don't get converted to
101656 * SIGKILL or just silently dropped.
101657 */
101658- kernel_sigaction(sig, (__force __sighandler_t)2);
101659+ kernel_sigaction(sig, (__force_user __sighandler_t)2);
101660 }
101661
101662 static inline void disallow_signal(int sig)
101663diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
101664index 9b88536..db7cc7f 100644
101665--- a/include/linux/skbuff.h
101666+++ b/include/linux/skbuff.h
101667@@ -784,7 +784,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t priority, int flags,
101668 int node);
101669 struct sk_buff *__build_skb(void *data, unsigned int frag_size);
101670 struct sk_buff *build_skb(void *data, unsigned int frag_size);
101671-static inline struct sk_buff *alloc_skb(unsigned int size,
101672+static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
101673 gfp_t priority)
101674 {
101675 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
101676@@ -1964,7 +1964,7 @@ static inline int skb_checksum_start_offset(const struct sk_buff *skb)
101677 return skb->csum_start - skb_headroom(skb);
101678 }
101679
101680-static inline int skb_transport_offset(const struct sk_buff *skb)
101681+static inline int __intentional_overflow(0) skb_transport_offset(const struct sk_buff *skb)
101682 {
101683 return skb_transport_header(skb) - skb->data;
101684 }
101685@@ -1979,7 +1979,7 @@ static inline u32 skb_inner_network_header_len(const struct sk_buff *skb)
101686 return skb->inner_transport_header - skb->inner_network_header;
101687 }
101688
101689-static inline int skb_network_offset(const struct sk_buff *skb)
101690+static inline int __intentional_overflow(0) skb_network_offset(const struct sk_buff *skb)
101691 {
101692 return skb_network_header(skb) - skb->data;
101693 }
101694@@ -2039,7 +2039,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
101695 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
101696 */
101697 #ifndef NET_SKB_PAD
101698-#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
101699+#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
101700 #endif
101701
101702 int ___pskb_trim(struct sk_buff *skb, unsigned int len);
101703@@ -2682,9 +2682,9 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock,
101704 int *err);
101705 unsigned int datagram_poll(struct file *file, struct socket *sock,
101706 struct poll_table_struct *wait);
101707-int skb_copy_datagram_iter(const struct sk_buff *from, int offset,
101708+int __intentional_overflow(0) skb_copy_datagram_iter(const struct sk_buff *from, int offset,
101709 struct iov_iter *to, int size);
101710-static inline int skb_copy_datagram_msg(const struct sk_buff *from, int offset,
101711+static inline int __intentional_overflow(2,4) skb_copy_datagram_msg(const struct sk_buff *from, int offset,
101712 struct msghdr *msg, int size)
101713 {
101714 return skb_copy_datagram_iter(from, offset, &msg->msg_iter, size);
101715@@ -3213,6 +3213,9 @@ static inline void nf_reset(struct sk_buff *skb)
101716 nf_bridge_put(skb->nf_bridge);
101717 skb->nf_bridge = NULL;
101718 #endif
101719+#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
101720+ skb->nf_trace = 0;
101721+#endif
101722 }
101723
101724 static inline void nf_reset_trace(struct sk_buff *skb)
101725diff --git a/include/linux/slab.h b/include/linux/slab.h
101726index a99f0e5..4efa730 100644
101727--- a/include/linux/slab.h
101728+++ b/include/linux/slab.h
101729@@ -15,14 +15,29 @@
101730 #include <linux/types.h>
101731 #include <linux/workqueue.h>
101732
101733+#include <linux/err.h>
101734
101735 /*
101736 * Flags to pass to kmem_cache_create().
101737 * The ones marked DEBUG are only valid if CONFIG_DEBUG_SLAB is set.
101738 */
101739 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
101740+
101741+#ifdef CONFIG_PAX_USERCOPY_SLABS
101742+#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
101743+#else
101744+#define SLAB_USERCOPY 0x00000000UL
101745+#endif
101746+
101747 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
101748 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
101749+
101750+#ifdef CONFIG_PAX_MEMORY_SANITIZE
101751+#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
101752+#else
101753+#define SLAB_NO_SANITIZE 0x00000000UL
101754+#endif
101755+
101756 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
101757 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
101758 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
101759@@ -98,10 +113,13 @@
101760 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
101761 * Both make kfree a no-op.
101762 */
101763-#define ZERO_SIZE_PTR ((void *)16)
101764+#define ZERO_SIZE_PTR \
101765+({ \
101766+ BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
101767+ (void *)(-MAX_ERRNO-1L); \
101768+})
101769
101770-#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
101771- (unsigned long)ZERO_SIZE_PTR)
101772+#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
101773
101774 #include <linux/kmemleak.h>
101775 #include <linux/kasan.h>
101776@@ -143,6 +161,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
101777 void kfree(const void *);
101778 void kzfree(const void *);
101779 size_t ksize(const void *);
101780+const char *check_heap_object(const void *ptr, unsigned long n);
101781+bool is_usercopy_object(const void *ptr);
101782
101783 /*
101784 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
101785@@ -235,6 +255,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
101786 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
101787 #endif
101788
101789+#ifdef CONFIG_PAX_USERCOPY_SLABS
101790+extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
101791+#endif
101792+
101793 /*
101794 * Figure out which kmalloc slab an allocation of a certain size
101795 * belongs to.
101796@@ -243,7 +267,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
101797 * 2 = 129 .. 192 bytes
101798 * n = 2^(n-1)+1 .. 2^n
101799 */
101800-static __always_inline int kmalloc_index(size_t size)
101801+static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
101802 {
101803 if (!size)
101804 return 0;
101805@@ -286,15 +310,15 @@ static __always_inline int kmalloc_index(size_t size)
101806 }
101807 #endif /* !CONFIG_SLOB */
101808
101809-void *__kmalloc(size_t size, gfp_t flags);
101810+void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
101811 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags);
101812 void kmem_cache_free(struct kmem_cache *, void *);
101813
101814 #ifdef CONFIG_NUMA
101815-void *__kmalloc_node(size_t size, gfp_t flags, int node);
101816+void *__kmalloc_node(size_t size, gfp_t flags, int node) __alloc_size(1) __size_overflow(1);
101817 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
101818 #else
101819-static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
101820+static __always_inline void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t flags, int node)
101821 {
101822 return __kmalloc(size, flags);
101823 }
101824diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
101825index 33d0490..70a6313 100644
101826--- a/include/linux/slab_def.h
101827+++ b/include/linux/slab_def.h
101828@@ -40,7 +40,7 @@ struct kmem_cache {
101829 /* 4) cache creation/removal */
101830 const char *name;
101831 struct list_head list;
101832- int refcount;
101833+ atomic_t refcount;
101834 int object_size;
101835 int align;
101836
101837@@ -56,10 +56,14 @@ struct kmem_cache {
101838 unsigned long node_allocs;
101839 unsigned long node_frees;
101840 unsigned long node_overflow;
101841- atomic_t allochit;
101842- atomic_t allocmiss;
101843- atomic_t freehit;
101844- atomic_t freemiss;
101845+ atomic_unchecked_t allochit;
101846+ atomic_unchecked_t allocmiss;
101847+ atomic_unchecked_t freehit;
101848+ atomic_unchecked_t freemiss;
101849+#ifdef CONFIG_PAX_MEMORY_SANITIZE
101850+ atomic_unchecked_t sanitized;
101851+ atomic_unchecked_t not_sanitized;
101852+#endif
101853
101854 /*
101855 * If debugging is enabled, then the allocator can add additional
101856diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
101857index 3388511..6252f90 100644
101858--- a/include/linux/slub_def.h
101859+++ b/include/linux/slub_def.h
101860@@ -74,7 +74,7 @@ struct kmem_cache {
101861 struct kmem_cache_order_objects max;
101862 struct kmem_cache_order_objects min;
101863 gfp_t allocflags; /* gfp flags to use on each alloc */
101864- int refcount; /* Refcount for slab cache destroy */
101865+ atomic_t refcount; /* Refcount for slab cache destroy */
101866 void (*ctor)(void *);
101867 int inuse; /* Offset to metadata */
101868 int align; /* Alignment */
101869diff --git a/include/linux/smp.h b/include/linux/smp.h
101870index c441407..f487b83 100644
101871--- a/include/linux/smp.h
101872+++ b/include/linux/smp.h
101873@@ -183,7 +183,9 @@ static inline void smp_init(void) { }
101874 #endif
101875
101876 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
101877+#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
101878 #define put_cpu() preempt_enable()
101879+#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
101880
101881 /*
101882 * Callback to arch code if there's nosmp or maxcpus=0 on the
101883diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
101884index fddebc6..6f0ae39 100644
101885--- a/include/linux/sock_diag.h
101886+++ b/include/linux/sock_diag.h
101887@@ -15,7 +15,7 @@ struct sock_diag_handler {
101888 __u8 family;
101889 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
101890 int (*get_info)(struct sk_buff *skb, struct sock *sk);
101891-};
101892+} __do_const;
101893
101894 int sock_diag_register(const struct sock_diag_handler *h);
101895 void sock_diag_unregister(const struct sock_diag_handler *h);
101896diff --git a/include/linux/sonet.h b/include/linux/sonet.h
101897index 680f9a3..f13aeb0 100644
101898--- a/include/linux/sonet.h
101899+++ b/include/linux/sonet.h
101900@@ -7,7 +7,7 @@
101901 #include <uapi/linux/sonet.h>
101902
101903 struct k_sonet_stats {
101904-#define __HANDLE_ITEM(i) atomic_t i
101905+#define __HANDLE_ITEM(i) atomic_unchecked_t i
101906 __SONET_ITEMS
101907 #undef __HANDLE_ITEM
101908 };
101909diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
101910index 07d8e53..dc934c9 100644
101911--- a/include/linux/sunrpc/addr.h
101912+++ b/include/linux/sunrpc/addr.h
101913@@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
101914 {
101915 switch (sap->sa_family) {
101916 case AF_INET:
101917- return ntohs(((struct sockaddr_in *)sap)->sin_port);
101918+ return ntohs(((const struct sockaddr_in *)sap)->sin_port);
101919 case AF_INET6:
101920- return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
101921+ return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
101922 }
101923 return 0;
101924 }
101925@@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
101926 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
101927 const struct sockaddr *src)
101928 {
101929- const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
101930+ const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
101931 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
101932
101933 dsin->sin_family = ssin->sin_family;
101934@@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
101935 if (sa->sa_family != AF_INET6)
101936 return 0;
101937
101938- return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
101939+ return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
101940 }
101941
101942 #endif /* _LINUX_SUNRPC_ADDR_H */
101943diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
101944index 131032f..5f9378a 100644
101945--- a/include/linux/sunrpc/clnt.h
101946+++ b/include/linux/sunrpc/clnt.h
101947@@ -101,7 +101,7 @@ struct rpc_procinfo {
101948 unsigned int p_timer; /* Which RTT timer to use */
101949 u32 p_statidx; /* Which procedure to account */
101950 const char * p_name; /* name of procedure */
101951-};
101952+} __do_const;
101953
101954 #ifdef __KERNEL__
101955
101956diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
101957index fae6fb9..023fbcd 100644
101958--- a/include/linux/sunrpc/svc.h
101959+++ b/include/linux/sunrpc/svc.h
101960@@ -420,7 +420,7 @@ struct svc_procedure {
101961 unsigned int pc_count; /* call count */
101962 unsigned int pc_cachetype; /* cache info (NFS) */
101963 unsigned int pc_xdrressize; /* maximum size of XDR reply */
101964-};
101965+} __do_const;
101966
101967 /*
101968 * Function prototypes.
101969diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
101970index 4929a8a..b8f29e9 100644
101971--- a/include/linux/sunrpc/svc_rdma.h
101972+++ b/include/linux/sunrpc/svc_rdma.h
101973@@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
101974 extern unsigned int svcrdma_max_requests;
101975 extern unsigned int svcrdma_max_req_size;
101976
101977-extern atomic_t rdma_stat_recv;
101978-extern atomic_t rdma_stat_read;
101979-extern atomic_t rdma_stat_write;
101980-extern atomic_t rdma_stat_sq_starve;
101981-extern atomic_t rdma_stat_rq_starve;
101982-extern atomic_t rdma_stat_rq_poll;
101983-extern atomic_t rdma_stat_rq_prod;
101984-extern atomic_t rdma_stat_sq_poll;
101985-extern atomic_t rdma_stat_sq_prod;
101986+extern atomic_unchecked_t rdma_stat_recv;
101987+extern atomic_unchecked_t rdma_stat_read;
101988+extern atomic_unchecked_t rdma_stat_write;
101989+extern atomic_unchecked_t rdma_stat_sq_starve;
101990+extern atomic_unchecked_t rdma_stat_rq_starve;
101991+extern atomic_unchecked_t rdma_stat_rq_poll;
101992+extern atomic_unchecked_t rdma_stat_rq_prod;
101993+extern atomic_unchecked_t rdma_stat_sq_poll;
101994+extern atomic_unchecked_t rdma_stat_sq_prod;
101995
101996 /*
101997 * Contexts are built when an RDMA request is created and are a
101998diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
101999index 8d71d65..f79586e 100644
102000--- a/include/linux/sunrpc/svcauth.h
102001+++ b/include/linux/sunrpc/svcauth.h
102002@@ -120,7 +120,7 @@ struct auth_ops {
102003 int (*release)(struct svc_rqst *rq);
102004 void (*domain_release)(struct auth_domain *);
102005 int (*set_client)(struct svc_rqst *rq);
102006-};
102007+} __do_const;
102008
102009 #define SVC_GARBAGE 1
102010 #define SVC_SYSERR 2
102011diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
102012index e7a018e..49f8b17 100644
102013--- a/include/linux/swiotlb.h
102014+++ b/include/linux/swiotlb.h
102015@@ -60,7 +60,8 @@ extern void
102016
102017 extern void
102018 swiotlb_free_coherent(struct device *hwdev, size_t size,
102019- void *vaddr, dma_addr_t dma_handle);
102020+ void *vaddr, dma_addr_t dma_handle,
102021+ struct dma_attrs *attrs);
102022
102023 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
102024 unsigned long offset, size_t size,
102025diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
102026index b45c45b..a6ae64c 100644
102027--- a/include/linux/syscalls.h
102028+++ b/include/linux/syscalls.h
102029@@ -102,7 +102,12 @@ union bpf_attr;
102030 #define __TYPE_IS_L(t) (__same_type((t)0, 0L))
102031 #define __TYPE_IS_UL(t) (__same_type((t)0, 0UL))
102032 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
102033-#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
102034+#define __SC_LONG(t, a) __typeof__( \
102035+ __builtin_choose_expr( \
102036+ sizeof(t) > sizeof(int), \
102037+ (t) 0, \
102038+ __builtin_choose_expr(__type_is_unsigned(t), 0UL, 0L) \
102039+ )) a
102040 #define __SC_CAST(t, a) (t) a
102041 #define __SC_ARGS(t, a) a
102042 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
102043@@ -384,11 +389,11 @@ asmlinkage long sys_sync(void);
102044 asmlinkage long sys_fsync(unsigned int fd);
102045 asmlinkage long sys_fdatasync(unsigned int fd);
102046 asmlinkage long sys_bdflush(int func, long data);
102047-asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
102048- char __user *type, unsigned long flags,
102049+asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
102050+ const char __user *type, unsigned long flags,
102051 void __user *data);
102052-asmlinkage long sys_umount(char __user *name, int flags);
102053-asmlinkage long sys_oldumount(char __user *name);
102054+asmlinkage long sys_umount(const char __user *name, int flags);
102055+asmlinkage long sys_oldumount(const char __user *name);
102056 asmlinkage long sys_truncate(const char __user *path, long length);
102057 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
102058 asmlinkage long sys_stat(const char __user *filename,
102059@@ -604,7 +609,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
102060 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
102061 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
102062 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
102063- struct sockaddr __user *, int);
102064+ struct sockaddr __user *, int) __intentional_overflow(0);
102065 asmlinkage long sys_sendmsg(int fd, struct user_msghdr __user *msg, unsigned flags);
102066 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
102067 unsigned int vlen, unsigned flags);
102068@@ -663,10 +668,10 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf);
102069
102070 asmlinkage long sys_semget(key_t key, int nsems, int semflg);
102071 asmlinkage long sys_semop(int semid, struct sembuf __user *sops,
102072- unsigned nsops);
102073+ long nsops);
102074 asmlinkage long sys_semctl(int semid, int semnum, int cmd, unsigned long arg);
102075 asmlinkage long sys_semtimedop(int semid, struct sembuf __user *sops,
102076- unsigned nsops,
102077+ long nsops,
102078 const struct timespec __user *timeout);
102079 asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg);
102080 asmlinkage long sys_shmget(key_t key, size_t size, int flag);
102081diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
102082index 27b3b0b..e093dd9 100644
102083--- a/include/linux/syscore_ops.h
102084+++ b/include/linux/syscore_ops.h
102085@@ -16,7 +16,7 @@ struct syscore_ops {
102086 int (*suspend)(void);
102087 void (*resume)(void);
102088 void (*shutdown)(void);
102089-};
102090+} __do_const;
102091
102092 extern void register_syscore_ops(struct syscore_ops *ops);
102093 extern void unregister_syscore_ops(struct syscore_ops *ops);
102094diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
102095index fa7bc29..0d96561 100644
102096--- a/include/linux/sysctl.h
102097+++ b/include/linux/sysctl.h
102098@@ -39,10 +39,16 @@ typedef int proc_handler (struct ctl_table *ctl, int write,
102099
102100 extern int proc_dostring(struct ctl_table *, int,
102101 void __user *, size_t *, loff_t *);
102102+extern int proc_dostring_modpriv(struct ctl_table *, int,
102103+ void __user *, size_t *, loff_t *);
102104 extern int proc_dointvec(struct ctl_table *, int,
102105 void __user *, size_t *, loff_t *);
102106+extern int proc_dointvec_secure(struct ctl_table *, int,
102107+ void __user *, size_t *, loff_t *);
102108 extern int proc_dointvec_minmax(struct ctl_table *, int,
102109 void __user *, size_t *, loff_t *);
102110+extern int proc_dointvec_minmax_secure(struct ctl_table *, int,
102111+ void __user *, size_t *, loff_t *);
102112 extern int proc_dointvec_jiffies(struct ctl_table *, int,
102113 void __user *, size_t *, loff_t *);
102114 extern int proc_dointvec_userhz_jiffies(struct ctl_table *, int,
102115@@ -113,7 +119,8 @@ struct ctl_table
102116 struct ctl_table_poll *poll;
102117 void *extra1;
102118 void *extra2;
102119-};
102120+} __do_const __randomize_layout;
102121+typedef struct ctl_table __no_const ctl_table_no_const;
102122
102123 struct ctl_node {
102124 struct rb_node node;
102125diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
102126index 9f65758..487a6f1 100644
102127--- a/include/linux/sysfs.h
102128+++ b/include/linux/sysfs.h
102129@@ -34,7 +34,8 @@ struct attribute {
102130 struct lock_class_key *key;
102131 struct lock_class_key skey;
102132 #endif
102133-};
102134+} __do_const;
102135+typedef struct attribute __no_const attribute_no_const;
102136
102137 /**
102138 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
102139@@ -78,7 +79,8 @@ struct attribute_group {
102140 struct attribute *, int);
102141 struct attribute **attrs;
102142 struct bin_attribute **bin_attrs;
102143-};
102144+} __do_const;
102145+typedef struct attribute_group __no_const attribute_group_no_const;
102146
102147 /**
102148 * Use these macros to make defining attributes easier. See include/linux/device.h
102149@@ -152,7 +154,8 @@ struct bin_attribute {
102150 char *, loff_t, size_t);
102151 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
102152 struct vm_area_struct *vma);
102153-};
102154+} __do_const;
102155+typedef struct bin_attribute __no_const bin_attribute_no_const;
102156
102157 /**
102158 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
102159diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
102160index 387fa7d..3fcde6b 100644
102161--- a/include/linux/sysrq.h
102162+++ b/include/linux/sysrq.h
102163@@ -16,6 +16,7 @@
102164
102165 #include <linux/errno.h>
102166 #include <linux/types.h>
102167+#include <linux/compiler.h>
102168
102169 /* Possible values of bitmask for enabling sysrq functions */
102170 /* 0x0001 is reserved for enable everything */
102171@@ -33,7 +34,7 @@ struct sysrq_key_op {
102172 char *help_msg;
102173 char *action_msg;
102174 int enable_mask;
102175-};
102176+} __do_const;
102177
102178 #ifdef CONFIG_MAGIC_SYSRQ
102179
102180diff --git a/include/linux/tcp.h b/include/linux/tcp.h
102181index 48c3696..e7a7ba6 100644
102182--- a/include/linux/tcp.h
102183+++ b/include/linux/tcp.h
102184@@ -63,13 +63,13 @@ struct tcp_fastopen_cookie {
102185
102186 /* This defines a selective acknowledgement block. */
102187 struct tcp_sack_block_wire {
102188- __be32 start_seq;
102189- __be32 end_seq;
102190+ __be32 start_seq __intentional_overflow(-1);
102191+ __be32 end_seq __intentional_overflow(-1);
102192 };
102193
102194 struct tcp_sack_block {
102195- u32 start_seq;
102196- u32 end_seq;
102197+ u32 start_seq __intentional_overflow(-1);
102198+ u32 end_seq __intentional_overflow(-1);
102199 };
102200
102201 /*These are used to set the sack_ok field in struct tcp_options_received */
102202@@ -153,7 +153,7 @@ struct tcp_sock {
102203 * total number of segments in.
102204 */
102205 u32 rcv_nxt; /* What we want to receive next */
102206- u32 copied_seq; /* Head of yet unread data */
102207+ u32 copied_seq __intentional_overflow(-1); /* Head of yet unread data */
102208 u32 rcv_wup; /* rcv_nxt on last window update sent */
102209 u32 snd_nxt; /* Next sequence we send */
102210 u32 segs_out; /* RFC4898 tcpEStatsPerfSegsOut
102211@@ -248,7 +248,7 @@ struct tcp_sock {
102212 u32 prr_out; /* Total number of pkts sent during Recovery. */
102213
102214 u32 rcv_wnd; /* Current receiver window */
102215- u32 write_seq; /* Tail(+1) of data held in tcp send buffer */
102216+ u32 write_seq __intentional_overflow(-1); /* Tail(+1) of data held in tcp send buffer */
102217 u32 notsent_lowat; /* TCP_NOTSENT_LOWAT */
102218 u32 pushed_seq; /* Last pushed seq, required to talk to windows */
102219 u32 lost_out; /* Lost packets */
102220@@ -291,7 +291,7 @@ struct tcp_sock {
102221 int undo_retrans; /* number of undoable retransmissions. */
102222 u32 total_retrans; /* Total retransmits for entire connection */
102223
102224- u32 urg_seq; /* Seq of received urgent pointer */
102225+ u32 urg_seq __intentional_overflow(-1); /* Seq of received urgent pointer */
102226 unsigned int keepalive_time; /* time before keep alive takes place */
102227 unsigned int keepalive_intvl; /* time interval between keep alive probes */
102228
102229diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
102230index ff307b5..f1a4468 100644
102231--- a/include/linux/thread_info.h
102232+++ b/include/linux/thread_info.h
102233@@ -145,6 +145,13 @@ static inline bool test_and_clear_restore_sigmask(void)
102234 #error "no set_restore_sigmask() provided and default one won't work"
102235 #endif
102236
102237+extern void __check_object_size(const void *ptr, unsigned long n, bool to_user, bool const_size);
102238+
102239+static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
102240+{
102241+ __check_object_size(ptr, n, to_user, __builtin_constant_p(n));
102242+}
102243+
102244 #endif /* __KERNEL__ */
102245
102246 #endif /* _LINUX_THREAD_INFO_H */
102247diff --git a/include/linux/tty.h b/include/linux/tty.h
102248index ad6c891..93a8f45 100644
102249--- a/include/linux/tty.h
102250+++ b/include/linux/tty.h
102251@@ -225,7 +225,7 @@ struct tty_port {
102252 const struct tty_port_operations *ops; /* Port operations */
102253 spinlock_t lock; /* Lock protecting tty field */
102254 int blocked_open; /* Waiting to open */
102255- int count; /* Usage count */
102256+ atomic_t count; /* Usage count */
102257 wait_queue_head_t open_wait; /* Open waiters */
102258 wait_queue_head_t close_wait; /* Close waiters */
102259 wait_queue_head_t delta_msr_wait; /* Modem status change */
102260@@ -313,7 +313,7 @@ struct tty_struct {
102261 /* If the tty has a pending do_SAK, queue it here - akpm */
102262 struct work_struct SAK_work;
102263 struct tty_port *port;
102264-};
102265+} __randomize_layout;
102266
102267 /* Each of a tty's open files has private_data pointing to tty_file_private */
102268 struct tty_file_private {
102269@@ -573,7 +573,7 @@ extern int tty_port_open(struct tty_port *port,
102270 struct tty_struct *tty, struct file *filp);
102271 static inline int tty_port_users(struct tty_port *port)
102272 {
102273- return port->count + port->blocked_open;
102274+ return atomic_read(&port->count) + port->blocked_open;
102275 }
102276
102277 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
102278diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
102279index 92e337c..f46757b 100644
102280--- a/include/linux/tty_driver.h
102281+++ b/include/linux/tty_driver.h
102282@@ -291,7 +291,7 @@ struct tty_operations {
102283 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
102284 #endif
102285 const struct file_operations *proc_fops;
102286-};
102287+} __do_const __randomize_layout;
102288
102289 struct tty_driver {
102290 int magic; /* magic number for this structure */
102291@@ -325,7 +325,7 @@ struct tty_driver {
102292
102293 const struct tty_operations *ops;
102294 struct list_head tty_drivers;
102295-};
102296+} __randomize_layout;
102297
102298 extern struct list_head tty_drivers;
102299
102300diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
102301index 00c9d68..bc0188b 100644
102302--- a/include/linux/tty_ldisc.h
102303+++ b/include/linux/tty_ldisc.h
102304@@ -215,7 +215,7 @@ struct tty_ldisc_ops {
102305
102306 struct module *owner;
102307
102308- int refcount;
102309+ atomic_t refcount;
102310 };
102311
102312 struct tty_ldisc {
102313diff --git a/include/linux/types.h b/include/linux/types.h
102314index 8715287..1be77ee 100644
102315--- a/include/linux/types.h
102316+++ b/include/linux/types.h
102317@@ -176,10 +176,26 @@ typedef struct {
102318 int counter;
102319 } atomic_t;
102320
102321+#ifdef CONFIG_PAX_REFCOUNT
102322+typedef struct {
102323+ int counter;
102324+} atomic_unchecked_t;
102325+#else
102326+typedef atomic_t atomic_unchecked_t;
102327+#endif
102328+
102329 #ifdef CONFIG_64BIT
102330 typedef struct {
102331 long counter;
102332 } atomic64_t;
102333+
102334+#ifdef CONFIG_PAX_REFCOUNT
102335+typedef struct {
102336+ long counter;
102337+} atomic64_unchecked_t;
102338+#else
102339+typedef atomic64_t atomic64_unchecked_t;
102340+#endif
102341 #endif
102342
102343 struct list_head {
102344diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
102345index ae572c1..73bd4ec 100644
102346--- a/include/linux/uaccess.h
102347+++ b/include/linux/uaccess.h
102348@@ -97,11 +97,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
102349 long ret; \
102350 mm_segment_t old_fs = get_fs(); \
102351 \
102352- set_fs(KERNEL_DS); \
102353 pagefault_disable(); \
102354- ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
102355- pagefault_enable(); \
102356+ set_fs(KERNEL_DS); \
102357+ ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
102358 set_fs(old_fs); \
102359+ pagefault_enable(); \
102360 ret; \
102361 })
102362
102363diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
102364index 0383552..a0125dd 100644
102365--- a/include/linux/uidgid.h
102366+++ b/include/linux/uidgid.h
102367@@ -187,4 +187,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
102368
102369 #endif /* CONFIG_USER_NS */
102370
102371+#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
102372+#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
102373+#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
102374+#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
102375+
102376 #endif /* _LINUX_UIDGID_H */
102377diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
102378index 32c0e83..671eb35 100644
102379--- a/include/linux/uio_driver.h
102380+++ b/include/linux/uio_driver.h
102381@@ -67,7 +67,7 @@ struct uio_device {
102382 struct module *owner;
102383 struct device *dev;
102384 int minor;
102385- atomic_t event;
102386+ atomic_unchecked_t event;
102387 struct fasync_struct *async_queue;
102388 wait_queue_head_t wait;
102389 struct uio_info *info;
102390diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
102391index 99c1b4d..562e6f3 100644
102392--- a/include/linux/unaligned/access_ok.h
102393+++ b/include/linux/unaligned/access_ok.h
102394@@ -4,34 +4,34 @@
102395 #include <linux/kernel.h>
102396 #include <asm/byteorder.h>
102397
102398-static inline u16 get_unaligned_le16(const void *p)
102399+static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
102400 {
102401- return le16_to_cpup((__le16 *)p);
102402+ return le16_to_cpup((const __le16 *)p);
102403 }
102404
102405-static inline u32 get_unaligned_le32(const void *p)
102406+static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
102407 {
102408- return le32_to_cpup((__le32 *)p);
102409+ return le32_to_cpup((const __le32 *)p);
102410 }
102411
102412-static inline u64 get_unaligned_le64(const void *p)
102413+static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
102414 {
102415- return le64_to_cpup((__le64 *)p);
102416+ return le64_to_cpup((const __le64 *)p);
102417 }
102418
102419-static inline u16 get_unaligned_be16(const void *p)
102420+static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
102421 {
102422- return be16_to_cpup((__be16 *)p);
102423+ return be16_to_cpup((const __be16 *)p);
102424 }
102425
102426-static inline u32 get_unaligned_be32(const void *p)
102427+static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
102428 {
102429- return be32_to_cpup((__be32 *)p);
102430+ return be32_to_cpup((const __be32 *)p);
102431 }
102432
102433-static inline u64 get_unaligned_be64(const void *p)
102434+static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
102435 {
102436- return be64_to_cpup((__be64 *)p);
102437+ return be64_to_cpup((const __be64 *)p);
102438 }
102439
102440 static inline void put_unaligned_le16(u16 val, void *p)
102441diff --git a/include/linux/usb.h b/include/linux/usb.h
102442index 447fe29..07a9cf0 100644
102443--- a/include/linux/usb.h
102444+++ b/include/linux/usb.h
102445@@ -363,7 +363,7 @@ struct usb_bus {
102446 * with the URB_SHORT_NOT_OK flag set.
102447 */
102448 unsigned no_sg_constraint:1; /* no sg constraint */
102449- unsigned sg_tablesize; /* 0 or largest number of sg list entries */
102450+ unsigned short sg_tablesize; /* 0 or largest number of sg list entries */
102451
102452 int devnum_next; /* Next open device number in
102453 * round-robin allocation */
102454@@ -592,7 +592,7 @@ struct usb_device {
102455 int maxchild;
102456
102457 u32 quirks;
102458- atomic_t urbnum;
102459+ atomic_unchecked_t urbnum;
102460
102461 unsigned long active_duration;
102462
102463@@ -1785,10 +1785,10 @@ void usb_sg_wait(struct usb_sg_request *io);
102464
102465 /* NOTE: these are not the standard USB_ENDPOINT_XFER_* values!! */
102466 /* (yet ... they're the values used by usbfs) */
102467-#define PIPE_ISOCHRONOUS 0
102468-#define PIPE_INTERRUPT 1
102469-#define PIPE_CONTROL 2
102470-#define PIPE_BULK 3
102471+#define PIPE_ISOCHRONOUS 0U
102472+#define PIPE_INTERRUPT 1U
102473+#define PIPE_CONTROL 2U
102474+#define PIPE_BULK 3U
102475
102476 #define usb_pipein(pipe) ((pipe) & USB_DIR_IN)
102477 #define usb_pipeout(pipe) (!usb_pipein(pipe))
102478diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
102479index c9aa779..46d6f69 100644
102480--- a/include/linux/usb/hcd.h
102481+++ b/include/linux/usb/hcd.h
102482@@ -23,6 +23,7 @@
102483
102484 #include <linux/rwsem.h>
102485 #include <linux/interrupt.h>
102486+#include <scsi/scsi_host.h>
102487
102488 #define MAX_TOPO_LEVEL 6
102489
102490diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
102491index 3dd5a78..ed69d7b 100644
102492--- a/include/linux/usb/renesas_usbhs.h
102493+++ b/include/linux/usb/renesas_usbhs.h
102494@@ -39,7 +39,7 @@ enum {
102495 */
102496 struct renesas_usbhs_driver_callback {
102497 int (*notify_hotplug)(struct platform_device *pdev);
102498-};
102499+} __no_const;
102500
102501 /*
102502 * callback functions for platform
102503diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
102504index 8297e5b..0dfae27 100644
102505--- a/include/linux/user_namespace.h
102506+++ b/include/linux/user_namespace.h
102507@@ -39,7 +39,7 @@ struct user_namespace {
102508 struct key *persistent_keyring_register;
102509 struct rw_semaphore persistent_keyring_register_sem;
102510 #endif
102511-};
102512+} __randomize_layout;
102513
102514 extern struct user_namespace init_user_ns;
102515
102516diff --git a/include/linux/utsname.h b/include/linux/utsname.h
102517index 5093f58..c103e58 100644
102518--- a/include/linux/utsname.h
102519+++ b/include/linux/utsname.h
102520@@ -25,7 +25,7 @@ struct uts_namespace {
102521 struct new_utsname name;
102522 struct user_namespace *user_ns;
102523 struct ns_common ns;
102524-};
102525+} __randomize_layout;
102526 extern struct uts_namespace init_uts_ns;
102527
102528 #ifdef CONFIG_UTS_NS
102529diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
102530index 6f8fbcf..4efc177 100644
102531--- a/include/linux/vermagic.h
102532+++ b/include/linux/vermagic.h
102533@@ -25,9 +25,42 @@
102534 #define MODULE_ARCH_VERMAGIC ""
102535 #endif
102536
102537+#ifdef CONFIG_PAX_REFCOUNT
102538+#define MODULE_PAX_REFCOUNT "REFCOUNT "
102539+#else
102540+#define MODULE_PAX_REFCOUNT ""
102541+#endif
102542+
102543+#ifdef CONSTIFY_PLUGIN
102544+#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
102545+#else
102546+#define MODULE_CONSTIFY_PLUGIN ""
102547+#endif
102548+
102549+#ifdef STACKLEAK_PLUGIN
102550+#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
102551+#else
102552+#define MODULE_STACKLEAK_PLUGIN ""
102553+#endif
102554+
102555+#ifdef RANDSTRUCT_PLUGIN
102556+#include <generated/randomize_layout_hash.h>
102557+#define MODULE_RANDSTRUCT_PLUGIN "RANDSTRUCT_PLUGIN_" RANDSTRUCT_HASHED_SEED
102558+#else
102559+#define MODULE_RANDSTRUCT_PLUGIN
102560+#endif
102561+
102562+#ifdef CONFIG_GRKERNSEC
102563+#define MODULE_GRSEC "GRSEC "
102564+#else
102565+#define MODULE_GRSEC ""
102566+#endif
102567+
102568 #define VERMAGIC_STRING \
102569 UTS_RELEASE " " \
102570 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
102571 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
102572- MODULE_ARCH_VERMAGIC
102573+ MODULE_ARCH_VERMAGIC \
102574+ MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
102575+ MODULE_GRSEC MODULE_RANDSTRUCT_PLUGIN
102576
102577diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
102578index b483abd..af305ad 100644
102579--- a/include/linux/vga_switcheroo.h
102580+++ b/include/linux/vga_switcheroo.h
102581@@ -63,9 +63,9 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
102582
102583 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
102584
102585-int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
102586+int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain);
102587 void vga_switcheroo_fini_domain_pm_ops(struct device *dev);
102588-int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
102589+int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain);
102590 #else
102591
102592 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
102593@@ -82,9 +82,9 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
102594
102595 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
102596
102597-static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
102598+static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
102599 static inline void vga_switcheroo_fini_domain_pm_ops(struct device *dev) {}
102600-static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
102601+static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
102602
102603 #endif
102604 #endif /* _LINUX_VGA_SWITCHEROO_H_ */
102605diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
102606index 0ec5983..d5888bb 100644
102607--- a/include/linux/vmalloc.h
102608+++ b/include/linux/vmalloc.h
102609@@ -18,6 +18,14 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
102610 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
102611 #define VM_NO_GUARD 0x00000040 /* don't add guard page */
102612 #define VM_KASAN 0x00000080 /* has allocated kasan shadow memory */
102613+
102614+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
102615+#define VM_KERNEXEC 0x00000100 /* allocate from executable kernel memory range */
102616+#endif
102617+
102618+#define VM_USERCOPY 0x00000200 /* allocation intended for copies to userland */
102619+
102620+
102621 /* bits [20..32] reserved for arch specific ioremap internals */
102622
102623 /*
102624@@ -67,6 +75,7 @@ static inline void vmalloc_init(void)
102625 #endif
102626
102627 extern void *vmalloc(unsigned long size);
102628+extern void *vmalloc_usercopy(unsigned long size);
102629 extern void *vzalloc(unsigned long size);
102630 extern void *vmalloc_user(unsigned long size);
102631 extern void *vmalloc_node(unsigned long size, int node);
102632@@ -86,6 +95,10 @@ extern void *vmap(struct page **pages, unsigned int count,
102633 unsigned long flags, pgprot_t prot);
102634 extern void vunmap(const void *addr);
102635
102636+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
102637+extern void unmap_process_stacks(struct task_struct *task);
102638+#endif
102639+
102640 extern int remap_vmalloc_range_partial(struct vm_area_struct *vma,
102641 unsigned long uaddr, void *kaddr,
102642 unsigned long size);
102643@@ -150,7 +163,7 @@ extern void free_vm_area(struct vm_struct *area);
102644
102645 /* for /dev/kmem */
102646 extern long vread(char *buf, char *addr, unsigned long count);
102647-extern long vwrite(char *buf, char *addr, unsigned long count);
102648+extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
102649
102650 /*
102651 * Internals. Dont't use..
102652diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
102653index 82e7db7..f8ce3d0 100644
102654--- a/include/linux/vmstat.h
102655+++ b/include/linux/vmstat.h
102656@@ -108,18 +108,18 @@ static inline void vm_events_fold_cpu(int cpu)
102657 /*
102658 * Zone based page accounting with per cpu differentials.
102659 */
102660-extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
102661+extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
102662
102663 static inline void zone_page_state_add(long x, struct zone *zone,
102664 enum zone_stat_item item)
102665 {
102666- atomic_long_add(x, &zone->vm_stat[item]);
102667- atomic_long_add(x, &vm_stat[item]);
102668+ atomic_long_add_unchecked(x, &zone->vm_stat[item]);
102669+ atomic_long_add_unchecked(x, &vm_stat[item]);
102670 }
102671
102672-static inline unsigned long global_page_state(enum zone_stat_item item)
102673+static inline unsigned long __intentional_overflow(-1) global_page_state(enum zone_stat_item item)
102674 {
102675- long x = atomic_long_read(&vm_stat[item]);
102676+ long x = atomic_long_read_unchecked(&vm_stat[item]);
102677 #ifdef CONFIG_SMP
102678 if (x < 0)
102679 x = 0;
102680@@ -127,10 +127,10 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
102681 return x;
102682 }
102683
102684-static inline unsigned long zone_page_state(struct zone *zone,
102685+static inline unsigned long __intentional_overflow(-1) zone_page_state(struct zone *zone,
102686 enum zone_stat_item item)
102687 {
102688- long x = atomic_long_read(&zone->vm_stat[item]);
102689+ long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
102690 #ifdef CONFIG_SMP
102691 if (x < 0)
102692 x = 0;
102693@@ -147,7 +147,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
102694 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
102695 enum zone_stat_item item)
102696 {
102697- long x = atomic_long_read(&zone->vm_stat[item]);
102698+ long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
102699
102700 #ifdef CONFIG_SMP
102701 int cpu;
102702@@ -234,14 +234,14 @@ static inline void __mod_zone_page_state(struct zone *zone,
102703
102704 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
102705 {
102706- atomic_long_inc(&zone->vm_stat[item]);
102707- atomic_long_inc(&vm_stat[item]);
102708+ atomic_long_inc_unchecked(&zone->vm_stat[item]);
102709+ atomic_long_inc_unchecked(&vm_stat[item]);
102710 }
102711
102712 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
102713 {
102714- atomic_long_dec(&zone->vm_stat[item]);
102715- atomic_long_dec(&vm_stat[item]);
102716+ atomic_long_dec_unchecked(&zone->vm_stat[item]);
102717+ atomic_long_dec_unchecked(&vm_stat[item]);
102718 }
102719
102720 static inline void __inc_zone_page_state(struct page *page,
102721diff --git a/include/linux/xattr.h b/include/linux/xattr.h
102722index 91b0a68..0e9adf6 100644
102723--- a/include/linux/xattr.h
102724+++ b/include/linux/xattr.h
102725@@ -28,7 +28,7 @@ struct xattr_handler {
102726 size_t size, int handler_flags);
102727 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
102728 size_t size, int flags, int handler_flags);
102729-};
102730+} __do_const;
102731
102732 struct xattr {
102733 const char *name;
102734@@ -37,6 +37,9 @@ struct xattr {
102735 };
102736
102737 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
102738+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
102739+ssize_t pax_getxattr(struct dentry *, void *, size_t);
102740+#endif
102741 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
102742 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
102743 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
102744diff --git a/include/linux/zlib.h b/include/linux/zlib.h
102745index 92dbbd3..13ab0b3 100644
102746--- a/include/linux/zlib.h
102747+++ b/include/linux/zlib.h
102748@@ -31,6 +31,7 @@
102749 #define _ZLIB_H
102750
102751 #include <linux/zconf.h>
102752+#include <linux/compiler.h>
102753
102754 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
102755 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
102756@@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
102757
102758 /* basic functions */
102759
102760-extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
102761+extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
102762 /*
102763 Returns the number of bytes that needs to be allocated for a per-
102764 stream workspace with the specified parameters. A pointer to this
102765diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
102766index acbcd2f..c3abe84 100644
102767--- a/include/media/v4l2-dev.h
102768+++ b/include/media/v4l2-dev.h
102769@@ -74,7 +74,7 @@ struct v4l2_file_operations {
102770 int (*mmap) (struct file *, struct vm_area_struct *);
102771 int (*open) (struct file *);
102772 int (*release) (struct file *);
102773-};
102774+} __do_const;
102775
102776 /*
102777 * Newer version of video_device, handled by videodev2.c
102778diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
102779index 9c58157..d86ebf5 100644
102780--- a/include/media/v4l2-device.h
102781+++ b/include/media/v4l2-device.h
102782@@ -93,7 +93,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
102783 this function returns 0. If the name ends with a digit (e.g. cx18),
102784 then the name will be set to cx18-0 since cx180 looks really odd. */
102785 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
102786- atomic_t *instance);
102787+ atomic_unchecked_t *instance);
102788
102789 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
102790 Since the parent disappears this ensures that v4l2_dev doesn't have an
102791diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
102792index 5122b5e..598b440 100644
102793--- a/include/net/9p/transport.h
102794+++ b/include/net/9p/transport.h
102795@@ -62,7 +62,7 @@ struct p9_trans_module {
102796 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
102797 int (*zc_request)(struct p9_client *, struct p9_req_t *,
102798 struct iov_iter *, struct iov_iter *, int , int, int);
102799-};
102800+} __do_const;
102801
102802 void v9fs_register_trans(struct p9_trans_module *m);
102803 void v9fs_unregister_trans(struct p9_trans_module *m);
102804diff --git a/include/net/af_unix.h b/include/net/af_unix.h
102805index 4a167b3..73dcbb3 100644
102806--- a/include/net/af_unix.h
102807+++ b/include/net/af_unix.h
102808@@ -36,7 +36,7 @@ struct unix_skb_parms {
102809 u32 secid; /* Security ID */
102810 #endif
102811 u32 consumed;
102812-};
102813+} __randomize_layout;
102814
102815 #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb))
102816
102817diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
102818index 2239a37..a83461f 100644
102819--- a/include/net/bluetooth/l2cap.h
102820+++ b/include/net/bluetooth/l2cap.h
102821@@ -609,7 +609,7 @@ struct l2cap_ops {
102822 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
102823 unsigned long hdr_len,
102824 unsigned long len, int nb);
102825-};
102826+} __do_const;
102827
102828 struct l2cap_conn {
102829 struct hci_conn *hcon;
102830diff --git a/include/net/bonding.h b/include/net/bonding.h
102831index 20defc0..3072903 100644
102832--- a/include/net/bonding.h
102833+++ b/include/net/bonding.h
102834@@ -661,7 +661,7 @@ extern struct rtnl_link_ops bond_link_ops;
102835
102836 static inline void bond_tx_drop(struct net_device *dev, struct sk_buff *skb)
102837 {
102838- atomic_long_inc(&dev->tx_dropped);
102839+ atomic_long_inc_unchecked(&dev->tx_dropped);
102840 dev_kfree_skb_any(skb);
102841 }
102842
102843diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
102844index f2ae33d..c457cf0 100644
102845--- a/include/net/caif/cfctrl.h
102846+++ b/include/net/caif/cfctrl.h
102847@@ -52,7 +52,7 @@ struct cfctrl_rsp {
102848 void (*radioset_rsp)(void);
102849 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
102850 struct cflayer *client_layer);
102851-};
102852+} __no_const;
102853
102854 /* Link Setup Parameters for CAIF-Links. */
102855 struct cfctrl_link_param {
102856@@ -101,8 +101,8 @@ struct cfctrl_request_info {
102857 struct cfctrl {
102858 struct cfsrvl serv;
102859 struct cfctrl_rsp res;
102860- atomic_t req_seq_no;
102861- atomic_t rsp_seq_no;
102862+ atomic_unchecked_t req_seq_no;
102863+ atomic_unchecked_t rsp_seq_no;
102864 struct list_head list;
102865 /* Protects from simultaneous access to first_req list */
102866 spinlock_t info_list_lock;
102867diff --git a/include/net/flow.h b/include/net/flow.h
102868index 8109a15..504466d 100644
102869--- a/include/net/flow.h
102870+++ b/include/net/flow.h
102871@@ -231,6 +231,6 @@ void flow_cache_fini(struct net *net);
102872
102873 void flow_cache_flush(struct net *net);
102874 void flow_cache_flush_deferred(struct net *net);
102875-extern atomic_t flow_cache_genid;
102876+extern atomic_unchecked_t flow_cache_genid;
102877
102878 #endif
102879diff --git a/include/net/genetlink.h b/include/net/genetlink.h
102880index a9af1cc..1f3fa7b 100644
102881--- a/include/net/genetlink.h
102882+++ b/include/net/genetlink.h
102883@@ -128,7 +128,7 @@ struct genl_ops {
102884 u8 cmd;
102885 u8 internal_flags;
102886 u8 flags;
102887-};
102888+} __do_const;
102889
102890 int __genl_register_family(struct genl_family *family);
102891
102892diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
102893index 0f712c0..cd762c4 100644
102894--- a/include/net/gro_cells.h
102895+++ b/include/net/gro_cells.h
102896@@ -27,7 +27,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
102897 cell = this_cpu_ptr(gcells->cells);
102898
102899 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
102900- atomic_long_inc(&dev->rx_dropped);
102901+ atomic_long_inc_unchecked(&dev->rx_dropped);
102902 kfree_skb(skb);
102903 return;
102904 }
102905diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
102906index 0320bbb..938789c 100644
102907--- a/include/net/inet_connection_sock.h
102908+++ b/include/net/inet_connection_sock.h
102909@@ -63,7 +63,7 @@ struct inet_connection_sock_af_ops {
102910 int (*bind_conflict)(const struct sock *sk,
102911 const struct inet_bind_bucket *tb, bool relax);
102912 void (*mtu_reduced)(struct sock *sk);
102913-};
102914+} __do_const;
102915
102916 /** inet_connection_sock - INET connection oriented sock
102917 *
102918diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
102919index 47eb67b..0e733b2 100644
102920--- a/include/net/inet_sock.h
102921+++ b/include/net/inet_sock.h
102922@@ -43,7 +43,7 @@
102923 struct ip_options {
102924 __be32 faddr;
102925 __be32 nexthop;
102926- unsigned char optlen;
102927+ unsigned char optlen __intentional_overflow(0);
102928 unsigned char srr;
102929 unsigned char rr;
102930 unsigned char ts;
102931diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
102932index d5332dd..10a5c3c 100644
102933--- a/include/net/inetpeer.h
102934+++ b/include/net/inetpeer.h
102935@@ -48,7 +48,7 @@ struct inet_peer {
102936 */
102937 union {
102938 struct {
102939- atomic_t rid; /* Frag reception counter */
102940+ atomic_unchecked_t rid; /* Frag reception counter */
102941 };
102942 struct rcu_head rcu;
102943 struct inet_peer *gc_next;
102944diff --git a/include/net/ip.h b/include/net/ip.h
102945index d5fe9f2..8da10ed 100644
102946--- a/include/net/ip.h
102947+++ b/include/net/ip.h
102948@@ -319,7 +319,7 @@ static inline unsigned int ip_skb_dst_mtu(const struct sk_buff *skb)
102949 }
102950 }
102951
102952-u32 ip_idents_reserve(u32 hash, int segs);
102953+u32 ip_idents_reserve(u32 hash, int segs) __intentional_overflow(-1);
102954 void __ip_select_ident(struct net *net, struct iphdr *iph, int segs);
102955
102956 static inline void ip_select_ident_segs(struct net *net, struct sk_buff *skb,
102957diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
102958index 5fa643b..d871e20 100644
102959--- a/include/net/ip_fib.h
102960+++ b/include/net/ip_fib.h
102961@@ -170,7 +170,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
102962
102963 #define FIB_RES_SADDR(net, res) \
102964 ((FIB_RES_NH(res).nh_saddr_genid == \
102965- atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
102966+ atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
102967 FIB_RES_NH(res).nh_saddr : \
102968 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
102969 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
102970diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
102971index 4e3731e..a242e28 100644
102972--- a/include/net/ip_vs.h
102973+++ b/include/net/ip_vs.h
102974@@ -551,7 +551,7 @@ struct ip_vs_conn {
102975 struct ip_vs_conn *control; /* Master control connection */
102976 atomic_t n_control; /* Number of controlled ones */
102977 struct ip_vs_dest *dest; /* real server */
102978- atomic_t in_pkts; /* incoming packet counter */
102979+ atomic_unchecked_t in_pkts; /* incoming packet counter */
102980
102981 /* Packet transmitter for different forwarding methods. If it
102982 * mangles the packet, it must return NF_DROP or better NF_STOLEN,
102983@@ -699,7 +699,7 @@ struct ip_vs_dest {
102984 __be16 port; /* port number of the server */
102985 union nf_inet_addr addr; /* IP address of the server */
102986 volatile unsigned int flags; /* dest status flags */
102987- atomic_t conn_flags; /* flags to copy to conn */
102988+ atomic_unchecked_t conn_flags; /* flags to copy to conn */
102989 atomic_t weight; /* server weight */
102990
102991 atomic_t refcnt; /* reference counter */
102992@@ -946,11 +946,11 @@ struct netns_ipvs {
102993 /* ip_vs_lblc */
102994 int sysctl_lblc_expiration;
102995 struct ctl_table_header *lblc_ctl_header;
102996- struct ctl_table *lblc_ctl_table;
102997+ ctl_table_no_const *lblc_ctl_table;
102998 /* ip_vs_lblcr */
102999 int sysctl_lblcr_expiration;
103000 struct ctl_table_header *lblcr_ctl_header;
103001- struct ctl_table *lblcr_ctl_table;
103002+ ctl_table_no_const *lblcr_ctl_table;
103003 /* ip_vs_est */
103004 struct list_head est_list; /* estimator list */
103005 spinlock_t est_lock;
103006diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
103007index 8d4f588..2e37ad2 100644
103008--- a/include/net/irda/ircomm_tty.h
103009+++ b/include/net/irda/ircomm_tty.h
103010@@ -33,6 +33,7 @@
103011 #include <linux/termios.h>
103012 #include <linux/timer.h>
103013 #include <linux/tty.h> /* struct tty_struct */
103014+#include <asm/local.h>
103015
103016 #include <net/irda/irias_object.h>
103017 #include <net/irda/ircomm_core.h>
103018diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
103019index 714cc9a..ea05f3e 100644
103020--- a/include/net/iucv/af_iucv.h
103021+++ b/include/net/iucv/af_iucv.h
103022@@ -149,7 +149,7 @@ struct iucv_skb_cb {
103023 struct iucv_sock_list {
103024 struct hlist_head head;
103025 rwlock_t lock;
103026- atomic_t autobind_name;
103027+ atomic_unchecked_t autobind_name;
103028 };
103029
103030 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
103031diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
103032index f3be818..bf46196 100644
103033--- a/include/net/llc_c_ac.h
103034+++ b/include/net/llc_c_ac.h
103035@@ -87,7 +87,7 @@
103036 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
103037 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
103038
103039-typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
103040+typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
103041
103042 int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
103043 int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
103044diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
103045index 3948cf1..83b28c4 100644
103046--- a/include/net/llc_c_ev.h
103047+++ b/include/net/llc_c_ev.h
103048@@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
103049 return (struct llc_conn_state_ev *)skb->cb;
103050 }
103051
103052-typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
103053-typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
103054+typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
103055+typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
103056
103057 int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
103058 int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
103059diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
103060index 48f3f89..0e92c50 100644
103061--- a/include/net/llc_c_st.h
103062+++ b/include/net/llc_c_st.h
103063@@ -37,7 +37,7 @@ struct llc_conn_state_trans {
103064 u8 next_state;
103065 const llc_conn_ev_qfyr_t *ev_qualifiers;
103066 const llc_conn_action_t *ev_actions;
103067-};
103068+} __do_const;
103069
103070 struct llc_conn_state {
103071 u8 current_state;
103072diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
103073index a61b98c..aade1eb 100644
103074--- a/include/net/llc_s_ac.h
103075+++ b/include/net/llc_s_ac.h
103076@@ -23,7 +23,7 @@
103077 #define SAP_ACT_TEST_IND 9
103078
103079 /* All action functions must look like this */
103080-typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
103081+typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
103082
103083 int llc_sap_action_unitdata_ind(struct llc_sap *sap, struct sk_buff *skb);
103084 int llc_sap_action_send_ui(struct llc_sap *sap, struct sk_buff *skb);
103085diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
103086index c4359e2..76dbc4a 100644
103087--- a/include/net/llc_s_st.h
103088+++ b/include/net/llc_s_st.h
103089@@ -20,7 +20,7 @@ struct llc_sap_state_trans {
103090 llc_sap_ev_t ev;
103091 u8 next_state;
103092 const llc_sap_action_t *ev_actions;
103093-};
103094+} __do_const;
103095
103096 struct llc_sap_state {
103097 u8 curr_state;
103098diff --git a/include/net/mac80211.h b/include/net/mac80211.h
103099index 6b1077c..7b72f67 100644
103100--- a/include/net/mac80211.h
103101+++ b/include/net/mac80211.h
103102@@ -5106,7 +5106,7 @@ struct ieee80211_tx_rate_control {
103103 struct sk_buff *skb;
103104 struct ieee80211_tx_rate reported_rate;
103105 bool rts, short_preamble;
103106- u8 max_rate_idx;
103107+ s8 max_rate_idx;
103108 u32 rate_idx_mask;
103109 u8 *rate_idx_mcs_mask;
103110 bool bss;
103111@@ -5143,7 +5143,7 @@ struct rate_control_ops {
103112 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
103113
103114 u32 (*get_expected_throughput)(void *priv_sta);
103115-};
103116+} __do_const;
103117
103118 static inline int rate_supported(struct ieee80211_sta *sta,
103119 enum ieee80211_band band,
103120diff --git a/include/net/neighbour.h b/include/net/neighbour.h
103121index bd33e66..6508d00 100644
103122--- a/include/net/neighbour.h
103123+++ b/include/net/neighbour.h
103124@@ -162,7 +162,7 @@ struct neigh_ops {
103125 void (*error_report)(struct neighbour *, struct sk_buff *);
103126 int (*output)(struct neighbour *, struct sk_buff *);
103127 int (*connected_output)(struct neighbour *, struct sk_buff *);
103128-};
103129+} __do_const;
103130
103131 struct pneigh_entry {
103132 struct pneigh_entry *next;
103133@@ -216,7 +216,7 @@ struct neigh_table {
103134 struct neigh_statistics __percpu *stats;
103135 struct neigh_hash_table __rcu *nht;
103136 struct pneigh_entry **phash_buckets;
103137-};
103138+} __randomize_layout;
103139
103140 enum {
103141 NEIGH_ARP_TABLE = 0,
103142diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
103143index e951453..0685f5b 100644
103144--- a/include/net/net_namespace.h
103145+++ b/include/net/net_namespace.h
103146@@ -53,7 +53,7 @@ struct net {
103147 */
103148 spinlock_t rules_mod_lock;
103149
103150- atomic64_t cookie_gen;
103151+ atomic64_unchecked_t cookie_gen;
103152
103153 struct list_head list; /* list of network namespaces */
103154 struct list_head cleanup_list; /* namespaces on death row */
103155@@ -135,8 +135,8 @@ struct net {
103156 struct netns_mpls mpls;
103157 #endif
103158 struct sock *diag_nlsk;
103159- atomic_t fnhe_genid;
103160-};
103161+ atomic_unchecked_t fnhe_genid;
103162+} __randomize_layout;
103163
103164 #include <linux/seq_file_net.h>
103165
103166@@ -271,7 +271,11 @@ static inline struct net *read_pnet(const possible_net_t *pnet)
103167 #define __net_init __init
103168 #define __net_exit __exit_refok
103169 #define __net_initdata __initdata
103170+#ifdef CONSTIFY_PLUGIN
103171 #define __net_initconst __initconst
103172+#else
103173+#define __net_initconst __initdata
103174+#endif
103175 #endif
103176
103177 int peernet2id_alloc(struct net *net, struct net *peer);
103178@@ -286,7 +290,7 @@ struct pernet_operations {
103179 void (*exit_batch)(struct list_head *net_exit_list);
103180 int *id;
103181 size_t size;
103182-};
103183+} __do_const;
103184
103185 /*
103186 * Use these carefully. If you implement a network device and it
103187@@ -334,12 +338,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
103188
103189 static inline int rt_genid_ipv4(struct net *net)
103190 {
103191- return atomic_read(&net->ipv4.rt_genid);
103192+ return atomic_read_unchecked(&net->ipv4.rt_genid);
103193 }
103194
103195 static inline void rt_genid_bump_ipv4(struct net *net)
103196 {
103197- atomic_inc(&net->ipv4.rt_genid);
103198+ atomic_inc_unchecked(&net->ipv4.rt_genid);
103199 }
103200
103201 extern void (*__fib6_flush_trees)(struct net *net);
103202@@ -366,12 +370,12 @@ static inline void rt_genid_bump_all(struct net *net)
103203
103204 static inline int fnhe_genid(struct net *net)
103205 {
103206- return atomic_read(&net->fnhe_genid);
103207+ return atomic_read_unchecked(&net->fnhe_genid);
103208 }
103209
103210 static inline void fnhe_genid_bump(struct net *net)
103211 {
103212- atomic_inc(&net->fnhe_genid);
103213+ atomic_inc_unchecked(&net->fnhe_genid);
103214 }
103215
103216 #endif /* __NET_NET_NAMESPACE_H */
103217diff --git a/include/net/netlink.h b/include/net/netlink.h
103218index 2a5dbcc..8243656 100644
103219--- a/include/net/netlink.h
103220+++ b/include/net/netlink.h
103221@@ -521,7 +521,7 @@ static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
103222 {
103223 if (mark) {
103224 WARN_ON((unsigned char *) mark < skb->data);
103225- skb_trim(skb, (unsigned char *) mark - skb->data);
103226+ skb_trim(skb, (const unsigned char *) mark - skb->data);
103227 }
103228 }
103229
103230diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
103231index 723b61c..4386367 100644
103232--- a/include/net/netns/conntrack.h
103233+++ b/include/net/netns/conntrack.h
103234@@ -14,10 +14,10 @@ struct nf_conntrack_ecache;
103235 struct nf_proto_net {
103236 #ifdef CONFIG_SYSCTL
103237 struct ctl_table_header *ctl_table_header;
103238- struct ctl_table *ctl_table;
103239+ ctl_table_no_const *ctl_table;
103240 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
103241 struct ctl_table_header *ctl_compat_header;
103242- struct ctl_table *ctl_compat_table;
103243+ ctl_table_no_const *ctl_compat_table;
103244 #endif
103245 #endif
103246 unsigned int users;
103247@@ -60,7 +60,7 @@ struct nf_ip_net {
103248 struct nf_icmp_net icmpv6;
103249 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
103250 struct ctl_table_header *ctl_table_header;
103251- struct ctl_table *ctl_table;
103252+ ctl_table_no_const *ctl_table;
103253 #endif
103254 };
103255
103256diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
103257index c68926b..106c147 100644
103258--- a/include/net/netns/ipv4.h
103259+++ b/include/net/netns/ipv4.h
103260@@ -93,7 +93,7 @@ struct netns_ipv4 {
103261
103262 struct ping_group_range ping_group_range;
103263
103264- atomic_t dev_addr_genid;
103265+ atomic_unchecked_t dev_addr_genid;
103266
103267 #ifdef CONFIG_SYSCTL
103268 unsigned long *sysctl_local_reserved_ports;
103269@@ -107,6 +107,6 @@ struct netns_ipv4 {
103270 struct fib_rules_ops *mr_rules_ops;
103271 #endif
103272 #endif
103273- atomic_t rt_genid;
103274+ atomic_unchecked_t rt_genid;
103275 };
103276 #endif
103277diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
103278index 8d93544..05c3e89 100644
103279--- a/include/net/netns/ipv6.h
103280+++ b/include/net/netns/ipv6.h
103281@@ -79,8 +79,8 @@ struct netns_ipv6 {
103282 struct fib_rules_ops *mr6_rules_ops;
103283 #endif
103284 #endif
103285- atomic_t dev_addr_genid;
103286- atomic_t fib6_sernum;
103287+ atomic_unchecked_t dev_addr_genid;
103288+ atomic_unchecked_t fib6_sernum;
103289 };
103290
103291 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
103292diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h
103293index 730d82a..045f2c4 100644
103294--- a/include/net/netns/xfrm.h
103295+++ b/include/net/netns/xfrm.h
103296@@ -78,7 +78,7 @@ struct netns_xfrm {
103297
103298 /* flow cache part */
103299 struct flow_cache flow_cache_global;
103300- atomic_t flow_cache_genid;
103301+ atomic_unchecked_t flow_cache_genid;
103302 struct list_head flow_cache_gc_list;
103303 spinlock_t flow_cache_gc_lock;
103304 struct work_struct flow_cache_gc_work;
103305diff --git a/include/net/ping.h b/include/net/ping.h
103306index ac80cb4..ec1ed09 100644
103307--- a/include/net/ping.h
103308+++ b/include/net/ping.h
103309@@ -54,7 +54,7 @@ struct ping_iter_state {
103310
103311 extern struct proto ping_prot;
103312 #if IS_ENABLED(CONFIG_IPV6)
103313-extern struct pingv6_ops pingv6_ops;
103314+extern struct pingv6_ops *pingv6_ops;
103315 #endif
103316
103317 struct pingfakehdr {
103318diff --git a/include/net/protocol.h b/include/net/protocol.h
103319index d6fcc1f..ca277058 100644
103320--- a/include/net/protocol.h
103321+++ b/include/net/protocol.h
103322@@ -49,7 +49,7 @@ struct net_protocol {
103323 * socket lookup?
103324 */
103325 icmp_strict_tag_validation:1;
103326-};
103327+} __do_const;
103328
103329 #if IS_ENABLED(CONFIG_IPV6)
103330 struct inet6_protocol {
103331@@ -62,7 +62,7 @@ struct inet6_protocol {
103332 u8 type, u8 code, int offset,
103333 __be32 info);
103334 unsigned int flags; /* INET6_PROTO_xxx */
103335-};
103336+} __do_const;
103337
103338 #define INET6_PROTO_NOPOLICY 0x1
103339 #define INET6_PROTO_FINAL 0x2
103340diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
103341index 343d922..7959cde 100644
103342--- a/include/net/rtnetlink.h
103343+++ b/include/net/rtnetlink.h
103344@@ -95,7 +95,7 @@ struct rtnl_link_ops {
103345 const struct net_device *dev,
103346 const struct net_device *slave_dev);
103347 struct net *(*get_link_net)(const struct net_device *dev);
103348-};
103349+} __do_const;
103350
103351 int __rtnl_link_register(struct rtnl_link_ops *ops);
103352 void __rtnl_link_unregister(struct rtnl_link_ops *ops);
103353diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h
103354index 4a5b9a3..ca27d73 100644
103355--- a/include/net/sctp/checksum.h
103356+++ b/include/net/sctp/checksum.h
103357@@ -61,8 +61,8 @@ static inline __le32 sctp_compute_cksum(const struct sk_buff *skb,
103358 unsigned int offset)
103359 {
103360 struct sctphdr *sh = sctp_hdr(skb);
103361- __le32 ret, old = sh->checksum;
103362- const struct skb_checksum_ops ops = {
103363+ __le32 ret, old = sh->checksum;
103364+ static const struct skb_checksum_ops ops = {
103365 .update = sctp_csum_update,
103366 .combine = sctp_csum_combine,
103367 };
103368diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
103369index 487ef34..d457f98 100644
103370--- a/include/net/sctp/sm.h
103371+++ b/include/net/sctp/sm.h
103372@@ -80,7 +80,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
103373 typedef struct {
103374 sctp_state_fn_t *fn;
103375 const char *name;
103376-} sctp_sm_table_entry_t;
103377+} __do_const sctp_sm_table_entry_t;
103378
103379 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
103380 * currently in use.
103381@@ -292,7 +292,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
103382 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
103383
103384 /* Extern declarations for major data structures. */
103385-extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
103386+extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
103387
103388
103389 /* Get the size of a DATA chunk payload. */
103390diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
103391index 495c87e..5b327ff 100644
103392--- a/include/net/sctp/structs.h
103393+++ b/include/net/sctp/structs.h
103394@@ -513,7 +513,7 @@ struct sctp_pf {
103395 void (*to_sk_saddr)(union sctp_addr *, struct sock *sk);
103396 void (*to_sk_daddr)(union sctp_addr *, struct sock *sk);
103397 struct sctp_af *af;
103398-};
103399+} __do_const;
103400
103401
103402 /* Structure to track chunk fragments that have been acked, but peer
103403diff --git a/include/net/sock.h b/include/net/sock.h
103404index f21f070..29ac73e 100644
103405--- a/include/net/sock.h
103406+++ b/include/net/sock.h
103407@@ -198,7 +198,7 @@ struct sock_common {
103408 struct in6_addr skc_v6_rcv_saddr;
103409 #endif
103410
103411- atomic64_t skc_cookie;
103412+ atomic64_unchecked_t skc_cookie;
103413
103414 /*
103415 * fields between dontcopy_begin/dontcopy_end
103416@@ -364,7 +364,7 @@ struct sock {
103417 unsigned int sk_napi_id;
103418 unsigned int sk_ll_usec;
103419 #endif
103420- atomic_t sk_drops;
103421+ atomic_unchecked_t sk_drops;
103422 int sk_rcvbuf;
103423
103424 struct sk_filter __rcu *sk_filter;
103425@@ -1038,7 +1038,7 @@ struct proto {
103426 void (*destroy_cgroup)(struct mem_cgroup *memcg);
103427 struct cg_proto *(*proto_cgroup)(struct mem_cgroup *memcg);
103428 #endif
103429-};
103430+} __randomize_layout;
103431
103432 /*
103433 * Bits in struct cg_proto.flags
103434@@ -1211,7 +1211,7 @@ static inline void memcg_memory_allocated_sub(struct cg_proto *prot,
103435 page_counter_uncharge(&prot->memory_allocated, amt);
103436 }
103437
103438-static inline long
103439+static inline long __intentional_overflow(-1)
103440 sk_memory_allocated(const struct sock *sk)
103441 {
103442 struct proto *prot = sk->sk_prot;
103443@@ -1776,7 +1776,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
103444 }
103445
103446 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
103447- struct iov_iter *from, char *to,
103448+ struct iov_iter *from, unsigned char *to,
103449 int copy, int offset)
103450 {
103451 if (skb->ip_summed == CHECKSUM_NONE) {
103452@@ -2023,7 +2023,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
103453 }
103454 }
103455
103456-struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
103457+struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
103458 bool force_schedule);
103459
103460 /**
103461@@ -2099,7 +2099,7 @@ struct sock_skb_cb {
103462 static inline void
103463 sock_skb_set_dropcount(const struct sock *sk, struct sk_buff *skb)
103464 {
103465- SOCK_SKB_CB(skb)->dropcount = atomic_read(&sk->sk_drops);
103466+ SOCK_SKB_CB(skb)->dropcount = atomic_read_unchecked(&sk->sk_drops);
103467 }
103468
103469 void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
103470diff --git a/include/net/tcp.h b/include/net/tcp.h
103471index 950cfec..0bf9d85 100644
103472--- a/include/net/tcp.h
103473+++ b/include/net/tcp.h
103474@@ -546,7 +546,7 @@ void tcp_retransmit_timer(struct sock *sk);
103475 void tcp_xmit_retransmit_queue(struct sock *);
103476 void tcp_simple_retransmit(struct sock *);
103477 int tcp_trim_head(struct sock *, struct sk_buff *, u32);
103478-int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int, gfp_t);
103479+int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int, gfp_t) __intentional_overflow(3);
103480
103481 void tcp_send_probe0(struct sock *);
103482 void tcp_send_partial(struct sock *);
103483@@ -724,8 +724,8 @@ static inline u32 tcp_skb_timestamp(const struct sk_buff *skb)
103484 * If this grows please adjust skbuff.h:skbuff->cb[xxx] size appropriately.
103485 */
103486 struct tcp_skb_cb {
103487- __u32 seq; /* Starting sequence number */
103488- __u32 end_seq; /* SEQ + FIN + SYN + datalen */
103489+ __u32 seq __intentional_overflow(-1); /* Starting sequence number */
103490+ __u32 end_seq __intentional_overflow(-1); /* SEQ + FIN + SYN + datalen */
103491 union {
103492 /* Note : tcp_tw_isn is used in input path only
103493 * (isn chosen by tcp_timewait_state_process())
103494@@ -753,7 +753,7 @@ struct tcp_skb_cb {
103495
103496 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
103497 /* 1 byte hole */
103498- __u32 ack_seq; /* Sequence number ACK'd */
103499+ __u32 ack_seq __intentional_overflow(-1); /* Sequence number ACK'd */
103500 union {
103501 struct inet_skb_parm h4;
103502 #if IS_ENABLED(CONFIG_IPV6)
103503diff --git a/include/net/xfrm.h b/include/net/xfrm.h
103504index f0ee97e..73e2b5a 100644
103505--- a/include/net/xfrm.h
103506+++ b/include/net/xfrm.h
103507@@ -284,7 +284,6 @@ struct xfrm_dst;
103508 struct xfrm_policy_afinfo {
103509 unsigned short family;
103510 struct dst_ops *dst_ops;
103511- void (*garbage_collect)(struct net *net);
103512 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
103513 const xfrm_address_t *saddr,
103514 const xfrm_address_t *daddr);
103515@@ -302,7 +301,7 @@ struct xfrm_policy_afinfo {
103516 struct net_device *dev,
103517 const struct flowi *fl);
103518 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
103519-};
103520+} __do_const;
103521
103522 int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
103523 int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
103524@@ -341,7 +340,7 @@ struct xfrm_state_afinfo {
103525 int (*transport_finish)(struct sk_buff *skb,
103526 int async);
103527 void (*local_error)(struct sk_buff *skb, u32 mtu);
103528-};
103529+} __do_const;
103530
103531 int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
103532 int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
103533@@ -436,7 +435,7 @@ struct xfrm_mode {
103534 struct module *owner;
103535 unsigned int encap;
103536 int flags;
103537-};
103538+} __do_const;
103539
103540 /* Flags for xfrm_mode. */
103541 enum {
103542@@ -531,7 +530,7 @@ struct xfrm_policy {
103543 struct timer_list timer;
103544
103545 struct flow_cache_object flo;
103546- atomic_t genid;
103547+ atomic_unchecked_t genid;
103548 u32 priority;
103549 u32 index;
103550 struct xfrm_mark mark;
103551@@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
103552 }
103553
103554 void xfrm_garbage_collect(struct net *net);
103555+void xfrm_garbage_collect_deferred(struct net *net);
103556
103557 #else
103558
103559@@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
103560 static inline void xfrm_garbage_collect(struct net *net)
103561 {
103562 }
103563+static inline void xfrm_garbage_collect_deferred(struct net *net)
103564+{
103565+}
103566 #endif
103567
103568 static __inline__
103569diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
103570index 036bd27..c0d7f17 100644
103571--- a/include/rdma/iw_cm.h
103572+++ b/include/rdma/iw_cm.h
103573@@ -123,7 +123,7 @@ struct iw_cm_verbs {
103574 int backlog);
103575
103576 int (*destroy_listen)(struct iw_cm_id *cm_id);
103577-};
103578+} __no_const;
103579
103580 /**
103581 * iw_create_cm_id - Create an IW CM identifier.
103582diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
103583index 93d14da..734b3d8 100644
103584--- a/include/scsi/libfc.h
103585+++ b/include/scsi/libfc.h
103586@@ -771,6 +771,7 @@ struct libfc_function_template {
103587 */
103588 void (*disc_stop_final) (struct fc_lport *);
103589 };
103590+typedef struct libfc_function_template __no_const libfc_function_template_no_const;
103591
103592 /**
103593 * struct fc_disc - Discovery context
103594@@ -875,7 +876,7 @@ struct fc_lport {
103595 struct fc_vport *vport;
103596
103597 /* Operational Information */
103598- struct libfc_function_template tt;
103599+ libfc_function_template_no_const tt;
103600 u8 link_up;
103601 u8 qfull;
103602 enum fc_lport_state state;
103603diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
103604index ae84b22..7954097 100644
103605--- a/include/scsi/scsi_device.h
103606+++ b/include/scsi/scsi_device.h
103607@@ -185,9 +185,9 @@ struct scsi_device {
103608 unsigned int max_device_blocked; /* what device_blocked counts down from */
103609 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
103610
103611- atomic_t iorequest_cnt;
103612- atomic_t iodone_cnt;
103613- atomic_t ioerr_cnt;
103614+ atomic_unchecked_t iorequest_cnt;
103615+ atomic_unchecked_t iodone_cnt;
103616+ atomic_unchecked_t ioerr_cnt;
103617
103618 struct device sdev_gendev,
103619 sdev_dev;
103620diff --git a/include/scsi/scsi_driver.h b/include/scsi/scsi_driver.h
103621index 891a658..fcd68df 100644
103622--- a/include/scsi/scsi_driver.h
103623+++ b/include/scsi/scsi_driver.h
103624@@ -14,7 +14,7 @@ struct scsi_driver {
103625 void (*rescan)(struct device *);
103626 int (*init_command)(struct scsi_cmnd *);
103627 void (*uninit_command)(struct scsi_cmnd *);
103628- int (*done)(struct scsi_cmnd *);
103629+ unsigned int (*done)(struct scsi_cmnd *);
103630 int (*eh_action)(struct scsi_cmnd *, int);
103631 };
103632 #define to_scsi_driver(drv) \
103633diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
103634index 784bc2c..855a04c 100644
103635--- a/include/scsi/scsi_transport_fc.h
103636+++ b/include/scsi/scsi_transport_fc.h
103637@@ -757,7 +757,8 @@ struct fc_function_template {
103638 unsigned long show_host_system_hostname:1;
103639
103640 unsigned long disable_target_scan:1;
103641-};
103642+} __do_const;
103643+typedef struct fc_function_template __no_const fc_function_template_no_const;
103644
103645
103646 /**
103647diff --git a/include/scsi/sg.h b/include/scsi/sg.h
103648index 3afec70..b196b43 100644
103649--- a/include/scsi/sg.h
103650+++ b/include/scsi/sg.h
103651@@ -52,7 +52,7 @@ typedef struct sg_io_hdr
103652 or scatter gather list */
103653 unsigned char __user *cmdp; /* [i], [*i] points to command to perform */
103654 void __user *sbp; /* [i], [*o] points to sense_buffer memory */
103655- unsigned int timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
103656+ unsigned int timeout __intentional_overflow(-1); /* [i] MAX_UINT->no timeout (unit: millisec) */
103657 unsigned int flags; /* [i] 0 -> default, see SG_FLAG... */
103658 int pack_id; /* [i->o] unused internally (normally) */
103659 void __user * usr_ptr; /* [i->o] unused internally */
103660diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
103661index fa1d055..3647940 100644
103662--- a/include/sound/compress_driver.h
103663+++ b/include/sound/compress_driver.h
103664@@ -130,7 +130,7 @@ struct snd_compr_ops {
103665 struct snd_compr_caps *caps);
103666 int (*get_codec_caps) (struct snd_compr_stream *stream,
103667 struct snd_compr_codec_caps *codec);
103668-};
103669+} __no_const;
103670
103671 /**
103672 * struct snd_compr: Compressed device
103673diff --git a/include/sound/soc.h b/include/sound/soc.h
103674index 93df8bf..c84577b 100644
103675--- a/include/sound/soc.h
103676+++ b/include/sound/soc.h
103677@@ -883,7 +883,7 @@ struct snd_soc_codec_driver {
103678 enum snd_soc_dapm_type, int);
103679
103680 bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */
103681-};
103682+} __do_const;
103683
103684 /* SoC platform interface */
103685 struct snd_soc_platform_driver {
103686@@ -910,7 +910,7 @@ struct snd_soc_platform_driver {
103687 const struct snd_compr_ops *compr_ops;
103688
103689 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
103690-};
103691+} __do_const;
103692
103693 struct snd_soc_dai_link_component {
103694 const char *name;
103695diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
103696index 17ae2d6..2c06382 100644
103697--- a/include/target/target_core_base.h
103698+++ b/include/target/target_core_base.h
103699@@ -751,7 +751,7 @@ struct se_device {
103700 atomic_long_t write_bytes;
103701 /* Active commands on this virtual SE device */
103702 atomic_t simple_cmds;
103703- atomic_t dev_ordered_id;
103704+ atomic_unchecked_t dev_ordered_id;
103705 atomic_t dev_ordered_sync;
103706 atomic_t dev_qf_count;
103707 u32 export_count;
103708diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
103709new file mode 100644
103710index 0000000..fb634b7
103711--- /dev/null
103712+++ b/include/trace/events/fs.h
103713@@ -0,0 +1,53 @@
103714+#undef TRACE_SYSTEM
103715+#define TRACE_SYSTEM fs
103716+
103717+#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
103718+#define _TRACE_FS_H
103719+
103720+#include <linux/fs.h>
103721+#include <linux/tracepoint.h>
103722+
103723+TRACE_EVENT(do_sys_open,
103724+
103725+ TP_PROTO(const char *filename, int flags, int mode),
103726+
103727+ TP_ARGS(filename, flags, mode),
103728+
103729+ TP_STRUCT__entry(
103730+ __string( filename, filename )
103731+ __field( int, flags )
103732+ __field( int, mode )
103733+ ),
103734+
103735+ TP_fast_assign(
103736+ __assign_str(filename, filename);
103737+ __entry->flags = flags;
103738+ __entry->mode = mode;
103739+ ),
103740+
103741+ TP_printk("\"%s\" %x %o",
103742+ __get_str(filename), __entry->flags, __entry->mode)
103743+);
103744+
103745+TRACE_EVENT(open_exec,
103746+
103747+ TP_PROTO(const char *filename),
103748+
103749+ TP_ARGS(filename),
103750+
103751+ TP_STRUCT__entry(
103752+ __string( filename, filename )
103753+ ),
103754+
103755+ TP_fast_assign(
103756+ __assign_str(filename, filename);
103757+ ),
103758+
103759+ TP_printk("\"%s\"",
103760+ __get_str(filename))
103761+);
103762+
103763+#endif /* _TRACE_FS_H */
103764+
103765+/* This part must be outside protection */
103766+#include <trace/define_trace.h>
103767diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
103768index ff8f6c0..6b6bae3 100644
103769--- a/include/trace/events/irq.h
103770+++ b/include/trace/events/irq.h
103771@@ -51,7 +51,7 @@ SOFTIRQ_NAME_LIST
103772 */
103773 TRACE_EVENT(irq_handler_entry,
103774
103775- TP_PROTO(int irq, struct irqaction *action),
103776+ TP_PROTO(int irq, const struct irqaction *action),
103777
103778 TP_ARGS(irq, action),
103779
103780@@ -81,7 +81,7 @@ TRACE_EVENT(irq_handler_entry,
103781 */
103782 TRACE_EVENT(irq_handler_exit,
103783
103784- TP_PROTO(int irq, struct irqaction *action, int ret),
103785+ TP_PROTO(int irq, const struct irqaction *action, int ret),
103786
103787 TP_ARGS(irq, action, ret),
103788
103789diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
103790index db809b7..05a44aa 100644
103791--- a/include/uapi/drm/i915_drm.h
103792+++ b/include/uapi/drm/i915_drm.h
103793@@ -354,6 +354,7 @@ typedef struct drm_i915_irq_wait {
103794 #define I915_PARAM_REVISION 32
103795 #define I915_PARAM_SUBSLICE_TOTAL 33
103796 #define I915_PARAM_EU_TOTAL 34
103797+#define I915_PARAM_HAS_LEGACY_CONTEXT 35
103798
103799 typedef struct drm_i915_getparam {
103800 int param;
103801diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
103802index 7caf44c..23c6f27 100644
103803--- a/include/uapi/linux/a.out.h
103804+++ b/include/uapi/linux/a.out.h
103805@@ -39,6 +39,14 @@ enum machine_type {
103806 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
103807 };
103808
103809+/* Constants for the N_FLAGS field */
103810+#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
103811+#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
103812+#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
103813+#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
103814+/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
103815+#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
103816+
103817 #if !defined (N_MAGIC)
103818 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
103819 #endif
103820diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h
103821index 22b6ad3..aeba37e 100644
103822--- a/include/uapi/linux/bcache.h
103823+++ b/include/uapi/linux/bcache.h
103824@@ -5,6 +5,7 @@
103825 * Bcache on disk data structures
103826 */
103827
103828+#include <linux/compiler.h>
103829 #include <asm/types.h>
103830
103831 #define BITMASK(name, type, field, offset, size) \
103832@@ -20,8 +21,8 @@ static inline void SET_##name(type *k, __u64 v) \
103833 /* Btree keys - all units are in sectors */
103834
103835 struct bkey {
103836- __u64 high;
103837- __u64 low;
103838+ __u64 high __intentional_overflow(-1);
103839+ __u64 low __intentional_overflow(-1);
103840 __u64 ptr[];
103841 };
103842
103843diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
103844index d876736..ccce5c0 100644
103845--- a/include/uapi/linux/byteorder/little_endian.h
103846+++ b/include/uapi/linux/byteorder/little_endian.h
103847@@ -42,51 +42,51 @@
103848
103849 static inline __le64 __cpu_to_le64p(const __u64 *p)
103850 {
103851- return (__force __le64)*p;
103852+ return (__force const __le64)*p;
103853 }
103854-static inline __u64 __le64_to_cpup(const __le64 *p)
103855+static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
103856 {
103857- return (__force __u64)*p;
103858+ return (__force const __u64)*p;
103859 }
103860 static inline __le32 __cpu_to_le32p(const __u32 *p)
103861 {
103862- return (__force __le32)*p;
103863+ return (__force const __le32)*p;
103864 }
103865 static inline __u32 __le32_to_cpup(const __le32 *p)
103866 {
103867- return (__force __u32)*p;
103868+ return (__force const __u32)*p;
103869 }
103870 static inline __le16 __cpu_to_le16p(const __u16 *p)
103871 {
103872- return (__force __le16)*p;
103873+ return (__force const __le16)*p;
103874 }
103875 static inline __u16 __le16_to_cpup(const __le16 *p)
103876 {
103877- return (__force __u16)*p;
103878+ return (__force const __u16)*p;
103879 }
103880 static inline __be64 __cpu_to_be64p(const __u64 *p)
103881 {
103882- return (__force __be64)__swab64p(p);
103883+ return (__force const __be64)__swab64p(p);
103884 }
103885 static inline __u64 __be64_to_cpup(const __be64 *p)
103886 {
103887- return __swab64p((__u64 *)p);
103888+ return __swab64p((const __u64 *)p);
103889 }
103890 static inline __be32 __cpu_to_be32p(const __u32 *p)
103891 {
103892- return (__force __be32)__swab32p(p);
103893+ return (__force const __be32)__swab32p(p);
103894 }
103895-static inline __u32 __be32_to_cpup(const __be32 *p)
103896+static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
103897 {
103898- return __swab32p((__u32 *)p);
103899+ return __swab32p((const __u32 *)p);
103900 }
103901 static inline __be16 __cpu_to_be16p(const __u16 *p)
103902 {
103903- return (__force __be16)__swab16p(p);
103904+ return (__force const __be16)__swab16p(p);
103905 }
103906 static inline __u16 __be16_to_cpup(const __be16 *p)
103907 {
103908- return __swab16p((__u16 *)p);
103909+ return __swab16p((const __u16 *)p);
103910 }
103911 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
103912 #define __le64_to_cpus(x) do { (void)(x); } while (0)
103913diff --git a/include/uapi/linux/connector.h b/include/uapi/linux/connector.h
103914index 4cb2835..cfbc4e2 100644
103915--- a/include/uapi/linux/connector.h
103916+++ b/include/uapi/linux/connector.h
103917@@ -69,7 +69,7 @@ struct cb_id {
103918 struct cn_msg {
103919 struct cb_id id;
103920
103921- __u32 seq;
103922+ __u32 seq __intentional_overflow(-1);
103923 __u32 ack;
103924
103925 __u16 len; /* Length of the following data */
103926diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
103927index 71e1d0e..6cc9caf 100644
103928--- a/include/uapi/linux/elf.h
103929+++ b/include/uapi/linux/elf.h
103930@@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
103931 #define PT_GNU_EH_FRAME 0x6474e550
103932
103933 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
103934+#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
103935+
103936+#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
103937+
103938+/* Constants for the e_flags field */
103939+#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
103940+#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
103941+#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
103942+#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
103943+/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
103944+#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
103945
103946 /*
103947 * Extended Numbering
103948@@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
103949 #define DT_DEBUG 21
103950 #define DT_TEXTREL 22
103951 #define DT_JMPREL 23
103952+#define DT_FLAGS 30
103953+ #define DF_TEXTREL 0x00000004
103954 #define DT_ENCODING 32
103955 #define OLD_DT_LOOS 0x60000000
103956 #define DT_LOOS 0x6000000d
103957@@ -240,6 +253,19 @@ typedef struct elf64_hdr {
103958 #define PF_W 0x2
103959 #define PF_X 0x1
103960
103961+#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
103962+#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
103963+#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
103964+#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
103965+#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
103966+#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
103967+/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
103968+/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
103969+#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
103970+#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
103971+#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
103972+#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
103973+
103974 typedef struct elf32_phdr{
103975 Elf32_Word p_type;
103976 Elf32_Off p_offset;
103977@@ -332,6 +358,8 @@ typedef struct elf64_shdr {
103978 #define EI_OSABI 7
103979 #define EI_PAD 8
103980
103981+#define EI_PAX 14
103982+
103983 #define ELFMAG0 0x7f /* EI_MAG */
103984 #define ELFMAG1 'E'
103985 #define ELFMAG2 'L'
103986diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
103987index aa169c4..6a2771d 100644
103988--- a/include/uapi/linux/personality.h
103989+++ b/include/uapi/linux/personality.h
103990@@ -30,6 +30,7 @@ enum {
103991 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
103992 ADDR_NO_RANDOMIZE | \
103993 ADDR_COMPAT_LAYOUT | \
103994+ ADDR_LIMIT_3GB | \
103995 MMAP_PAGE_ZERO)
103996
103997 /*
103998diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
103999index 7530e74..e714828 100644
104000--- a/include/uapi/linux/screen_info.h
104001+++ b/include/uapi/linux/screen_info.h
104002@@ -43,7 +43,8 @@ struct screen_info {
104003 __u16 pages; /* 0x32 */
104004 __u16 vesa_attributes; /* 0x34 */
104005 __u32 capabilities; /* 0x36 */
104006- __u8 _reserved[6]; /* 0x3a */
104007+ __u16 vesapm_size; /* 0x3a */
104008+ __u8 _reserved[4]; /* 0x3c */
104009 } __attribute__((packed));
104010
104011 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
104012diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
104013index 0e011eb..82681b1 100644
104014--- a/include/uapi/linux/swab.h
104015+++ b/include/uapi/linux/swab.h
104016@@ -43,7 +43,7 @@
104017 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
104018 */
104019
104020-static inline __attribute_const__ __u16 __fswab16(__u16 val)
104021+static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
104022 {
104023 #ifdef __HAVE_BUILTIN_BSWAP16__
104024 return __builtin_bswap16(val);
104025@@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
104026 #endif
104027 }
104028
104029-static inline __attribute_const__ __u32 __fswab32(__u32 val)
104030+static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
104031 {
104032 #ifdef __HAVE_BUILTIN_BSWAP32__
104033 return __builtin_bswap32(val);
104034@@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
104035 #endif
104036 }
104037
104038-static inline __attribute_const__ __u64 __fswab64(__u64 val)
104039+static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
104040 {
104041 #ifdef __HAVE_BUILTIN_BSWAP64__
104042 return __builtin_bswap64(val);
104043diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
104044index 1590c49..5eab462 100644
104045--- a/include/uapi/linux/xattr.h
104046+++ b/include/uapi/linux/xattr.h
104047@@ -73,5 +73,9 @@
104048 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
104049 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
104050
104051+/* User namespace */
104052+#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
104053+#define XATTR_PAX_FLAGS_SUFFIX "flags"
104054+#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
104055
104056 #endif /* _UAPI_LINUX_XATTR_H */
104057diff --git a/include/video/udlfb.h b/include/video/udlfb.h
104058index f9466fa..f4e2b81 100644
104059--- a/include/video/udlfb.h
104060+++ b/include/video/udlfb.h
104061@@ -53,10 +53,10 @@ struct dlfb_data {
104062 u32 pseudo_palette[256];
104063 int blank_mode; /*one of FB_BLANK_ */
104064 /* blit-only rendering path metrics, exposed through sysfs */
104065- atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
104066- atomic_t bytes_identical; /* saved effort with backbuffer comparison */
104067- atomic_t bytes_sent; /* to usb, after compression including overhead */
104068- atomic_t cpu_kcycles_used; /* transpired during pixel processing */
104069+ atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
104070+ atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
104071+ atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
104072+ atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
104073 };
104074
104075 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
104076diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
104077index 30f5362..8ed8ac9 100644
104078--- a/include/video/uvesafb.h
104079+++ b/include/video/uvesafb.h
104080@@ -122,6 +122,7 @@ struct uvesafb_par {
104081 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
104082 u8 pmi_setpal; /* PMI for palette changes */
104083 u16 *pmi_base; /* protected mode interface location */
104084+ u8 *pmi_code; /* protected mode code location */
104085 void *pmi_start;
104086 void *pmi_pal;
104087 u8 *vbe_state_orig; /*
104088diff --git a/init/Kconfig b/init/Kconfig
104089index af09b4f..5ee6e6a 100644
104090--- a/init/Kconfig
104091+++ b/init/Kconfig
104092@@ -642,6 +642,7 @@ config RCU_FAST_NO_HZ
104093 config TREE_RCU_TRACE
104094 def_bool RCU_TRACE && ( TREE_RCU || PREEMPT_RCU )
104095 select DEBUG_FS
104096+ depends on !GRKERNSEC_KMEM
104097 help
104098 This option provides tracing for the TREE_RCU and
104099 PREEMPT_RCU implementations, permitting Makefile to
104100@@ -1139,6 +1140,7 @@ endif # CGROUPS
104101 config CHECKPOINT_RESTORE
104102 bool "Checkpoint/restore support" if EXPERT
104103 select PROC_CHILDREN
104104+ depends on !GRKERNSEC
104105 default n
104106 help
104107 Enables additional kernel features in a sake of checkpoint/restore.
104108@@ -1664,7 +1666,7 @@ config SLUB_DEBUG
104109
104110 config COMPAT_BRK
104111 bool "Disable heap randomization"
104112- default y
104113+ default n
104114 help
104115 Randomizing heap placement makes heap exploits harder, but it
104116 also breaks ancient binaries (including anything libc5 based).
104117@@ -1994,7 +1996,7 @@ config INIT_ALL_POSSIBLE
104118 config STOP_MACHINE
104119 bool
104120 default y
104121- depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
104122+ depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
104123 help
104124 Need stop_machine() primitive.
104125
104126diff --git a/init/Makefile b/init/Makefile
104127index 7bc47ee..6da2dc7 100644
104128--- a/init/Makefile
104129+++ b/init/Makefile
104130@@ -2,6 +2,9 @@
104131 # Makefile for the linux kernel.
104132 #
104133
104134+ccflags-y := $(GCC_PLUGINS_CFLAGS)
104135+asflags-y := $(GCC_PLUGINS_AFLAGS)
104136+
104137 obj-y := main.o version.o mounts.o
104138 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
104139 obj-y += noinitramfs.o
104140diff --git a/init/do_mounts.c b/init/do_mounts.c
104141index dea5de9..bbdbb5f 100644
104142--- a/init/do_mounts.c
104143+++ b/init/do_mounts.c
104144@@ -363,11 +363,11 @@ static void __init get_fs_names(char *page)
104145 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
104146 {
104147 struct super_block *s;
104148- int err = sys_mount(name, "/root", fs, flags, data);
104149+ int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
104150 if (err)
104151 return err;
104152
104153- sys_chdir("/root");
104154+ sys_chdir((const char __force_user *)"/root");
104155 s = current->fs->pwd.dentry->d_sb;
104156 ROOT_DEV = s->s_dev;
104157 printk(KERN_INFO
104158@@ -490,18 +490,18 @@ void __init change_floppy(char *fmt, ...)
104159 va_start(args, fmt);
104160 vsprintf(buf, fmt, args);
104161 va_end(args);
104162- fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
104163+ fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
104164 if (fd >= 0) {
104165 sys_ioctl(fd, FDEJECT, 0);
104166 sys_close(fd);
104167 }
104168 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
104169- fd = sys_open("/dev/console", O_RDWR, 0);
104170+ fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
104171 if (fd >= 0) {
104172 sys_ioctl(fd, TCGETS, (long)&termios);
104173 termios.c_lflag &= ~ICANON;
104174 sys_ioctl(fd, TCSETSF, (long)&termios);
104175- sys_read(fd, &c, 1);
104176+ sys_read(fd, (char __user *)&c, 1);
104177 termios.c_lflag |= ICANON;
104178 sys_ioctl(fd, TCSETSF, (long)&termios);
104179 sys_close(fd);
104180@@ -600,8 +600,8 @@ void __init prepare_namespace(void)
104181 mount_root();
104182 out:
104183 devtmpfs_mount("dev");
104184- sys_mount(".", "/", NULL, MS_MOVE, NULL);
104185- sys_chroot(".");
104186+ sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
104187+ sys_chroot((const char __force_user *)".");
104188 }
104189
104190 static bool is_tmpfs;
104191diff --git a/init/do_mounts.h b/init/do_mounts.h
104192index f5b978a..69dbfe8 100644
104193--- a/init/do_mounts.h
104194+++ b/init/do_mounts.h
104195@@ -15,15 +15,15 @@ extern int root_mountflags;
104196
104197 static inline int create_dev(char *name, dev_t dev)
104198 {
104199- sys_unlink(name);
104200- return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
104201+ sys_unlink((char __force_user *)name);
104202+ return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
104203 }
104204
104205 #if BITS_PER_LONG == 32
104206 static inline u32 bstat(char *name)
104207 {
104208 struct stat64 stat;
104209- if (sys_stat64(name, &stat) != 0)
104210+ if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
104211 return 0;
104212 if (!S_ISBLK(stat.st_mode))
104213 return 0;
104214@@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
104215 static inline u32 bstat(char *name)
104216 {
104217 struct stat stat;
104218- if (sys_newstat(name, &stat) != 0)
104219+ if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
104220 return 0;
104221 if (!S_ISBLK(stat.st_mode))
104222 return 0;
104223diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
104224index 3e0878e..8a9d7a0 100644
104225--- a/init/do_mounts_initrd.c
104226+++ b/init/do_mounts_initrd.c
104227@@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
104228 {
104229 sys_unshare(CLONE_FS | CLONE_FILES);
104230 /* stdin/stdout/stderr for /linuxrc */
104231- sys_open("/dev/console", O_RDWR, 0);
104232+ sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
104233 sys_dup(0);
104234 sys_dup(0);
104235 /* move initrd over / and chdir/chroot in initrd root */
104236- sys_chdir("/root");
104237- sys_mount(".", "/", NULL, MS_MOVE, NULL);
104238- sys_chroot(".");
104239+ sys_chdir((const char __force_user *)"/root");
104240+ sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
104241+ sys_chroot((const char __force_user *)".");
104242 sys_setsid();
104243 return 0;
104244 }
104245@@ -59,8 +59,8 @@ static void __init handle_initrd(void)
104246 create_dev("/dev/root.old", Root_RAM0);
104247 /* mount initrd on rootfs' /root */
104248 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
104249- sys_mkdir("/old", 0700);
104250- sys_chdir("/old");
104251+ sys_mkdir((const char __force_user *)"/old", 0700);
104252+ sys_chdir((const char __force_user *)"/old");
104253
104254 /* try loading default modules from initrd */
104255 load_default_modules();
104256@@ -80,31 +80,31 @@ static void __init handle_initrd(void)
104257 current->flags &= ~PF_FREEZER_SKIP;
104258
104259 /* move initrd to rootfs' /old */
104260- sys_mount("..", ".", NULL, MS_MOVE, NULL);
104261+ sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
104262 /* switch root and cwd back to / of rootfs */
104263- sys_chroot("..");
104264+ sys_chroot((const char __force_user *)"..");
104265
104266 if (new_decode_dev(real_root_dev) == Root_RAM0) {
104267- sys_chdir("/old");
104268+ sys_chdir((const char __force_user *)"/old");
104269 return;
104270 }
104271
104272- sys_chdir("/");
104273+ sys_chdir((const char __force_user *)"/");
104274 ROOT_DEV = new_decode_dev(real_root_dev);
104275 mount_root();
104276
104277 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
104278- error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
104279+ error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
104280 if (!error)
104281 printk("okay\n");
104282 else {
104283- int fd = sys_open("/dev/root.old", O_RDWR, 0);
104284+ int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
104285 if (error == -ENOENT)
104286 printk("/initrd does not exist. Ignored.\n");
104287 else
104288 printk("failed\n");
104289 printk(KERN_NOTICE "Unmounting old root\n");
104290- sys_umount("/old", MNT_DETACH);
104291+ sys_umount((char __force_user *)"/old", MNT_DETACH);
104292 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
104293 if (fd < 0) {
104294 error = fd;
104295@@ -127,11 +127,11 @@ int __init initrd_load(void)
104296 * mounted in the normal path.
104297 */
104298 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
104299- sys_unlink("/initrd.image");
104300+ sys_unlink((const char __force_user *)"/initrd.image");
104301 handle_initrd();
104302 return 1;
104303 }
104304 }
104305- sys_unlink("/initrd.image");
104306+ sys_unlink((const char __force_user *)"/initrd.image");
104307 return 0;
104308 }
104309diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
104310index 8cb6db5..d729f50 100644
104311--- a/init/do_mounts_md.c
104312+++ b/init/do_mounts_md.c
104313@@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
104314 partitioned ? "_d" : "", minor,
104315 md_setup_args[ent].device_names);
104316
104317- fd = sys_open(name, 0, 0);
104318+ fd = sys_open((char __force_user *)name, 0, 0);
104319 if (fd < 0) {
104320 printk(KERN_ERR "md: open failed - cannot start "
104321 "array %s\n", name);
104322@@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
104323 * array without it
104324 */
104325 sys_close(fd);
104326- fd = sys_open(name, 0, 0);
104327+ fd = sys_open((char __force_user *)name, 0, 0);
104328 sys_ioctl(fd, BLKRRPART, 0);
104329 }
104330 sys_close(fd);
104331@@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
104332
104333 wait_for_device_probe();
104334
104335- fd = sys_open("/dev/md0", 0, 0);
104336+ fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
104337 if (fd >= 0) {
104338 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
104339 sys_close(fd);
104340diff --git a/init/init_task.c b/init/init_task.c
104341index ba0a7f36..2bcf1d5 100644
104342--- a/init/init_task.c
104343+++ b/init/init_task.c
104344@@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
104345 * Initial thread structure. Alignment of this is handled by a special
104346 * linker map entry.
104347 */
104348+#ifdef CONFIG_X86
104349+union thread_union init_thread_union __init_task_data;
104350+#else
104351 union thread_union init_thread_union __init_task_data =
104352 { INIT_THREAD_INFO(init_task) };
104353+#endif
104354diff --git a/init/initramfs.c b/init/initramfs.c
104355index ad1bd77..dca2c1b 100644
104356--- a/init/initramfs.c
104357+++ b/init/initramfs.c
104358@@ -25,7 +25,7 @@ static ssize_t __init xwrite(int fd, const char *p, size_t count)
104359
104360 /* sys_write only can write MAX_RW_COUNT aka 2G-4K bytes at most */
104361 while (count) {
104362- ssize_t rv = sys_write(fd, p, count);
104363+ ssize_t rv = sys_write(fd, (char __force_user *)p, count);
104364
104365 if (rv < 0) {
104366 if (rv == -EINTR || rv == -EAGAIN)
104367@@ -107,7 +107,7 @@ static void __init free_hash(void)
104368 }
104369 }
104370
104371-static long __init do_utime(char *filename, time_t mtime)
104372+static long __init do_utime(char __force_user *filename, time_t mtime)
104373 {
104374 struct timespec t[2];
104375
104376@@ -142,7 +142,7 @@ static void __init dir_utime(void)
104377 struct dir_entry *de, *tmp;
104378 list_for_each_entry_safe(de, tmp, &dir_list, list) {
104379 list_del(&de->list);
104380- do_utime(de->name, de->mtime);
104381+ do_utime((char __force_user *)de->name, de->mtime);
104382 kfree(de->name);
104383 kfree(de);
104384 }
104385@@ -304,7 +304,7 @@ static int __init maybe_link(void)
104386 if (nlink >= 2) {
104387 char *old = find_link(major, minor, ino, mode, collected);
104388 if (old)
104389- return (sys_link(old, collected) < 0) ? -1 : 1;
104390+ return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
104391 }
104392 return 0;
104393 }
104394@@ -313,11 +313,11 @@ static void __init clean_path(char *path, umode_t fmode)
104395 {
104396 struct stat st;
104397
104398- if (!sys_newlstat(path, &st) && (st.st_mode ^ fmode) & S_IFMT) {
104399+ if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode ^ fmode) & S_IFMT) {
104400 if (S_ISDIR(st.st_mode))
104401- sys_rmdir(path);
104402+ sys_rmdir((char __force_user *)path);
104403 else
104404- sys_unlink(path);
104405+ sys_unlink((char __force_user *)path);
104406 }
104407 }
104408
104409@@ -338,7 +338,7 @@ static int __init do_name(void)
104410 int openflags = O_WRONLY|O_CREAT;
104411 if (ml != 1)
104412 openflags |= O_TRUNC;
104413- wfd = sys_open(collected, openflags, mode);
104414+ wfd = sys_open((char __force_user *)collected, openflags, mode);
104415
104416 if (wfd >= 0) {
104417 sys_fchown(wfd, uid, gid);
104418@@ -350,17 +350,17 @@ static int __init do_name(void)
104419 }
104420 }
104421 } else if (S_ISDIR(mode)) {
104422- sys_mkdir(collected, mode);
104423- sys_chown(collected, uid, gid);
104424- sys_chmod(collected, mode);
104425+ sys_mkdir((char __force_user *)collected, mode);
104426+ sys_chown((char __force_user *)collected, uid, gid);
104427+ sys_chmod((char __force_user *)collected, mode);
104428 dir_add(collected, mtime);
104429 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
104430 S_ISFIFO(mode) || S_ISSOCK(mode)) {
104431 if (maybe_link() == 0) {
104432- sys_mknod(collected, mode, rdev);
104433- sys_chown(collected, uid, gid);
104434- sys_chmod(collected, mode);
104435- do_utime(collected, mtime);
104436+ sys_mknod((char __force_user *)collected, mode, rdev);
104437+ sys_chown((char __force_user *)collected, uid, gid);
104438+ sys_chmod((char __force_user *)collected, mode);
104439+ do_utime((char __force_user *)collected, mtime);
104440 }
104441 }
104442 return 0;
104443@@ -372,7 +372,7 @@ static int __init do_copy(void)
104444 if (xwrite(wfd, victim, body_len) != body_len)
104445 error("write error");
104446 sys_close(wfd);
104447- do_utime(vcollected, mtime);
104448+ do_utime((char __force_user *)vcollected, mtime);
104449 kfree(vcollected);
104450 eat(body_len);
104451 state = SkipIt;
104452@@ -390,9 +390,9 @@ static int __init do_symlink(void)
104453 {
104454 collected[N_ALIGN(name_len) + body_len] = '\0';
104455 clean_path(collected, 0);
104456- sys_symlink(collected + N_ALIGN(name_len), collected);
104457- sys_lchown(collected, uid, gid);
104458- do_utime(collected, mtime);
104459+ sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
104460+ sys_lchown((char __force_user *)collected, uid, gid);
104461+ do_utime((char __force_user *)collected, mtime);
104462 state = SkipIt;
104463 next_state = Reset;
104464 return 0;
104465diff --git a/init/main.c b/init/main.c
104466index 5650655..937d1b1 100644
104467--- a/init/main.c
104468+++ b/init/main.c
104469@@ -97,6 +97,8 @@ extern void radix_tree_init(void);
104470 static inline void mark_rodata_ro(void) { }
104471 #endif
104472
104473+extern void grsecurity_init(void);
104474+
104475 /*
104476 * Debug helper: via this flag we know that we are in 'early bootup code'
104477 * where only the boot processor is running with IRQ disabled. This means
104478@@ -158,6 +160,37 @@ static int __init set_reset_devices(char *str)
104479
104480 __setup("reset_devices", set_reset_devices);
104481
104482+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
104483+kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
104484+static int __init setup_grsec_proc_gid(char *str)
104485+{
104486+ grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
104487+ return 1;
104488+}
104489+__setup("grsec_proc_gid=", setup_grsec_proc_gid);
104490+#endif
104491+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
104492+int grsec_enable_sysfs_restrict = 1;
104493+static int __init setup_grsec_sysfs_restrict(char *str)
104494+{
104495+ if (!simple_strtol(str, NULL, 0))
104496+ grsec_enable_sysfs_restrict = 0;
104497+ return 1;
104498+}
104499+__setup("grsec_sysfs_restrict", setup_grsec_sysfs_restrict);
104500+#endif
104501+
104502+#ifdef CONFIG_PAX_SOFTMODE
104503+int pax_softmode;
104504+
104505+static int __init setup_pax_softmode(char *str)
104506+{
104507+ get_option(&str, &pax_softmode);
104508+ return 1;
104509+}
104510+__setup("pax_softmode=", setup_pax_softmode);
104511+#endif
104512+
104513 static const char *argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
104514 const char *envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
104515 static const char *panic_later, *panic_param;
104516@@ -731,7 +764,7 @@ static bool __init_or_module initcall_blacklisted(initcall_t fn)
104517 struct blacklist_entry *entry;
104518 char *fn_name;
104519
104520- fn_name = kasprintf(GFP_KERNEL, "%pf", fn);
104521+ fn_name = kasprintf(GFP_KERNEL, "%pX", fn);
104522 if (!fn_name)
104523 return false;
104524
104525@@ -783,7 +816,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
104526 {
104527 int count = preempt_count();
104528 int ret;
104529- char msgbuf[64];
104530+ const char *msg1 = "", *msg2 = "";
104531
104532 if (initcall_blacklisted(fn))
104533 return -EPERM;
104534@@ -793,18 +826,17 @@ int __init_or_module do_one_initcall(initcall_t fn)
104535 else
104536 ret = fn();
104537
104538- msgbuf[0] = 0;
104539-
104540 if (preempt_count() != count) {
104541- sprintf(msgbuf, "preemption imbalance ");
104542+ msg1 = " preemption imbalance";
104543 preempt_count_set(count);
104544 }
104545 if (irqs_disabled()) {
104546- strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
104547+ msg2 = " disabled interrupts";
104548 local_irq_enable();
104549 }
104550- WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
104551+ WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
104552
104553+ add_latent_entropy();
104554 return ret;
104555 }
104556
104557@@ -910,8 +942,8 @@ static int run_init_process(const char *init_filename)
104558 {
104559 argv_init[0] = init_filename;
104560 return do_execve(getname_kernel(init_filename),
104561- (const char __user *const __user *)argv_init,
104562- (const char __user *const __user *)envp_init);
104563+ (const char __user *const __force_user *)argv_init,
104564+ (const char __user *const __force_user *)envp_init);
104565 }
104566
104567 static int try_to_run_init_process(const char *init_filename)
104568@@ -928,6 +960,10 @@ static int try_to_run_init_process(const char *init_filename)
104569 return ret;
104570 }
104571
104572+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
104573+extern int gr_init_ran;
104574+#endif
104575+
104576 static noinline void __init kernel_init_freeable(void);
104577
104578 static int __ref kernel_init(void *unused)
104579@@ -952,6 +988,11 @@ static int __ref kernel_init(void *unused)
104580 ramdisk_execute_command, ret);
104581 }
104582
104583+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
104584+ /* if no initrd was used, be extra sure we enforce chroot restrictions */
104585+ gr_init_ran = 1;
104586+#endif
104587+
104588 /*
104589 * We try each of these until one succeeds.
104590 *
104591@@ -1009,7 +1050,7 @@ static noinline void __init kernel_init_freeable(void)
104592 do_basic_setup();
104593
104594 /* Open the /dev/console on the rootfs, this should never fail */
104595- if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
104596+ if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
104597 pr_err("Warning: unable to open an initial console.\n");
104598
104599 (void) sys_dup(0);
104600@@ -1022,11 +1063,13 @@ static noinline void __init kernel_init_freeable(void)
104601 if (!ramdisk_execute_command)
104602 ramdisk_execute_command = "/init";
104603
104604- if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
104605+ if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
104606 ramdisk_execute_command = NULL;
104607 prepare_namespace();
104608 }
104609
104610+ grsecurity_init();
104611+
104612 /*
104613 * Ok, we have completed the initial bootup, and
104614 * we're essentially up and running. Get rid of the
104615diff --git a/ipc/compat.c b/ipc/compat.c
104616index 9b3c85f..5266b0f 100644
104617--- a/ipc/compat.c
104618+++ b/ipc/compat.c
104619@@ -396,7 +396,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,
104620 COMPAT_SHMLBA);
104621 if (err < 0)
104622 return err;
104623- return put_user(raddr, (compat_ulong_t *)compat_ptr(third));
104624+ return put_user(raddr, (compat_ulong_t __user *)compat_ptr(third));
104625 }
104626 case SHMDT:
104627 return sys_shmdt(compat_ptr(ptr));
104628@@ -747,7 +747,7 @@ COMPAT_SYSCALL_DEFINE3(shmctl, int, first, int, second, void __user *, uptr)
104629 }
104630
104631 COMPAT_SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsems,
104632- unsigned, nsops,
104633+ compat_long_t, nsops,
104634 const struct compat_timespec __user *, timeout)
104635 {
104636 struct timespec __user *ts64;
104637diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
104638index 8ad93c2..efd80f8 100644
104639--- a/ipc/ipc_sysctl.c
104640+++ b/ipc/ipc_sysctl.c
104641@@ -30,7 +30,7 @@ static void *get_ipc(struct ctl_table *table)
104642 static int proc_ipc_dointvec(struct ctl_table *table, int write,
104643 void __user *buffer, size_t *lenp, loff_t *ppos)
104644 {
104645- struct ctl_table ipc_table;
104646+ ctl_table_no_const ipc_table;
104647
104648 memcpy(&ipc_table, table, sizeof(ipc_table));
104649 ipc_table.data = get_ipc(table);
104650@@ -41,7 +41,7 @@ static int proc_ipc_dointvec(struct ctl_table *table, int write,
104651 static int proc_ipc_dointvec_minmax(struct ctl_table *table, int write,
104652 void __user *buffer, size_t *lenp, loff_t *ppos)
104653 {
104654- struct ctl_table ipc_table;
104655+ ctl_table_no_const ipc_table;
104656
104657 memcpy(&ipc_table, table, sizeof(ipc_table));
104658 ipc_table.data = get_ipc(table);
104659@@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(struct ctl_table *table, int write,
104660 static int proc_ipc_doulongvec_minmax(struct ctl_table *table, int write,
104661 void __user *buffer, size_t *lenp, loff_t *ppos)
104662 {
104663- struct ctl_table ipc_table;
104664+ ctl_table_no_const ipc_table;
104665 memcpy(&ipc_table, table, sizeof(ipc_table));
104666 ipc_table.data = get_ipc(table);
104667
104668@@ -76,7 +76,7 @@ static int proc_ipc_doulongvec_minmax(struct ctl_table *table, int write,
104669 static int proc_ipc_auto_msgmni(struct ctl_table *table, int write,
104670 void __user *buffer, size_t *lenp, loff_t *ppos)
104671 {
104672- struct ctl_table ipc_table;
104673+ ctl_table_no_const ipc_table;
104674 int dummy = 0;
104675
104676 memcpy(&ipc_table, table, sizeof(ipc_table));
104677diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
104678index 68d4e95..1477ded 100644
104679--- a/ipc/mq_sysctl.c
104680+++ b/ipc/mq_sysctl.c
104681@@ -25,7 +25,7 @@ static void *get_mq(struct ctl_table *table)
104682 static int proc_mq_dointvec(struct ctl_table *table, int write,
104683 void __user *buffer, size_t *lenp, loff_t *ppos)
104684 {
104685- struct ctl_table mq_table;
104686+ ctl_table_no_const mq_table;
104687 memcpy(&mq_table, table, sizeof(mq_table));
104688 mq_table.data = get_mq(table);
104689
104690@@ -35,7 +35,7 @@ static int proc_mq_dointvec(struct ctl_table *table, int write,
104691 static int proc_mq_dointvec_minmax(struct ctl_table *table, int write,
104692 void __user *buffer, size_t *lenp, loff_t *ppos)
104693 {
104694- struct ctl_table mq_table;
104695+ ctl_table_no_const mq_table;
104696 memcpy(&mq_table, table, sizeof(mq_table));
104697 mq_table.data = get_mq(table);
104698
104699diff --git a/ipc/mqueue.c b/ipc/mqueue.c
104700index 161a180..be31d93 100644
104701--- a/ipc/mqueue.c
104702+++ b/ipc/mqueue.c
104703@@ -274,6 +274,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
104704 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
104705 info->attr.mq_msgsize);
104706
104707+ gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
104708 spin_lock(&mq_lock);
104709 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
104710 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
104711diff --git a/ipc/sem.c b/ipc/sem.c
104712index b471e5a..89aef1d 100644
104713--- a/ipc/sem.c
104714+++ b/ipc/sem.c
104715@@ -1790,7 +1790,7 @@ static int get_queue_result(struct sem_queue *q)
104716 }
104717
104718 SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
104719- unsigned, nsops, const struct timespec __user *, timeout)
104720+ long, nsops, const struct timespec __user *, timeout)
104721 {
104722 int error = -EINVAL;
104723 struct sem_array *sma;
104724@@ -2025,7 +2025,7 @@ out_free:
104725 }
104726
104727 SYSCALL_DEFINE3(semop, int, semid, struct sembuf __user *, tsops,
104728- unsigned, nsops)
104729+ long, nsops)
104730 {
104731 return sys_semtimedop(semid, tsops, nsops, NULL);
104732 }
104733diff --git a/ipc/shm.c b/ipc/shm.c
104734index 0e61fd4..c545631 100644
104735--- a/ipc/shm.c
104736+++ b/ipc/shm.c
104737@@ -72,6 +72,14 @@ static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp);
104738 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
104739 #endif
104740
104741+#ifdef CONFIG_GRKERNSEC
104742+extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
104743+ const u64 shm_createtime, const kuid_t cuid,
104744+ const int shmid);
104745+extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
104746+ const u64 shm_createtime);
104747+#endif
104748+
104749 void shm_init_ns(struct ipc_namespace *ns)
104750 {
104751 ns->shm_ctlmax = SHMMAX;
104752@@ -555,6 +563,9 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
104753 shp->shm_lprid = 0;
104754 shp->shm_atim = shp->shm_dtim = 0;
104755 shp->shm_ctim = get_seconds();
104756+#ifdef CONFIG_GRKERNSEC
104757+ shp->shm_createtime = ktime_get_ns();
104758+#endif
104759 shp->shm_segsz = size;
104760 shp->shm_nattch = 0;
104761 shp->shm_file = file;
104762@@ -1098,6 +1109,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
104763 f_mode = FMODE_READ | FMODE_WRITE;
104764 }
104765 if (shmflg & SHM_EXEC) {
104766+
104767+#ifdef CONFIG_PAX_MPROTECT
104768+ if (current->mm->pax_flags & MF_PAX_MPROTECT)
104769+ goto out;
104770+#endif
104771+
104772 prot |= PROT_EXEC;
104773 acc_mode |= S_IXUGO;
104774 }
104775@@ -1122,6 +1139,15 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
104776 if (err)
104777 goto out_unlock;
104778
104779+#ifdef CONFIG_GRKERNSEC
104780+ if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
104781+ shp->shm_perm.cuid, shmid) ||
104782+ !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
104783+ err = -EACCES;
104784+ goto out_unlock;
104785+ }
104786+#endif
104787+
104788 ipc_lock_object(&shp->shm_perm);
104789
104790 /* check if shm_destroy() is tearing down shp */
104791@@ -1134,6 +1160,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
104792 path = shp->shm_file->f_path;
104793 path_get(&path);
104794 shp->shm_nattch++;
104795+#ifdef CONFIG_GRKERNSEC
104796+ shp->shm_lapid = current->pid;
104797+#endif
104798 size = i_size_read(d_inode(path.dentry));
104799 ipc_unlock_object(&shp->shm_perm);
104800 rcu_read_unlock();
104801diff --git a/ipc/util.c b/ipc/util.c
104802index 0f401d9..049b0ff 100644
104803--- a/ipc/util.c
104804+++ b/ipc/util.c
104805@@ -71,6 +71,8 @@ struct ipc_proc_iface {
104806 int (*show)(struct seq_file *, void *);
104807 };
104808
104809+extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
104810+
104811 /**
104812 * ipc_init - initialise ipc subsystem
104813 *
104814@@ -494,6 +496,10 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
104815 granted_mode >>= 6;
104816 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
104817 granted_mode >>= 3;
104818+
104819+ if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
104820+ return -1;
104821+
104822 /* is there some bit set in requested_mode but not in granted_mode? */
104823 if ((requested_mode & ~granted_mode & 0007) &&
104824 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
104825diff --git a/kernel/audit.c b/kernel/audit.c
104826index f9e6065..3fcb6ab 100644
104827--- a/kernel/audit.c
104828+++ b/kernel/audit.c
104829@@ -124,7 +124,7 @@ u32 audit_sig_sid = 0;
104830 3) suppressed due to audit_rate_limit
104831 4) suppressed due to audit_backlog_limit
104832 */
104833-static atomic_t audit_lost = ATOMIC_INIT(0);
104834+static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
104835
104836 /* The netlink socket. */
104837 static struct sock *audit_sock;
104838@@ -258,7 +258,7 @@ void audit_log_lost(const char *message)
104839 unsigned long now;
104840 int print;
104841
104842- atomic_inc(&audit_lost);
104843+ atomic_inc_unchecked(&audit_lost);
104844
104845 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
104846
104847@@ -275,7 +275,7 @@ void audit_log_lost(const char *message)
104848 if (print) {
104849 if (printk_ratelimit())
104850 pr_warn("audit_lost=%u audit_rate_limit=%u audit_backlog_limit=%u\n",
104851- atomic_read(&audit_lost),
104852+ atomic_read_unchecked(&audit_lost),
104853 audit_rate_limit,
104854 audit_backlog_limit);
104855 audit_panic(message);
104856@@ -833,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
104857 s.pid = audit_pid;
104858 s.rate_limit = audit_rate_limit;
104859 s.backlog_limit = audit_backlog_limit;
104860- s.lost = atomic_read(&audit_lost);
104861+ s.lost = atomic_read_unchecked(&audit_lost);
104862 s.backlog = skb_queue_len(&audit_skb_queue);
104863 s.feature_bitmap = AUDIT_FEATURE_BITMAP_ALL;
104864 s.backlog_wait_time = audit_backlog_wait_time_master;
104865diff --git a/kernel/auditsc.c b/kernel/auditsc.c
104866index e85bdfd..441a638 100644
104867--- a/kernel/auditsc.c
104868+++ b/kernel/auditsc.c
104869@@ -1021,7 +1021,7 @@ static int audit_log_single_execve_arg(struct audit_context *context,
104870 * for strings that are too long, we should not have created
104871 * any.
104872 */
104873- if (WARN_ON_ONCE(len < 0 || len > MAX_ARG_STRLEN - 1)) {
104874+ if (WARN_ON_ONCE(len > MAX_ARG_STRLEN - 1)) {
104875 send_sig(SIGKILL, current, 0);
104876 return -1;
104877 }
104878@@ -1952,7 +1952,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
104879 }
104880
104881 /* global counter which is incremented every time something logs in */
104882-static atomic_t session_id = ATOMIC_INIT(0);
104883+static atomic_unchecked_t session_id = ATOMIC_INIT(0);
104884
104885 static int audit_set_loginuid_perm(kuid_t loginuid)
104886 {
104887@@ -2019,7 +2019,7 @@ int audit_set_loginuid(kuid_t loginuid)
104888
104889 /* are we setting or clearing? */
104890 if (uid_valid(loginuid))
104891- sessionid = (unsigned int)atomic_inc_return(&session_id);
104892+ sessionid = (unsigned int)atomic_inc_return_unchecked(&session_id);
104893
104894 task->sessionid = sessionid;
104895 task->loginuid = loginuid;
104896diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
104897index c5bedc8..6ec8715 100644
104898--- a/kernel/bpf/core.c
104899+++ b/kernel/bpf/core.c
104900@@ -145,14 +145,17 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
104901 * random section of illegal instructions.
104902 */
104903 size = round_up(proglen + sizeof(*hdr) + 128, PAGE_SIZE);
104904- hdr = module_alloc(size);
104905+ hdr = module_alloc_exec(size);
104906 if (hdr == NULL)
104907 return NULL;
104908
104909 /* Fill space with illegal/arch-dep instructions. */
104910 bpf_fill_ill_insns(hdr, size);
104911
104912+ pax_open_kernel();
104913 hdr->pages = size / PAGE_SIZE;
104914+ pax_close_kernel();
104915+
104916 hole = min_t(unsigned int, size - (proglen + sizeof(*hdr)),
104917 PAGE_SIZE - sizeof(*hdr));
104918 start = (prandom_u32() % hole) & ~(alignment - 1);
104919@@ -165,7 +168,7 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
104920
104921 void bpf_jit_binary_free(struct bpf_binary_header *hdr)
104922 {
104923- module_memfree(hdr);
104924+ module_memfree_exec(hdr);
104925 }
104926 #endif /* CONFIG_BPF_JIT */
104927
104928diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
104929index a1b14d1..7dce5d9 100644
104930--- a/kernel/bpf/syscall.c
104931+++ b/kernel/bpf/syscall.c
104932@@ -592,11 +592,15 @@ SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, siz
104933 int err;
104934
104935 /* the syscall is limited to root temporarily. This restriction will be
104936- * lifted when security audit is clean. Note that eBPF+tracing must have
104937- * this restriction, since it may pass kernel data to user space
104938+ * lifted by upstream when a half-assed security audit is clean. Note
104939+ * that eBPF+tracing must have this restriction, since it may pass
104940+ * kernel data to user space
104941 */
104942 if (!capable(CAP_SYS_ADMIN))
104943 return -EPERM;
104944+#ifdef CONFIG_GRKERNSEC
104945+ return -EPERM;
104946+#endif
104947
104948 if (!access_ok(VERIFY_READ, uattr, 1))
104949 return -EFAULT;
104950diff --git a/kernel/capability.c b/kernel/capability.c
104951index 45432b5..988f1e4 100644
104952--- a/kernel/capability.c
104953+++ b/kernel/capability.c
104954@@ -193,6 +193,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
104955 * before modification is attempted and the application
104956 * fails.
104957 */
104958+ if (tocopy > ARRAY_SIZE(kdata))
104959+ return -EFAULT;
104960+
104961 if (copy_to_user(dataptr, kdata, tocopy
104962 * sizeof(struct __user_cap_data_struct))) {
104963 return -EFAULT;
104964@@ -298,10 +301,11 @@ bool has_ns_capability(struct task_struct *t,
104965 int ret;
104966
104967 rcu_read_lock();
104968- ret = security_capable(__task_cred(t), ns, cap);
104969+ ret = security_capable(__task_cred(t), ns, cap) == 0 &&
104970+ gr_task_is_capable(t, __task_cred(t), cap);
104971 rcu_read_unlock();
104972
104973- return (ret == 0);
104974+ return ret;
104975 }
104976
104977 /**
104978@@ -338,10 +342,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
104979 int ret;
104980
104981 rcu_read_lock();
104982- ret = security_capable_noaudit(__task_cred(t), ns, cap);
104983+ ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
104984 rcu_read_unlock();
104985
104986- return (ret == 0);
104987+ return ret;
104988 }
104989
104990 /**
104991@@ -379,7 +383,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
104992 BUG();
104993 }
104994
104995- if (security_capable(current_cred(), ns, cap) == 0) {
104996+ if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
104997 current->flags |= PF_SUPERPRIV;
104998 return true;
104999 }
105000@@ -387,6 +391,20 @@ bool ns_capable(struct user_namespace *ns, int cap)
105001 }
105002 EXPORT_SYMBOL(ns_capable);
105003
105004+bool ns_capable_nolog(struct user_namespace *ns, int cap)
105005+{
105006+ if (unlikely(!cap_valid(cap))) {
105007+ pr_crit("capable_nolog() called with invalid cap=%u\n", cap);
105008+ BUG();
105009+ }
105010+
105011+ if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
105012+ current->flags |= PF_SUPERPRIV;
105013+ return true;
105014+ }
105015+ return false;
105016+}
105017+EXPORT_SYMBOL(ns_capable_nolog);
105018
105019 /**
105020 * capable - Determine if the current task has a superior capability in effect
105021@@ -403,6 +421,13 @@ bool capable(int cap)
105022 return ns_capable(&init_user_ns, cap);
105023 }
105024 EXPORT_SYMBOL(capable);
105025+
105026+bool capable_nolog(int cap)
105027+{
105028+ return ns_capable_nolog(&init_user_ns, cap);
105029+}
105030+EXPORT_SYMBOL(capable_nolog);
105031+
105032 #endif /* CONFIG_MULTIUSER */
105033
105034 /**
105035@@ -447,3 +472,12 @@ bool capable_wrt_inode_uidgid(const struct inode *inode, int cap)
105036 kgid_has_mapping(ns, inode->i_gid);
105037 }
105038 EXPORT_SYMBOL(capable_wrt_inode_uidgid);
105039+
105040+bool capable_wrt_inode_uidgid_nolog(const struct inode *inode, int cap)
105041+{
105042+ struct user_namespace *ns = current_user_ns();
105043+
105044+ return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid) &&
105045+ kgid_has_mapping(ns, inode->i_gid);
105046+}
105047+EXPORT_SYMBOL(capable_wrt_inode_uidgid_nolog);
105048diff --git a/kernel/cgroup.c b/kernel/cgroup.c
105049index fe6f855..7dba913 100644
105050--- a/kernel/cgroup.c
105051+++ b/kernel/cgroup.c
105052@@ -5425,6 +5425,9 @@ static void cgroup_release_agent(struct work_struct *work)
105053 if (!pathbuf || !agentbuf)
105054 goto out;
105055
105056+ if (agentbuf[0] == '\0')
105057+ goto out;
105058+
105059 path = cgroup_path(cgrp, pathbuf, PATH_MAX);
105060 if (!path)
105061 goto out;
105062@@ -5610,7 +5613,7 @@ static int cgroup_css_links_read(struct seq_file *seq, void *v)
105063 struct task_struct *task;
105064 int count = 0;
105065
105066- seq_printf(seq, "css_set %p\n", cset);
105067+ seq_printf(seq, "css_set %pK\n", cset);
105068
105069 list_for_each_entry(task, &cset->tasks, cg_list) {
105070 if (count++ > MAX_TASKS_SHOWN_PER_CSS)
105071diff --git a/kernel/compat.c b/kernel/compat.c
105072index 333d364..762ec00 100644
105073--- a/kernel/compat.c
105074+++ b/kernel/compat.c
105075@@ -13,6 +13,7 @@
105076
105077 #include <linux/linkage.h>
105078 #include <linux/compat.h>
105079+#include <linux/module.h>
105080 #include <linux/errno.h>
105081 #include <linux/time.h>
105082 #include <linux/signal.h>
105083@@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
105084 mm_segment_t oldfs;
105085 long ret;
105086
105087- restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
105088+ restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
105089 oldfs = get_fs();
105090 set_fs(KERNEL_DS);
105091 ret = hrtimer_nanosleep_restart(restart);
105092@@ -252,7 +253,7 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,
105093 oldfs = get_fs();
105094 set_fs(KERNEL_DS);
105095 ret = hrtimer_nanosleep(&tu,
105096- rmtp ? (struct timespec __user *)&rmt : NULL,
105097+ rmtp ? (struct timespec __force_user *)&rmt : NULL,
105098 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
105099 set_fs(oldfs);
105100
105101@@ -378,7 +379,7 @@ COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set)
105102 mm_segment_t old_fs = get_fs();
105103
105104 set_fs(KERNEL_DS);
105105- ret = sys_sigpending((old_sigset_t __user *) &s);
105106+ ret = sys_sigpending((old_sigset_t __force_user *) &s);
105107 set_fs(old_fs);
105108 if (ret == 0)
105109 ret = put_user(s, set);
105110@@ -468,7 +469,7 @@ COMPAT_SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
105111 mm_segment_t old_fs = get_fs();
105112
105113 set_fs(KERNEL_DS);
105114- ret = sys_old_getrlimit(resource, (struct rlimit __user *)&r);
105115+ ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
105116 set_fs(old_fs);
105117
105118 if (!ret) {
105119@@ -550,8 +551,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
105120 set_fs (KERNEL_DS);
105121 ret = sys_wait4(pid,
105122 (stat_addr ?
105123- (unsigned int __user *) &status : NULL),
105124- options, (struct rusage __user *) &r);
105125+ (unsigned int __force_user *) &status : NULL),
105126+ options, (struct rusage __force_user *) &r);
105127 set_fs (old_fs);
105128
105129 if (ret > 0) {
105130@@ -577,8 +578,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
105131 memset(&info, 0, sizeof(info));
105132
105133 set_fs(KERNEL_DS);
105134- ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
105135- uru ? (struct rusage __user *)&ru : NULL);
105136+ ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
105137+ uru ? (struct rusage __force_user *)&ru : NULL);
105138 set_fs(old_fs);
105139
105140 if ((ret < 0) || (info.si_signo == 0))
105141@@ -712,8 +713,8 @@ COMPAT_SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
105142 oldfs = get_fs();
105143 set_fs(KERNEL_DS);
105144 err = sys_timer_settime(timer_id, flags,
105145- (struct itimerspec __user *) &newts,
105146- (struct itimerspec __user *) &oldts);
105147+ (struct itimerspec __force_user *) &newts,
105148+ (struct itimerspec __force_user *) &oldts);
105149 set_fs(oldfs);
105150 if (!err && old && put_compat_itimerspec(old, &oldts))
105151 return -EFAULT;
105152@@ -730,7 +731,7 @@ COMPAT_SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
105153 oldfs = get_fs();
105154 set_fs(KERNEL_DS);
105155 err = sys_timer_gettime(timer_id,
105156- (struct itimerspec __user *) &ts);
105157+ (struct itimerspec __force_user *) &ts);
105158 set_fs(oldfs);
105159 if (!err && put_compat_itimerspec(setting, &ts))
105160 return -EFAULT;
105161@@ -749,7 +750,7 @@ COMPAT_SYSCALL_DEFINE2(clock_settime, clockid_t, which_clock,
105162 oldfs = get_fs();
105163 set_fs(KERNEL_DS);
105164 err = sys_clock_settime(which_clock,
105165- (struct timespec __user *) &ts);
105166+ (struct timespec __force_user *) &ts);
105167 set_fs(oldfs);
105168 return err;
105169 }
105170@@ -764,7 +765,7 @@ COMPAT_SYSCALL_DEFINE2(clock_gettime, clockid_t, which_clock,
105171 oldfs = get_fs();
105172 set_fs(KERNEL_DS);
105173 err = sys_clock_gettime(which_clock,
105174- (struct timespec __user *) &ts);
105175+ (struct timespec __force_user *) &ts);
105176 set_fs(oldfs);
105177 if (!err && compat_put_timespec(&ts, tp))
105178 return -EFAULT;
105179@@ -784,7 +785,7 @@ COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock,
105180
105181 oldfs = get_fs();
105182 set_fs(KERNEL_DS);
105183- ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
105184+ ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
105185 set_fs(oldfs);
105186
105187 err = compat_put_timex(utp, &txc);
105188@@ -804,7 +805,7 @@ COMPAT_SYSCALL_DEFINE2(clock_getres, clockid_t, which_clock,
105189 oldfs = get_fs();
105190 set_fs(KERNEL_DS);
105191 err = sys_clock_getres(which_clock,
105192- (struct timespec __user *) &ts);
105193+ (struct timespec __force_user *) &ts);
105194 set_fs(oldfs);
105195 if (!err && tp && compat_put_timespec(&ts, tp))
105196 return -EFAULT;
105197@@ -818,7 +819,7 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
105198 struct timespec tu;
105199 struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
105200
105201- restart->nanosleep.rmtp = (struct timespec __user *) &tu;
105202+ restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
105203 oldfs = get_fs();
105204 set_fs(KERNEL_DS);
105205 err = clock_nanosleep_restart(restart);
105206@@ -850,8 +851,8 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
105207 oldfs = get_fs();
105208 set_fs(KERNEL_DS);
105209 err = sys_clock_nanosleep(which_clock, flags,
105210- (struct timespec __user *) &in,
105211- (struct timespec __user *) &out);
105212+ (struct timespec __force_user *) &in,
105213+ (struct timespec __force_user *) &out);
105214 set_fs(oldfs);
105215
105216 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
105217@@ -1147,7 +1148,7 @@ COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval,
105218 mm_segment_t old_fs = get_fs();
105219
105220 set_fs(KERNEL_DS);
105221- ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
105222+ ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
105223 set_fs(old_fs);
105224 if (compat_put_timespec(&t, interval))
105225 return -EFAULT;
105226diff --git a/kernel/configs.c b/kernel/configs.c
105227index c18b1f1..b9a0132 100644
105228--- a/kernel/configs.c
105229+++ b/kernel/configs.c
105230@@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
105231 struct proc_dir_entry *entry;
105232
105233 /* create the current config file */
105234+#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
105235+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
105236+ entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
105237+ &ikconfig_file_ops);
105238+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
105239+ entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
105240+ &ikconfig_file_ops);
105241+#endif
105242+#else
105243 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
105244 &ikconfig_file_ops);
105245+#endif
105246+
105247 if (!entry)
105248 return -ENOMEM;
105249
105250diff --git a/kernel/cred.c b/kernel/cred.c
105251index ec1c076..7da8a0e 100644
105252--- a/kernel/cred.c
105253+++ b/kernel/cred.c
105254@@ -167,6 +167,15 @@ void exit_creds(struct task_struct *tsk)
105255 validate_creds(cred);
105256 alter_cred_subscribers(cred, -1);
105257 put_cred(cred);
105258+
105259+#ifdef CONFIG_GRKERNSEC_SETXID
105260+ cred = (struct cred *) tsk->delayed_cred;
105261+ if (cred != NULL) {
105262+ tsk->delayed_cred = NULL;
105263+ validate_creds(cred);
105264+ put_cred(cred);
105265+ }
105266+#endif
105267 }
105268
105269 /**
105270@@ -414,7 +423,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
105271 * Always returns 0 thus allowing this function to be tail-called at the end
105272 * of, say, sys_setgid().
105273 */
105274-int commit_creds(struct cred *new)
105275+static int __commit_creds(struct cred *new)
105276 {
105277 struct task_struct *task = current;
105278 const struct cred *old = task->real_cred;
105279@@ -433,6 +442,8 @@ int commit_creds(struct cred *new)
105280
105281 get_cred(new); /* we will require a ref for the subj creds too */
105282
105283+ gr_set_role_label(task, new->uid, new->gid);
105284+
105285 /* dumpability changes */
105286 if (!uid_eq(old->euid, new->euid) ||
105287 !gid_eq(old->egid, new->egid) ||
105288@@ -482,6 +493,105 @@ int commit_creds(struct cred *new)
105289 put_cred(old);
105290 return 0;
105291 }
105292+#ifdef CONFIG_GRKERNSEC_SETXID
105293+extern int set_user(struct cred *new);
105294+
105295+void gr_delayed_cred_worker(void)
105296+{
105297+ const struct cred *new = current->delayed_cred;
105298+ struct cred *ncred;
105299+
105300+ current->delayed_cred = NULL;
105301+
105302+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
105303+ // from doing get_cred on it when queueing this
105304+ put_cred(new);
105305+ return;
105306+ } else if (new == NULL)
105307+ return;
105308+
105309+ ncred = prepare_creds();
105310+ if (!ncred)
105311+ goto die;
105312+ // uids
105313+ ncred->uid = new->uid;
105314+ ncred->euid = new->euid;
105315+ ncred->suid = new->suid;
105316+ ncred->fsuid = new->fsuid;
105317+ // gids
105318+ ncred->gid = new->gid;
105319+ ncred->egid = new->egid;
105320+ ncred->sgid = new->sgid;
105321+ ncred->fsgid = new->fsgid;
105322+ // groups
105323+ set_groups(ncred, new->group_info);
105324+ // caps
105325+ ncred->securebits = new->securebits;
105326+ ncred->cap_inheritable = new->cap_inheritable;
105327+ ncred->cap_permitted = new->cap_permitted;
105328+ ncred->cap_effective = new->cap_effective;
105329+ ncred->cap_bset = new->cap_bset;
105330+
105331+ if (set_user(ncred)) {
105332+ abort_creds(ncred);
105333+ goto die;
105334+ }
105335+
105336+ // from doing get_cred on it when queueing this
105337+ put_cred(new);
105338+
105339+ __commit_creds(ncred);
105340+ return;
105341+die:
105342+ // from doing get_cred on it when queueing this
105343+ put_cred(new);
105344+ do_group_exit(SIGKILL);
105345+}
105346+#endif
105347+
105348+int commit_creds(struct cred *new)
105349+{
105350+#ifdef CONFIG_GRKERNSEC_SETXID
105351+ int ret;
105352+ int schedule_it = 0;
105353+ struct task_struct *t;
105354+ unsigned oldsecurebits = current_cred()->securebits;
105355+
105356+ /* we won't get called with tasklist_lock held for writing
105357+ and interrupts disabled as the cred struct in that case is
105358+ init_cred
105359+ */
105360+ if (grsec_enable_setxid && !current_is_single_threaded() &&
105361+ uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
105362+ !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
105363+ schedule_it = 1;
105364+ }
105365+ ret = __commit_creds(new);
105366+ if (schedule_it) {
105367+ rcu_read_lock();
105368+ read_lock(&tasklist_lock);
105369+ for (t = next_thread(current); t != current;
105370+ t = next_thread(t)) {
105371+ /* we'll check if the thread has uid 0 in
105372+ * the delayed worker routine
105373+ */
105374+ if (task_securebits(t) == oldsecurebits &&
105375+ t->delayed_cred == NULL) {
105376+ t->delayed_cred = get_cred(new);
105377+ set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
105378+ set_tsk_need_resched(t);
105379+ }
105380+ }
105381+ read_unlock(&tasklist_lock);
105382+ rcu_read_unlock();
105383+ }
105384+
105385+ return ret;
105386+#else
105387+ return __commit_creds(new);
105388+#endif
105389+}
105390+
105391 EXPORT_SYMBOL(commit_creds);
105392
105393 /**
105394diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
105395index 0874e2e..5b32cc9 100644
105396--- a/kernel/debug/debug_core.c
105397+++ b/kernel/debug/debug_core.c
105398@@ -127,7 +127,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
105399 */
105400 static atomic_t masters_in_kgdb;
105401 static atomic_t slaves_in_kgdb;
105402-static atomic_t kgdb_break_tasklet_var;
105403+static atomic_unchecked_t kgdb_break_tasklet_var;
105404 atomic_t kgdb_setting_breakpoint;
105405
105406 struct task_struct *kgdb_usethread;
105407@@ -137,7 +137,7 @@ int kgdb_single_step;
105408 static pid_t kgdb_sstep_pid;
105409
105410 /* to keep track of the CPU which is doing the single stepping*/
105411-atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
105412+atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
105413
105414 /*
105415 * If you are debugging a problem where roundup (the collection of
105416@@ -552,7 +552,7 @@ return_normal:
105417 * kernel will only try for the value of sstep_tries before
105418 * giving up and continuing on.
105419 */
105420- if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
105421+ if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
105422 (kgdb_info[cpu].task &&
105423 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
105424 atomic_set(&kgdb_active, -1);
105425@@ -654,8 +654,8 @@ cpu_master_loop:
105426 }
105427
105428 kgdb_restore:
105429- if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
105430- int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
105431+ if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
105432+ int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
105433 if (kgdb_info[sstep_cpu].task)
105434 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
105435 else
105436@@ -949,18 +949,18 @@ static void kgdb_unregister_callbacks(void)
105437 static void kgdb_tasklet_bpt(unsigned long ing)
105438 {
105439 kgdb_breakpoint();
105440- atomic_set(&kgdb_break_tasklet_var, 0);
105441+ atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
105442 }
105443
105444 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
105445
105446 void kgdb_schedule_breakpoint(void)
105447 {
105448- if (atomic_read(&kgdb_break_tasklet_var) ||
105449+ if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
105450 atomic_read(&kgdb_active) != -1 ||
105451 atomic_read(&kgdb_setting_breakpoint))
105452 return;
105453- atomic_inc(&kgdb_break_tasklet_var);
105454+ atomic_inc_unchecked(&kgdb_break_tasklet_var);
105455 tasklet_schedule(&kgdb_tasklet_breakpoint);
105456 }
105457 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
105458diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
105459index 41213454..861e178 100644
105460--- a/kernel/debug/kdb/kdb_main.c
105461+++ b/kernel/debug/kdb/kdb_main.c
105462@@ -2021,7 +2021,7 @@ static int kdb_lsmod(int argc, const char **argv)
105463 continue;
105464
105465 kdb_printf("%-20s%8u 0x%p ", mod->name,
105466- mod->core_size, (void *)mod);
105467+ mod->core_size_rx + mod->core_size_rw, (void *)mod);
105468 #ifdef CONFIG_MODULE_UNLOAD
105469 kdb_printf("%4d ", module_refcount(mod));
105470 #endif
105471@@ -2031,7 +2031,7 @@ static int kdb_lsmod(int argc, const char **argv)
105472 kdb_printf(" (Loading)");
105473 else
105474 kdb_printf(" (Live)");
105475- kdb_printf(" 0x%p", mod->module_core);
105476+ kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
105477
105478 #ifdef CONFIG_MODULE_UNLOAD
105479 {
105480diff --git a/kernel/events/core.c b/kernel/events/core.c
105481index e6feb51..470c853 100644
105482--- a/kernel/events/core.c
105483+++ b/kernel/events/core.c
105484@@ -174,8 +174,15 @@ static struct srcu_struct pmus_srcu;
105485 * 0 - disallow raw tracepoint access for unpriv
105486 * 1 - disallow cpu events for unpriv
105487 * 2 - disallow kernel profiling for unpriv
105488+ * 3 - disallow all unpriv perf event use
105489 */
105490-int sysctl_perf_event_paranoid __read_mostly = 1;
105491+#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
105492+int sysctl_perf_event_legitimately_concerned __read_only = 3;
105493+#elif defined(CONFIG_GRKERNSEC_HIDESYM)
105494+int sysctl_perf_event_legitimately_concerned __read_only = 2;
105495+#else
105496+int sysctl_perf_event_legitimately_concerned __read_only = 1;
105497+#endif
105498
105499 /* Minimum for 512 kiB + 1 user control page */
105500 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
105501@@ -201,7 +208,7 @@ void update_perf_cpu_limits(void)
105502
105503 tmp *= sysctl_perf_cpu_time_max_percent;
105504 do_div(tmp, 100);
105505- ACCESS_ONCE(perf_sample_allowed_ns) = tmp;
105506+ ACCESS_ONCE_RW(perf_sample_allowed_ns) = tmp;
105507 }
105508
105509 static int perf_rotate_context(struct perf_cpu_context *cpuctx);
105510@@ -307,7 +314,7 @@ void perf_sample_event_took(u64 sample_len_ns)
105511 }
105512 }
105513
105514-static atomic64_t perf_event_id;
105515+static atomic64_unchecked_t perf_event_id;
105516
105517 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
105518 enum event_type_t event_type);
105519@@ -3753,9 +3760,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
105520 mutex_lock(&event->child_mutex);
105521 total += perf_event_read(event);
105522 *enabled += event->total_time_enabled +
105523- atomic64_read(&event->child_total_time_enabled);
105524+ atomic64_read_unchecked(&event->child_total_time_enabled);
105525 *running += event->total_time_running +
105526- atomic64_read(&event->child_total_time_running);
105527+ atomic64_read_unchecked(&event->child_total_time_running);
105528
105529 list_for_each_entry(child, &event->child_list, child_list) {
105530 total += perf_event_read(child);
105531@@ -4285,10 +4292,10 @@ void perf_event_update_userpage(struct perf_event *event)
105532 userpg->offset -= local64_read(&event->hw.prev_count);
105533
105534 userpg->time_enabled = enabled +
105535- atomic64_read(&event->child_total_time_enabled);
105536+ atomic64_read_unchecked(&event->child_total_time_enabled);
105537
105538 userpg->time_running = running +
105539- atomic64_read(&event->child_total_time_running);
105540+ atomic64_read_unchecked(&event->child_total_time_running);
105541
105542 arch_perf_update_userpage(event, userpg, now);
105543
105544@@ -4963,7 +4970,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
105545
105546 /* Data. */
105547 sp = perf_user_stack_pointer(regs);
105548- rem = __output_copy_user(handle, (void *) sp, dump_size);
105549+ rem = __output_copy_user(handle, (void __user *) sp, dump_size);
105550 dyn_size = dump_size - rem;
105551
105552 perf_output_skip(handle, rem);
105553@@ -5054,11 +5061,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
105554 values[n++] = perf_event_count(event);
105555 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
105556 values[n++] = enabled +
105557- atomic64_read(&event->child_total_time_enabled);
105558+ atomic64_read_unchecked(&event->child_total_time_enabled);
105559 }
105560 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
105561 values[n++] = running +
105562- atomic64_read(&event->child_total_time_running);
105563+ atomic64_read_unchecked(&event->child_total_time_running);
105564 }
105565 if (read_format & PERF_FORMAT_ID)
105566 values[n++] = primary_event_id(event);
105567@@ -7588,7 +7595,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
105568 event->parent = parent_event;
105569
105570 event->ns = get_pid_ns(task_active_pid_ns(current));
105571- event->id = atomic64_inc_return(&perf_event_id);
105572+ event->id = atomic64_inc_return_unchecked(&perf_event_id);
105573
105574 event->state = PERF_EVENT_STATE_INACTIVE;
105575
105576@@ -7947,6 +7954,11 @@ SYSCALL_DEFINE5(perf_event_open,
105577 if (flags & ~PERF_FLAG_ALL)
105578 return -EINVAL;
105579
105580+#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
105581+ if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
105582+ return -EACCES;
105583+#endif
105584+
105585 err = perf_copy_attr(attr_uptr, &attr);
105586 if (err)
105587 return err;
105588@@ -8395,10 +8407,10 @@ static void sync_child_event(struct perf_event *child_event,
105589 /*
105590 * Add back the child's count to the parent's count:
105591 */
105592- atomic64_add(child_val, &parent_event->child_count);
105593- atomic64_add(child_event->total_time_enabled,
105594+ atomic64_add_unchecked(child_val, &parent_event->child_count);
105595+ atomic64_add_unchecked(child_event->total_time_enabled,
105596 &parent_event->child_total_time_enabled);
105597- atomic64_add(child_event->total_time_running,
105598+ atomic64_add_unchecked(child_event->total_time_running,
105599 &parent_event->child_total_time_running);
105600
105601 /*
105602diff --git a/kernel/events/internal.h b/kernel/events/internal.h
105603index 2bbad9c..056f20c 100644
105604--- a/kernel/events/internal.h
105605+++ b/kernel/events/internal.h
105606@@ -115,10 +115,10 @@ static inline unsigned long perf_aux_size(struct ring_buffer *rb)
105607 return rb->aux_nr_pages << PAGE_SHIFT;
105608 }
105609
105610-#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
105611+#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
105612 static inline unsigned long \
105613 func_name(struct perf_output_handle *handle, \
105614- const void *buf, unsigned long len) \
105615+ const void user *buf, unsigned long len) \
105616 { \
105617 unsigned long size, written; \
105618 \
105619@@ -151,7 +151,7 @@ memcpy_common(void *dst, const void *src, unsigned long n)
105620 return 0;
105621 }
105622
105623-DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
105624+DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
105625
105626 static inline unsigned long
105627 memcpy_skip(void *dst, const void *src, unsigned long n)
105628@@ -159,7 +159,7 @@ memcpy_skip(void *dst, const void *src, unsigned long n)
105629 return 0;
105630 }
105631
105632-DEFINE_OUTPUT_COPY(__output_skip, memcpy_skip)
105633+DEFINE_OUTPUT_COPY(__output_skip, memcpy_skip, )
105634
105635 #ifndef arch_perf_out_copy_user
105636 #define arch_perf_out_copy_user arch_perf_out_copy_user
105637@@ -177,7 +177,7 @@ arch_perf_out_copy_user(void *dst, const void *src, unsigned long n)
105638 }
105639 #endif
105640
105641-DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
105642+DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
105643
105644 /* Callchain handling */
105645 extern struct perf_callchain_entry *
105646diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
105647index cb346f2..e4dc317 100644
105648--- a/kernel/events/uprobes.c
105649+++ b/kernel/events/uprobes.c
105650@@ -1670,7 +1670,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
105651 {
105652 struct page *page;
105653 uprobe_opcode_t opcode;
105654- int result;
105655+ long result;
105656
105657 pagefault_disable();
105658 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
105659diff --git a/kernel/exit.c b/kernel/exit.c
105660index 031325e..c6342c4 100644
105661--- a/kernel/exit.c
105662+++ b/kernel/exit.c
105663@@ -171,6 +171,10 @@ void release_task(struct task_struct *p)
105664 struct task_struct *leader;
105665 int zap_leader;
105666 repeat:
105667+#ifdef CONFIG_NET
105668+ gr_del_task_from_ip_table(p);
105669+#endif
105670+
105671 /* don't need to get the RCU readlock here - the process is dead and
105672 * can't be modifying its own credentials. But shut RCU-lockdep up */
105673 rcu_read_lock();
105674@@ -656,6 +660,8 @@ void do_exit(long code)
105675 int group_dead;
105676 TASKS_RCU(int tasks_rcu_i);
105677
105678+ set_fs(USER_DS);
105679+
105680 profile_task_exit(tsk);
105681
105682 WARN_ON(blk_needs_flush_plug(tsk));
105683@@ -672,7 +678,6 @@ void do_exit(long code)
105684 * mm_release()->clear_child_tid() from writing to a user-controlled
105685 * kernel address.
105686 */
105687- set_fs(USER_DS);
105688
105689 ptrace_event(PTRACE_EVENT_EXIT, code);
105690
105691@@ -730,6 +735,9 @@ void do_exit(long code)
105692 tsk->exit_code = code;
105693 taskstats_exit(tsk, group_dead);
105694
105695+ gr_acl_handle_psacct(tsk, code);
105696+ gr_acl_handle_exit();
105697+
105698 exit_mm(tsk);
105699
105700 if (group_dead)
105701@@ -847,7 +855,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
105702 * Take down every thread in the group. This is called by fatal signals
105703 * as well as by sys_exit_group (below).
105704 */
105705-void
105706+__noreturn void
105707 do_group_exit(int exit_code)
105708 {
105709 struct signal_struct *sig = current->signal;
105710diff --git a/kernel/fork.c b/kernel/fork.c
105711index e769c8c..9fa1de5 100644
105712--- a/kernel/fork.c
105713+++ b/kernel/fork.c
105714@@ -188,12 +188,54 @@ static void free_thread_info(struct thread_info *ti)
105715 void thread_info_cache_init(void)
105716 {
105717 thread_info_cache = kmem_cache_create("thread_info", THREAD_SIZE,
105718- THREAD_SIZE, 0, NULL);
105719+ THREAD_SIZE, SLAB_USERCOPY, NULL);
105720 BUG_ON(thread_info_cache == NULL);
105721 }
105722 # endif
105723 #endif
105724
105725+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
105726+static inline struct thread_info *gr_alloc_thread_info_node(struct task_struct *tsk,
105727+ int node, void **lowmem_stack)
105728+{
105729+ struct page *pages[THREAD_SIZE / PAGE_SIZE];
105730+ void *ret = NULL;
105731+ unsigned int i;
105732+
105733+ *lowmem_stack = alloc_thread_info_node(tsk, node);
105734+ if (*lowmem_stack == NULL)
105735+ goto out;
105736+
105737+ for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++)
105738+ pages[i] = virt_to_page(*lowmem_stack + (i * PAGE_SIZE));
105739+
105740+ /* use VM_IOREMAP to gain THREAD_SIZE alignment */
105741+ ret = vmap(pages, THREAD_SIZE / PAGE_SIZE, VM_IOREMAP, PAGE_KERNEL);
105742+ if (ret == NULL) {
105743+ free_thread_info(*lowmem_stack);
105744+ *lowmem_stack = NULL;
105745+ }
105746+
105747+out:
105748+ return ret;
105749+}
105750+
105751+static inline void gr_free_thread_info(struct task_struct *tsk, struct thread_info *ti)
105752+{
105753+ unmap_process_stacks(tsk);
105754+}
105755+#else
105756+static inline struct thread_info *gr_alloc_thread_info_node(struct task_struct *tsk,
105757+ int node, void **lowmem_stack)
105758+{
105759+ return alloc_thread_info_node(tsk, node);
105760+}
105761+static inline void gr_free_thread_info(struct task_struct *tsk, struct thread_info *ti)
105762+{
105763+ free_thread_info(ti);
105764+}
105765+#endif
105766+
105767 /* SLAB cache for signal_struct structures (tsk->signal) */
105768 static struct kmem_cache *signal_cachep;
105769
105770@@ -212,18 +254,22 @@ struct kmem_cache *vm_area_cachep;
105771 /* SLAB cache for mm_struct structures (tsk->mm) */
105772 static struct kmem_cache *mm_cachep;
105773
105774-static void account_kernel_stack(struct thread_info *ti, int account)
105775+static void account_kernel_stack(struct task_struct *tsk, struct thread_info *ti, int account)
105776 {
105777+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
105778+ struct zone *zone = page_zone(virt_to_page(tsk->lowmem_stack));
105779+#else
105780 struct zone *zone = page_zone(virt_to_page(ti));
105781+#endif
105782
105783 mod_zone_page_state(zone, NR_KERNEL_STACK, account);
105784 }
105785
105786 void free_task(struct task_struct *tsk)
105787 {
105788- account_kernel_stack(tsk->stack, -1);
105789+ account_kernel_stack(tsk, tsk->stack, -1);
105790 arch_release_thread_info(tsk->stack);
105791- free_thread_info(tsk->stack);
105792+ gr_free_thread_info(tsk, tsk->stack);
105793 rt_mutex_debug_task_free(tsk);
105794 ftrace_graph_exit_task(tsk);
105795 put_seccomp_filter(tsk);
105796@@ -289,7 +335,7 @@ static void set_max_threads(unsigned int max_threads_suggested)
105797
105798 #ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT
105799 /* Initialized by the architecture: */
105800-int arch_task_struct_size __read_mostly;
105801+size_t arch_task_struct_size __read_mostly;
105802 #endif
105803
105804 void __init fork_init(void)
105805@@ -334,6 +380,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
105806 {
105807 struct task_struct *tsk;
105808 struct thread_info *ti;
105809+ void *lowmem_stack;
105810 int node = tsk_fork_get_node(orig);
105811 int err;
105812
105813@@ -341,7 +388,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
105814 if (!tsk)
105815 return NULL;
105816
105817- ti = alloc_thread_info_node(tsk, node);
105818+ ti = gr_alloc_thread_info_node(tsk, node, &lowmem_stack);
105819 if (!ti)
105820 goto free_tsk;
105821
105822@@ -350,6 +397,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
105823 goto free_ti;
105824
105825 tsk->stack = ti;
105826+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
105827+ tsk->lowmem_stack = lowmem_stack;
105828+#endif
105829 #ifdef CONFIG_SECCOMP
105830 /*
105831 * We must handle setting up seccomp filters once we're under
105832@@ -366,7 +416,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
105833 set_task_stack_end_magic(tsk);
105834
105835 #ifdef CONFIG_CC_STACKPROTECTOR
105836- tsk->stack_canary = get_random_int();
105837+ tsk->stack_canary = pax_get_random_long();
105838 #endif
105839
105840 /*
105841@@ -380,24 +430,89 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
105842 tsk->splice_pipe = NULL;
105843 tsk->task_frag.page = NULL;
105844
105845- account_kernel_stack(ti, 1);
105846+ account_kernel_stack(tsk, ti, 1);
105847
105848 return tsk;
105849
105850 free_ti:
105851- free_thread_info(ti);
105852+ gr_free_thread_info(tsk, ti);
105853 free_tsk:
105854 free_task_struct(tsk);
105855 return NULL;
105856 }
105857
105858 #ifdef CONFIG_MMU
105859-static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
105860+static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
105861+{
105862+ struct vm_area_struct *tmp;
105863+ unsigned long charge;
105864+ struct file *file;
105865+ int retval;
105866+
105867+ charge = 0;
105868+ if (mpnt->vm_flags & VM_ACCOUNT) {
105869+ unsigned long len = vma_pages(mpnt);
105870+
105871+ if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
105872+ goto fail_nomem;
105873+ charge = len;
105874+ }
105875+ tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
105876+ if (!tmp)
105877+ goto fail_nomem;
105878+ *tmp = *mpnt;
105879+ tmp->vm_mm = mm;
105880+ INIT_LIST_HEAD(&tmp->anon_vma_chain);
105881+ retval = vma_dup_policy(mpnt, tmp);
105882+ if (retval)
105883+ goto fail_nomem_policy;
105884+ if (anon_vma_fork(tmp, mpnt))
105885+ goto fail_nomem_anon_vma_fork;
105886+ tmp->vm_flags &= ~VM_LOCKED;
105887+ tmp->vm_next = tmp->vm_prev = NULL;
105888+ tmp->vm_mirror = NULL;
105889+ file = tmp->vm_file;
105890+ if (file) {
105891+ struct inode *inode = file_inode(file);
105892+ struct address_space *mapping = file->f_mapping;
105893+
105894+ get_file(file);
105895+ if (tmp->vm_flags & VM_DENYWRITE)
105896+ atomic_dec(&inode->i_writecount);
105897+ i_mmap_lock_write(mapping);
105898+ if (tmp->vm_flags & VM_SHARED)
105899+ atomic_inc(&mapping->i_mmap_writable);
105900+ flush_dcache_mmap_lock(mapping);
105901+ /* insert tmp into the share list, just after mpnt */
105902+ vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
105903+ flush_dcache_mmap_unlock(mapping);
105904+ i_mmap_unlock_write(mapping);
105905+ }
105906+
105907+ /*
105908+ * Clear hugetlb-related page reserves for children. This only
105909+ * affects MAP_PRIVATE mappings. Faults generated by the child
105910+ * are not guaranteed to succeed, even if read-only
105911+ */
105912+ if (is_vm_hugetlb_page(tmp))
105913+ reset_vma_resv_huge_pages(tmp);
105914+
105915+ return tmp;
105916+
105917+fail_nomem_anon_vma_fork:
105918+ mpol_put(vma_policy(tmp));
105919+fail_nomem_policy:
105920+ kmem_cache_free(vm_area_cachep, tmp);
105921+fail_nomem:
105922+ vm_unacct_memory(charge);
105923+ return NULL;
105924+}
105925+
105926+static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
105927 {
105928 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
105929 struct rb_node **rb_link, *rb_parent;
105930 int retval;
105931- unsigned long charge;
105932
105933 uprobe_start_dup_mmap();
105934 down_write(&oldmm->mmap_sem);
105935@@ -428,51 +543,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
105936
105937 prev = NULL;
105938 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
105939- struct file *file;
105940-
105941 if (mpnt->vm_flags & VM_DONTCOPY) {
105942 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
105943 -vma_pages(mpnt));
105944 continue;
105945 }
105946- charge = 0;
105947- if (mpnt->vm_flags & VM_ACCOUNT) {
105948- unsigned long len = vma_pages(mpnt);
105949-
105950- if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
105951- goto fail_nomem;
105952- charge = len;
105953- }
105954- tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
105955- if (!tmp)
105956- goto fail_nomem;
105957- *tmp = *mpnt;
105958- INIT_LIST_HEAD(&tmp->anon_vma_chain);
105959- retval = vma_dup_policy(mpnt, tmp);
105960- if (retval)
105961- goto fail_nomem_policy;
105962- tmp->vm_mm = mm;
105963- if (anon_vma_fork(tmp, mpnt))
105964- goto fail_nomem_anon_vma_fork;
105965- tmp->vm_flags &= ~VM_LOCKED;
105966- tmp->vm_next = tmp->vm_prev = NULL;
105967- file = tmp->vm_file;
105968- if (file) {
105969- struct inode *inode = file_inode(file);
105970- struct address_space *mapping = file->f_mapping;
105971-
105972- get_file(file);
105973- if (tmp->vm_flags & VM_DENYWRITE)
105974- atomic_dec(&inode->i_writecount);
105975- i_mmap_lock_write(mapping);
105976- if (tmp->vm_flags & VM_SHARED)
105977- atomic_inc(&mapping->i_mmap_writable);
105978- flush_dcache_mmap_lock(mapping);
105979- /* insert tmp into the share list, just after mpnt */
105980- vma_interval_tree_insert_after(tmp, mpnt,
105981- &mapping->i_mmap);
105982- flush_dcache_mmap_unlock(mapping);
105983- i_mmap_unlock_write(mapping);
105984+ tmp = dup_vma(mm, oldmm, mpnt);
105985+ if (!tmp) {
105986+ retval = -ENOMEM;
105987+ goto out;
105988 }
105989
105990 /*
105991@@ -504,6 +583,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
105992 if (retval)
105993 goto out;
105994 }
105995+
105996+#ifdef CONFIG_PAX_SEGMEXEC
105997+ if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
105998+ struct vm_area_struct *mpnt_m;
105999+
106000+ for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
106001+ BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
106002+
106003+ if (!mpnt->vm_mirror)
106004+ continue;
106005+
106006+ if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
106007+ BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
106008+ mpnt->vm_mirror = mpnt_m;
106009+ } else {
106010+ BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
106011+ mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
106012+ mpnt_m->vm_mirror->vm_mirror = mpnt_m;
106013+ mpnt->vm_mirror->vm_mirror = mpnt;
106014+ }
106015+ }
106016+ BUG_ON(mpnt_m);
106017+ }
106018+#endif
106019+
106020 /* a new mm has just been created */
106021 arch_dup_mmap(oldmm, mm);
106022 retval = 0;
106023@@ -513,14 +617,6 @@ out:
106024 up_write(&oldmm->mmap_sem);
106025 uprobe_end_dup_mmap();
106026 return retval;
106027-fail_nomem_anon_vma_fork:
106028- mpol_put(vma_policy(tmp));
106029-fail_nomem_policy:
106030- kmem_cache_free(vm_area_cachep, tmp);
106031-fail_nomem:
106032- retval = -ENOMEM;
106033- vm_unacct_memory(charge);
106034- goto out;
106035 }
106036
106037 static inline int mm_alloc_pgd(struct mm_struct *mm)
106038@@ -795,8 +891,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
106039 return ERR_PTR(err);
106040
106041 mm = get_task_mm(task);
106042- if (mm && mm != current->mm &&
106043- !ptrace_may_access(task, mode)) {
106044+ if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
106045+ (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
106046 mmput(mm);
106047 mm = ERR_PTR(-EACCES);
106048 }
106049@@ -997,13 +1093,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
106050 spin_unlock(&fs->lock);
106051 return -EAGAIN;
106052 }
106053- fs->users++;
106054+ atomic_inc(&fs->users);
106055 spin_unlock(&fs->lock);
106056 return 0;
106057 }
106058 tsk->fs = copy_fs_struct(fs);
106059 if (!tsk->fs)
106060 return -ENOMEM;
106061+ /* Carry through gr_chroot_dentry and is_chrooted instead
106062+ of recomputing it here. Already copied when the task struct
106063+ is duplicated. This allows pivot_root to not be treated as
106064+ a chroot
106065+ */
106066+ //gr_set_chroot_entries(tsk, &tsk->fs->root);
106067+
106068 return 0;
106069 }
106070
106071@@ -1238,7 +1341,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
106072 * parts of the process environment (as per the clone
106073 * flags). The actual kick-off is left to the caller.
106074 */
106075-static struct task_struct *copy_process(unsigned long clone_flags,
106076+static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
106077 unsigned long stack_start,
106078 unsigned long stack_size,
106079 int __user *child_tidptr,
106080@@ -1310,6 +1413,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
106081 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
106082 #endif
106083 retval = -EAGAIN;
106084+
106085+ gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
106086+
106087 if (atomic_read(&p->real_cred->user->processes) >=
106088 task_rlimit(p, RLIMIT_NPROC)) {
106089 if (p->real_cred->user != INIT_USER &&
106090@@ -1560,6 +1666,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
106091 goto bad_fork_free_pid;
106092 }
106093
106094+ /* synchronizes with gr_set_acls()
106095+ we need to call this past the point of no return for fork()
106096+ */
106097+ gr_copy_label(p);
106098+
106099 if (likely(p->pid)) {
106100 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
106101
106102@@ -1649,6 +1760,8 @@ bad_fork_cleanup_count:
106103 bad_fork_free:
106104 free_task(p);
106105 fork_out:
106106+ gr_log_forkfail(retval);
106107+
106108 return ERR_PTR(retval);
106109 }
106110
106111@@ -1711,6 +1824,7 @@ long _do_fork(unsigned long clone_flags,
106112
106113 p = copy_process(clone_flags, stack_start, stack_size,
106114 child_tidptr, NULL, trace, tls);
106115+ add_latent_entropy();
106116 /*
106117 * Do this prior waking up the new thread - the thread pointer
106118 * might get invalid after that point, if the thread exits quickly.
106119@@ -1727,6 +1841,8 @@ long _do_fork(unsigned long clone_flags,
106120 if (clone_flags & CLONE_PARENT_SETTID)
106121 put_user(nr, parent_tidptr);
106122
106123+ gr_handle_brute_check();
106124+
106125 if (clone_flags & CLONE_VFORK) {
106126 p->vfork_done = &vfork;
106127 init_completion(&vfork);
106128@@ -1859,7 +1975,7 @@ void __init proc_caches_init(void)
106129 mm_cachep = kmem_cache_create("mm_struct",
106130 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
106131 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
106132- vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
106133+ vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
106134 mmap_init();
106135 nsproxy_cache_init();
106136 }
106137@@ -1907,7 +2023,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
106138 return 0;
106139
106140 /* don't need lock here; in the worst case we'll do useless copy */
106141- if (fs->users == 1)
106142+ if (atomic_read(&fs->users) == 1)
106143 return 0;
106144
106145 *new_fsp = copy_fs_struct(fs);
106146@@ -2019,7 +2135,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
106147 fs = current->fs;
106148 spin_lock(&fs->lock);
106149 current->fs = new_fs;
106150- if (--fs->users)
106151+ gr_set_chroot_entries(current, &current->fs->root);
106152+ if (atomic_dec_return(&fs->users))
106153 new_fs = NULL;
106154 else
106155 new_fs = fs;
106156@@ -2083,7 +2200,7 @@ int unshare_files(struct files_struct **displaced)
106157 int sysctl_max_threads(struct ctl_table *table, int write,
106158 void __user *buffer, size_t *lenp, loff_t *ppos)
106159 {
106160- struct ctl_table t;
106161+ ctl_table_no_const t;
106162 int ret;
106163 int threads = max_threads;
106164 int min = MIN_THREADS;
106165diff --git a/kernel/futex.c b/kernel/futex.c
106166index c4a182f..e789324 100644
106167--- a/kernel/futex.c
106168+++ b/kernel/futex.c
106169@@ -201,7 +201,7 @@ struct futex_pi_state {
106170 atomic_t refcount;
106171
106172 union futex_key key;
106173-};
106174+} __randomize_layout;
106175
106176 /**
106177 * struct futex_q - The hashed futex queue entry, one per waiting task
106178@@ -235,7 +235,7 @@ struct futex_q {
106179 struct rt_mutex_waiter *rt_waiter;
106180 union futex_key *requeue_pi_key;
106181 u32 bitset;
106182-};
106183+} __randomize_layout;
106184
106185 static const struct futex_q futex_q_init = {
106186 /* list gets initialized in queue_me()*/
106187@@ -402,6 +402,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
106188 struct page *page, *page_head;
106189 int err, ro = 0;
106190
106191+#ifdef CONFIG_PAX_SEGMEXEC
106192+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
106193+ return -EFAULT;
106194+#endif
106195+
106196 /*
106197 * The futex address must be "naturally" aligned.
106198 */
106199@@ -601,7 +606,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
106200
106201 static int get_futex_value_locked(u32 *dest, u32 __user *from)
106202 {
106203- int ret;
106204+ unsigned long ret;
106205
106206 pagefault_disable();
106207 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
106208@@ -3030,6 +3035,7 @@ static void __init futex_detect_cmpxchg(void)
106209 {
106210 #ifndef CONFIG_HAVE_FUTEX_CMPXCHG
106211 u32 curval;
106212+ mm_segment_t oldfs;
106213
106214 /*
106215 * This will fail and we want it. Some arch implementations do
106216@@ -3041,8 +3047,11 @@ static void __init futex_detect_cmpxchg(void)
106217 * implementation, the non-functional ones will return
106218 * -ENOSYS.
106219 */
106220+ oldfs = get_fs();
106221+ set_fs(USER_DS);
106222 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
106223 futex_cmpxchg_enabled = 1;
106224+ set_fs(oldfs);
106225 #endif
106226 }
106227
106228diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
106229index 55c8c93..9ba7ad6 100644
106230--- a/kernel/futex_compat.c
106231+++ b/kernel/futex_compat.c
106232@@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
106233 return 0;
106234 }
106235
106236-static void __user *futex_uaddr(struct robust_list __user *entry,
106237+static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
106238 compat_long_t futex_offset)
106239 {
106240 compat_uptr_t base = ptr_to_compat(entry);
106241diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
106242index 7080ae1..c9b3761 100644
106243--- a/kernel/gcov/base.c
106244+++ b/kernel/gcov/base.c
106245@@ -123,11 +123,6 @@ void gcov_enable_events(void)
106246 }
106247
106248 #ifdef CONFIG_MODULES
106249-static inline int within(void *addr, void *start, unsigned long size)
106250-{
106251- return ((addr >= start) && (addr < start + size));
106252-}
106253-
106254 /* Update list and generate events when modules are unloaded. */
106255 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
106256 void *data)
106257@@ -142,7 +137,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
106258
106259 /* Remove entries located in module from linked list. */
106260 while ((info = gcov_info_next(info))) {
106261- if (within(info, mod->module_core, mod->core_size)) {
106262+ if (within_module_core_rw((unsigned long)info, mod)) {
106263 gcov_info_unlink(prev, info);
106264 if (gcov_events_enabled)
106265 gcov_event(GCOV_REMOVE, info);
106266diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
106267index f974485..c5b8afd 100644
106268--- a/kernel/irq/manage.c
106269+++ b/kernel/irq/manage.c
106270@@ -937,7 +937,7 @@ static int irq_thread(void *data)
106271
106272 action_ret = handler_fn(desc, action);
106273 if (action_ret == IRQ_HANDLED)
106274- atomic_inc(&desc->threads_handled);
106275+ atomic_inc_unchecked(&desc->threads_handled);
106276
106277 wake_threads_waitq(desc);
106278 }
106279diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
106280index 7bf1f1b..d73e508 100644
106281--- a/kernel/irq/msi.c
106282+++ b/kernel/irq/msi.c
106283@@ -195,16 +195,18 @@ static void msi_domain_update_dom_ops(struct msi_domain_info *info)
106284 return;
106285 }
106286
106287+ pax_open_kernel();
106288 if (ops->get_hwirq == NULL)
106289- ops->get_hwirq = msi_domain_ops_default.get_hwirq;
106290+ *(void **)&ops->get_hwirq = msi_domain_ops_default.get_hwirq;
106291 if (ops->msi_init == NULL)
106292- ops->msi_init = msi_domain_ops_default.msi_init;
106293+ *(void **)&ops->msi_init = msi_domain_ops_default.msi_init;
106294 if (ops->msi_check == NULL)
106295- ops->msi_check = msi_domain_ops_default.msi_check;
106296+ *(void **)&ops->msi_check = msi_domain_ops_default.msi_check;
106297 if (ops->msi_prepare == NULL)
106298- ops->msi_prepare = msi_domain_ops_default.msi_prepare;
106299+ *(void **)&ops->msi_prepare = msi_domain_ops_default.msi_prepare;
106300 if (ops->set_desc == NULL)
106301- ops->set_desc = msi_domain_ops_default.set_desc;
106302+ *(void **)&ops->set_desc = msi_domain_ops_default.set_desc;
106303+ pax_close_kernel();
106304 }
106305
106306 static void msi_domain_update_chip_ops(struct msi_domain_info *info)
106307@@ -212,12 +214,14 @@ static void msi_domain_update_chip_ops(struct msi_domain_info *info)
106308 struct irq_chip *chip = info->chip;
106309
106310 BUG_ON(!chip);
106311+ pax_open_kernel();
106312 if (!chip->irq_mask)
106313- chip->irq_mask = pci_msi_mask_irq;
106314+ *(void **)&chip->irq_mask = pci_msi_mask_irq;
106315 if (!chip->irq_unmask)
106316- chip->irq_unmask = pci_msi_unmask_irq;
106317+ *(void **)&chip->irq_unmask = pci_msi_unmask_irq;
106318 if (!chip->irq_set_affinity)
106319- chip->irq_set_affinity = msi_domain_set_affinity;
106320+ *(void **)&chip->irq_set_affinity = msi_domain_set_affinity;
106321+ pax_close_kernel();
106322 }
106323
106324 /**
106325diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
106326index e2514b0..de3dfe0 100644
106327--- a/kernel/irq/spurious.c
106328+++ b/kernel/irq/spurious.c
106329@@ -337,7 +337,7 @@ void note_interrupt(unsigned int irq, struct irq_desc *desc,
106330 * count. We just care about the count being
106331 * different than the one we saw before.
106332 */
106333- handled = atomic_read(&desc->threads_handled);
106334+ handled = atomic_read_unchecked(&desc->threads_handled);
106335 handled |= SPURIOUS_DEFERRED;
106336 if (handled != desc->threads_handled_last) {
106337 action_ret = IRQ_HANDLED;
106338diff --git a/kernel/jump_label.c b/kernel/jump_label.c
106339index 52ebaca..ec6f5cb 100644
106340--- a/kernel/jump_label.c
106341+++ b/kernel/jump_label.c
106342@@ -14,6 +14,7 @@
106343 #include <linux/err.h>
106344 #include <linux/static_key.h>
106345 #include <linux/jump_label_ratelimit.h>
106346+#include <linux/mm.h>
106347
106348 #ifdef HAVE_JUMP_LABEL
106349
106350@@ -51,7 +52,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
106351
106352 size = (((unsigned long)stop - (unsigned long)start)
106353 / sizeof(struct jump_entry));
106354+ pax_open_kernel();
106355 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
106356+ pax_close_kernel();
106357 }
106358
106359 static void jump_label_update(struct static_key *key, int enable);
106360@@ -363,10 +366,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
106361 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
106362 struct jump_entry *iter;
106363
106364+ pax_open_kernel();
106365 for (iter = iter_start; iter < iter_stop; iter++) {
106366 if (within_module_init(iter->code, mod))
106367 iter->code = 0;
106368 }
106369+ pax_close_kernel();
106370 }
106371
106372 static int
106373diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
106374index 5c5987f..bc502b0 100644
106375--- a/kernel/kallsyms.c
106376+++ b/kernel/kallsyms.c
106377@@ -11,6 +11,9 @@
106378 * Changed the compression method from stem compression to "table lookup"
106379 * compression (see scripts/kallsyms.c for a more complete description)
106380 */
106381+#ifdef CONFIG_GRKERNSEC_HIDESYM
106382+#define __INCLUDED_BY_HIDESYM 1
106383+#endif
106384 #include <linux/kallsyms.h>
106385 #include <linux/module.h>
106386 #include <linux/init.h>
106387@@ -54,12 +57,33 @@ extern const unsigned long kallsyms_markers[] __weak;
106388
106389 static inline int is_kernel_inittext(unsigned long addr)
106390 {
106391+ if (system_state != SYSTEM_BOOTING)
106392+ return 0;
106393+
106394 if (addr >= (unsigned long)_sinittext
106395 && addr <= (unsigned long)_einittext)
106396 return 1;
106397 return 0;
106398 }
106399
106400+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
106401+#ifdef CONFIG_MODULES
106402+static inline int is_module_text(unsigned long addr)
106403+{
106404+ if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
106405+ return 1;
106406+
106407+ addr = ktla_ktva(addr);
106408+ return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
106409+}
106410+#else
106411+static inline int is_module_text(unsigned long addr)
106412+{
106413+ return 0;
106414+}
106415+#endif
106416+#endif
106417+
106418 static inline int is_kernel_text(unsigned long addr)
106419 {
106420 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
106421@@ -70,13 +94,28 @@ static inline int is_kernel_text(unsigned long addr)
106422
106423 static inline int is_kernel(unsigned long addr)
106424 {
106425+
106426+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
106427+ if (is_kernel_text(addr) || is_kernel_inittext(addr))
106428+ return 1;
106429+
106430+ if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
106431+#else
106432 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
106433+#endif
106434+
106435 return 1;
106436 return in_gate_area_no_mm(addr);
106437 }
106438
106439 static int is_ksym_addr(unsigned long addr)
106440 {
106441+
106442+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
106443+ if (is_module_text(addr))
106444+ return 0;
106445+#endif
106446+
106447 if (all_var)
106448 return is_kernel(addr);
106449
106450@@ -481,7 +520,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
106451
106452 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
106453 {
106454- iter->name[0] = '\0';
106455 iter->nameoff = get_symbol_offset(new_pos);
106456 iter->pos = new_pos;
106457 }
106458@@ -529,6 +567,11 @@ static int s_show(struct seq_file *m, void *p)
106459 {
106460 struct kallsym_iter *iter = m->private;
106461
106462+#ifdef CONFIG_GRKERNSEC_HIDESYM
106463+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
106464+ return 0;
106465+#endif
106466+
106467 /* Some debugging symbols have no name. Ignore them. */
106468 if (!iter->name[0])
106469 return 0;
106470@@ -542,6 +585,7 @@ static int s_show(struct seq_file *m, void *p)
106471 */
106472 type = iter->exported ? toupper(iter->type) :
106473 tolower(iter->type);
106474+
106475 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
106476 type, iter->name, iter->module_name);
106477 } else
106478diff --git a/kernel/kcmp.c b/kernel/kcmp.c
106479index 0aa69ea..a7fcafb 100644
106480--- a/kernel/kcmp.c
106481+++ b/kernel/kcmp.c
106482@@ -100,6 +100,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
106483 struct task_struct *task1, *task2;
106484 int ret;
106485
106486+#ifdef CONFIG_GRKERNSEC
106487+ return -ENOSYS;
106488+#endif
106489+
106490 rcu_read_lock();
106491
106492 /*
106493diff --git a/kernel/kexec.c b/kernel/kexec.c
106494index a785c10..6dbb06f 100644
106495--- a/kernel/kexec.c
106496+++ b/kernel/kexec.c
106497@@ -1243,7 +1243,7 @@ static int kimage_load_segment(struct kimage *image,
106498 */
106499 struct kimage *kexec_image;
106500 struct kimage *kexec_crash_image;
106501-int kexec_load_disabled;
106502+int kexec_load_disabled __read_only;
106503
106504 static DEFINE_MUTEX(kexec_mutex);
106505
106506@@ -1359,7 +1359,8 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry,
106507 compat_ulong_t, flags)
106508 {
106509 struct compat_kexec_segment in;
106510- struct kexec_segment out, __user *ksegments;
106511+ struct kexec_segment out;
106512+ struct kexec_segment __user *ksegments;
106513 unsigned long i, result;
106514
106515 /* Don't allow clients that don't understand the native
106516diff --git a/kernel/kmod.c b/kernel/kmod.c
106517index 2777f40..a689506 100644
106518--- a/kernel/kmod.c
106519+++ b/kernel/kmod.c
106520@@ -68,7 +68,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
106521 kfree(info->argv);
106522 }
106523
106524-static int call_modprobe(char *module_name, int wait)
106525+static int call_modprobe(char *module_name, char *module_param, int wait)
106526 {
106527 struct subprocess_info *info;
106528 static char *envp[] = {
106529@@ -78,7 +78,7 @@ static int call_modprobe(char *module_name, int wait)
106530 NULL
106531 };
106532
106533- char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
106534+ char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
106535 if (!argv)
106536 goto out;
106537
106538@@ -90,7 +90,8 @@ static int call_modprobe(char *module_name, int wait)
106539 argv[1] = "-q";
106540 argv[2] = "--";
106541 argv[3] = module_name; /* check free_modprobe_argv() */
106542- argv[4] = NULL;
106543+ argv[4] = module_param;
106544+ argv[5] = NULL;
106545
106546 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
106547 NULL, free_modprobe_argv, NULL);
106548@@ -122,9 +123,8 @@ out:
106549 * If module auto-loading support is disabled then this function
106550 * becomes a no-operation.
106551 */
106552-int __request_module(bool wait, const char *fmt, ...)
106553+static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
106554 {
106555- va_list args;
106556 char module_name[MODULE_NAME_LEN];
106557 unsigned int max_modprobes;
106558 int ret;
106559@@ -143,9 +143,7 @@ int __request_module(bool wait, const char *fmt, ...)
106560 if (!modprobe_path[0])
106561 return 0;
106562
106563- va_start(args, fmt);
106564- ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
106565- va_end(args);
106566+ ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
106567 if (ret >= MODULE_NAME_LEN)
106568 return -ENAMETOOLONG;
106569
106570@@ -153,6 +151,20 @@ int __request_module(bool wait, const char *fmt, ...)
106571 if (ret)
106572 return ret;
106573
106574+#ifdef CONFIG_GRKERNSEC_MODHARDEN
106575+ if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
106576+ /* hack to workaround consolekit/udisks stupidity */
106577+ read_lock(&tasklist_lock);
106578+ if (!strcmp(current->comm, "mount") &&
106579+ current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
106580+ read_unlock(&tasklist_lock);
106581+ printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
106582+ return -EPERM;
106583+ }
106584+ read_unlock(&tasklist_lock);
106585+ }
106586+#endif
106587+
106588 /* If modprobe needs a service that is in a module, we get a recursive
106589 * loop. Limit the number of running kmod threads to max_threads/2 or
106590 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
106591@@ -181,16 +193,61 @@ int __request_module(bool wait, const char *fmt, ...)
106592
106593 trace_module_request(module_name, wait, _RET_IP_);
106594
106595- ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
106596+ ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
106597
106598 atomic_dec(&kmod_concurrent);
106599 return ret;
106600 }
106601+
106602+int ___request_module(bool wait, char *module_param, const char *fmt, ...)
106603+{
106604+ va_list args;
106605+ int ret;
106606+
106607+ va_start(args, fmt);
106608+ ret = ____request_module(wait, module_param, fmt, args);
106609+ va_end(args);
106610+
106611+ return ret;
106612+}
106613+
106614+int __request_module(bool wait, const char *fmt, ...)
106615+{
106616+ va_list args;
106617+ int ret;
106618+
106619+#ifdef CONFIG_GRKERNSEC_MODHARDEN
106620+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
106621+ char module_param[MODULE_NAME_LEN];
106622+
106623+ memset(module_param, 0, sizeof(module_param));
106624+
106625+ snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
106626+
106627+ va_start(args, fmt);
106628+ ret = ____request_module(wait, module_param, fmt, args);
106629+ va_end(args);
106630+
106631+ return ret;
106632+ }
106633+#endif
106634+
106635+ va_start(args, fmt);
106636+ ret = ____request_module(wait, NULL, fmt, args);
106637+ va_end(args);
106638+
106639+ return ret;
106640+}
106641+
106642 EXPORT_SYMBOL(__request_module);
106643 #endif /* CONFIG_MODULES */
106644
106645 static void call_usermodehelper_freeinfo(struct subprocess_info *info)
106646 {
106647+#ifdef CONFIG_GRKERNSEC
106648+ kfree(info->path);
106649+ info->path = info->origpath;
106650+#endif
106651 if (info->cleanup)
106652 (*info->cleanup)(info);
106653 kfree(info);
106654@@ -232,6 +289,21 @@ static int ____call_usermodehelper(void *data)
106655 */
106656 set_user_nice(current, 0);
106657
106658+#ifdef CONFIG_GRKERNSEC
106659+ /* this is race-free as far as userland is concerned as we copied
106660+ out the path to be used prior to this point and are now operating
106661+ on that copy
106662+ */
106663+ if ((strncmp(sub_info->path, "/sbin/", 6) && strncmp(sub_info->path, "/usr/lib/", 9) &&
106664+ strncmp(sub_info->path, "/lib/", 5) && strncmp(sub_info->path, "/lib64/", 7) &&
106665+ strncmp(sub_info->path, "/usr/libexec/", 13) && strncmp(sub_info->path, "/usr/bin/", 9) &&
106666+ strcmp(sub_info->path, "/usr/share/apport/apport")) || strstr(sub_info->path, "..")) {
106667+ printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of permitted system paths\n", sub_info->path);
106668+ retval = -EPERM;
106669+ goto out;
106670+ }
106671+#endif
106672+
106673 retval = -ENOMEM;
106674 new = prepare_kernel_cred(current);
106675 if (!new)
106676@@ -254,8 +326,8 @@ static int ____call_usermodehelper(void *data)
106677 commit_creds(new);
106678
106679 retval = do_execve(getname_kernel(sub_info->path),
106680- (const char __user *const __user *)sub_info->argv,
106681- (const char __user *const __user *)sub_info->envp);
106682+ (const char __user *const __force_user *)sub_info->argv,
106683+ (const char __user *const __force_user *)sub_info->envp);
106684 out:
106685 sub_info->retval = retval;
106686 /* wait_for_helper() will call umh_complete if UHM_WAIT_PROC. */
106687@@ -288,7 +360,7 @@ static int wait_for_helper(void *data)
106688 *
106689 * Thus the __user pointer cast is valid here.
106690 */
106691- sys_wait4(pid, (int __user *)&ret, 0, NULL);
106692+ sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
106693
106694 /*
106695 * If ret is 0, either ____call_usermodehelper failed and the
106696@@ -510,7 +582,12 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
106697 goto out;
106698
106699 INIT_WORK(&sub_info->work, __call_usermodehelper);
106700+#ifdef CONFIG_GRKERNSEC
106701+ sub_info->origpath = path;
106702+ sub_info->path = kstrdup(path, gfp_mask);
106703+#else
106704 sub_info->path = path;
106705+#endif
106706 sub_info->argv = argv;
106707 sub_info->envp = envp;
106708
106709@@ -612,7 +689,7 @@ EXPORT_SYMBOL(call_usermodehelper);
106710 static int proc_cap_handler(struct ctl_table *table, int write,
106711 void __user *buffer, size_t *lenp, loff_t *ppos)
106712 {
106713- struct ctl_table t;
106714+ ctl_table_no_const t;
106715 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
106716 kernel_cap_t new_cap;
106717 int err, i;
106718diff --git a/kernel/kprobes.c b/kernel/kprobes.c
106719index c90e417..e6c515d 100644
106720--- a/kernel/kprobes.c
106721+++ b/kernel/kprobes.c
106722@@ -31,6 +31,9 @@
106723 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
106724 * <prasanna@in.ibm.com> added function-return probes.
106725 */
106726+#ifdef CONFIG_GRKERNSEC_HIDESYM
106727+#define __INCLUDED_BY_HIDESYM 1
106728+#endif
106729 #include <linux/kprobes.h>
106730 #include <linux/hash.h>
106731 #include <linux/init.h>
106732@@ -122,12 +125,12 @@ enum kprobe_slot_state {
106733
106734 static void *alloc_insn_page(void)
106735 {
106736- return module_alloc(PAGE_SIZE);
106737+ return module_alloc_exec(PAGE_SIZE);
106738 }
106739
106740 static void free_insn_page(void *page)
106741 {
106742- module_memfree(page);
106743+ module_memfree_exec(page);
106744 }
106745
106746 struct kprobe_insn_cache kprobe_insn_slots = {
106747@@ -2198,11 +2201,11 @@ static void report_probe(struct seq_file *pi, struct kprobe *p,
106748 kprobe_type = "k";
106749
106750 if (sym)
106751- seq_printf(pi, "%p %s %s+0x%x %s ",
106752+ seq_printf(pi, "%pK %s %s+0x%x %s ",
106753 p->addr, kprobe_type, sym, offset,
106754 (modname ? modname : " "));
106755 else
106756- seq_printf(pi, "%p %s %p ",
106757+ seq_printf(pi, "%pK %s %pK ",
106758 p->addr, kprobe_type, p->addr);
106759
106760 if (!pp)
106761diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
106762index 6683cce..daf8999 100644
106763--- a/kernel/ksysfs.c
106764+++ b/kernel/ksysfs.c
106765@@ -50,6 +50,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
106766 {
106767 if (count+1 > UEVENT_HELPER_PATH_LEN)
106768 return -ENOENT;
106769+ if (!capable(CAP_SYS_ADMIN))
106770+ return -EPERM;
106771 memcpy(uevent_helper, buf, count);
106772 uevent_helper[count] = '\0';
106773 if (count && uevent_helper[count-1] == '\n')
106774@@ -176,7 +178,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
106775 return count;
106776 }
106777
106778-static struct bin_attribute notes_attr = {
106779+static bin_attribute_no_const notes_attr __read_only = {
106780 .attr = {
106781 .name = "notes",
106782 .mode = S_IRUGO,
106783diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
106784index 8acfbf7..0c5a34a 100644
106785--- a/kernel/locking/lockdep.c
106786+++ b/kernel/locking/lockdep.c
106787@@ -613,6 +613,10 @@ static int static_obj(void *obj)
106788 end = (unsigned long) &_end,
106789 addr = (unsigned long) obj;
106790
106791+#ifdef CONFIG_PAX_KERNEXEC
106792+ start = ktla_ktva(start);
106793+#endif
106794+
106795 /*
106796 * static variable?
106797 */
106798@@ -757,6 +761,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
106799 if (!static_obj(lock->key)) {
106800 debug_locks_off();
106801 printk("INFO: trying to register non-static key.\n");
106802+ printk("lock:%pS key:%pS.\n", lock, lock->key);
106803 printk("the code is fine but needs lockdep annotation.\n");
106804 printk("turning off the locking correctness validator.\n");
106805 dump_stack();
106806@@ -3102,7 +3107,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
106807 if (!class)
106808 return 0;
106809 }
106810- atomic_inc((atomic_t *)&class->ops);
106811+ atomic_long_inc_unchecked((atomic_long_unchecked_t *)&class->ops);
106812 if (very_verbose(class)) {
106813 printk("\nacquire class [%p] %s", class->key, class->name);
106814 if (class->name_version > 1)
106815diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
106816index d83d798..ea3120d 100644
106817--- a/kernel/locking/lockdep_proc.c
106818+++ b/kernel/locking/lockdep_proc.c
106819@@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
106820 return 0;
106821 }
106822
106823- seq_printf(m, "%p", class->key);
106824+ seq_printf(m, "%pK", class->key);
106825 #ifdef CONFIG_DEBUG_LOCKDEP
106826 seq_printf(m, " OPS:%8ld", class->ops);
106827 #endif
106828@@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
106829
106830 list_for_each_entry(entry, &class->locks_after, entry) {
106831 if (entry->distance == 1) {
106832- seq_printf(m, " -> [%p] ", entry->class->key);
106833+ seq_printf(m, " -> [%pK] ", entry->class->key);
106834 print_name(m, entry->class);
106835 seq_puts(m, "\n");
106836 }
106837@@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
106838 if (!class->key)
106839 continue;
106840
106841- seq_printf(m, "[%p] ", class->key);
106842+ seq_printf(m, "[%pK] ", class->key);
106843 print_name(m, class);
106844 seq_puts(m, "\n");
106845 }
106846@@ -508,7 +508,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
106847 if (!i)
106848 seq_line(m, '-', 40-namelen, namelen);
106849
106850- snprintf(ip, sizeof(ip), "[<%p>]",
106851+ snprintf(ip, sizeof(ip), "[<%pK>]",
106852 (void *)class->contention_point[i]);
106853 seq_printf(m, "%40s %14lu %29s %pS\n",
106854 name, stats->contention_point[i],
106855@@ -523,7 +523,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
106856 if (!i)
106857 seq_line(m, '-', 40-namelen, namelen);
106858
106859- snprintf(ip, sizeof(ip), "[<%p>]",
106860+ snprintf(ip, sizeof(ip), "[<%pK>]",
106861 (void *)class->contending_point[i]);
106862 seq_printf(m, "%40s %14lu %29s %pS\n",
106863 name, stats->contending_point[i],
106864diff --git a/kernel/locking/mutex-debug.c b/kernel/locking/mutex-debug.c
106865index 3ef3736..9c951fa 100644
106866--- a/kernel/locking/mutex-debug.c
106867+++ b/kernel/locking/mutex-debug.c
106868@@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
106869 }
106870
106871 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
106872- struct thread_info *ti)
106873+ struct task_struct *task)
106874 {
106875 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
106876
106877 /* Mark the current thread as blocked on the lock: */
106878- ti->task->blocked_on = waiter;
106879+ task->blocked_on = waiter;
106880 }
106881
106882 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
106883- struct thread_info *ti)
106884+ struct task_struct *task)
106885 {
106886 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
106887- DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
106888- DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
106889- ti->task->blocked_on = NULL;
106890+ DEBUG_LOCKS_WARN_ON(waiter->task != task);
106891+ DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
106892+ task->blocked_on = NULL;
106893
106894 list_del_init(&waiter->list);
106895 waiter->task = NULL;
106896diff --git a/kernel/locking/mutex-debug.h b/kernel/locking/mutex-debug.h
106897index 0799fd3..d06ae3b 100644
106898--- a/kernel/locking/mutex-debug.h
106899+++ b/kernel/locking/mutex-debug.h
106900@@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
106901 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
106902 extern void debug_mutex_add_waiter(struct mutex *lock,
106903 struct mutex_waiter *waiter,
106904- struct thread_info *ti);
106905+ struct task_struct *task);
106906 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
106907- struct thread_info *ti);
106908+ struct task_struct *task);
106909 extern void debug_mutex_unlock(struct mutex *lock);
106910 extern void debug_mutex_init(struct mutex *lock, const char *name,
106911 struct lock_class_key *key);
106912diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
106913index 4cccea6..4382db9 100644
106914--- a/kernel/locking/mutex.c
106915+++ b/kernel/locking/mutex.c
106916@@ -533,7 +533,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
106917 goto skip_wait;
106918
106919 debug_mutex_lock_common(lock, &waiter);
106920- debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
106921+ debug_mutex_add_waiter(lock, &waiter, task);
106922
106923 /* add waiting tasks to the end of the waitqueue (FIFO): */
106924 list_add_tail(&waiter.list, &lock->wait_list);
106925@@ -580,7 +580,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
106926 }
106927 __set_task_state(task, TASK_RUNNING);
106928
106929- mutex_remove_waiter(lock, &waiter, current_thread_info());
106930+ mutex_remove_waiter(lock, &waiter, task);
106931 /* set it to 0 if there are no waiters left: */
106932 if (likely(list_empty(&lock->wait_list)))
106933 atomic_set(&lock->count, 0);
106934@@ -601,7 +601,7 @@ skip_wait:
106935 return 0;
106936
106937 err:
106938- mutex_remove_waiter(lock, &waiter, task_thread_info(task));
106939+ mutex_remove_waiter(lock, &waiter, task);
106940 spin_unlock_mutex(&lock->wait_lock, flags);
106941 debug_mutex_free_waiter(&waiter);
106942 mutex_release(&lock->dep_map, 1, ip);
106943diff --git a/kernel/locking/rtmutex-tester.c b/kernel/locking/rtmutex-tester.c
106944index 1d96dd0..994ff19 100644
106945--- a/kernel/locking/rtmutex-tester.c
106946+++ b/kernel/locking/rtmutex-tester.c
106947@@ -22,7 +22,7 @@
106948 #define MAX_RT_TEST_MUTEXES 8
106949
106950 static spinlock_t rttest_lock;
106951-static atomic_t rttest_event;
106952+static atomic_unchecked_t rttest_event;
106953
106954 struct test_thread_data {
106955 int opcode;
106956@@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
106957
106958 case RTTEST_LOCKCONT:
106959 td->mutexes[td->opdata] = 1;
106960- td->event = atomic_add_return(1, &rttest_event);
106961+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106962 return 0;
106963
106964 case RTTEST_RESET:
106965@@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
106966 return 0;
106967
106968 case RTTEST_RESETEVENT:
106969- atomic_set(&rttest_event, 0);
106970+ atomic_set_unchecked(&rttest_event, 0);
106971 return 0;
106972
106973 default:
106974@@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
106975 return ret;
106976
106977 td->mutexes[id] = 1;
106978- td->event = atomic_add_return(1, &rttest_event);
106979+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106980 rt_mutex_lock(&mutexes[id]);
106981- td->event = atomic_add_return(1, &rttest_event);
106982+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106983 td->mutexes[id] = 4;
106984 return 0;
106985
106986@@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
106987 return ret;
106988
106989 td->mutexes[id] = 1;
106990- td->event = atomic_add_return(1, &rttest_event);
106991+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106992 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
106993- td->event = atomic_add_return(1, &rttest_event);
106994+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106995 td->mutexes[id] = ret ? 0 : 4;
106996 return ret ? -EINTR : 0;
106997
106998@@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
106999 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
107000 return ret;
107001
107002- td->event = atomic_add_return(1, &rttest_event);
107003+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107004 rt_mutex_unlock(&mutexes[id]);
107005- td->event = atomic_add_return(1, &rttest_event);
107006+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107007 td->mutexes[id] = 0;
107008 return 0;
107009
107010@@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
107011 break;
107012
107013 td->mutexes[dat] = 2;
107014- td->event = atomic_add_return(1, &rttest_event);
107015+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107016 break;
107017
107018 default:
107019@@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
107020 return;
107021
107022 td->mutexes[dat] = 3;
107023- td->event = atomic_add_return(1, &rttest_event);
107024+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107025 break;
107026
107027 case RTTEST_LOCKNOWAIT:
107028@@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
107029 return;
107030
107031 td->mutexes[dat] = 1;
107032- td->event = atomic_add_return(1, &rttest_event);
107033+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107034 return;
107035
107036 default:
107037diff --git a/kernel/module.c b/kernel/module.c
107038index b86b7bf..f5eaa56 100644
107039--- a/kernel/module.c
107040+++ b/kernel/module.c
107041@@ -59,6 +59,7 @@
107042 #include <linux/jump_label.h>
107043 #include <linux/pfn.h>
107044 #include <linux/bsearch.h>
107045+#include <linux/grsecurity.h>
107046 #include <uapi/linux/module.h>
107047 #include "module-internal.h"
107048
107049@@ -108,7 +109,7 @@ static LIST_HEAD(modules);
107050 * Use a latched RB-tree for __module_address(); this allows us to use
107051 * RCU-sched lookups of the address from any context.
107052 *
107053- * Because modules have two address ranges: init and core, we need two
107054+ * Because modules have four address ranges: init_{rw,rx} and core_{rw,rx}, we need four
107055 * latch_tree_nodes entries. Therefore we need the back-pointer from
107056 * mod_tree_node.
107057 *
107058@@ -125,10 +126,14 @@ static __always_inline unsigned long __mod_tree_val(struct latch_tree_node *n)
107059 struct mod_tree_node *mtn = container_of(n, struct mod_tree_node, node);
107060 struct module *mod = mtn->mod;
107061
107062- if (unlikely(mtn == &mod->mtn_init))
107063- return (unsigned long)mod->module_init;
107064+ if (unlikely(mtn == &mod->mtn_init_rw))
107065+ return (unsigned long)mod->module_init_rw;
107066+ if (unlikely(mtn == &mod->mtn_init_rx))
107067+ return (unsigned long)mod->module_init_rx;
107068
107069- return (unsigned long)mod->module_core;
107070+ if (unlikely(mtn == &mod->mtn_core_rw))
107071+ return (unsigned long)mod->module_core_rw;
107072+ return (unsigned long)mod->module_core_rx;
107073 }
107074
107075 static __always_inline unsigned long __mod_tree_size(struct latch_tree_node *n)
107076@@ -136,10 +141,14 @@ static __always_inline unsigned long __mod_tree_size(struct latch_tree_node *n)
107077 struct mod_tree_node *mtn = container_of(n, struct mod_tree_node, node);
107078 struct module *mod = mtn->mod;
107079
107080- if (unlikely(mtn == &mod->mtn_init))
107081- return (unsigned long)mod->init_size;
107082+ if (unlikely(mtn == &mod->mtn_init_rw))
107083+ return (unsigned long)mod->init_size_rw;
107084+ if (unlikely(mtn == &mod->mtn_init_rx))
107085+ return (unsigned long)mod->init_size_rx;
107086
107087- return (unsigned long)mod->core_size;
107088+ if (unlikely(mtn == &mod->mtn_core_rw))
107089+ return (unsigned long)mod->core_size_rw;
107090+ return (unsigned long)mod->core_size_rx;
107091 }
107092
107093 static __always_inline bool
107094@@ -172,14 +181,19 @@ static const struct latch_tree_ops mod_tree_ops = {
107095
107096 static struct mod_tree_root {
107097 struct latch_tree_root root;
107098- unsigned long addr_min;
107099- unsigned long addr_max;
107100+ unsigned long addr_min_rw;
107101+ unsigned long addr_min_rx;
107102+ unsigned long addr_max_rw;
107103+ unsigned long addr_max_rx;
107104 } mod_tree __cacheline_aligned = {
107105- .addr_min = -1UL,
107106+ .addr_min_rw = -1UL,
107107+ .addr_min_rx = -1UL,
107108 };
107109
107110-#define module_addr_min mod_tree.addr_min
107111-#define module_addr_max mod_tree.addr_max
107112+#define module_addr_min_rw mod_tree.addr_min_rw
107113+#define module_addr_min_rx mod_tree.addr_min_rx
107114+#define module_addr_max_rw mod_tree.addr_max_rw
107115+#define module_addr_max_rx mod_tree.addr_max_rx
107116
107117 static noinline void __mod_tree_insert(struct mod_tree_node *node)
107118 {
107119@@ -197,23 +211,31 @@ static void __mod_tree_remove(struct mod_tree_node *node)
107120 */
107121 static void mod_tree_insert(struct module *mod)
107122 {
107123- mod->mtn_core.mod = mod;
107124- mod->mtn_init.mod = mod;
107125+ mod->mtn_core_rw.mod = mod;
107126+ mod->mtn_core_rx.mod = mod;
107127+ mod->mtn_init_rw.mod = mod;
107128+ mod->mtn_init_rx.mod = mod;
107129
107130- __mod_tree_insert(&mod->mtn_core);
107131- if (mod->init_size)
107132- __mod_tree_insert(&mod->mtn_init);
107133+ __mod_tree_insert(&mod->mtn_core_rw);
107134+ __mod_tree_insert(&mod->mtn_core_rx);
107135+ if (mod->init_size_rw)
107136+ __mod_tree_insert(&mod->mtn_init_rw);
107137+ if (mod->init_size_rx)
107138+ __mod_tree_insert(&mod->mtn_init_rx);
107139 }
107140
107141 static void mod_tree_remove_init(struct module *mod)
107142 {
107143- if (mod->init_size)
107144- __mod_tree_remove(&mod->mtn_init);
107145+ if (mod->init_size_rw)
107146+ __mod_tree_remove(&mod->mtn_init_rw);
107147+ if (mod->init_size_rx)
107148+ __mod_tree_remove(&mod->mtn_init_rx);
107149 }
107150
107151 static void mod_tree_remove(struct module *mod)
107152 {
107153- __mod_tree_remove(&mod->mtn_core);
107154+ __mod_tree_remove(&mod->mtn_core_rw);
107155+ __mod_tree_remove(&mod->mtn_core_rx);
107156 mod_tree_remove_init(mod);
107157 }
107158
107159@@ -230,7 +252,8 @@ static struct module *mod_find(unsigned long addr)
107160
107161 #else /* MODULES_TREE_LOOKUP */
107162
107163-static unsigned long module_addr_min = -1UL, module_addr_max = 0;
107164+static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
107165+static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
107166
107167 static void mod_tree_insert(struct module *mod) { }
107168 static void mod_tree_remove_init(struct module *mod) { }
107169@@ -254,22 +277,36 @@ static struct module *mod_find(unsigned long addr)
107170 * Bounds of module text, for speeding up __module_address.
107171 * Protected by module_mutex.
107172 */
107173-static void __mod_update_bounds(void *base, unsigned int size)
107174+static void __mod_update_bounds_rw(void *base, unsigned int size)
107175 {
107176 unsigned long min = (unsigned long)base;
107177 unsigned long max = min + size;
107178
107179- if (min < module_addr_min)
107180- module_addr_min = min;
107181- if (max > module_addr_max)
107182- module_addr_max = max;
107183+ if (min < module_addr_min_rw)
107184+ module_addr_min_rw = min;
107185+ if (max > module_addr_max_rw)
107186+ module_addr_max_rw = max;
107187+}
107188+
107189+static void __mod_update_bounds_rx(void *base, unsigned int size)
107190+{
107191+ unsigned long min = (unsigned long)base;
107192+ unsigned long max = min + size;
107193+
107194+ if (min < module_addr_min_rx)
107195+ module_addr_min_rx = min;
107196+ if (max > module_addr_max_rx)
107197+ module_addr_max_rx = max;
107198 }
107199
107200 static void mod_update_bounds(struct module *mod)
107201 {
107202- __mod_update_bounds(mod->module_core, mod->core_size);
107203- if (mod->init_size)
107204- __mod_update_bounds(mod->module_init, mod->init_size);
107205+ __mod_update_bounds_rw(mod->module_core_rw, mod->core_size_rw);
107206+ __mod_update_bounds_rx(mod->module_core_rx, mod->core_size_rx);
107207+ if (mod->init_size_rw)
107208+ __mod_update_bounds_rw(mod->module_init_rw, mod->init_size_rw);
107209+ if (mod->init_size_rx)
107210+ __mod_update_bounds_rx(mod->module_init_rx, mod->init_size_rx);
107211 }
107212
107213 #ifdef CONFIG_KGDB_KDB
107214@@ -298,7 +335,7 @@ module_param(sig_enforce, bool_enable_only, 0644);
107215 #endif /* !CONFIG_MODULE_SIG_FORCE */
107216
107217 /* Block module loading/unloading? */
107218-int modules_disabled = 0;
107219+int modules_disabled __read_only = 0;
107220 core_param(nomodule, modules_disabled, bint, 0);
107221
107222 /* Waiting for a module to finish initializing? */
107223@@ -473,7 +510,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
107224 return true;
107225
107226 list_for_each_entry_rcu(mod, &modules, list) {
107227- struct symsearch arr[] = {
107228+ struct symsearch modarr[] = {
107229 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
107230 NOT_GPL_ONLY, false },
107231 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
107232@@ -498,7 +535,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
107233 if (mod->state == MODULE_STATE_UNFORMED)
107234 continue;
107235
107236- if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
107237+ if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
107238 return true;
107239 }
107240 return false;
107241@@ -644,7 +681,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
107242 if (!pcpusec->sh_size)
107243 return 0;
107244
107245- if (align > PAGE_SIZE) {
107246+ if (align-1 >= PAGE_SIZE) {
107247 pr_warn("%s: per-cpu alignment %li > %li\n",
107248 mod->name, align, PAGE_SIZE);
107249 align = PAGE_SIZE;
107250@@ -1210,7 +1247,7 @@ struct module_attribute module_uevent =
107251 static ssize_t show_coresize(struct module_attribute *mattr,
107252 struct module_kobject *mk, char *buffer)
107253 {
107254- return sprintf(buffer, "%u\n", mk->mod->core_size);
107255+ return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
107256 }
107257
107258 static struct module_attribute modinfo_coresize =
107259@@ -1219,7 +1256,7 @@ static struct module_attribute modinfo_coresize =
107260 static ssize_t show_initsize(struct module_attribute *mattr,
107261 struct module_kobject *mk, char *buffer)
107262 {
107263- return sprintf(buffer, "%u\n", mk->mod->init_size);
107264+ return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
107265 }
107266
107267 static struct module_attribute modinfo_initsize =
107268@@ -1311,12 +1348,29 @@ static int check_version(Elf_Shdr *sechdrs,
107269 goto bad_version;
107270 }
107271
107272+#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
107273+ /*
107274+ * avoid potentially printing jibberish on attempted load
107275+ * of a module randomized with a different seed
107276+ */
107277+ pr_warn("no symbol version for %s\n", symname);
107278+#else
107279 pr_warn("%s: no symbol version for %s\n", mod->name, symname);
107280+#endif
107281 return 0;
107282
107283 bad_version:
107284+#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
107285+ /*
107286+ * avoid potentially printing jibberish on attempted load
107287+ * of a module randomized with a different seed
107288+ */
107289+ pr_warn("attempted module disagrees about version of symbol %s\n",
107290+ symname);
107291+#else
107292 pr_warn("%s: disagrees about version of symbol %s\n",
107293 mod->name, symname);
107294+#endif
107295 return 0;
107296 }
107297
107298@@ -1444,7 +1498,7 @@ resolve_symbol_wait(struct module *mod,
107299 */
107300 #ifdef CONFIG_SYSFS
107301
107302-#ifdef CONFIG_KALLSYMS
107303+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
107304 static inline bool sect_empty(const Elf_Shdr *sect)
107305 {
107306 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
107307@@ -1582,7 +1636,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
107308 {
107309 unsigned int notes, loaded, i;
107310 struct module_notes_attrs *notes_attrs;
107311- struct bin_attribute *nattr;
107312+ bin_attribute_no_const *nattr;
107313
107314 /* failed to create section attributes, so can't create notes */
107315 if (!mod->sect_attrs)
107316@@ -1694,7 +1748,7 @@ static void del_usage_links(struct module *mod)
107317 static int module_add_modinfo_attrs(struct module *mod)
107318 {
107319 struct module_attribute *attr;
107320- struct module_attribute *temp_attr;
107321+ module_attribute_no_const *temp_attr;
107322 int error = 0;
107323 int i;
107324
107325@@ -1911,21 +1965,21 @@ static void set_section_ro_nx(void *base,
107326
107327 static void unset_module_core_ro_nx(struct module *mod)
107328 {
107329- set_page_attributes(mod->module_core + mod->core_text_size,
107330- mod->module_core + mod->core_size,
107331+ set_page_attributes(mod->module_core_rw,
107332+ mod->module_core_rw + mod->core_size_rw,
107333 set_memory_x);
107334- set_page_attributes(mod->module_core,
107335- mod->module_core + mod->core_ro_size,
107336+ set_page_attributes(mod->module_core_rx,
107337+ mod->module_core_rx + mod->core_size_rx,
107338 set_memory_rw);
107339 }
107340
107341 static void unset_module_init_ro_nx(struct module *mod)
107342 {
107343- set_page_attributes(mod->module_init + mod->init_text_size,
107344- mod->module_init + mod->init_size,
107345+ set_page_attributes(mod->module_init_rw,
107346+ mod->module_init_rw + mod->init_size_rw,
107347 set_memory_x);
107348- set_page_attributes(mod->module_init,
107349- mod->module_init + mod->init_ro_size,
107350+ set_page_attributes(mod->module_init_rx,
107351+ mod->module_init_rx + mod->init_size_rx,
107352 set_memory_rw);
107353 }
107354
107355@@ -1938,14 +1992,14 @@ void set_all_modules_text_rw(void)
107356 list_for_each_entry_rcu(mod, &modules, list) {
107357 if (mod->state == MODULE_STATE_UNFORMED)
107358 continue;
107359- if ((mod->module_core) && (mod->core_text_size)) {
107360- set_page_attributes(mod->module_core,
107361- mod->module_core + mod->core_text_size,
107362+ if ((mod->module_core_rx) && (mod->core_size_rx)) {
107363+ set_page_attributes(mod->module_core_rx,
107364+ mod->module_core_rx + mod->core_size_rx,
107365 set_memory_rw);
107366 }
107367- if ((mod->module_init) && (mod->init_text_size)) {
107368- set_page_attributes(mod->module_init,
107369- mod->module_init + mod->init_text_size,
107370+ if ((mod->module_init_rx) && (mod->init_size_rx)) {
107371+ set_page_attributes(mod->module_init_rx,
107372+ mod->module_init_rx + mod->init_size_rx,
107373 set_memory_rw);
107374 }
107375 }
107376@@ -1961,14 +2015,14 @@ void set_all_modules_text_ro(void)
107377 list_for_each_entry_rcu(mod, &modules, list) {
107378 if (mod->state == MODULE_STATE_UNFORMED)
107379 continue;
107380- if ((mod->module_core) && (mod->core_text_size)) {
107381- set_page_attributes(mod->module_core,
107382- mod->module_core + mod->core_text_size,
107383+ if ((mod->module_core_rx) && (mod->core_size_rx)) {
107384+ set_page_attributes(mod->module_core_rx,
107385+ mod->module_core_rx + mod->core_size_rx,
107386 set_memory_ro);
107387 }
107388- if ((mod->module_init) && (mod->init_text_size)) {
107389- set_page_attributes(mod->module_init,
107390- mod->module_init + mod->init_text_size,
107391+ if ((mod->module_init_rx) && (mod->init_size_rx)) {
107392+ set_page_attributes(mod->module_init_rx,
107393+ mod->module_init_rx + mod->init_size_rx,
107394 set_memory_ro);
107395 }
107396 }
107397@@ -1977,7 +2031,15 @@ void set_all_modules_text_ro(void)
107398 #else
107399 static inline void set_section_ro_nx(void *base, unsigned long text_size, unsigned long ro_size, unsigned long total_size) { }
107400 static void unset_module_core_ro_nx(struct module *mod) { }
107401-static void unset_module_init_ro_nx(struct module *mod) { }
107402+static void unset_module_init_ro_nx(struct module *mod)
107403+{
107404+
107405+#ifdef CONFIG_PAX_KERNEXEC
107406+ set_memory_nx((unsigned long)mod->module_init_rx, PFN_UP(mod->init_size_rx));
107407+ set_memory_rw((unsigned long)mod->module_init_rx, PFN_UP(mod->init_size_rx));
107408+#endif
107409+
107410+}
107411 #endif
107412
107413 void __weak module_memfree(void *module_region)
107414@@ -2032,16 +2094,19 @@ static void free_module(struct module *mod)
107415 /* This may be NULL, but that's OK */
107416 unset_module_init_ro_nx(mod);
107417 module_arch_freeing_init(mod);
107418- module_memfree(mod->module_init);
107419+ module_memfree(mod->module_init_rw);
107420+ module_memfree_exec(mod->module_init_rx);
107421 kfree(mod->args);
107422 percpu_modfree(mod);
107423
107424 /* Free lock-classes; relies on the preceding sync_rcu(). */
107425- lockdep_free_key_range(mod->module_core, mod->core_size);
107426+ lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
107427+ lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
107428
107429 /* Finally, free the core (containing the module structure) */
107430 unset_module_core_ro_nx(mod);
107431- module_memfree(mod->module_core);
107432+ module_memfree_exec(mod->module_core_rx);
107433+ module_memfree(mod->module_core_rw);
107434
107435 #ifdef CONFIG_MPU
107436 update_protections(current->mm);
107437@@ -2110,9 +2175,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
107438 int ret = 0;
107439 const struct kernel_symbol *ksym;
107440
107441+#ifdef CONFIG_GRKERNSEC_MODHARDEN
107442+ int is_fs_load = 0;
107443+ int register_filesystem_found = 0;
107444+ char *p;
107445+
107446+ p = strstr(mod->args, "grsec_modharden_fs");
107447+ if (p) {
107448+ char *endptr = p + sizeof("grsec_modharden_fs") - 1;
107449+ /* copy \0 as well */
107450+ memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
107451+ is_fs_load = 1;
107452+ }
107453+#endif
107454+
107455 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
107456 const char *name = info->strtab + sym[i].st_name;
107457
107458+#ifdef CONFIG_GRKERNSEC_MODHARDEN
107459+ /* it's a real shame this will never get ripped and copied
107460+ upstream! ;(
107461+ */
107462+ if (is_fs_load && !strcmp(name, "register_filesystem"))
107463+ register_filesystem_found = 1;
107464+#endif
107465+
107466 switch (sym[i].st_shndx) {
107467 case SHN_COMMON:
107468 /* Ignore common symbols */
107469@@ -2137,7 +2224,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
107470 ksym = resolve_symbol_wait(mod, info, name);
107471 /* Ok if resolved. */
107472 if (ksym && !IS_ERR(ksym)) {
107473+ pax_open_kernel();
107474 sym[i].st_value = ksym->value;
107475+ pax_close_kernel();
107476 break;
107477 }
107478
107479@@ -2156,11 +2245,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
107480 secbase = (unsigned long)mod_percpu(mod);
107481 else
107482 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
107483+ pax_open_kernel();
107484 sym[i].st_value += secbase;
107485+ pax_close_kernel();
107486 break;
107487 }
107488 }
107489
107490+#ifdef CONFIG_GRKERNSEC_MODHARDEN
107491+ if (is_fs_load && !register_filesystem_found) {
107492+ printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
107493+ ret = -EPERM;
107494+ }
107495+#endif
107496+
107497 return ret;
107498 }
107499
107500@@ -2244,22 +2342,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
107501 || s->sh_entsize != ~0UL
107502 || strstarts(sname, ".init"))
107503 continue;
107504- s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
107505+ if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
107506+ s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
107507+ else
107508+ s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
107509 pr_debug("\t%s\n", sname);
107510 }
107511- switch (m) {
107512- case 0: /* executable */
107513- mod->core_size = debug_align(mod->core_size);
107514- mod->core_text_size = mod->core_size;
107515- break;
107516- case 1: /* RO: text and ro-data */
107517- mod->core_size = debug_align(mod->core_size);
107518- mod->core_ro_size = mod->core_size;
107519- break;
107520- case 3: /* whole core */
107521- mod->core_size = debug_align(mod->core_size);
107522- break;
107523- }
107524 }
107525
107526 pr_debug("Init section allocation order:\n");
107527@@ -2273,23 +2361,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
107528 || s->sh_entsize != ~0UL
107529 || !strstarts(sname, ".init"))
107530 continue;
107531- s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
107532- | INIT_OFFSET_MASK);
107533+ if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
107534+ s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
107535+ else
107536+ s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
107537+ s->sh_entsize |= INIT_OFFSET_MASK;
107538 pr_debug("\t%s\n", sname);
107539 }
107540- switch (m) {
107541- case 0: /* executable */
107542- mod->init_size = debug_align(mod->init_size);
107543- mod->init_text_size = mod->init_size;
107544- break;
107545- case 1: /* RO: text and ro-data */
107546- mod->init_size = debug_align(mod->init_size);
107547- mod->init_ro_size = mod->init_size;
107548- break;
107549- case 3: /* whole init */
107550- mod->init_size = debug_align(mod->init_size);
107551- break;
107552- }
107553 }
107554 }
107555
107556@@ -2462,7 +2540,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
107557
107558 /* Put symbol section at end of init part of module. */
107559 symsect->sh_flags |= SHF_ALLOC;
107560- symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
107561+ symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
107562 info->index.sym) | INIT_OFFSET_MASK;
107563 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
107564
107565@@ -2479,16 +2557,16 @@ static void layout_symtab(struct module *mod, struct load_info *info)
107566 }
107567
107568 /* Append room for core symbols at end of core part. */
107569- info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
107570- info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
107571- mod->core_size += strtab_size;
107572- mod->core_size = debug_align(mod->core_size);
107573+ info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
107574+ info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
107575+ mod->core_size_rx += strtab_size;
107576+ mod->core_size_rx = debug_align(mod->core_size_rx);
107577
107578 /* Put string table section at end of init part of module. */
107579 strsect->sh_flags |= SHF_ALLOC;
107580- strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
107581+ strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
107582 info->index.str) | INIT_OFFSET_MASK;
107583- mod->init_size = debug_align(mod->init_size);
107584+ mod->init_size_rx = debug_align(mod->init_size_rx);
107585 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
107586 }
107587
107588@@ -2505,12 +2583,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
107589 /* Make sure we get permanent strtab: don't use info->strtab. */
107590 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
107591
107592+ pax_open_kernel();
107593+
107594 /* Set types up while we still have access to sections. */
107595 for (i = 0; i < mod->num_symtab; i++)
107596 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
107597
107598- mod->core_symtab = dst = mod->module_core + info->symoffs;
107599- mod->core_strtab = s = mod->module_core + info->stroffs;
107600+ mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
107601+ mod->core_strtab = s = mod->module_core_rx + info->stroffs;
107602 src = mod->symtab;
107603 for (ndst = i = 0; i < mod->num_symtab; i++) {
107604 if (i == 0 ||
107605@@ -2522,6 +2602,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
107606 }
107607 }
107608 mod->core_num_syms = ndst;
107609+
107610+ pax_close_kernel();
107611 }
107612 #else
107613 static inline void layout_symtab(struct module *mod, struct load_info *info)
107614@@ -2821,7 +2903,15 @@ static struct module *setup_load_info(struct load_info *info, int flags)
107615 mod = (void *)info->sechdrs[info->index.mod].sh_addr;
107616
107617 if (info->index.sym == 0) {
107618+#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
107619+ /*
107620+ * avoid potentially printing jibberish on attempted load
107621+ * of a module randomized with a different seed
107622+ */
107623+ pr_warn("module has no symbols (stripped?)\n");
107624+#else
107625 pr_warn("%s: module has no symbols (stripped?)\n", mod->name);
107626+#endif
107627 return ERR_PTR(-ENOEXEC);
107628 }
107629
107630@@ -2837,8 +2927,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
107631 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
107632 {
107633 const char *modmagic = get_modinfo(info, "vermagic");
107634+ const char *license = get_modinfo(info, "license");
107635 int err;
107636
107637+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
107638+ if (!license || !license_is_gpl_compatible(license))
107639+ return -ENOEXEC;
107640+#endif
107641+
107642 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
107643 modmagic = NULL;
107644
107645@@ -2863,7 +2959,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
107646 }
107647
107648 /* Set up license info based on the info section */
107649- set_license(mod, get_modinfo(info, "license"));
107650+ set_license(mod, license);
107651
107652 return 0;
107653 }
107654@@ -2960,7 +3056,7 @@ static int move_module(struct module *mod, struct load_info *info)
107655 void *ptr;
107656
107657 /* Do the allocs. */
107658- ptr = module_alloc(mod->core_size);
107659+ ptr = module_alloc(mod->core_size_rw);
107660 /*
107661 * The pointer to this block is stored in the module structure
107662 * which is inside the block. Just mark it as not being a
107663@@ -2970,11 +3066,11 @@ static int move_module(struct module *mod, struct load_info *info)
107664 if (!ptr)
107665 return -ENOMEM;
107666
107667- memset(ptr, 0, mod->core_size);
107668- mod->module_core = ptr;
107669+ memset(ptr, 0, mod->core_size_rw);
107670+ mod->module_core_rw = ptr;
107671
107672- if (mod->init_size) {
107673- ptr = module_alloc(mod->init_size);
107674+ if (mod->init_size_rw) {
107675+ ptr = module_alloc(mod->init_size_rw);
107676 /*
107677 * The pointer to this block is stored in the module structure
107678 * which is inside the block. This block doesn't need to be
107679@@ -2983,13 +3079,45 @@ static int move_module(struct module *mod, struct load_info *info)
107680 */
107681 kmemleak_ignore(ptr);
107682 if (!ptr) {
107683- module_memfree(mod->module_core);
107684+ module_memfree(mod->module_core_rw);
107685 return -ENOMEM;
107686 }
107687- memset(ptr, 0, mod->init_size);
107688- mod->module_init = ptr;
107689+ memset(ptr, 0, mod->init_size_rw);
107690+ mod->module_init_rw = ptr;
107691 } else
107692- mod->module_init = NULL;
107693+ mod->module_init_rw = NULL;
107694+
107695+ ptr = module_alloc_exec(mod->core_size_rx);
107696+ kmemleak_not_leak(ptr);
107697+ if (!ptr) {
107698+ if (mod->module_init_rw)
107699+ module_memfree(mod->module_init_rw);
107700+ module_memfree(mod->module_core_rw);
107701+ return -ENOMEM;
107702+ }
107703+
107704+ pax_open_kernel();
107705+ memset(ptr, 0, mod->core_size_rx);
107706+ pax_close_kernel();
107707+ mod->module_core_rx = ptr;
107708+
107709+ if (mod->init_size_rx) {
107710+ ptr = module_alloc_exec(mod->init_size_rx);
107711+ kmemleak_ignore(ptr);
107712+ if (!ptr && mod->init_size_rx) {
107713+ module_memfree_exec(mod->module_core_rx);
107714+ if (mod->module_init_rw)
107715+ module_memfree(mod->module_init_rw);
107716+ module_memfree(mod->module_core_rw);
107717+ return -ENOMEM;
107718+ }
107719+
107720+ pax_open_kernel();
107721+ memset(ptr, 0, mod->init_size_rx);
107722+ pax_close_kernel();
107723+ mod->module_init_rx = ptr;
107724+ } else
107725+ mod->module_init_rx = NULL;
107726
107727 /* Transfer each section which specifies SHF_ALLOC */
107728 pr_debug("final section addresses:\n");
107729@@ -3000,16 +3128,45 @@ static int move_module(struct module *mod, struct load_info *info)
107730 if (!(shdr->sh_flags & SHF_ALLOC))
107731 continue;
107732
107733- if (shdr->sh_entsize & INIT_OFFSET_MASK)
107734- dest = mod->module_init
107735- + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
107736- else
107737- dest = mod->module_core + shdr->sh_entsize;
107738+ if (shdr->sh_entsize & INIT_OFFSET_MASK) {
107739+ if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
107740+ dest = mod->module_init_rw
107741+ + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
107742+ else
107743+ dest = mod->module_init_rx
107744+ + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
107745+ } else {
107746+ if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
107747+ dest = mod->module_core_rw + shdr->sh_entsize;
107748+ else
107749+ dest = mod->module_core_rx + shdr->sh_entsize;
107750+ }
107751+
107752+ if (shdr->sh_type != SHT_NOBITS) {
107753+
107754+#ifdef CONFIG_PAX_KERNEXEC
107755+#ifdef CONFIG_X86_64
107756+ if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
107757+ set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
107758+#endif
107759+ if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
107760+ pax_open_kernel();
107761+ memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
107762+ pax_close_kernel();
107763+ } else
107764+#endif
107765
107766- if (shdr->sh_type != SHT_NOBITS)
107767 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
107768+ }
107769 /* Update sh_addr to point to copy in image. */
107770- shdr->sh_addr = (unsigned long)dest;
107771+
107772+#ifdef CONFIG_PAX_KERNEXEC
107773+ if (shdr->sh_flags & SHF_EXECINSTR)
107774+ shdr->sh_addr = ktva_ktla((unsigned long)dest);
107775+ else
107776+#endif
107777+
107778+ shdr->sh_addr = (unsigned long)dest;
107779 pr_debug("\t0x%lx %s\n",
107780 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
107781 }
107782@@ -3066,12 +3223,12 @@ static void flush_module_icache(const struct module *mod)
107783 * Do it before processing of module parameters, so the module
107784 * can provide parameter accessor functions of its own.
107785 */
107786- if (mod->module_init)
107787- flush_icache_range((unsigned long)mod->module_init,
107788- (unsigned long)mod->module_init
107789- + mod->init_size);
107790- flush_icache_range((unsigned long)mod->module_core,
107791- (unsigned long)mod->module_core + mod->core_size);
107792+ if (mod->module_init_rx)
107793+ flush_icache_range((unsigned long)mod->module_init_rx,
107794+ (unsigned long)mod->module_init_rx
107795+ + mod->init_size_rx);
107796+ flush_icache_range((unsigned long)mod->module_core_rx,
107797+ (unsigned long)mod->module_core_rx + mod->core_size_rx);
107798
107799 set_fs(old_fs);
107800 }
107801@@ -3129,8 +3286,10 @@ static void module_deallocate(struct module *mod, struct load_info *info)
107802 {
107803 percpu_modfree(mod);
107804 module_arch_freeing_init(mod);
107805- module_memfree(mod->module_init);
107806- module_memfree(mod->module_core);
107807+ module_memfree_exec(mod->module_init_rx);
107808+ module_memfree_exec(mod->module_core_rx);
107809+ module_memfree(mod->module_init_rw);
107810+ module_memfree(mod->module_core_rw);
107811 }
107812
107813 int __weak module_finalize(const Elf_Ehdr *hdr,
107814@@ -3143,7 +3302,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
107815 static int post_relocation(struct module *mod, const struct load_info *info)
107816 {
107817 /* Sort exception table now relocations are done. */
107818+ pax_open_kernel();
107819 sort_extable(mod->extable, mod->extable + mod->num_exentries);
107820+ pax_close_kernel();
107821
107822 /* Copy relocated percpu area over. */
107823 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
107824@@ -3191,13 +3352,15 @@ static void do_mod_ctors(struct module *mod)
107825 /* For freeing module_init on success, in case kallsyms traversing */
107826 struct mod_initfree {
107827 struct rcu_head rcu;
107828- void *module_init;
107829+ void *module_init_rw;
107830+ void *module_init_rx;
107831 };
107832
107833 static void do_free_init(struct rcu_head *head)
107834 {
107835 struct mod_initfree *m = container_of(head, struct mod_initfree, rcu);
107836- module_memfree(m->module_init);
107837+ module_memfree(m->module_init_rw);
107838+ module_memfree_exec(m->module_init_rx);
107839 kfree(m);
107840 }
107841
107842@@ -3217,7 +3380,8 @@ static noinline int do_init_module(struct module *mod)
107843 ret = -ENOMEM;
107844 goto fail;
107845 }
107846- freeinit->module_init = mod->module_init;
107847+ freeinit->module_init_rw = mod->module_init_rw;
107848+ freeinit->module_init_rx = mod->module_init_rx;
107849
107850 /*
107851 * We want to find out whether @mod uses async during init. Clear
107852@@ -3277,10 +3441,10 @@ static noinline int do_init_module(struct module *mod)
107853 mod_tree_remove_init(mod);
107854 unset_module_init_ro_nx(mod);
107855 module_arch_freeing_init(mod);
107856- mod->module_init = NULL;
107857- mod->init_size = 0;
107858- mod->init_ro_size = 0;
107859- mod->init_text_size = 0;
107860+ mod->module_init_rw = NULL;
107861+ mod->module_init_rx = NULL;
107862+ mod->init_size_rw = 0;
107863+ mod->init_size_rx = 0;
107864 /*
107865 * We want to free module_init, but be aware that kallsyms may be
107866 * walking this with preempt disabled. In all the failure paths, we
107867@@ -3370,16 +3534,16 @@ static int complete_formation(struct module *mod, struct load_info *info)
107868 module_bug_finalize(info->hdr, info->sechdrs, mod);
107869
107870 /* Set RO and NX regions for core */
107871- set_section_ro_nx(mod->module_core,
107872- mod->core_text_size,
107873- mod->core_ro_size,
107874- mod->core_size);
107875+ set_section_ro_nx(mod->module_core_rx,
107876+ mod->core_size_rx,
107877+ mod->core_size_rx,
107878+ mod->core_size_rx);
107879
107880 /* Set RO and NX regions for init */
107881- set_section_ro_nx(mod->module_init,
107882- mod->init_text_size,
107883- mod->init_ro_size,
107884- mod->init_size);
107885+ set_section_ro_nx(mod->module_init_rx,
107886+ mod->init_size_rx,
107887+ mod->init_size_rx,
107888+ mod->init_size_rx);
107889
107890 /* Mark state as coming so strong_try_module_get() ignores us,
107891 * but kallsyms etc. can see us. */
107892@@ -3474,9 +3638,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
107893 if (err)
107894 goto free_unload;
107895
107896+ /* Now copy in args */
107897+ mod->args = strndup_user(uargs, ~0UL >> 1);
107898+ if (IS_ERR(mod->args)) {
107899+ err = PTR_ERR(mod->args);
107900+ goto free_unload;
107901+ }
107902+
107903 /* Set up MODINFO_ATTR fields */
107904 setup_modinfo(mod, info);
107905
107906+#ifdef CONFIG_GRKERNSEC_MODHARDEN
107907+ {
107908+ char *p, *p2;
107909+
107910+ if (strstr(mod->args, "grsec_modharden_netdev")) {
107911+ 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);
107912+ err = -EPERM;
107913+ goto free_modinfo;
107914+ } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
107915+ p += sizeof("grsec_modharden_normal") - 1;
107916+ p2 = strstr(p, "_");
107917+ if (p2) {
107918+ *p2 = '\0';
107919+ printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
107920+ *p2 = '_';
107921+ }
107922+ err = -EPERM;
107923+ goto free_modinfo;
107924+ }
107925+ }
107926+#endif
107927+
107928 /* Fix up syms, so that st_value is a pointer to location. */
107929 err = simplify_symbols(mod, info);
107930 if (err < 0)
107931@@ -3492,13 +3685,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
107932
107933 flush_module_icache(mod);
107934
107935- /* Now copy in args */
107936- mod->args = strndup_user(uargs, ~0UL >> 1);
107937- if (IS_ERR(mod->args)) {
107938- err = PTR_ERR(mod->args);
107939- goto free_arch_cleanup;
107940- }
107941-
107942 dynamic_debug_setup(info->debug, info->num_debug);
107943
107944 /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */
107945@@ -3550,11 +3736,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
107946 ddebug_cleanup:
107947 dynamic_debug_remove(info->debug);
107948 synchronize_sched();
107949- kfree(mod->args);
107950- free_arch_cleanup:
107951 module_arch_cleanup(mod);
107952 free_modinfo:
107953 free_modinfo(mod);
107954+ kfree(mod->args);
107955 free_unload:
107956 module_unload_free(mod);
107957 unlink_mod:
107958@@ -3568,7 +3753,8 @@ static int load_module(struct load_info *info, const char __user *uargs,
107959 mutex_unlock(&module_mutex);
107960 free_module:
107961 /* Free lock-classes; relies on the preceding sync_rcu() */
107962- lockdep_free_key_range(mod->module_core, mod->core_size);
107963+ lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
107964+ lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
107965
107966 module_deallocate(mod, info);
107967 free_copy:
107968@@ -3645,10 +3831,16 @@ static const char *get_ksymbol(struct module *mod,
107969 unsigned long nextval;
107970
107971 /* At worse, next value is at end of module */
107972- if (within_module_init(addr, mod))
107973- nextval = (unsigned long)mod->module_init+mod->init_text_size;
107974+ if (within_module_init_rx(addr, mod))
107975+ nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
107976+ else if (within_module_init_rw(addr, mod))
107977+ nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
107978+ else if (within_module_core_rx(addr, mod))
107979+ nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
107980+ else if (within_module_core_rw(addr, mod))
107981+ nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
107982 else
107983- nextval = (unsigned long)mod->module_core+mod->core_text_size;
107984+ return NULL;
107985
107986 /* Scan for closest preceding symbol, and next symbol. (ELF
107987 starts real symbols at 1). */
107988@@ -3895,7 +4087,7 @@ static int m_show(struct seq_file *m, void *p)
107989 return 0;
107990
107991 seq_printf(m, "%s %u",
107992- mod->name, mod->init_size + mod->core_size);
107993+ mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
107994 print_unload_info(m, mod);
107995
107996 /* Informative for users. */
107997@@ -3904,7 +4096,7 @@ static int m_show(struct seq_file *m, void *p)
107998 mod->state == MODULE_STATE_COMING ? "Loading" :
107999 "Live");
108000 /* Used by oprofile and other similar tools. */
108001- seq_printf(m, " 0x%pK", mod->module_core);
108002+ seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
108003
108004 /* Taints info */
108005 if (mod->taints)
108006@@ -3940,7 +4132,17 @@ static const struct file_operations proc_modules_operations = {
108007
108008 static int __init proc_modules_init(void)
108009 {
108010+#ifndef CONFIG_GRKERNSEC_HIDESYM
108011+#ifdef CONFIG_GRKERNSEC_PROC_USER
108012+ proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
108013+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
108014+ proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
108015+#else
108016 proc_create("modules", 0, NULL, &proc_modules_operations);
108017+#endif
108018+#else
108019+ proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
108020+#endif
108021 return 0;
108022 }
108023 module_init(proc_modules_init);
108024@@ -4001,7 +4203,8 @@ struct module *__module_address(unsigned long addr)
108025 {
108026 struct module *mod;
108027
108028- if (addr < module_addr_min || addr > module_addr_max)
108029+ if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
108030+ (addr < module_addr_min_rw || addr > module_addr_max_rw))
108031 return NULL;
108032
108033 module_assert_mutex_or_preempt();
108034@@ -4044,11 +4247,20 @@ bool is_module_text_address(unsigned long addr)
108035 */
108036 struct module *__module_text_address(unsigned long addr)
108037 {
108038- struct module *mod = __module_address(addr);
108039+ struct module *mod;
108040+
108041+#ifdef CONFIG_X86_32
108042+ addr = ktla_ktva(addr);
108043+#endif
108044+
108045+ if (addr < module_addr_min_rx || addr > module_addr_max_rx)
108046+ return NULL;
108047+
108048+ mod = __module_address(addr);
108049+
108050 if (mod) {
108051 /* Make sure it's within the text section. */
108052- if (!within(addr, mod->module_init, mod->init_text_size)
108053- && !within(addr, mod->module_core, mod->core_text_size))
108054+ if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
108055 mod = NULL;
108056 }
108057 return mod;
108058diff --git a/kernel/notifier.c b/kernel/notifier.c
108059index ae9fc7c..5085fbf 100644
108060--- a/kernel/notifier.c
108061+++ b/kernel/notifier.c
108062@@ -5,6 +5,7 @@
108063 #include <linux/rcupdate.h>
108064 #include <linux/vmalloc.h>
108065 #include <linux/reboot.h>
108066+#include <linux/mm.h>
108067
108068 /*
108069 * Notifier list for kernel code which wants to be called
108070@@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
108071 while ((*nl) != NULL) {
108072 if (n->priority > (*nl)->priority)
108073 break;
108074- nl = &((*nl)->next);
108075+ nl = (struct notifier_block **)&((*nl)->next);
108076 }
108077- n->next = *nl;
108078+ pax_open_kernel();
108079+ *(const void **)&n->next = *nl;
108080 rcu_assign_pointer(*nl, n);
108081+ pax_close_kernel();
108082 return 0;
108083 }
108084
108085@@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
108086 return 0;
108087 if (n->priority > (*nl)->priority)
108088 break;
108089- nl = &((*nl)->next);
108090+ nl = (struct notifier_block **)&((*nl)->next);
108091 }
108092- n->next = *nl;
108093+ pax_open_kernel();
108094+ *(const void **)&n->next = *nl;
108095 rcu_assign_pointer(*nl, n);
108096+ pax_close_kernel();
108097 return 0;
108098 }
108099
108100@@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
108101 {
108102 while ((*nl) != NULL) {
108103 if ((*nl) == n) {
108104+ pax_open_kernel();
108105 rcu_assign_pointer(*nl, n->next);
108106+ pax_close_kernel();
108107 return 0;
108108 }
108109- nl = &((*nl)->next);
108110+ nl = (struct notifier_block **)&((*nl)->next);
108111 }
108112 return -ENOENT;
108113 }
108114diff --git a/kernel/padata.c b/kernel/padata.c
108115index b38bea9..91acfbe 100644
108116--- a/kernel/padata.c
108117+++ b/kernel/padata.c
108118@@ -54,7 +54,7 @@ static int padata_cpu_hash(struct parallel_data *pd)
108119 * seq_nr mod. number of cpus in use.
108120 */
108121
108122- seq_nr = atomic_inc_return(&pd->seq_nr);
108123+ seq_nr = atomic_inc_return_unchecked(&pd->seq_nr);
108124 cpu_index = seq_nr % cpumask_weight(pd->cpumask.pcpu);
108125
108126 return padata_index_to_cpu(pd, cpu_index);
108127@@ -428,7 +428,7 @@ static struct parallel_data *padata_alloc_pd(struct padata_instance *pinst,
108128 padata_init_pqueues(pd);
108129 padata_init_squeues(pd);
108130 setup_timer(&pd->timer, padata_reorder_timer, (unsigned long)pd);
108131- atomic_set(&pd->seq_nr, -1);
108132+ atomic_set_unchecked(&pd->seq_nr, -1);
108133 atomic_set(&pd->reorder_objects, 0);
108134 atomic_set(&pd->refcnt, 0);
108135 pd->pinst = pinst;
108136diff --git a/kernel/panic.c b/kernel/panic.c
108137index 04e91ff..2419384 100644
108138--- a/kernel/panic.c
108139+++ b/kernel/panic.c
108140@@ -54,7 +54,7 @@ EXPORT_SYMBOL(panic_blink);
108141 /*
108142 * Stop ourself in panic -- architecture code may override this
108143 */
108144-void __weak panic_smp_self_stop(void)
108145+void __weak __noreturn panic_smp_self_stop(void)
108146 {
108147 while (1)
108148 cpu_relax();
108149@@ -426,7 +426,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
108150 disable_trace_on_warning();
108151
108152 pr_warn("------------[ cut here ]------------\n");
108153- pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
108154+ pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
108155 raw_smp_processor_id(), current->pid, file, line, caller);
108156
108157 if (args)
108158@@ -491,7 +491,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
108159 */
108160 __visible void __stack_chk_fail(void)
108161 {
108162- panic("stack-protector: Kernel stack is corrupted in: %p\n",
108163+ dump_stack();
108164+ panic("stack-protector: Kernel stack is corrupted in: %pA\n",
108165 __builtin_return_address(0));
108166 }
108167 EXPORT_SYMBOL(__stack_chk_fail);
108168diff --git a/kernel/pid.c b/kernel/pid.c
108169index 4fd07d5..02bce4f 100644
108170--- a/kernel/pid.c
108171+++ b/kernel/pid.c
108172@@ -33,6 +33,7 @@
108173 #include <linux/rculist.h>
108174 #include <linux/bootmem.h>
108175 #include <linux/hash.h>
108176+#include <linux/security.h>
108177 #include <linux/pid_namespace.h>
108178 #include <linux/init_task.h>
108179 #include <linux/syscalls.h>
108180@@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
108181
108182 int pid_max = PID_MAX_DEFAULT;
108183
108184-#define RESERVED_PIDS 300
108185+#define RESERVED_PIDS 500
108186
108187 int pid_max_min = RESERVED_PIDS + 1;
108188 int pid_max_max = PID_MAX_LIMIT;
108189@@ -451,10 +452,18 @@ EXPORT_SYMBOL(pid_task);
108190 */
108191 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
108192 {
108193+ struct task_struct *task;
108194+
108195 rcu_lockdep_assert(rcu_read_lock_held(),
108196 "find_task_by_pid_ns() needs rcu_read_lock()"
108197 " protection");
108198- return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
108199+
108200+ task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
108201+
108202+ if (gr_pid_is_chrooted(task))
108203+ return NULL;
108204+
108205+ return task;
108206 }
108207
108208 struct task_struct *find_task_by_vpid(pid_t vnr)
108209@@ -462,6 +471,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
108210 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
108211 }
108212
108213+struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
108214+{
108215+ rcu_lockdep_assert(rcu_read_lock_held(),
108216+ "find_task_by_pid_ns() needs rcu_read_lock()"
108217+ " protection");
108218+ return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
108219+}
108220+
108221 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
108222 {
108223 struct pid *pid;
108224diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
108225index a65ba13..f600dbb 100644
108226--- a/kernel/pid_namespace.c
108227+++ b/kernel/pid_namespace.c
108228@@ -274,7 +274,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
108229 void __user *buffer, size_t *lenp, loff_t *ppos)
108230 {
108231 struct pid_namespace *pid_ns = task_active_pid_ns(current);
108232- struct ctl_table tmp = *table;
108233+ ctl_table_no_const tmp = *table;
108234
108235 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
108236 return -EPERM;
108237diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
108238index 9e30231..75a6d97 100644
108239--- a/kernel/power/Kconfig
108240+++ b/kernel/power/Kconfig
108241@@ -24,6 +24,8 @@ config HIBERNATE_CALLBACKS
108242 config HIBERNATION
108243 bool "Hibernation (aka 'suspend to disk')"
108244 depends on SWAP && ARCH_HIBERNATION_POSSIBLE
108245+ depends on !GRKERNSEC_KMEM
108246+ depends on !PAX_MEMORY_SANITIZE
108247 select HIBERNATE_CALLBACKS
108248 select LZO_COMPRESS
108249 select LZO_DECOMPRESS
108250diff --git a/kernel/power/process.c b/kernel/power/process.c
108251index 564f786..361a18e 100644
108252--- a/kernel/power/process.c
108253+++ b/kernel/power/process.c
108254@@ -35,6 +35,7 @@ static int try_to_freeze_tasks(bool user_only)
108255 unsigned int elapsed_msecs;
108256 bool wakeup = false;
108257 int sleep_usecs = USEC_PER_MSEC;
108258+ bool timedout = false;
108259
108260 do_gettimeofday(&start);
108261
108262@@ -45,13 +46,20 @@ static int try_to_freeze_tasks(bool user_only)
108263
108264 while (true) {
108265 todo = 0;
108266+ if (time_after(jiffies, end_time))
108267+ timedout = true;
108268 read_lock(&tasklist_lock);
108269 for_each_process_thread(g, p) {
108270 if (p == current || !freeze_task(p))
108271 continue;
108272
108273- if (!freezer_should_skip(p))
108274+ if (!freezer_should_skip(p)) {
108275 todo++;
108276+ if (timedout) {
108277+ printk(KERN_ERR "Task refusing to freeze:\n");
108278+ sched_show_task(p);
108279+ }
108280+ }
108281 }
108282 read_unlock(&tasklist_lock);
108283
108284@@ -60,7 +68,7 @@ static int try_to_freeze_tasks(bool user_only)
108285 todo += wq_busy;
108286 }
108287
108288- if (!todo || time_after(jiffies, end_time))
108289+ if (!todo || timedout)
108290 break;
108291
108292 if (pm_wakeup_pending()) {
108293diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
108294index cf8c242..84e7843 100644
108295--- a/kernel/printk/printk.c
108296+++ b/kernel/printk/printk.c
108297@@ -475,7 +475,7 @@ static int log_store(int facility, int level,
108298 return msg->text_len;
108299 }
108300
108301-int dmesg_restrict = IS_ENABLED(CONFIG_SECURITY_DMESG_RESTRICT);
108302+int dmesg_restrict __read_only = IS_ENABLED(CONFIG_SECURITY_DMESG_RESTRICT);
108303
108304 static int syslog_action_restricted(int type)
108305 {
108306@@ -498,6 +498,11 @@ int check_syslog_permissions(int type, int source)
108307 if (source == SYSLOG_FROM_PROC && type != SYSLOG_ACTION_OPEN)
108308 goto ok;
108309
108310+#ifdef CONFIG_GRKERNSEC_DMESG
108311+ if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
108312+ return -EPERM;
108313+#endif
108314+
108315 if (syslog_action_restricted(type)) {
108316 if (capable(CAP_SYSLOG))
108317 goto ok;
108318diff --git a/kernel/profile.c b/kernel/profile.c
108319index a7bcd28..5b368fa 100644
108320--- a/kernel/profile.c
108321+++ b/kernel/profile.c
108322@@ -37,7 +37,7 @@ struct profile_hit {
108323 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
108324 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
108325
108326-static atomic_t *prof_buffer;
108327+static atomic_unchecked_t *prof_buffer;
108328 static unsigned long prof_len, prof_shift;
108329
108330 int prof_on __read_mostly;
108331@@ -256,7 +256,7 @@ static void profile_flip_buffers(void)
108332 hits[i].pc = 0;
108333 continue;
108334 }
108335- atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
108336+ atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
108337 hits[i].hits = hits[i].pc = 0;
108338 }
108339 }
108340@@ -317,9 +317,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
108341 * Add the current hit(s) and flush the write-queue out
108342 * to the global buffer:
108343 */
108344- atomic_add(nr_hits, &prof_buffer[pc]);
108345+ atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
108346 for (i = 0; i < NR_PROFILE_HIT; ++i) {
108347- atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
108348+ atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
108349 hits[i].pc = hits[i].hits = 0;
108350 }
108351 out:
108352@@ -394,7 +394,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
108353 {
108354 unsigned long pc;
108355 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
108356- atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
108357+ atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
108358 }
108359 #endif /* !CONFIG_SMP */
108360
108361@@ -489,7 +489,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
108362 return -EFAULT;
108363 buf++; p++; count--; read++;
108364 }
108365- pnt = (char *)prof_buffer + p - sizeof(atomic_t);
108366+ pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
108367 if (copy_to_user(buf, (void *)pnt, count))
108368 return -EFAULT;
108369 read += count;
108370@@ -520,7 +520,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
108371 }
108372 #endif
108373 profile_discard_flip_buffers();
108374- memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
108375+ memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
108376 return count;
108377 }
108378
108379diff --git a/kernel/ptrace.c b/kernel/ptrace.c
108380index c8e0e05..2be5614 100644
108381--- a/kernel/ptrace.c
108382+++ b/kernel/ptrace.c
108383@@ -321,7 +321,7 @@ static int ptrace_attach(struct task_struct *task, long request,
108384 if (seize)
108385 flags |= PT_SEIZED;
108386 rcu_read_lock();
108387- if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
108388+ if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
108389 flags |= PT_PTRACE_CAP;
108390 rcu_read_unlock();
108391 task->ptrace = flags;
108392@@ -514,7 +514,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
108393 break;
108394 return -EIO;
108395 }
108396- if (copy_to_user(dst, buf, retval))
108397+ if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
108398 return -EFAULT;
108399 copied += retval;
108400 src += retval;
108401@@ -802,7 +802,7 @@ int ptrace_request(struct task_struct *child, long request,
108402 bool seized = child->ptrace & PT_SEIZED;
108403 int ret = -EIO;
108404 siginfo_t siginfo, *si;
108405- void __user *datavp = (void __user *) data;
108406+ void __user *datavp = (__force void __user *) data;
108407 unsigned long __user *datalp = datavp;
108408 unsigned long flags;
108409
108410@@ -1048,14 +1048,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
108411 goto out;
108412 }
108413
108414+ if (gr_handle_ptrace(child, request)) {
108415+ ret = -EPERM;
108416+ goto out_put_task_struct;
108417+ }
108418+
108419 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
108420 ret = ptrace_attach(child, request, addr, data);
108421 /*
108422 * Some architectures need to do book-keeping after
108423 * a ptrace attach.
108424 */
108425- if (!ret)
108426+ if (!ret) {
108427 arch_ptrace_attach(child);
108428+ gr_audit_ptrace(child);
108429+ }
108430 goto out_put_task_struct;
108431 }
108432
108433@@ -1083,7 +1090,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
108434 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
108435 if (copied != sizeof(tmp))
108436 return -EIO;
108437- return put_user(tmp, (unsigned long __user *)data);
108438+ return put_user(tmp, (__force unsigned long __user *)data);
108439 }
108440
108441 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
108442@@ -1176,7 +1183,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
108443 }
108444
108445 COMPAT_SYSCALL_DEFINE4(ptrace, compat_long_t, request, compat_long_t, pid,
108446- compat_long_t, addr, compat_long_t, data)
108447+ compat_ulong_t, addr, compat_ulong_t, data)
108448 {
108449 struct task_struct *child;
108450 long ret;
108451@@ -1192,14 +1199,21 @@ COMPAT_SYSCALL_DEFINE4(ptrace, compat_long_t, request, compat_long_t, pid,
108452 goto out;
108453 }
108454
108455+ if (gr_handle_ptrace(child, request)) {
108456+ ret = -EPERM;
108457+ goto out_put_task_struct;
108458+ }
108459+
108460 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
108461 ret = ptrace_attach(child, request, addr, data);
108462 /*
108463 * Some architectures need to do book-keeping after
108464 * a ptrace attach.
108465 */
108466- if (!ret)
108467+ if (!ret) {
108468 arch_ptrace_attach(child);
108469+ gr_audit_ptrace(child);
108470+ }
108471 goto out_put_task_struct;
108472 }
108473
108474diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
108475index 59e32684..d2eb3d9 100644
108476--- a/kernel/rcu/rcutorture.c
108477+++ b/kernel/rcu/rcutorture.c
108478@@ -134,12 +134,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1],
108479 rcu_torture_count) = { 0 };
108480 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1],
108481 rcu_torture_batch) = { 0 };
108482-static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
108483-static atomic_t n_rcu_torture_alloc;
108484-static atomic_t n_rcu_torture_alloc_fail;
108485-static atomic_t n_rcu_torture_free;
108486-static atomic_t n_rcu_torture_mberror;
108487-static atomic_t n_rcu_torture_error;
108488+static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
108489+static atomic_unchecked_t n_rcu_torture_alloc;
108490+static atomic_unchecked_t n_rcu_torture_alloc_fail;
108491+static atomic_unchecked_t n_rcu_torture_free;
108492+static atomic_unchecked_t n_rcu_torture_mberror;
108493+static atomic_unchecked_t n_rcu_torture_error;
108494 static long n_rcu_torture_barrier_error;
108495 static long n_rcu_torture_boost_ktrerror;
108496 static long n_rcu_torture_boost_rterror;
108497@@ -148,7 +148,7 @@ static long n_rcu_torture_boosts;
108498 static long n_rcu_torture_timers;
108499 static long n_barrier_attempts;
108500 static long n_barrier_successes;
108501-static atomic_long_t n_cbfloods;
108502+static atomic_long_unchecked_t n_cbfloods;
108503 static struct list_head rcu_torture_removed;
108504
108505 static int rcu_torture_writer_state;
108506@@ -211,11 +211,11 @@ rcu_torture_alloc(void)
108507
108508 spin_lock_bh(&rcu_torture_lock);
108509 if (list_empty(&rcu_torture_freelist)) {
108510- atomic_inc(&n_rcu_torture_alloc_fail);
108511+ atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
108512 spin_unlock_bh(&rcu_torture_lock);
108513 return NULL;
108514 }
108515- atomic_inc(&n_rcu_torture_alloc);
108516+ atomic_inc_unchecked(&n_rcu_torture_alloc);
108517 p = rcu_torture_freelist.next;
108518 list_del_init(p);
108519 spin_unlock_bh(&rcu_torture_lock);
108520@@ -228,7 +228,7 @@ rcu_torture_alloc(void)
108521 static void
108522 rcu_torture_free(struct rcu_torture *p)
108523 {
108524- atomic_inc(&n_rcu_torture_free);
108525+ atomic_inc_unchecked(&n_rcu_torture_free);
108526 spin_lock_bh(&rcu_torture_lock);
108527 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
108528 spin_unlock_bh(&rcu_torture_lock);
108529@@ -309,7 +309,7 @@ rcu_torture_pipe_update_one(struct rcu_torture *rp)
108530 i = rp->rtort_pipe_count;
108531 if (i > RCU_TORTURE_PIPE_LEN)
108532 i = RCU_TORTURE_PIPE_LEN;
108533- atomic_inc(&rcu_torture_wcount[i]);
108534+ atomic_inc_unchecked(&rcu_torture_wcount[i]);
108535 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
108536 rp->rtort_mbtest = 0;
108537 return true;
108538@@ -830,7 +830,7 @@ rcu_torture_cbflood(void *arg)
108539 VERBOSE_TOROUT_STRING("rcu_torture_cbflood task started");
108540 do {
108541 schedule_timeout_interruptible(cbflood_inter_holdoff);
108542- atomic_long_inc(&n_cbfloods);
108543+ atomic_long_inc_unchecked(&n_cbfloods);
108544 WARN_ON(signal_pending(current));
108545 for (i = 0; i < cbflood_n_burst; i++) {
108546 for (j = 0; j < cbflood_n_per_burst; j++) {
108547@@ -957,7 +957,7 @@ rcu_torture_writer(void *arg)
108548 i = old_rp->rtort_pipe_count;
108549 if (i > RCU_TORTURE_PIPE_LEN)
108550 i = RCU_TORTURE_PIPE_LEN;
108551- atomic_inc(&rcu_torture_wcount[i]);
108552+ atomic_inc_unchecked(&rcu_torture_wcount[i]);
108553 old_rp->rtort_pipe_count++;
108554 switch (synctype[torture_random(&rand) % nsynctypes]) {
108555 case RTWS_DEF_FREE:
108556@@ -1095,7 +1095,7 @@ static void rcu_torture_timer(unsigned long unused)
108557 return;
108558 }
108559 if (p->rtort_mbtest == 0)
108560- atomic_inc(&n_rcu_torture_mberror);
108561+ atomic_inc_unchecked(&n_rcu_torture_mberror);
108562 spin_lock(&rand_lock);
108563 cur_ops->read_delay(&rand);
108564 n_rcu_torture_timers++;
108565@@ -1170,7 +1170,7 @@ rcu_torture_reader(void *arg)
108566 continue;
108567 }
108568 if (p->rtort_mbtest == 0)
108569- atomic_inc(&n_rcu_torture_mberror);
108570+ atomic_inc_unchecked(&n_rcu_torture_mberror);
108571 cur_ops->read_delay(&rand);
108572 preempt_disable();
108573 pipe_count = p->rtort_pipe_count;
108574@@ -1239,11 +1239,11 @@ rcu_torture_stats_print(void)
108575 rcu_torture_current,
108576 rcu_torture_current_version,
108577 list_empty(&rcu_torture_freelist),
108578- atomic_read(&n_rcu_torture_alloc),
108579- atomic_read(&n_rcu_torture_alloc_fail),
108580- atomic_read(&n_rcu_torture_free));
108581+ atomic_read_unchecked(&n_rcu_torture_alloc),
108582+ atomic_read_unchecked(&n_rcu_torture_alloc_fail),
108583+ atomic_read_unchecked(&n_rcu_torture_free));
108584 pr_cont("rtmbe: %d rtbke: %ld rtbre: %ld ",
108585- atomic_read(&n_rcu_torture_mberror),
108586+ atomic_read_unchecked(&n_rcu_torture_mberror),
108587 n_rcu_torture_boost_ktrerror,
108588 n_rcu_torture_boost_rterror);
108589 pr_cont("rtbf: %ld rtb: %ld nt: %ld ",
108590@@ -1255,17 +1255,17 @@ rcu_torture_stats_print(void)
108591 n_barrier_successes,
108592 n_barrier_attempts,
108593 n_rcu_torture_barrier_error);
108594- pr_cont("cbflood: %ld\n", atomic_long_read(&n_cbfloods));
108595+ pr_cont("cbflood: %ld\n", atomic_long_read_unchecked(&n_cbfloods));
108596
108597 pr_alert("%s%s ", torture_type, TORTURE_FLAG);
108598- if (atomic_read(&n_rcu_torture_mberror) != 0 ||
108599+ if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
108600 n_rcu_torture_barrier_error != 0 ||
108601 n_rcu_torture_boost_ktrerror != 0 ||
108602 n_rcu_torture_boost_rterror != 0 ||
108603 n_rcu_torture_boost_failure != 0 ||
108604 i > 1) {
108605 pr_cont("%s", "!!! ");
108606- atomic_inc(&n_rcu_torture_error);
108607+ atomic_inc_unchecked(&n_rcu_torture_error);
108608 WARN_ON_ONCE(1);
108609 }
108610 pr_cont("Reader Pipe: ");
108611@@ -1282,7 +1282,7 @@ rcu_torture_stats_print(void)
108612 pr_alert("%s%s ", torture_type, TORTURE_FLAG);
108613 pr_cont("Free-Block Circulation: ");
108614 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
108615- pr_cont(" %d", atomic_read(&rcu_torture_wcount[i]));
108616+ pr_cont(" %d", atomic_read_unchecked(&rcu_torture_wcount[i]));
108617 }
108618 pr_cont("\n");
108619
108620@@ -1636,7 +1636,7 @@ rcu_torture_cleanup(void)
108621
108622 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
108623
108624- if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
108625+ if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
108626 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
108627 else if (torture_onoff_failures())
108628 rcu_torture_print_module_parms(cur_ops,
108629@@ -1761,18 +1761,18 @@ rcu_torture_init(void)
108630
108631 rcu_torture_current = NULL;
108632 rcu_torture_current_version = 0;
108633- atomic_set(&n_rcu_torture_alloc, 0);
108634- atomic_set(&n_rcu_torture_alloc_fail, 0);
108635- atomic_set(&n_rcu_torture_free, 0);
108636- atomic_set(&n_rcu_torture_mberror, 0);
108637- atomic_set(&n_rcu_torture_error, 0);
108638+ atomic_set_unchecked(&n_rcu_torture_alloc, 0);
108639+ atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
108640+ atomic_set_unchecked(&n_rcu_torture_free, 0);
108641+ atomic_set_unchecked(&n_rcu_torture_mberror, 0);
108642+ atomic_set_unchecked(&n_rcu_torture_error, 0);
108643 n_rcu_torture_barrier_error = 0;
108644 n_rcu_torture_boost_ktrerror = 0;
108645 n_rcu_torture_boost_rterror = 0;
108646 n_rcu_torture_boost_failure = 0;
108647 n_rcu_torture_boosts = 0;
108648 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
108649- atomic_set(&rcu_torture_wcount[i], 0);
108650+ atomic_set_unchecked(&rcu_torture_wcount[i], 0);
108651 for_each_possible_cpu(cpu) {
108652 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
108653 per_cpu(rcu_torture_count, cpu)[i] = 0;
108654diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
108655index c291bd6..8a01679 100644
108656--- a/kernel/rcu/tiny.c
108657+++ b/kernel/rcu/tiny.c
108658@@ -42,7 +42,7 @@
108659 /* Forward declarations for tiny_plugin.h. */
108660 struct rcu_ctrlblk;
108661 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
108662-static void rcu_process_callbacks(struct softirq_action *unused);
108663+static void rcu_process_callbacks(void);
108664 static void __call_rcu(struct rcu_head *head,
108665 void (*func)(struct rcu_head *rcu),
108666 struct rcu_ctrlblk *rcp);
108667@@ -170,7 +170,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
108668 false));
108669 }
108670
108671-static void rcu_process_callbacks(struct softirq_action *unused)
108672+static __latent_entropy void rcu_process_callbacks(void)
108673 {
108674 __rcu_process_callbacks(&rcu_sched_ctrlblk);
108675 __rcu_process_callbacks(&rcu_bh_ctrlblk);
108676diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
108677index 65137bc..775d7ad 100644
108678--- a/kernel/rcu/tree.c
108679+++ b/kernel/rcu/tree.c
108680@@ -326,7 +326,7 @@ static void rcu_momentary_dyntick_idle(void)
108681 */
108682 rdtp = this_cpu_ptr(&rcu_dynticks);
108683 smp_mb__before_atomic(); /* Earlier stuff before QS. */
108684- atomic_add(2, &rdtp->dynticks); /* QS. */
108685+ atomic_add_unchecked(2, &rdtp->dynticks); /* QS. */
108686 smp_mb__after_atomic(); /* Later stuff after QS. */
108687 break;
108688 }
108689@@ -639,10 +639,10 @@ static void rcu_eqs_enter_common(long long oldval, bool user)
108690 rcu_prepare_for_idle();
108691 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
108692 smp_mb__before_atomic(); /* See above. */
108693- atomic_inc(&rdtp->dynticks);
108694+ atomic_inc_unchecked(&rdtp->dynticks);
108695 smp_mb__after_atomic(); /* Force ordering with next sojourn. */
108696 WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) &&
108697- atomic_read(&rdtp->dynticks) & 0x1);
108698+ atomic_read_unchecked(&rdtp->dynticks) & 0x1);
108699 rcu_dynticks_task_enter();
108700
108701 /*
108702@@ -765,11 +765,11 @@ static void rcu_eqs_exit_common(long long oldval, int user)
108703
108704 rcu_dynticks_task_exit();
108705 smp_mb__before_atomic(); /* Force ordering w/previous sojourn. */
108706- atomic_inc(&rdtp->dynticks);
108707+ atomic_inc_unchecked(&rdtp->dynticks);
108708 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
108709 smp_mb__after_atomic(); /* See above. */
108710 WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) &&
108711- !(atomic_read(&rdtp->dynticks) & 0x1));
108712+ !(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
108713 rcu_cleanup_after_idle();
108714 trace_rcu_dyntick(TPS("End"), oldval, rdtp->dynticks_nesting);
108715 if (IS_ENABLED(CONFIG_RCU_EQS_DEBUG) &&
108716@@ -905,12 +905,12 @@ void rcu_nmi_enter(void)
108717 * to be in the outermost NMI handler that interrupted an RCU-idle
108718 * period (observation due to Andy Lutomirski).
108719 */
108720- if (!(atomic_read(&rdtp->dynticks) & 0x1)) {
108721+ if (!(atomic_read_unchecked(&rdtp->dynticks) & 0x1)) {
108722 smp_mb__before_atomic(); /* Force delay from prior write. */
108723- atomic_inc(&rdtp->dynticks);
108724+ atomic_inc_unchecked(&rdtp->dynticks);
108725 /* atomic_inc() before later RCU read-side crit sects */
108726 smp_mb__after_atomic(); /* See above. */
108727- WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
108728+ WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
108729 incby = 1;
108730 }
108731 rdtp->dynticks_nmi_nesting += incby;
108732@@ -935,7 +935,7 @@ void rcu_nmi_exit(void)
108733 * to us!)
108734 */
108735 WARN_ON_ONCE(rdtp->dynticks_nmi_nesting <= 0);
108736- WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
108737+ WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
108738
108739 /*
108740 * If the nesting level is not 1, the CPU wasn't RCU-idle, so
108741@@ -950,9 +950,9 @@ void rcu_nmi_exit(void)
108742 rdtp->dynticks_nmi_nesting = 0;
108743 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
108744 smp_mb__before_atomic(); /* See above. */
108745- atomic_inc(&rdtp->dynticks);
108746+ atomic_inc_unchecked(&rdtp->dynticks);
108747 smp_mb__after_atomic(); /* Force delay to next write. */
108748- WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
108749+ WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
108750 }
108751
108752 /**
108753@@ -965,7 +965,7 @@ void rcu_nmi_exit(void)
108754 */
108755 bool notrace __rcu_is_watching(void)
108756 {
108757- return atomic_read(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1;
108758+ return atomic_read_unchecked(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1;
108759 }
108760
108761 /**
108762@@ -1048,7 +1048,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
108763 static int dyntick_save_progress_counter(struct rcu_data *rdp,
108764 bool *isidle, unsigned long *maxj)
108765 {
108766- rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
108767+ rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
108768 rcu_sysidle_check_cpu(rdp, isidle, maxj);
108769 if ((rdp->dynticks_snap & 0x1) == 0) {
108770 trace_rcu_fqs(rdp->rsp->name, rdp->gpnum, rdp->cpu, TPS("dti"));
108771@@ -1074,7 +1074,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
108772 int *rcrmp;
108773 unsigned int snap;
108774
108775- curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
108776+ curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
108777 snap = (unsigned int)rdp->dynticks_snap;
108778
108779 /*
108780@@ -2895,7 +2895,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
108781 /*
108782 * Do RCU core processing for the current CPU.
108783 */
108784-static void rcu_process_callbacks(struct softirq_action *unused)
108785+static void rcu_process_callbacks(void)
108786 {
108787 struct rcu_state *rsp;
108788
108789@@ -3319,11 +3319,11 @@ void synchronize_sched_expedited(void)
108790 * counter wrap on a 32-bit system. Quite a few more CPUs would of
108791 * course be required on a 64-bit system.
108792 */
108793- if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
108794+ if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
108795 (ulong)atomic_long_read(&rsp->expedited_done) +
108796 ULONG_MAX / 8)) {
108797 wait_rcu_gp(call_rcu_sched);
108798- atomic_long_inc(&rsp->expedited_wrap);
108799+ atomic_long_inc_return_unchecked(&rsp->expedited_wrap);
108800 return;
108801 }
108802
108803@@ -3331,12 +3331,12 @@ void synchronize_sched_expedited(void)
108804 * Take a ticket. Note that atomic_inc_return() implies a
108805 * full memory barrier.
108806 */
108807- snap = atomic_long_inc_return(&rsp->expedited_start);
108808+ snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
108809 firstsnap = snap;
108810 if (!try_get_online_cpus()) {
108811 /* CPU hotplug operation in flight, fall back to normal GP. */
108812 wait_rcu_gp(call_rcu_sched);
108813- atomic_long_inc(&rsp->expedited_normal);
108814+ atomic_long_inc_unchecked(&rsp->expedited_normal);
108815 return;
108816 }
108817 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
108818@@ -3349,7 +3349,7 @@ void synchronize_sched_expedited(void)
108819 for_each_cpu(cpu, cm) {
108820 struct rcu_dynticks *rdtp = &per_cpu(rcu_dynticks, cpu);
108821
108822- if (!(atomic_add_return(0, &rdtp->dynticks) & 0x1))
108823+ if (!(atomic_add_return_unchecked(0, &rdtp->dynticks) & 0x1))
108824 cpumask_clear_cpu(cpu, cm);
108825 }
108826 if (cpumask_weight(cm) == 0)
108827@@ -3364,14 +3364,14 @@ void synchronize_sched_expedited(void)
108828 synchronize_sched_expedited_cpu_stop,
108829 NULL) == -EAGAIN) {
108830 put_online_cpus();
108831- atomic_long_inc(&rsp->expedited_tryfail);
108832+ atomic_long_inc_unchecked(&rsp->expedited_tryfail);
108833
108834 /* Check to see if someone else did our work for us. */
108835 s = atomic_long_read(&rsp->expedited_done);
108836 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
108837 /* ensure test happens before caller kfree */
108838 smp_mb__before_atomic(); /* ^^^ */
108839- atomic_long_inc(&rsp->expedited_workdone1);
108840+ atomic_long_inc_unchecked(&rsp->expedited_workdone1);
108841 free_cpumask_var(cm);
108842 return;
108843 }
108844@@ -3381,7 +3381,7 @@ void synchronize_sched_expedited(void)
108845 udelay(trycount * num_online_cpus());
108846 } else {
108847 wait_rcu_gp(call_rcu_sched);
108848- atomic_long_inc(&rsp->expedited_normal);
108849+ atomic_long_inc_unchecked(&rsp->expedited_normal);
108850 free_cpumask_var(cm);
108851 return;
108852 }
108853@@ -3391,7 +3391,7 @@ void synchronize_sched_expedited(void)
108854 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
108855 /* ensure test happens before caller kfree */
108856 smp_mb__before_atomic(); /* ^^^ */
108857- atomic_long_inc(&rsp->expedited_workdone2);
108858+ atomic_long_inc_unchecked(&rsp->expedited_workdone2);
108859 free_cpumask_var(cm);
108860 return;
108861 }
108862@@ -3406,14 +3406,14 @@ void synchronize_sched_expedited(void)
108863 if (!try_get_online_cpus()) {
108864 /* CPU hotplug operation in flight, use normal GP. */
108865 wait_rcu_gp(call_rcu_sched);
108866- atomic_long_inc(&rsp->expedited_normal);
108867+ atomic_long_inc_unchecked(&rsp->expedited_normal);
108868 free_cpumask_var(cm);
108869 return;
108870 }
108871- snap = atomic_long_read(&rsp->expedited_start);
108872+ snap = atomic_long_read_unchecked(&rsp->expedited_start);
108873 smp_mb(); /* ensure read is before try_stop_cpus(). */
108874 }
108875- atomic_long_inc(&rsp->expedited_stoppedcpus);
108876+ atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
108877
108878 all_cpus_idle:
108879 free_cpumask_var(cm);
108880@@ -3425,16 +3425,16 @@ all_cpus_idle:
108881 * than we did already did their update.
108882 */
108883 do {
108884- atomic_long_inc(&rsp->expedited_done_tries);
108885+ atomic_long_inc_unchecked(&rsp->expedited_done_tries);
108886 s = atomic_long_read(&rsp->expedited_done);
108887 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
108888 /* ensure test happens before caller kfree */
108889 smp_mb__before_atomic(); /* ^^^ */
108890- atomic_long_inc(&rsp->expedited_done_lost);
108891+ atomic_long_inc_unchecked(&rsp->expedited_done_lost);
108892 break;
108893 }
108894 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
108895- atomic_long_inc(&rsp->expedited_done_exit);
108896+ atomic_long_inc_unchecked(&rsp->expedited_done_exit);
108897
108898 put_online_cpus();
108899 }
108900@@ -3767,7 +3767,7 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
108901 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
108902 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
108903 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
108904- WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
108905+ WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
108906 rdp->cpu = cpu;
108907 rdp->rsp = rsp;
108908 rcu_boot_init_nocb_percpu_data(rdp);
108909@@ -3798,8 +3798,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp)
108910 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
108911 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
108912 rcu_sysidle_init_percpu_data(rdp->dynticks);
108913- atomic_set(&rdp->dynticks->dynticks,
108914- (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
108915+ atomic_set_unchecked(&rdp->dynticks->dynticks,
108916+ (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
108917 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
108918
108919 /*
108920diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h
108921index 4adb7ca..20910e6 100644
108922--- a/kernel/rcu/tree.h
108923+++ b/kernel/rcu/tree.h
108924@@ -108,11 +108,11 @@ struct rcu_dynticks {
108925 long long dynticks_nesting; /* Track irq/process nesting level. */
108926 /* Process level is worth LLONG_MAX/2. */
108927 int dynticks_nmi_nesting; /* Track NMI nesting level. */
108928- atomic_t dynticks; /* Even value for idle, else odd. */
108929+ atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
108930 #ifdef CONFIG_NO_HZ_FULL_SYSIDLE
108931 long long dynticks_idle_nesting;
108932 /* irq/process nesting level from idle. */
108933- atomic_t dynticks_idle; /* Even value for idle, else odd. */
108934+ atomic_unchecked_t dynticks_idle;/* Even value for idle, else odd. */
108935 /* "Idle" excludes userspace execution. */
108936 unsigned long dynticks_idle_jiffies;
108937 /* End of last non-NMI non-idle period. */
108938@@ -483,17 +483,17 @@ struct rcu_state {
108939 /* _rcu_barrier(). */
108940 /* End of fields guarded by barrier_mutex. */
108941
108942- atomic_long_t expedited_start; /* Starting ticket. */
108943- atomic_long_t expedited_done; /* Done ticket. */
108944- atomic_long_t expedited_wrap; /* # near-wrap incidents. */
108945- atomic_long_t expedited_tryfail; /* # acquisition failures. */
108946- atomic_long_t expedited_workdone1; /* # done by others #1. */
108947- atomic_long_t expedited_workdone2; /* # done by others #2. */
108948- atomic_long_t expedited_normal; /* # fallbacks to normal. */
108949- atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
108950- atomic_long_t expedited_done_tries; /* # tries to update _done. */
108951- atomic_long_t expedited_done_lost; /* # times beaten to _done. */
108952- atomic_long_t expedited_done_exit; /* # times exited _done loop. */
108953+ atomic_long_unchecked_t expedited_start; /* Starting ticket. */
108954+ atomic_long_t expedited_done; /* Done ticket. */
108955+ atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
108956+ atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
108957+ atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
108958+ atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
108959+ atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
108960+ atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
108961+ atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
108962+ atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
108963+ atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
108964
108965 unsigned long jiffies_force_qs; /* Time at which to invoke */
108966 /* force_quiescent_state(). */
108967diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
108968index 013485f..2e678db 100644
108969--- a/kernel/rcu/tree_plugin.h
108970+++ b/kernel/rcu/tree_plugin.h
108971@@ -1294,7 +1294,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
108972 free_cpumask_var(cm);
108973 }
108974
108975-static struct smp_hotplug_thread rcu_cpu_thread_spec = {
108976+static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
108977 .store = &rcu_cpu_kthread_task,
108978 .thread_should_run = rcu_cpu_kthread_should_run,
108979 .thread_fn = rcu_cpu_kthread,
108980@@ -1767,7 +1767,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
108981 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
108982 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u fqs=%ld %s\n",
108983 cpu, ticks_value, ticks_title,
108984- atomic_read(&rdtp->dynticks) & 0xfff,
108985+ atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
108986 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
108987 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
108988 READ_ONCE(rsp->n_force_qs) - rsp->n_force_qs_gpstart,
108989@@ -2675,9 +2675,9 @@ static void rcu_sysidle_enter(int irq)
108990 j = jiffies;
108991 WRITE_ONCE(rdtp->dynticks_idle_jiffies, j);
108992 smp_mb__before_atomic();
108993- atomic_inc(&rdtp->dynticks_idle);
108994+ atomic_inc_unchecked(&rdtp->dynticks_idle);
108995 smp_mb__after_atomic();
108996- WARN_ON_ONCE(atomic_read(&rdtp->dynticks_idle) & 0x1);
108997+ WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1);
108998 }
108999
109000 /*
109001@@ -2748,9 +2748,9 @@ static void rcu_sysidle_exit(int irq)
109002
109003 /* Record end of idle period. */
109004 smp_mb__before_atomic();
109005- atomic_inc(&rdtp->dynticks_idle);
109006+ atomic_inc_unchecked(&rdtp->dynticks_idle);
109007 smp_mb__after_atomic();
109008- WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks_idle) & 0x1));
109009+ WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1));
109010
109011 /*
109012 * If we are the timekeeping CPU, we are permitted to be non-idle
109013@@ -2796,7 +2796,7 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle,
109014 WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu);
109015
109016 /* Pick up current idle and NMI-nesting counter and check. */
109017- cur = atomic_read(&rdtp->dynticks_idle);
109018+ cur = atomic_read_unchecked(&rdtp->dynticks_idle);
109019 if (cur & 0x1) {
109020 *isidle = false; /* We are not idle! */
109021 return;
109022diff --git a/kernel/rcu/tree_trace.c b/kernel/rcu/tree_trace.c
109023index 3ea7ffc..cb06f2d 100644
109024--- a/kernel/rcu/tree_trace.c
109025+++ b/kernel/rcu/tree_trace.c
109026@@ -125,7 +125,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
109027 rdp->rcu_qs_ctr_snap == per_cpu(rcu_qs_ctr, rdp->cpu),
109028 rdp->qs_pending);
109029 seq_printf(m, " dt=%d/%llx/%d df=%lu",
109030- atomic_read(&rdp->dynticks->dynticks),
109031+ atomic_read_unchecked(&rdp->dynticks->dynticks),
109032 rdp->dynticks->dynticks_nesting,
109033 rdp->dynticks->dynticks_nmi_nesting,
109034 rdp->dynticks_fqs);
109035@@ -186,17 +186,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
109036 struct rcu_state *rsp = (struct rcu_state *)m->private;
109037
109038 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",
109039- atomic_long_read(&rsp->expedited_start),
109040+ atomic_long_read_unchecked(&rsp->expedited_start),
109041 atomic_long_read(&rsp->expedited_done),
109042- atomic_long_read(&rsp->expedited_wrap),
109043- atomic_long_read(&rsp->expedited_tryfail),
109044- atomic_long_read(&rsp->expedited_workdone1),
109045- atomic_long_read(&rsp->expedited_workdone2),
109046- atomic_long_read(&rsp->expedited_normal),
109047- atomic_long_read(&rsp->expedited_stoppedcpus),
109048- atomic_long_read(&rsp->expedited_done_tries),
109049- atomic_long_read(&rsp->expedited_done_lost),
109050- atomic_long_read(&rsp->expedited_done_exit));
109051+ atomic_long_read_unchecked(&rsp->expedited_wrap),
109052+ atomic_long_read_unchecked(&rsp->expedited_tryfail),
109053+ atomic_long_read_unchecked(&rsp->expedited_workdone1),
109054+ atomic_long_read_unchecked(&rsp->expedited_workdone2),
109055+ atomic_long_read_unchecked(&rsp->expedited_normal),
109056+ atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
109057+ atomic_long_read_unchecked(&rsp->expedited_done_tries),
109058+ atomic_long_read_unchecked(&rsp->expedited_done_lost),
109059+ atomic_long_read_unchecked(&rsp->expedited_done_exit));
109060 return 0;
109061 }
109062
109063diff --git a/kernel/resource.c b/kernel/resource.c
109064index fed052a..ad13346 100644
109065--- a/kernel/resource.c
109066+++ b/kernel/resource.c
109067@@ -162,8 +162,18 @@ static const struct file_operations proc_iomem_operations = {
109068
109069 static int __init ioresources_init(void)
109070 {
109071+#ifdef CONFIG_GRKERNSEC_PROC_ADD
109072+#ifdef CONFIG_GRKERNSEC_PROC_USER
109073+ proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
109074+ proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
109075+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
109076+ proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
109077+ proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
109078+#endif
109079+#else
109080 proc_create("ioports", 0, NULL, &proc_ioports_operations);
109081 proc_create("iomem", 0, NULL, &proc_iomem_operations);
109082+#endif
109083 return 0;
109084 }
109085 __initcall(ioresources_init);
109086diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
109087index 750ed60..eb01466 100644
109088--- a/kernel/sched/auto_group.c
109089+++ b/kernel/sched/auto_group.c
109090@@ -9,7 +9,7 @@
109091
109092 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
109093 static struct autogroup autogroup_default;
109094-static atomic_t autogroup_seq_nr;
109095+static atomic_unchecked_t autogroup_seq_nr;
109096
109097 void __init autogroup_init(struct task_struct *init_task)
109098 {
109099@@ -77,7 +77,7 @@ static inline struct autogroup *autogroup_create(void)
109100
109101 kref_init(&ag->kref);
109102 init_rwsem(&ag->lock);
109103- ag->id = atomic_inc_return(&autogroup_seq_nr);
109104+ ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
109105 ag->tg = tg;
109106 #ifdef CONFIG_RT_GROUP_SCHED
109107 /*
109108diff --git a/kernel/sched/core.c b/kernel/sched/core.c
109109index 6776631..45eb6ee 100644
109110--- a/kernel/sched/core.c
109111+++ b/kernel/sched/core.c
109112@@ -2080,7 +2080,7 @@ void set_numabalancing_state(bool enabled)
109113 int sysctl_numa_balancing(struct ctl_table *table, int write,
109114 void __user *buffer, size_t *lenp, loff_t *ppos)
109115 {
109116- struct ctl_table t;
109117+ ctl_table_no_const t;
109118 int err;
109119 int state = numabalancing_enabled;
109120
109121@@ -2573,8 +2573,10 @@ context_switch(struct rq *rq, struct task_struct *prev,
109122 next->active_mm = oldmm;
109123 atomic_inc(&oldmm->mm_count);
109124 enter_lazy_tlb(oldmm, next);
109125- } else
109126+ } else {
109127 switch_mm(oldmm, mm, next);
109128+ populate_stack();
109129+ }
109130
109131 if (!prev->mm) {
109132 prev->active_mm = NULL;
109133@@ -3393,6 +3395,8 @@ int can_nice(const struct task_struct *p, const int nice)
109134 /* convert nice value [19,-20] to rlimit style value [1,40] */
109135 int nice_rlim = nice_to_rlimit(nice);
109136
109137+ gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
109138+
109139 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
109140 capable(CAP_SYS_NICE));
109141 }
109142@@ -3419,7 +3423,8 @@ SYSCALL_DEFINE1(nice, int, increment)
109143 nice = task_nice(current) + increment;
109144
109145 nice = clamp_val(nice, MIN_NICE, MAX_NICE);
109146- if (increment < 0 && !can_nice(current, nice))
109147+ if (increment < 0 && (!can_nice(current, nice) ||
109148+ gr_handle_chroot_nice()))
109149 return -EPERM;
109150
109151 retval = security_task_setnice(current, nice);
109152@@ -3731,6 +3736,7 @@ recheck:
109153 if (policy != p->policy && !rlim_rtprio)
109154 return -EPERM;
109155
109156+ gr_learn_resource(p, RLIMIT_RTPRIO, attr->sched_priority, 1);
109157 /* can't increase priority */
109158 if (attr->sched_priority > p->rt_priority &&
109159 attr->sched_priority > rlim_rtprio)
109160@@ -5055,6 +5061,7 @@ void idle_task_exit(void)
109161
109162 if (mm != &init_mm) {
109163 switch_mm(mm, &init_mm, current);
109164+ populate_stack();
109165 finish_arch_post_lock_switch();
109166 }
109167 mmdrop(mm);
109168@@ -5157,7 +5164,7 @@ static void migrate_tasks(struct rq *dead_rq)
109169
109170 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
109171
109172-static struct ctl_table sd_ctl_dir[] = {
109173+static ctl_table_no_const sd_ctl_dir[] __read_only = {
109174 {
109175 .procname = "sched_domain",
109176 .mode = 0555,
109177@@ -5174,17 +5181,17 @@ static struct ctl_table sd_ctl_root[] = {
109178 {}
109179 };
109180
109181-static struct ctl_table *sd_alloc_ctl_entry(int n)
109182+static ctl_table_no_const *sd_alloc_ctl_entry(int n)
109183 {
109184- struct ctl_table *entry =
109185+ ctl_table_no_const *entry =
109186 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
109187
109188 return entry;
109189 }
109190
109191-static void sd_free_ctl_entry(struct ctl_table **tablep)
109192+static void sd_free_ctl_entry(ctl_table_no_const *tablep)
109193 {
109194- struct ctl_table *entry;
109195+ ctl_table_no_const *entry;
109196
109197 /*
109198 * In the intermediate directories, both the child directory and
109199@@ -5192,22 +5199,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
109200 * will always be set. In the lowest directory the names are
109201 * static strings and all have proc handlers.
109202 */
109203- for (entry = *tablep; entry->mode; entry++) {
109204- if (entry->child)
109205- sd_free_ctl_entry(&entry->child);
109206+ for (entry = tablep; entry->mode; entry++) {
109207+ if (entry->child) {
109208+ sd_free_ctl_entry(entry->child);
109209+ pax_open_kernel();
109210+ entry->child = NULL;
109211+ pax_close_kernel();
109212+ }
109213 if (entry->proc_handler == NULL)
109214 kfree(entry->procname);
109215 }
109216
109217- kfree(*tablep);
109218- *tablep = NULL;
109219+ kfree(tablep);
109220 }
109221
109222 static int min_load_idx = 0;
109223 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
109224
109225 static void
109226-set_table_entry(struct ctl_table *entry,
109227+set_table_entry(ctl_table_no_const *entry,
109228 const char *procname, void *data, int maxlen,
109229 umode_t mode, proc_handler *proc_handler,
109230 bool load_idx)
109231@@ -5227,7 +5237,7 @@ set_table_entry(struct ctl_table *entry,
109232 static struct ctl_table *
109233 sd_alloc_ctl_domain_table(struct sched_domain *sd)
109234 {
109235- struct ctl_table *table = sd_alloc_ctl_entry(14);
109236+ ctl_table_no_const *table = sd_alloc_ctl_entry(14);
109237
109238 if (table == NULL)
109239 return NULL;
109240@@ -5265,9 +5275,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
109241 return table;
109242 }
109243
109244-static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
109245+static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
109246 {
109247- struct ctl_table *entry, *table;
109248+ ctl_table_no_const *entry, *table;
109249 struct sched_domain *sd;
109250 int domain_num = 0, i;
109251 char buf[32];
109252@@ -5294,11 +5304,13 @@ static struct ctl_table_header *sd_sysctl_header;
109253 static void register_sched_domain_sysctl(void)
109254 {
109255 int i, cpu_num = num_possible_cpus();
109256- struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
109257+ ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
109258 char buf[32];
109259
109260 WARN_ON(sd_ctl_dir[0].child);
109261+ pax_open_kernel();
109262 sd_ctl_dir[0].child = entry;
109263+ pax_close_kernel();
109264
109265 if (entry == NULL)
109266 return;
109267@@ -5321,8 +5333,12 @@ static void unregister_sched_domain_sysctl(void)
109268 if (sd_sysctl_header)
109269 unregister_sysctl_table(sd_sysctl_header);
109270 sd_sysctl_header = NULL;
109271- if (sd_ctl_dir[0].child)
109272- sd_free_ctl_entry(&sd_ctl_dir[0].child);
109273+ if (sd_ctl_dir[0].child) {
109274+ sd_free_ctl_entry(sd_ctl_dir[0].child);
109275+ pax_open_kernel();
109276+ sd_ctl_dir[0].child = NULL;
109277+ pax_close_kernel();
109278+ }
109279 }
109280 #else
109281 static void register_sched_domain_sysctl(void)
109282diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
109283index d113c3b..91a6fcc 100644
109284--- a/kernel/sched/fair.c
109285+++ b/kernel/sched/fair.c
109286@@ -7958,7 +7958,7 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) { }
109287 * run_rebalance_domains is triggered when needed from the scheduler tick.
109288 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
109289 */
109290-static void run_rebalance_domains(struct softirq_action *h)
109291+static __latent_entropy void run_rebalance_domains(void)
109292 {
109293 struct rq *this_rq = this_rq();
109294 enum cpu_idle_type idle = this_rq->idle_balance ?
109295diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
109296index 08ab96b..82ab34c 100644
109297--- a/kernel/sched/sched.h
109298+++ b/kernel/sched/sched.h
109299@@ -1242,7 +1242,7 @@ struct sched_class {
109300 #ifdef CONFIG_FAIR_GROUP_SCHED
109301 void (*task_move_group) (struct task_struct *p, int on_rq);
109302 #endif
109303-};
109304+} __do_const;
109305
109306 static inline void put_prev_task(struct rq *rq, struct task_struct *prev)
109307 {
109308diff --git a/kernel/signal.c b/kernel/signal.c
109309index 0f6bbbe..d77d2c3 100644
109310--- a/kernel/signal.c
109311+++ b/kernel/signal.c
109312@@ -53,12 +53,12 @@ static struct kmem_cache *sigqueue_cachep;
109313
109314 int print_fatal_signals __read_mostly;
109315
109316-static void __user *sig_handler(struct task_struct *t, int sig)
109317+static __sighandler_t sig_handler(struct task_struct *t, int sig)
109318 {
109319 return t->sighand->action[sig - 1].sa.sa_handler;
109320 }
109321
109322-static int sig_handler_ignored(void __user *handler, int sig)
109323+static int sig_handler_ignored(__sighandler_t handler, int sig)
109324 {
109325 /* Is it explicitly or implicitly ignored? */
109326 return handler == SIG_IGN ||
109327@@ -67,7 +67,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
109328
109329 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
109330 {
109331- void __user *handler;
109332+ __sighandler_t handler;
109333
109334 handler = sig_handler(t, sig);
109335
109336@@ -372,6 +372,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
109337 atomic_inc(&user->sigpending);
109338 rcu_read_unlock();
109339
109340+ if (!override_rlimit)
109341+ gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
109342+
109343 if (override_rlimit ||
109344 atomic_read(&user->sigpending) <=
109345 task_rlimit(t, RLIMIT_SIGPENDING)) {
109346@@ -494,7 +497,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
109347
109348 int unhandled_signal(struct task_struct *tsk, int sig)
109349 {
109350- void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
109351+ __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
109352 if (is_global_init(tsk))
109353 return 1;
109354 if (handler != SIG_IGN && handler != SIG_DFL)
109355@@ -788,6 +791,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
109356 }
109357 }
109358
109359+ /* allow glibc communication via tgkill to other threads in our
109360+ thread group */
109361+ if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
109362+ sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
109363+ && gr_handle_signal(t, sig))
109364+ return -EPERM;
109365+
109366 return security_task_kill(t, info, sig, 0);
109367 }
109368
109369@@ -1171,7 +1181,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
109370 return send_signal(sig, info, p, 1);
109371 }
109372
109373-static int
109374+int
109375 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
109376 {
109377 return send_signal(sig, info, t, 0);
109378@@ -1208,6 +1218,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
109379 unsigned long int flags;
109380 int ret, blocked, ignored;
109381 struct k_sigaction *action;
109382+ int is_unhandled = 0;
109383
109384 spin_lock_irqsave(&t->sighand->siglock, flags);
109385 action = &t->sighand->action[sig-1];
109386@@ -1222,9 +1233,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
109387 }
109388 if (action->sa.sa_handler == SIG_DFL)
109389 t->signal->flags &= ~SIGNAL_UNKILLABLE;
109390+ if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
109391+ is_unhandled = 1;
109392 ret = specific_send_sig_info(sig, info, t);
109393 spin_unlock_irqrestore(&t->sighand->siglock, flags);
109394
109395+ /* only deal with unhandled signals, java etc trigger SIGSEGV during
109396+ normal operation */
109397+ if (is_unhandled) {
109398+ gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
109399+ gr_handle_crash(t, sig);
109400+ }
109401+
109402 return ret;
109403 }
109404
109405@@ -1305,8 +1325,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
109406 ret = check_kill_permission(sig, info, p);
109407 rcu_read_unlock();
109408
109409- if (!ret && sig)
109410+ if (!ret && sig) {
109411 ret = do_send_sig_info(sig, info, p, true);
109412+ if (!ret)
109413+ gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
109414+ }
109415
109416 return ret;
109417 }
109418@@ -2913,7 +2936,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
109419 int error = -ESRCH;
109420
109421 rcu_read_lock();
109422- p = find_task_by_vpid(pid);
109423+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
109424+ /* allow glibc communication via tgkill to other threads in our
109425+ thread group */
109426+ if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
109427+ sig == (SIGRTMIN+1) && tgid == info->si_pid)
109428+ p = find_task_by_vpid_unrestricted(pid);
109429+ else
109430+#endif
109431+ p = find_task_by_vpid(pid);
109432 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
109433 error = check_kill_permission(sig, info, p);
109434 /*
109435@@ -3242,8 +3273,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
109436 }
109437 seg = get_fs();
109438 set_fs(KERNEL_DS);
109439- ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
109440- (stack_t __force __user *) &uoss,
109441+ ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
109442+ (stack_t __force_user *) &uoss,
109443 compat_user_stack_pointer());
109444 set_fs(seg);
109445 if (ret >= 0 && uoss_ptr) {
109446diff --git a/kernel/smpboot.c b/kernel/smpboot.c
109447index 7c434c3..155d90a 100644
109448--- a/kernel/smpboot.c
109449+++ b/kernel/smpboot.c
109450@@ -305,7 +305,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
109451 }
109452 smpboot_unpark_thread(plug_thread, cpu);
109453 }
109454- list_add(&plug_thread->list, &hotplug_threads);
109455+ pax_list_add(&plug_thread->list, &hotplug_threads);
109456 out:
109457 mutex_unlock(&smpboot_threads_lock);
109458 put_online_cpus();
109459@@ -323,7 +323,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
109460 {
109461 get_online_cpus();
109462 mutex_lock(&smpboot_threads_lock);
109463- list_del(&plug_thread->list);
109464+ pax_list_del(&plug_thread->list);
109465 smpboot_destroy_threads(plug_thread);
109466 mutex_unlock(&smpboot_threads_lock);
109467 put_online_cpus();
109468diff --git a/kernel/softirq.c b/kernel/softirq.c
109469index 479e443..66d845e1 100644
109470--- a/kernel/softirq.c
109471+++ b/kernel/softirq.c
109472@@ -53,7 +53,7 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
109473 EXPORT_SYMBOL(irq_stat);
109474 #endif
109475
109476-static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
109477+static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
109478
109479 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
109480
109481@@ -270,7 +270,7 @@ restart:
109482 kstat_incr_softirqs_this_cpu(vec_nr);
109483
109484 trace_softirq_entry(vec_nr);
109485- h->action(h);
109486+ h->action();
109487 trace_softirq_exit(vec_nr);
109488 if (unlikely(prev_count != preempt_count())) {
109489 pr_err("huh, entered softirq %u %s %p with preempt_count %08x, exited with %08x?\n",
109490@@ -430,7 +430,7 @@ void __raise_softirq_irqoff(unsigned int nr)
109491 or_softirq_pending(1UL << nr);
109492 }
109493
109494-void open_softirq(int nr, void (*action)(struct softirq_action *))
109495+void __init open_softirq(int nr, void (*action)(void))
109496 {
109497 softirq_vec[nr].action = action;
109498 }
109499@@ -482,7 +482,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
109500 }
109501 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
109502
109503-static void tasklet_action(struct softirq_action *a)
109504+static void tasklet_action(void)
109505 {
109506 struct tasklet_struct *list;
109507
109508@@ -518,7 +518,7 @@ static void tasklet_action(struct softirq_action *a)
109509 }
109510 }
109511
109512-static void tasklet_hi_action(struct softirq_action *a)
109513+static __latent_entropy void tasklet_hi_action(void)
109514 {
109515 struct tasklet_struct *list;
109516
109517@@ -744,7 +744,7 @@ static struct notifier_block cpu_nfb = {
109518 .notifier_call = cpu_callback
109519 };
109520
109521-static struct smp_hotplug_thread softirq_threads = {
109522+static struct smp_hotplug_thread softirq_threads __read_only = {
109523 .store = &ksoftirqd,
109524 .thread_should_run = ksoftirqd_should_run,
109525 .thread_fn = run_ksoftirqd,
109526diff --git a/kernel/sys.c b/kernel/sys.c
109527index 259fda2..e824a93 100644
109528--- a/kernel/sys.c
109529+++ b/kernel/sys.c
109530@@ -160,6 +160,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
109531 error = -EACCES;
109532 goto out;
109533 }
109534+
109535+ if (gr_handle_chroot_setpriority(p, niceval)) {
109536+ error = -EACCES;
109537+ goto out;
109538+ }
109539+
109540 no_nice = security_task_setnice(p, niceval);
109541 if (no_nice) {
109542 error = no_nice;
109543@@ -366,6 +372,20 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
109544 goto error;
109545 }
109546
109547+ if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
109548+ goto error;
109549+
109550+ if (!gid_eq(new->gid, old->gid)) {
109551+ /* make sure we generate a learn log for what will
109552+ end up being a role transition after a full-learning
109553+ policy is generated
109554+ CAP_SETGID is required to perform a transition
109555+ we may not log a CAP_SETGID check above, e.g.
109556+ in the case where new rgid = old egid
109557+ */
109558+ gr_learn_cap(current, new, CAP_SETGID);
109559+ }
109560+
109561 if (rgid != (gid_t) -1 ||
109562 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
109563 new->sgid = new->egid;
109564@@ -401,6 +421,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
109565 old = current_cred();
109566
109567 retval = -EPERM;
109568+
109569+ if (gr_check_group_change(kgid, kgid, kgid))
109570+ goto error;
109571+
109572 if (ns_capable(old->user_ns, CAP_SETGID))
109573 new->gid = new->egid = new->sgid = new->fsgid = kgid;
109574 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
109575@@ -418,7 +442,7 @@ error:
109576 /*
109577 * change the user struct in a credentials set to match the new UID
109578 */
109579-static int set_user(struct cred *new)
109580+int set_user(struct cred *new)
109581 {
109582 struct user_struct *new_user;
109583
109584@@ -498,7 +522,18 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
109585 goto error;
109586 }
109587
109588+ if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
109589+ goto error;
109590+
109591 if (!uid_eq(new->uid, old->uid)) {
109592+ /* make sure we generate a learn log for what will
109593+ end up being a role transition after a full-learning
109594+ policy is generated
109595+ CAP_SETUID is required to perform a transition
109596+ we may not log a CAP_SETUID check above, e.g.
109597+ in the case where new ruid = old euid
109598+ */
109599+ gr_learn_cap(current, new, CAP_SETUID);
109600 retval = set_user(new);
109601 if (retval < 0)
109602 goto error;
109603@@ -548,6 +583,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
109604 old = current_cred();
109605
109606 retval = -EPERM;
109607+
109608+ if (gr_check_crash_uid(kuid))
109609+ goto error;
109610+ if (gr_check_user_change(kuid, kuid, kuid))
109611+ goto error;
109612+
109613 if (ns_capable(old->user_ns, CAP_SETUID)) {
109614 new->suid = new->uid = kuid;
109615 if (!uid_eq(kuid, old->uid)) {
109616@@ -617,6 +658,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
109617 goto error;
109618 }
109619
109620+ if (gr_check_user_change(kruid, keuid, INVALID_UID))
109621+ goto error;
109622+
109623 if (ruid != (uid_t) -1) {
109624 new->uid = kruid;
109625 if (!uid_eq(kruid, old->uid)) {
109626@@ -701,6 +745,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
109627 goto error;
109628 }
109629
109630+ if (gr_check_group_change(krgid, kegid, INVALID_GID))
109631+ goto error;
109632+
109633 if (rgid != (gid_t) -1)
109634 new->gid = krgid;
109635 if (egid != (gid_t) -1)
109636@@ -765,12 +812,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
109637 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
109638 ns_capable(old->user_ns, CAP_SETUID)) {
109639 if (!uid_eq(kuid, old->fsuid)) {
109640+ if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
109641+ goto error;
109642+
109643 new->fsuid = kuid;
109644 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
109645 goto change_okay;
109646 }
109647 }
109648
109649+error:
109650 abort_creds(new);
109651 return old_fsuid;
109652
109653@@ -803,12 +854,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
109654 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
109655 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
109656 ns_capable(old->user_ns, CAP_SETGID)) {
109657+ if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
109658+ goto error;
109659+
109660 if (!gid_eq(kgid, old->fsgid)) {
109661 new->fsgid = kgid;
109662 goto change_okay;
109663 }
109664 }
109665
109666+error:
109667 abort_creds(new);
109668 return old_fsgid;
109669
109670@@ -1187,19 +1242,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
109671 return -EFAULT;
109672
109673 down_read(&uts_sem);
109674- error = __copy_to_user(&name->sysname, &utsname()->sysname,
109675+ error = __copy_to_user(name->sysname, &utsname()->sysname,
109676 __OLD_UTS_LEN);
109677 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
109678- error |= __copy_to_user(&name->nodename, &utsname()->nodename,
109679+ error |= __copy_to_user(name->nodename, &utsname()->nodename,
109680 __OLD_UTS_LEN);
109681 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
109682- error |= __copy_to_user(&name->release, &utsname()->release,
109683+ error |= __copy_to_user(name->release, &utsname()->release,
109684 __OLD_UTS_LEN);
109685 error |= __put_user(0, name->release + __OLD_UTS_LEN);
109686- error |= __copy_to_user(&name->version, &utsname()->version,
109687+ error |= __copy_to_user(name->version, &utsname()->version,
109688 __OLD_UTS_LEN);
109689 error |= __put_user(0, name->version + __OLD_UTS_LEN);
109690- error |= __copy_to_user(&name->machine, &utsname()->machine,
109691+ error |= __copy_to_user(name->machine, &utsname()->machine,
109692 __OLD_UTS_LEN);
109693 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
109694 up_read(&uts_sem);
109695@@ -1400,6 +1455,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
109696 */
109697 new_rlim->rlim_cur = 1;
109698 }
109699+ /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
109700+ is changed to a lower value. Since tasks can be created by the same
109701+ user in between this limit change and an execve by this task, force
109702+ a recheck only for this task by setting PF_NPROC_EXCEEDED
109703+ */
109704+ if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
109705+ tsk->flags |= PF_NPROC_EXCEEDED;
109706 }
109707 if (!retval) {
109708 if (old_rlim)
109709diff --git a/kernel/sysctl.c b/kernel/sysctl.c
109710index 19b62b5..74cc287 100644
109711--- a/kernel/sysctl.c
109712+++ b/kernel/sysctl.c
109713@@ -94,7 +94,6 @@
109714 #endif
109715
109716 #if defined(CONFIG_SYSCTL)
109717-
109718 /* External variables not in a header file. */
109719 extern int suid_dumpable;
109720 #ifdef CONFIG_COREDUMP
109721@@ -111,22 +110,24 @@ extern int sysctl_nr_open_min, sysctl_nr_open_max;
109722 #ifndef CONFIG_MMU
109723 extern int sysctl_nr_trim_pages;
109724 #endif
109725+extern int sysctl_modify_ldt;
109726
109727 /* Constants used for minimum and maximum */
109728 #ifdef CONFIG_LOCKUP_DETECTOR
109729-static int sixty = 60;
109730+static int sixty __read_only = 60;
109731 #endif
109732
109733-static int __maybe_unused neg_one = -1;
109734+static int __maybe_unused neg_one __read_only = -1;
109735
109736-static int zero;
109737-static int __maybe_unused one = 1;
109738-static int __maybe_unused two = 2;
109739-static int __maybe_unused four = 4;
109740-static unsigned long one_ul = 1;
109741-static int one_hundred = 100;
109742+static int zero __read_only = 0;
109743+static int __maybe_unused one __read_only = 1;
109744+static int __maybe_unused two __read_only = 2;
109745+static int __maybe_unused three __read_only = 3;
109746+static int __maybe_unused four __read_only = 4;
109747+static unsigned long one_ul __read_only = 1;
109748+static int one_hundred __read_only = 100;
109749 #ifdef CONFIG_PRINTK
109750-static int ten_thousand = 10000;
109751+static int ten_thousand __read_only = 10000;
109752 #endif
109753
109754 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
109755@@ -180,10 +181,8 @@ static int proc_taint(struct ctl_table *table, int write,
109756 void __user *buffer, size_t *lenp, loff_t *ppos);
109757 #endif
109758
109759-#ifdef CONFIG_PRINTK
109760-static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
109761+static int proc_dointvec_minmax_secure_sysadmin(struct ctl_table *table, int write,
109762 void __user *buffer, size_t *lenp, loff_t *ppos);
109763-#endif
109764
109765 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
109766 void __user *buffer, size_t *lenp, loff_t *ppos);
109767@@ -214,6 +213,8 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write,
109768
109769 #endif
109770
109771+extern struct ctl_table grsecurity_table[];
109772+
109773 static struct ctl_table kern_table[];
109774 static struct ctl_table vm_table[];
109775 static struct ctl_table fs_table[];
109776@@ -228,6 +229,20 @@ extern struct ctl_table epoll_table[];
109777 int sysctl_legacy_va_layout;
109778 #endif
109779
109780+#ifdef CONFIG_PAX_SOFTMODE
109781+static struct ctl_table pax_table[] = {
109782+ {
109783+ .procname = "softmode",
109784+ .data = &pax_softmode,
109785+ .maxlen = sizeof(unsigned int),
109786+ .mode = 0600,
109787+ .proc_handler = &proc_dointvec,
109788+ },
109789+
109790+ { }
109791+};
109792+#endif
109793+
109794 /* The default sysctl tables: */
109795
109796 static struct ctl_table sysctl_base_table[] = {
109797@@ -276,6 +291,22 @@ static int max_extfrag_threshold = 1000;
109798 #endif
109799
109800 static struct ctl_table kern_table[] = {
109801+#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
109802+ {
109803+ .procname = "grsecurity",
109804+ .mode = 0500,
109805+ .child = grsecurity_table,
109806+ },
109807+#endif
109808+
109809+#ifdef CONFIG_PAX_SOFTMODE
109810+ {
109811+ .procname = "pax",
109812+ .mode = 0500,
109813+ .child = pax_table,
109814+ },
109815+#endif
109816+
109817 {
109818 .procname = "sched_child_runs_first",
109819 .data = &sysctl_sched_child_runs_first,
109820@@ -628,7 +659,7 @@ static struct ctl_table kern_table[] = {
109821 .maxlen = sizeof(int),
109822 .mode = 0644,
109823 /* only handle a transition from default "0" to "1" */
109824- .proc_handler = proc_dointvec_minmax,
109825+ .proc_handler = proc_dointvec_minmax_secure,
109826 .extra1 = &one,
109827 .extra2 = &one,
109828 },
109829@@ -639,7 +670,7 @@ static struct ctl_table kern_table[] = {
109830 .data = &modprobe_path,
109831 .maxlen = KMOD_PATH_LEN,
109832 .mode = 0644,
109833- .proc_handler = proc_dostring,
109834+ .proc_handler = proc_dostring_modpriv,
109835 },
109836 {
109837 .procname = "modules_disabled",
109838@@ -647,7 +678,7 @@ static struct ctl_table kern_table[] = {
109839 .maxlen = sizeof(int),
109840 .mode = 0644,
109841 /* only handle a transition from default "0" to "1" */
109842- .proc_handler = proc_dointvec_minmax,
109843+ .proc_handler = proc_dointvec_minmax_secure,
109844 .extra1 = &one,
109845 .extra2 = &one,
109846 },
109847@@ -802,20 +833,24 @@ static struct ctl_table kern_table[] = {
109848 .data = &dmesg_restrict,
109849 .maxlen = sizeof(int),
109850 .mode = 0644,
109851- .proc_handler = proc_dointvec_minmax_sysadmin,
109852+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
109853 .extra1 = &zero,
109854 .extra2 = &one,
109855 },
109856+#endif
109857 {
109858 .procname = "kptr_restrict",
109859 .data = &kptr_restrict,
109860 .maxlen = sizeof(int),
109861 .mode = 0644,
109862- .proc_handler = proc_dointvec_minmax_sysadmin,
109863+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
109864+#ifdef CONFIG_GRKERNSEC_HIDESYM
109865+ .extra1 = &two,
109866+#else
109867 .extra1 = &zero,
109868+#endif
109869 .extra2 = &two,
109870 },
109871-#endif
109872 {
109873 .procname = "ngroups_max",
109874 .data = &ngroups_max,
109875@@ -960,6 +995,15 @@ static struct ctl_table kern_table[] = {
109876 .mode = 0644,
109877 .proc_handler = proc_dointvec,
109878 },
109879+ {
109880+ .procname = "modify_ldt",
109881+ .data = &sysctl_modify_ldt,
109882+ .maxlen = sizeof(int),
109883+ .mode = 0644,
109884+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
109885+ .extra1 = &zero,
109886+ .extra2 = &one,
109887+ },
109888 #endif
109889 #if defined(CONFIG_MMU)
109890 {
109891@@ -1082,10 +1126,17 @@ static struct ctl_table kern_table[] = {
109892 */
109893 {
109894 .procname = "perf_event_paranoid",
109895- .data = &sysctl_perf_event_paranoid,
109896- .maxlen = sizeof(sysctl_perf_event_paranoid),
109897+ .data = &sysctl_perf_event_legitimately_concerned,
109898+ .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
109899 .mode = 0644,
109900- .proc_handler = proc_dointvec,
109901+ /* go ahead, be a hero */
109902+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
109903+ .extra1 = &neg_one,
109904+#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
109905+ .extra2 = &three,
109906+#else
109907+ .extra2 = &two,
109908+#endif
109909 },
109910 {
109911 .procname = "perf_event_mlock_kb",
109912@@ -1376,6 +1427,13 @@ static struct ctl_table vm_table[] = {
109913 .proc_handler = proc_dointvec_minmax,
109914 .extra1 = &zero,
109915 },
109916+ {
109917+ .procname = "heap_stack_gap",
109918+ .data = &sysctl_heap_stack_gap,
109919+ .maxlen = sizeof(sysctl_heap_stack_gap),
109920+ .mode = 0644,
109921+ .proc_handler = proc_doulongvec_minmax,
109922+ },
109923 #else
109924 {
109925 .procname = "nr_trim_pages",
109926@@ -1852,6 +1910,16 @@ int proc_dostring(struct ctl_table *table, int write,
109927 (char __user *)buffer, lenp, ppos);
109928 }
109929
109930+int proc_dostring_modpriv(struct ctl_table *table, int write,
109931+ void __user *buffer, size_t *lenp, loff_t *ppos)
109932+{
109933+ if (write && !capable(CAP_SYS_MODULE))
109934+ return -EPERM;
109935+
109936+ return _proc_do_string(table->data, table->maxlen, write,
109937+ buffer, lenp, ppos);
109938+}
109939+
109940 static size_t proc_skip_spaces(char **buf)
109941 {
109942 size_t ret;
109943@@ -1957,6 +2025,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
109944 len = strlen(tmp);
109945 if (len > *size)
109946 len = *size;
109947+ if (len > sizeof(tmp))
109948+ len = sizeof(tmp);
109949 if (copy_to_user(*buf, tmp, len))
109950 return -EFAULT;
109951 *size -= len;
109952@@ -1995,7 +2065,7 @@ static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
109953 int val = *valp;
109954 if (val < 0) {
109955 *negp = true;
109956- *lvalp = (unsigned long)-val;
109957+ *lvalp = -(unsigned long)val;
109958 } else {
109959 *negp = false;
109960 *lvalp = (unsigned long)val;
109961@@ -2135,6 +2205,44 @@ int proc_dointvec(struct ctl_table *table, int write,
109962 NULL,NULL);
109963 }
109964
109965+static int do_proc_dointvec_conv_secure(bool *negp, unsigned long *lvalp,
109966+ int *valp,
109967+ int write, void *data)
109968+{
109969+ if (write) {
109970+ if (*negp) {
109971+ if (*lvalp > (unsigned long) INT_MAX + 1)
109972+ return -EINVAL;
109973+ pax_open_kernel();
109974+ *valp = -*lvalp;
109975+ pax_close_kernel();
109976+ } else {
109977+ if (*lvalp > (unsigned long) INT_MAX)
109978+ return -EINVAL;
109979+ pax_open_kernel();
109980+ *valp = *lvalp;
109981+ pax_close_kernel();
109982+ }
109983+ } else {
109984+ int val = *valp;
109985+ if (val < 0) {
109986+ *negp = true;
109987+ *lvalp = -(unsigned long)val;
109988+ } else {
109989+ *negp = false;
109990+ *lvalp = (unsigned long)val;
109991+ }
109992+ }
109993+ return 0;
109994+}
109995+
109996+int proc_dointvec_secure(struct ctl_table *table, int write,
109997+ void __user *buffer, size_t *lenp, loff_t *ppos)
109998+{
109999+ return do_proc_dointvec(table,write,buffer,lenp,ppos,
110000+ do_proc_dointvec_conv_secure,NULL);
110001+}
110002+
110003 /*
110004 * Taint values can only be increased
110005 * This means we can safely use a temporary.
110006@@ -2142,7 +2250,7 @@ int proc_dointvec(struct ctl_table *table, int write,
110007 static int proc_taint(struct ctl_table *table, int write,
110008 void __user *buffer, size_t *lenp, loff_t *ppos)
110009 {
110010- struct ctl_table t;
110011+ ctl_table_no_const t;
110012 unsigned long tmptaint = get_taint();
110013 int err;
110014
110015@@ -2170,16 +2278,14 @@ static int proc_taint(struct ctl_table *table, int write,
110016 return err;
110017 }
110018
110019-#ifdef CONFIG_PRINTK
110020-static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
110021+static int proc_dointvec_minmax_secure_sysadmin(struct ctl_table *table, int write,
110022 void __user *buffer, size_t *lenp, loff_t *ppos)
110023 {
110024 if (write && !capable(CAP_SYS_ADMIN))
110025 return -EPERM;
110026
110027- return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
110028+ return proc_dointvec_minmax_secure(table, write, buffer, lenp, ppos);
110029 }
110030-#endif
110031
110032 struct do_proc_dointvec_minmax_conv_param {
110033 int *min;
110034@@ -2201,7 +2307,33 @@ static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
110035 int val = *valp;
110036 if (val < 0) {
110037 *negp = true;
110038- *lvalp = (unsigned long)-val;
110039+ *lvalp = -(unsigned long)val;
110040+ } else {
110041+ *negp = false;
110042+ *lvalp = (unsigned long)val;
110043+ }
110044+ }
110045+ return 0;
110046+}
110047+
110048+static int do_proc_dointvec_minmax_conv_secure(bool *negp, unsigned long *lvalp,
110049+ int *valp,
110050+ int write, void *data)
110051+{
110052+ struct do_proc_dointvec_minmax_conv_param *param = data;
110053+ if (write) {
110054+ int val = *negp ? -*lvalp : *lvalp;
110055+ if ((param->min && *param->min > val) ||
110056+ (param->max && *param->max < val))
110057+ return -EINVAL;
110058+ pax_open_kernel();
110059+ *valp = val;
110060+ pax_close_kernel();
110061+ } else {
110062+ int val = *valp;
110063+ if (val < 0) {
110064+ *negp = true;
110065+ *lvalp = -(unsigned long)val;
110066 } else {
110067 *negp = false;
110068 *lvalp = (unsigned long)val;
110069@@ -2237,6 +2369,17 @@ int proc_dointvec_minmax(struct ctl_table *table, int write,
110070 do_proc_dointvec_minmax_conv, &param);
110071 }
110072
110073+int proc_dointvec_minmax_secure(struct ctl_table *table, int write,
110074+ void __user *buffer, size_t *lenp, loff_t *ppos)
110075+{
110076+ struct do_proc_dointvec_minmax_conv_param param = {
110077+ .min = (int *) table->extra1,
110078+ .max = (int *) table->extra2,
110079+ };
110080+ return do_proc_dointvec(table, write, buffer, lenp, ppos,
110081+ do_proc_dointvec_minmax_conv_secure, &param);
110082+}
110083+
110084 static void validate_coredump_safety(void)
110085 {
110086 #ifdef CONFIG_COREDUMP
110087@@ -2436,7 +2579,7 @@ static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
110088 unsigned long lval;
110089 if (val < 0) {
110090 *negp = true;
110091- lval = (unsigned long)-val;
110092+ lval = -(unsigned long)val;
110093 } else {
110094 *negp = false;
110095 lval = (unsigned long)val;
110096@@ -2459,7 +2602,7 @@ static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp
110097 unsigned long lval;
110098 if (val < 0) {
110099 *negp = true;
110100- lval = (unsigned long)-val;
110101+ lval = -(unsigned long)val;
110102 } else {
110103 *negp = false;
110104 lval = (unsigned long)val;
110105@@ -2484,7 +2627,7 @@ static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
110106 unsigned long lval;
110107 if (val < 0) {
110108 *negp = true;
110109- lval = (unsigned long)-val;
110110+ lval = -(unsigned long)val;
110111 } else {
110112 *negp = false;
110113 lval = (unsigned long)val;
110114@@ -2739,6 +2882,12 @@ int proc_dostring(struct ctl_table *table, int write,
110115 return -ENOSYS;
110116 }
110117
110118+int proc_dostring_modpriv(struct ctl_table *table, int write,
110119+ void __user *buffer, size_t *lenp, loff_t *ppos)
110120+{
110121+ return -ENOSYS;
110122+}
110123+
110124 int proc_dointvec(struct ctl_table *table, int write,
110125 void __user *buffer, size_t *lenp, loff_t *ppos)
110126 {
110127@@ -2795,5 +2944,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
110128 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
110129 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
110130 EXPORT_SYMBOL(proc_dostring);
110131+EXPORT_SYMBOL(proc_dostring_modpriv);
110132 EXPORT_SYMBOL(proc_doulongvec_minmax);
110133 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
110134diff --git a/kernel/taskstats.c b/kernel/taskstats.c
110135index 21f82c2..c1984e5 100644
110136--- a/kernel/taskstats.c
110137+++ b/kernel/taskstats.c
110138@@ -28,9 +28,12 @@
110139 #include <linux/fs.h>
110140 #include <linux/file.h>
110141 #include <linux/pid_namespace.h>
110142+#include <linux/grsecurity.h>
110143 #include <net/genetlink.h>
110144 #include <linux/atomic.h>
110145
110146+extern int gr_is_taskstats_denied(int pid);
110147+
110148 /*
110149 * Maximum length of a cpumask that can be specified in
110150 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
110151@@ -567,6 +570,9 @@ err:
110152
110153 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
110154 {
110155+ if (gr_is_taskstats_denied(current->pid))
110156+ return -EACCES;
110157+
110158 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
110159 return cmd_attr_register_cpumask(info);
110160 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
110161diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
110162index 7fbba635..7cc64ae 100644
110163--- a/kernel/time/alarmtimer.c
110164+++ b/kernel/time/alarmtimer.c
110165@@ -820,7 +820,7 @@ static int __init alarmtimer_init(void)
110166 struct platform_device *pdev;
110167 int error = 0;
110168 int i;
110169- struct k_clock alarm_clock = {
110170+ static struct k_clock alarm_clock = {
110171 .clock_getres = alarm_clock_getres,
110172 .clock_get = alarm_clock_get,
110173 .timer_create = alarm_timer_create,
110174diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
110175index 892e3da..cb71aa5 100644
110176--- a/kernel/time/posix-cpu-timers.c
110177+++ b/kernel/time/posix-cpu-timers.c
110178@@ -1470,14 +1470,14 @@ struct k_clock clock_posix_cpu = {
110179
110180 static __init int init_posix_cpu_timers(void)
110181 {
110182- struct k_clock process = {
110183+ static struct k_clock process = {
110184 .clock_getres = process_cpu_clock_getres,
110185 .clock_get = process_cpu_clock_get,
110186 .timer_create = process_cpu_timer_create,
110187 .nsleep = process_cpu_nsleep,
110188 .nsleep_restart = process_cpu_nsleep_restart,
110189 };
110190- struct k_clock thread = {
110191+ static struct k_clock thread = {
110192 .clock_getres = thread_cpu_clock_getres,
110193 .clock_get = thread_cpu_clock_get,
110194 .timer_create = thread_cpu_timer_create,
110195diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
110196index 31d11ac..5a3bb13 100644
110197--- a/kernel/time/posix-timers.c
110198+++ b/kernel/time/posix-timers.c
110199@@ -43,6 +43,7 @@
110200 #include <linux/hash.h>
110201 #include <linux/posix-clock.h>
110202 #include <linux/posix-timers.h>
110203+#include <linux/grsecurity.h>
110204 #include <linux/syscalls.h>
110205 #include <linux/wait.h>
110206 #include <linux/workqueue.h>
110207@@ -124,7 +125,7 @@ static DEFINE_SPINLOCK(hash_lock);
110208 * which we beg off on and pass to do_sys_settimeofday().
110209 */
110210
110211-static struct k_clock posix_clocks[MAX_CLOCKS];
110212+static struct k_clock *posix_clocks[MAX_CLOCKS];
110213
110214 /*
110215 * These ones are defined below.
110216@@ -284,7 +285,7 @@ static int posix_get_hrtimer_res(clockid_t which_clock, struct timespec *tp)
110217 */
110218 static __init int init_posix_timers(void)
110219 {
110220- struct k_clock clock_realtime = {
110221+ static struct k_clock clock_realtime = {
110222 .clock_getres = posix_get_hrtimer_res,
110223 .clock_get = posix_clock_realtime_get,
110224 .clock_set = posix_clock_realtime_set,
110225@@ -296,7 +297,7 @@ static __init int init_posix_timers(void)
110226 .timer_get = common_timer_get,
110227 .timer_del = common_timer_del,
110228 };
110229- struct k_clock clock_monotonic = {
110230+ static struct k_clock clock_monotonic = {
110231 .clock_getres = posix_get_hrtimer_res,
110232 .clock_get = posix_ktime_get_ts,
110233 .nsleep = common_nsleep,
110234@@ -306,19 +307,19 @@ static __init int init_posix_timers(void)
110235 .timer_get = common_timer_get,
110236 .timer_del = common_timer_del,
110237 };
110238- struct k_clock clock_monotonic_raw = {
110239+ static struct k_clock clock_monotonic_raw = {
110240 .clock_getres = posix_get_hrtimer_res,
110241 .clock_get = posix_get_monotonic_raw,
110242 };
110243- struct k_clock clock_realtime_coarse = {
110244+ static struct k_clock clock_realtime_coarse = {
110245 .clock_getres = posix_get_coarse_res,
110246 .clock_get = posix_get_realtime_coarse,
110247 };
110248- struct k_clock clock_monotonic_coarse = {
110249+ static struct k_clock clock_monotonic_coarse = {
110250 .clock_getres = posix_get_coarse_res,
110251 .clock_get = posix_get_monotonic_coarse,
110252 };
110253- struct k_clock clock_tai = {
110254+ static struct k_clock clock_tai = {
110255 .clock_getres = posix_get_hrtimer_res,
110256 .clock_get = posix_get_tai,
110257 .nsleep = common_nsleep,
110258@@ -328,7 +329,7 @@ static __init int init_posix_timers(void)
110259 .timer_get = common_timer_get,
110260 .timer_del = common_timer_del,
110261 };
110262- struct k_clock clock_boottime = {
110263+ static struct k_clock clock_boottime = {
110264 .clock_getres = posix_get_hrtimer_res,
110265 .clock_get = posix_get_boottime,
110266 .nsleep = common_nsleep,
110267@@ -540,7 +541,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
110268 return;
110269 }
110270
110271- posix_clocks[clock_id] = *new_clock;
110272+ posix_clocks[clock_id] = new_clock;
110273 }
110274 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
110275
110276@@ -586,9 +587,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
110277 return (id & CLOCKFD_MASK) == CLOCKFD ?
110278 &clock_posix_dynamic : &clock_posix_cpu;
110279
110280- if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
110281+ if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
110282 return NULL;
110283- return &posix_clocks[id];
110284+ return posix_clocks[id];
110285 }
110286
110287 static int common_timer_create(struct k_itimer *new_timer)
110288@@ -606,7 +607,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
110289 struct k_clock *kc = clockid_to_kclock(which_clock);
110290 struct k_itimer *new_timer;
110291 int error, new_timer_id;
110292- sigevent_t event;
110293+ sigevent_t event = { };
110294 int it_id_set = IT_ID_NOT_SET;
110295
110296 if (!kc)
110297@@ -1021,6 +1022,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
110298 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
110299 return -EFAULT;
110300
110301+ /* only the CLOCK_REALTIME clock can be set, all other clocks
110302+ have their clock_set fptr set to a nosettime dummy function
110303+ CLOCK_REALTIME has a NULL clock_set fptr which causes it to
110304+ call common_clock_set, which calls do_sys_settimeofday, which
110305+ we hook
110306+ */
110307+
110308 return kc->clock_set(which_clock, &new_tp);
110309 }
110310
110311diff --git a/kernel/time/time.c b/kernel/time/time.c
110312index 85d5bb1..aeca463 100644
110313--- a/kernel/time/time.c
110314+++ b/kernel/time/time.c
110315@@ -177,6 +177,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
110316 if (tz->tz_minuteswest > 15*60 || tz->tz_minuteswest < -15*60)
110317 return -EINVAL;
110318
110319+ /* we log in do_settimeofday called below, so don't log twice
110320+ */
110321+ if (!tv)
110322+ gr_log_timechange();
110323+
110324 sys_tz = *tz;
110325 update_vsyscall_tz();
110326 if (firsttime) {
110327diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
110328index a20d411..255b10a 100644
110329--- a/kernel/time/timekeeping.c
110330+++ b/kernel/time/timekeeping.c
110331@@ -15,6 +15,7 @@
110332 #include <linux/init.h>
110333 #include <linux/mm.h>
110334 #include <linux/sched.h>
110335+#include <linux/grsecurity.h>
110336 #include <linux/syscore_ops.h>
110337 #include <linux/clocksource.h>
110338 #include <linux/jiffies.h>
110339@@ -915,6 +916,8 @@ int do_settimeofday64(const struct timespec64 *ts)
110340 if (!timespec64_valid_strict(ts))
110341 return -EINVAL;
110342
110343+ gr_log_timechange();
110344+
110345 raw_spin_lock_irqsave(&timekeeper_lock, flags);
110346 write_seqcount_begin(&tk_core.seq);
110347
110348diff --git a/kernel/time/timer.c b/kernel/time/timer.c
110349index 84190f0..6f4ccad 100644
110350--- a/kernel/time/timer.c
110351+++ b/kernel/time/timer.c
110352@@ -1406,7 +1406,7 @@ void update_process_times(int user_tick)
110353 /*
110354 * This function runs timers and the timer-tq in bottom half context.
110355 */
110356-static void run_timer_softirq(struct softirq_action *h)
110357+static __latent_entropy void run_timer_softirq(void)
110358 {
110359 struct tvec_base *base = this_cpu_ptr(&tvec_bases);
110360
110361diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
110362index a4536e1..5d8774c 100644
110363--- a/kernel/time/timer_list.c
110364+++ b/kernel/time/timer_list.c
110365@@ -50,12 +50,16 @@ static void SEQ_printf(struct seq_file *m, const char *fmt, ...)
110366
110367 static void print_name_offset(struct seq_file *m, void *sym)
110368 {
110369+#ifdef CONFIG_GRKERNSEC_HIDESYM
110370+ SEQ_printf(m, "<%p>", NULL);
110371+#else
110372 char symname[KSYM_NAME_LEN];
110373
110374 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
110375 SEQ_printf(m, "<%pK>", sym);
110376 else
110377 SEQ_printf(m, "%s", symname);
110378+#endif
110379 }
110380
110381 static void
110382@@ -124,11 +128,14 @@ next_one:
110383 static void
110384 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
110385 {
110386+#ifdef CONFIG_GRKERNSEC_HIDESYM
110387+ SEQ_printf(m, " .base: %p\n", NULL);
110388+#else
110389 SEQ_printf(m, " .base: %pK\n", base);
110390+#endif
110391 SEQ_printf(m, " .index: %d\n", base->index);
110392
110393 SEQ_printf(m, " .resolution: %u nsecs\n", (unsigned) hrtimer_resolution);
110394-
110395 SEQ_printf(m, " .get_time: ");
110396 print_name_offset(m, base->get_time);
110397 SEQ_printf(m, "\n");
110398@@ -399,7 +406,11 @@ static int __init init_timer_list_procfs(void)
110399 {
110400 struct proc_dir_entry *pe;
110401
110402+#ifdef CONFIG_GRKERNSEC_PROC_ADD
110403+ pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
110404+#else
110405 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
110406+#endif
110407 if (!pe)
110408 return -ENOMEM;
110409 return 0;
110410diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
110411index 1adecb4..b4fb631 100644
110412--- a/kernel/time/timer_stats.c
110413+++ b/kernel/time/timer_stats.c
110414@@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
110415 static unsigned long nr_entries;
110416 static struct entry entries[MAX_ENTRIES];
110417
110418-static atomic_t overflow_count;
110419+static atomic_unchecked_t overflow_count;
110420
110421 /*
110422 * The entries are in a hash-table, for fast lookup:
110423@@ -140,7 +140,7 @@ static void reset_entries(void)
110424 nr_entries = 0;
110425 memset(entries, 0, sizeof(entries));
110426 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
110427- atomic_set(&overflow_count, 0);
110428+ atomic_set_unchecked(&overflow_count, 0);
110429 }
110430
110431 static struct entry *alloc_entry(void)
110432@@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
110433 if (likely(entry))
110434 entry->count++;
110435 else
110436- atomic_inc(&overflow_count);
110437+ atomic_inc_unchecked(&overflow_count);
110438
110439 out_unlock:
110440 raw_spin_unlock_irqrestore(lock, flags);
110441@@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
110442
110443 static void print_name_offset(struct seq_file *m, unsigned long addr)
110444 {
110445+#ifdef CONFIG_GRKERNSEC_HIDESYM
110446+ seq_printf(m, "<%p>", NULL);
110447+#else
110448 char symname[KSYM_NAME_LEN];
110449
110450 if (lookup_symbol_name(addr, symname) < 0)
110451- seq_printf(m, "<%p>", (void *)addr);
110452+ seq_printf(m, "<%pK>", (void *)addr);
110453 else
110454 seq_printf(m, "%s", symname);
110455+#endif
110456 }
110457
110458 static int tstats_show(struct seq_file *m, void *v)
110459@@ -300,8 +304,8 @@ static int tstats_show(struct seq_file *m, void *v)
110460
110461 seq_puts(m, "Timer Stats Version: v0.3\n");
110462 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
110463- if (atomic_read(&overflow_count))
110464- seq_printf(m, "Overflow: %d entries\n", atomic_read(&overflow_count));
110465+ if (atomic_read_unchecked(&overflow_count))
110466+ seq_printf(m, "Overflow: %d entries\n", atomic_read_unchecked(&overflow_count));
110467 seq_printf(m, "Collection: %s\n", timer_stats_active ? "active" : "inactive");
110468
110469 for (i = 0; i < nr_entries; i++) {
110470@@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
110471 {
110472 struct proc_dir_entry *pe;
110473
110474+#ifdef CONFIG_GRKERNSEC_PROC_ADD
110475+ pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
110476+#else
110477 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
110478+#endif
110479 if (!pe)
110480 return -ENOMEM;
110481 return 0;
110482diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
110483index 3b9a48a..6125816 100644
110484--- a/kernel/trace/Kconfig
110485+++ b/kernel/trace/Kconfig
110486@@ -120,6 +120,7 @@ config TRACING_SUPPORT
110487 # irqflags tracing for your architecture.
110488 depends on TRACE_IRQFLAGS_SUPPORT || PPC32
110489 depends on STACKTRACE_SUPPORT
110490+ depends on !GRKERNSEC_KMEM
110491 default y
110492
110493 if TRACING_SUPPORT
110494@@ -378,6 +379,7 @@ config BLK_DEV_IO_TRACE
110495 depends on BLOCK
110496 select RELAY
110497 select DEBUG_FS
110498+ depends on !GRKERNSEC_KMEM
110499 select TRACEPOINTS
110500 select GENERIC_TRACER
110501 select STACKTRACE
110502diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
110503index b3e6b39..719099b 100644
110504--- a/kernel/trace/blktrace.c
110505+++ b/kernel/trace/blktrace.c
110506@@ -328,7 +328,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
110507 struct blk_trace *bt = filp->private_data;
110508 char buf[16];
110509
110510- snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
110511+ snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
110512
110513 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
110514 }
110515@@ -386,7 +386,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
110516 return 1;
110517
110518 bt = buf->chan->private_data;
110519- atomic_inc(&bt->dropped);
110520+ atomic_inc_unchecked(&bt->dropped);
110521 return 0;
110522 }
110523
110524@@ -485,7 +485,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
110525
110526 bt->dir = dir;
110527 bt->dev = dev;
110528- atomic_set(&bt->dropped, 0);
110529+ atomic_set_unchecked(&bt->dropped, 0);
110530 INIT_LIST_HEAD(&bt->running_list);
110531
110532 ret = -EIO;
110533diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
110534index eb11011..43adc29 100644
110535--- a/kernel/trace/ftrace.c
110536+++ b/kernel/trace/ftrace.c
110537@@ -2413,12 +2413,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
110538 if (unlikely(ftrace_disabled))
110539 return 0;
110540
110541+ ret = ftrace_arch_code_modify_prepare();
110542+ FTRACE_WARN_ON(ret);
110543+ if (ret)
110544+ return 0;
110545+
110546 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
110547+ FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
110548 if (ret) {
110549 ftrace_bug(ret, rec);
110550- return 0;
110551 }
110552- return 1;
110553+ return ret ? 0 : 1;
110554 }
110555
110556 /*
110557@@ -4807,8 +4812,10 @@ static int ftrace_process_locs(struct module *mod,
110558 if (!count)
110559 return 0;
110560
110561+ pax_open_kernel();
110562 sort(start, count, sizeof(*start),
110563 ftrace_cmp_ips, ftrace_swap_ips);
110564+ pax_close_kernel();
110565
110566 start_pg = ftrace_allocate_pages(count);
110567 if (!start_pg)
110568@@ -5675,7 +5682,7 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list)
110569
110570 if (t->ret_stack == NULL) {
110571 atomic_set(&t->tracing_graph_pause, 0);
110572- atomic_set(&t->trace_overrun, 0);
110573+ atomic_set_unchecked(&t->trace_overrun, 0);
110574 t->curr_ret_stack = -1;
110575 /* Make sure the tasks see the -1 first: */
110576 smp_wmb();
110577@@ -5898,7 +5905,7 @@ static void
110578 graph_init_task(struct task_struct *t, struct ftrace_ret_stack *ret_stack)
110579 {
110580 atomic_set(&t->tracing_graph_pause, 0);
110581- atomic_set(&t->trace_overrun, 0);
110582+ atomic_set_unchecked(&t->trace_overrun, 0);
110583 t->ftrace_timestamp = 0;
110584 /* make curr_ret_stack visible before we add the ret_stack */
110585 smp_wmb();
110586diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
110587index 6260717..b9bd83c 100644
110588--- a/kernel/trace/ring_buffer.c
110589+++ b/kernel/trace/ring_buffer.c
110590@@ -296,9 +296,9 @@ struct buffer_data_page {
110591 */
110592 struct buffer_page {
110593 struct list_head list; /* list of buffer pages */
110594- local_t write; /* index for next write */
110595+ local_unchecked_t write; /* index for next write */
110596 unsigned read; /* index for next read */
110597- local_t entries; /* entries on this page */
110598+ local_unchecked_t entries; /* entries on this page */
110599 unsigned long real_end; /* real end of data */
110600 struct buffer_data_page *page; /* Actual data page */
110601 };
110602@@ -437,11 +437,11 @@ struct ring_buffer_per_cpu {
110603 unsigned long last_overrun;
110604 local_t entries_bytes;
110605 local_t entries;
110606- local_t overrun;
110607- local_t commit_overrun;
110608- local_t dropped_events;
110609+ local_unchecked_t overrun;
110610+ local_unchecked_t commit_overrun;
110611+ local_unchecked_t dropped_events;
110612 local_t committing;
110613- local_t commits;
110614+ local_unchecked_t commits;
110615 unsigned long read;
110616 unsigned long read_bytes;
110617 u64 write_stamp;
110618@@ -1011,8 +1011,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
110619 *
110620 * We add a counter to the write field to denote this.
110621 */
110622- old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
110623- old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
110624+ old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
110625+ old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
110626
110627 /*
110628 * Just make sure we have seen our old_write and synchronize
110629@@ -1040,8 +1040,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
110630 * cmpxchg to only update if an interrupt did not already
110631 * do it for us. If the cmpxchg fails, we don't care.
110632 */
110633- (void)local_cmpxchg(&next_page->write, old_write, val);
110634- (void)local_cmpxchg(&next_page->entries, old_entries, eval);
110635+ (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
110636+ (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
110637
110638 /*
110639 * No need to worry about races with clearing out the commit.
110640@@ -1409,12 +1409,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
110641
110642 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
110643 {
110644- return local_read(&bpage->entries) & RB_WRITE_MASK;
110645+ return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
110646 }
110647
110648 static inline unsigned long rb_page_write(struct buffer_page *bpage)
110649 {
110650- return local_read(&bpage->write) & RB_WRITE_MASK;
110651+ return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
110652 }
110653
110654 static int
110655@@ -1509,7 +1509,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
110656 * bytes consumed in ring buffer from here.
110657 * Increment overrun to account for the lost events.
110658 */
110659- local_add(page_entries, &cpu_buffer->overrun);
110660+ local_add_unchecked(page_entries, &cpu_buffer->overrun);
110661 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
110662 }
110663
110664@@ -2071,7 +2071,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
110665 * it is our responsibility to update
110666 * the counters.
110667 */
110668- local_add(entries, &cpu_buffer->overrun);
110669+ local_add_unchecked(entries, &cpu_buffer->overrun);
110670 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
110671
110672 /*
110673@@ -2221,7 +2221,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
110674 if (tail == BUF_PAGE_SIZE)
110675 tail_page->real_end = 0;
110676
110677- local_sub(length, &tail_page->write);
110678+ local_sub_unchecked(length, &tail_page->write);
110679 return;
110680 }
110681
110682@@ -2256,7 +2256,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
110683 rb_event_set_padding(event);
110684
110685 /* Set the write back to the previous setting */
110686- local_sub(length, &tail_page->write);
110687+ local_sub_unchecked(length, &tail_page->write);
110688 return;
110689 }
110690
110691@@ -2268,7 +2268,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
110692
110693 /* Set write to end of buffer */
110694 length = (tail + length) - BUF_PAGE_SIZE;
110695- local_sub(length, &tail_page->write);
110696+ local_sub_unchecked(length, &tail_page->write);
110697 }
110698
110699 /*
110700@@ -2294,7 +2294,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
110701 * about it.
110702 */
110703 if (unlikely(next_page == commit_page)) {
110704- local_inc(&cpu_buffer->commit_overrun);
110705+ local_inc_unchecked(&cpu_buffer->commit_overrun);
110706 goto out_reset;
110707 }
110708
110709@@ -2324,7 +2324,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
110710 * this is easy, just stop here.
110711 */
110712 if (!(buffer->flags & RB_FL_OVERWRITE)) {
110713- local_inc(&cpu_buffer->dropped_events);
110714+ local_inc_unchecked(&cpu_buffer->dropped_events);
110715 goto out_reset;
110716 }
110717
110718@@ -2350,7 +2350,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
110719 cpu_buffer->tail_page) &&
110720 (cpu_buffer->commit_page ==
110721 cpu_buffer->reader_page))) {
110722- local_inc(&cpu_buffer->commit_overrun);
110723+ local_inc_unchecked(&cpu_buffer->commit_overrun);
110724 goto out_reset;
110725 }
110726 }
110727@@ -2398,7 +2398,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
110728 length += RB_LEN_TIME_EXTEND;
110729
110730 tail_page = cpu_buffer->tail_page;
110731- write = local_add_return(length, &tail_page->write);
110732+ write = local_add_return_unchecked(length, &tail_page->write);
110733
110734 /* set write to only the index of the write */
110735 write &= RB_WRITE_MASK;
110736@@ -2422,7 +2422,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
110737 kmemcheck_annotate_bitfield(event, bitfield);
110738 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
110739
110740- local_inc(&tail_page->entries);
110741+ local_inc_unchecked(&tail_page->entries);
110742
110743 /*
110744 * If this is the first commit on the page, then update
110745@@ -2455,7 +2455,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
110746
110747 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
110748 unsigned long write_mask =
110749- local_read(&bpage->write) & ~RB_WRITE_MASK;
110750+ local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
110751 unsigned long event_length = rb_event_length(event);
110752 /*
110753 * This is on the tail page. It is possible that
110754@@ -2465,7 +2465,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
110755 */
110756 old_index += write_mask;
110757 new_index += write_mask;
110758- index = local_cmpxchg(&bpage->write, old_index, new_index);
110759+ index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
110760 if (index == old_index) {
110761 /* update counters */
110762 local_sub(event_length, &cpu_buffer->entries_bytes);
110763@@ -2480,7 +2480,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
110764 static void rb_start_commit(struct ring_buffer_per_cpu *cpu_buffer)
110765 {
110766 local_inc(&cpu_buffer->committing);
110767- local_inc(&cpu_buffer->commits);
110768+ local_inc_unchecked(&cpu_buffer->commits);
110769 }
110770
110771 static inline void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer)
110772@@ -2492,7 +2492,7 @@ static inline void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer)
110773 return;
110774
110775 again:
110776- commits = local_read(&cpu_buffer->commits);
110777+ commits = local_read_unchecked(&cpu_buffer->commits);
110778 /* synchronize with interrupts */
110779 barrier();
110780 if (local_read(&cpu_buffer->committing) == 1)
110781@@ -2508,7 +2508,7 @@ static inline void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer)
110782 * updating of the commit page and the clearing of the
110783 * committing counter.
110784 */
110785- if (unlikely(local_read(&cpu_buffer->commits) != commits) &&
110786+ if (unlikely(local_read_unchecked(&cpu_buffer->commits) != commits) &&
110787 !local_read(&cpu_buffer->committing)) {
110788 local_inc(&cpu_buffer->committing);
110789 goto again;
110790@@ -2538,7 +2538,7 @@ rb_reserve_next_event(struct ring_buffer *buffer,
110791 barrier();
110792 if (unlikely(ACCESS_ONCE(cpu_buffer->buffer) != buffer)) {
110793 local_dec(&cpu_buffer->committing);
110794- local_dec(&cpu_buffer->commits);
110795+ local_dec_unchecked(&cpu_buffer->commits);
110796 return NULL;
110797 }
110798 #endif
110799@@ -2852,7 +2852,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
110800
110801 /* Do the likely case first */
110802 if (likely(bpage->page == (void *)addr)) {
110803- local_dec(&bpage->entries);
110804+ local_dec_unchecked(&bpage->entries);
110805 return;
110806 }
110807
110808@@ -2864,7 +2864,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
110809 start = bpage;
110810 do {
110811 if (bpage->page == (void *)addr) {
110812- local_dec(&bpage->entries);
110813+ local_dec_unchecked(&bpage->entries);
110814 return;
110815 }
110816 rb_inc_page(cpu_buffer, &bpage);
110817@@ -3152,7 +3152,7 @@ static inline unsigned long
110818 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
110819 {
110820 return local_read(&cpu_buffer->entries) -
110821- (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
110822+ (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
110823 }
110824
110825 /**
110826@@ -3241,7 +3241,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
110827 return 0;
110828
110829 cpu_buffer = buffer->buffers[cpu];
110830- ret = local_read(&cpu_buffer->overrun);
110831+ ret = local_read_unchecked(&cpu_buffer->overrun);
110832
110833 return ret;
110834 }
110835@@ -3264,7 +3264,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
110836 return 0;
110837
110838 cpu_buffer = buffer->buffers[cpu];
110839- ret = local_read(&cpu_buffer->commit_overrun);
110840+ ret = local_read_unchecked(&cpu_buffer->commit_overrun);
110841
110842 return ret;
110843 }
110844@@ -3286,7 +3286,7 @@ ring_buffer_dropped_events_cpu(struct ring_buffer *buffer, int cpu)
110845 return 0;
110846
110847 cpu_buffer = buffer->buffers[cpu];
110848- ret = local_read(&cpu_buffer->dropped_events);
110849+ ret = local_read_unchecked(&cpu_buffer->dropped_events);
110850
110851 return ret;
110852 }
110853@@ -3349,7 +3349,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
110854 /* if you care about this being correct, lock the buffer */
110855 for_each_buffer_cpu(buffer, cpu) {
110856 cpu_buffer = buffer->buffers[cpu];
110857- overruns += local_read(&cpu_buffer->overrun);
110858+ overruns += local_read_unchecked(&cpu_buffer->overrun);
110859 }
110860
110861 return overruns;
110862@@ -3520,8 +3520,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
110863 /*
110864 * Reset the reader page to size zero.
110865 */
110866- local_set(&cpu_buffer->reader_page->write, 0);
110867- local_set(&cpu_buffer->reader_page->entries, 0);
110868+ local_set_unchecked(&cpu_buffer->reader_page->write, 0);
110869+ local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
110870 local_set(&cpu_buffer->reader_page->page->commit, 0);
110871 cpu_buffer->reader_page->real_end = 0;
110872
110873@@ -3555,7 +3555,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
110874 * want to compare with the last_overrun.
110875 */
110876 smp_mb();
110877- overwrite = local_read(&(cpu_buffer->overrun));
110878+ overwrite = local_read_unchecked(&(cpu_buffer->overrun));
110879
110880 /*
110881 * Here's the tricky part.
110882@@ -4137,8 +4137,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
110883
110884 cpu_buffer->head_page
110885 = list_entry(cpu_buffer->pages, struct buffer_page, list);
110886- local_set(&cpu_buffer->head_page->write, 0);
110887- local_set(&cpu_buffer->head_page->entries, 0);
110888+ local_set_unchecked(&cpu_buffer->head_page->write, 0);
110889+ local_set_unchecked(&cpu_buffer->head_page->entries, 0);
110890 local_set(&cpu_buffer->head_page->page->commit, 0);
110891
110892 cpu_buffer->head_page->read = 0;
110893@@ -4148,18 +4148,18 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
110894
110895 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
110896 INIT_LIST_HEAD(&cpu_buffer->new_pages);
110897- local_set(&cpu_buffer->reader_page->write, 0);
110898- local_set(&cpu_buffer->reader_page->entries, 0);
110899+ local_set_unchecked(&cpu_buffer->reader_page->write, 0);
110900+ local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
110901 local_set(&cpu_buffer->reader_page->page->commit, 0);
110902 cpu_buffer->reader_page->read = 0;
110903
110904 local_set(&cpu_buffer->entries_bytes, 0);
110905- local_set(&cpu_buffer->overrun, 0);
110906- local_set(&cpu_buffer->commit_overrun, 0);
110907- local_set(&cpu_buffer->dropped_events, 0);
110908+ local_set_unchecked(&cpu_buffer->overrun, 0);
110909+ local_set_unchecked(&cpu_buffer->commit_overrun, 0);
110910+ local_set_unchecked(&cpu_buffer->dropped_events, 0);
110911 local_set(&cpu_buffer->entries, 0);
110912 local_set(&cpu_buffer->committing, 0);
110913- local_set(&cpu_buffer->commits, 0);
110914+ local_set_unchecked(&cpu_buffer->commits, 0);
110915 cpu_buffer->read = 0;
110916 cpu_buffer->read_bytes = 0;
110917
110918@@ -4549,8 +4549,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
110919 rb_init_page(bpage);
110920 bpage = reader->page;
110921 reader->page = *data_page;
110922- local_set(&reader->write, 0);
110923- local_set(&reader->entries, 0);
110924+ local_set_unchecked(&reader->write, 0);
110925+ local_set_unchecked(&reader->entries, 0);
110926 reader->read = 0;
110927 *data_page = bpage;
110928
110929diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
110930index abcbf7f..ef8b6fe 100644
110931--- a/kernel/trace/trace.c
110932+++ b/kernel/trace/trace.c
110933@@ -3539,7 +3539,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
110934 return 0;
110935 }
110936
110937-int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
110938+int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
110939 {
110940 /* do nothing if flag is already set */
110941 if (!!(trace_flags & mask) == !!enabled)
110942diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
110943index 74bde81..f9abfd4 100644
110944--- a/kernel/trace/trace.h
110945+++ b/kernel/trace/trace.h
110946@@ -1272,7 +1272,7 @@ extern const char *__stop___tracepoint_str[];
110947 void trace_printk_init_buffers(void);
110948 void trace_printk_start_comm(void);
110949 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
110950-int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
110951+int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
110952
110953 /*
110954 * Normal trace_printk() and friends allocates special buffers
110955diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
110956index 0f06532..247c8e7 100644
110957--- a/kernel/trace/trace_clock.c
110958+++ b/kernel/trace/trace_clock.c
110959@@ -127,7 +127,7 @@ u64 notrace trace_clock_global(void)
110960 }
110961 EXPORT_SYMBOL_GPL(trace_clock_global);
110962
110963-static atomic64_t trace_counter;
110964+static atomic64_unchecked_t trace_counter;
110965
110966 /*
110967 * trace_clock_counter(): simply an atomic counter.
110968@@ -136,5 +136,5 @@ static atomic64_t trace_counter;
110969 */
110970 u64 notrace trace_clock_counter(void)
110971 {
110972- return atomic64_add_return(1, &trace_counter);
110973+ return atomic64_inc_return_unchecked(&trace_counter);
110974 }
110975diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
110976index 404a372..d9e5547 100644
110977--- a/kernel/trace/trace_events.c
110978+++ b/kernel/trace/trace_events.c
110979@@ -1887,7 +1887,6 @@ __trace_early_add_new_event(struct trace_event_call *call,
110980 return 0;
110981 }
110982
110983-struct ftrace_module_file_ops;
110984 static void __add_event_to_tracers(struct trace_event_call *call);
110985
110986 /* Add an additional event_call dynamically */
110987diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
110988index 8968bf7..e6623fc 100644
110989--- a/kernel/trace/trace_functions_graph.c
110990+++ b/kernel/trace/trace_functions_graph.c
110991@@ -132,7 +132,7 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
110992
110993 /* The return trace stack is full */
110994 if (current->curr_ret_stack == FTRACE_RETFUNC_DEPTH - 1) {
110995- atomic_inc(&current->trace_overrun);
110996+ atomic_inc_unchecked(&current->trace_overrun);
110997 return -EBUSY;
110998 }
110999
111000@@ -229,7 +229,7 @@ ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret,
111001 *ret = current->ret_stack[index].ret;
111002 trace->func = current->ret_stack[index].func;
111003 trace->calltime = current->ret_stack[index].calltime;
111004- trace->overrun = atomic_read(&current->trace_overrun);
111005+ trace->overrun = atomic_read_unchecked(&current->trace_overrun);
111006 trace->depth = index;
111007 }
111008
111009diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
111010index 638e110..99b73b2 100644
111011--- a/kernel/trace/trace_mmiotrace.c
111012+++ b/kernel/trace/trace_mmiotrace.c
111013@@ -24,7 +24,7 @@ struct header_iter {
111014 static struct trace_array *mmio_trace_array;
111015 static bool overrun_detected;
111016 static unsigned long prev_overruns;
111017-static atomic_t dropped_count;
111018+static atomic_unchecked_t dropped_count;
111019
111020 static void mmio_reset_data(struct trace_array *tr)
111021 {
111022@@ -124,7 +124,7 @@ static void mmio_close(struct trace_iterator *iter)
111023
111024 static unsigned long count_overruns(struct trace_iterator *iter)
111025 {
111026- unsigned long cnt = atomic_xchg(&dropped_count, 0);
111027+ unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
111028 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
111029
111030 if (over > prev_overruns)
111031@@ -307,7 +307,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
111032 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
111033 sizeof(*entry), 0, pc);
111034 if (!event) {
111035- atomic_inc(&dropped_count);
111036+ atomic_inc_unchecked(&dropped_count);
111037 return;
111038 }
111039 entry = ring_buffer_event_data(event);
111040@@ -337,7 +337,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
111041 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
111042 sizeof(*entry), 0, pc);
111043 if (!event) {
111044- atomic_inc(&dropped_count);
111045+ atomic_inc_unchecked(&dropped_count);
111046 return;
111047 }
111048 entry = ring_buffer_event_data(event);
111049diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
111050index dfab253..8e9b477 100644
111051--- a/kernel/trace/trace_output.c
111052+++ b/kernel/trace/trace_output.c
111053@@ -752,14 +752,16 @@ int register_trace_event(struct trace_event *event)
111054 goto out;
111055 }
111056
111057+ pax_open_kernel();
111058 if (event->funcs->trace == NULL)
111059- event->funcs->trace = trace_nop_print;
111060+ *(void **)&event->funcs->trace = trace_nop_print;
111061 if (event->funcs->raw == NULL)
111062- event->funcs->raw = trace_nop_print;
111063+ *(void **)&event->funcs->raw = trace_nop_print;
111064 if (event->funcs->hex == NULL)
111065- event->funcs->hex = trace_nop_print;
111066+ *(void **)&event->funcs->hex = trace_nop_print;
111067 if (event->funcs->binary == NULL)
111068- event->funcs->binary = trace_nop_print;
111069+ *(void **)&event->funcs->binary = trace_nop_print;
111070+ pax_close_kernel();
111071
111072 key = event->type & (EVENT_HASHSIZE - 1);
111073
111074diff --git a/kernel/trace/trace_seq.c b/kernel/trace/trace_seq.c
111075index e694c9f..6775a38 100644
111076--- a/kernel/trace/trace_seq.c
111077+++ b/kernel/trace/trace_seq.c
111078@@ -337,7 +337,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
111079 return 0;
111080 }
111081
111082- seq_buf_path(&s->seq, path, "\n");
111083+ seq_buf_path(&s->seq, path, "\n\\");
111084
111085 if (unlikely(seq_buf_has_overflowed(&s->seq))) {
111086 s->seq.len = save_len;
111087diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
111088index 3f34496..0492d95 100644
111089--- a/kernel/trace/trace_stack.c
111090+++ b/kernel/trace/trace_stack.c
111091@@ -88,7 +88,7 @@ check_stack(unsigned long ip, unsigned long *stack)
111092 return;
111093
111094 /* we do not handle interrupt stacks yet */
111095- if (!object_is_on_stack(stack))
111096+ if (!object_starts_on_stack(stack))
111097 return;
111098
111099 local_irq_save(flags);
111100diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
111101index 7d567a4..407a28d 100644
111102--- a/kernel/trace/trace_syscalls.c
111103+++ b/kernel/trace/trace_syscalls.c
111104@@ -590,6 +590,8 @@ static int perf_sysenter_enable(struct trace_event_call *call)
111105 int num;
111106
111107 num = ((struct syscall_metadata *)call->data)->syscall_nr;
111108+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
111109+ return -EINVAL;
111110
111111 mutex_lock(&syscall_trace_lock);
111112 if (!sys_perf_refcount_enter)
111113@@ -610,6 +612,8 @@ static void perf_sysenter_disable(struct trace_event_call *call)
111114 int num;
111115
111116 num = ((struct syscall_metadata *)call->data)->syscall_nr;
111117+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
111118+ return;
111119
111120 mutex_lock(&syscall_trace_lock);
111121 sys_perf_refcount_enter--;
111122@@ -662,6 +666,8 @@ static int perf_sysexit_enable(struct trace_event_call *call)
111123 int num;
111124
111125 num = ((struct syscall_metadata *)call->data)->syscall_nr;
111126+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
111127+ return -EINVAL;
111128
111129 mutex_lock(&syscall_trace_lock);
111130 if (!sys_perf_refcount_exit)
111131@@ -682,6 +688,8 @@ static void perf_sysexit_disable(struct trace_event_call *call)
111132 int num;
111133
111134 num = ((struct syscall_metadata *)call->data)->syscall_nr;
111135+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
111136+ return;
111137
111138 mutex_lock(&syscall_trace_lock);
111139 sys_perf_refcount_exit--;
111140diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
111141index 4109f83..fe1f830 100644
111142--- a/kernel/user_namespace.c
111143+++ b/kernel/user_namespace.c
111144@@ -83,6 +83,21 @@ int create_user_ns(struct cred *new)
111145 !kgid_has_mapping(parent_ns, group))
111146 return -EPERM;
111147
111148+#ifdef CONFIG_GRKERNSEC
111149+ /*
111150+ * This doesn't really inspire confidence:
111151+ * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
111152+ * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
111153+ * Increases kernel attack surface in areas developers
111154+ * previously cared little about ("low importance due
111155+ * to requiring "root" capability")
111156+ * To be removed when this code receives *proper* review
111157+ */
111158+ if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
111159+ !capable(CAP_SETGID))
111160+ return -EPERM;
111161+#endif
111162+
111163 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
111164 if (!ns)
111165 return -ENOMEM;
111166@@ -980,7 +995,7 @@ static int userns_install(struct nsproxy *nsproxy, struct ns_common *ns)
111167 if (atomic_read(&current->mm->mm_users) > 1)
111168 return -EINVAL;
111169
111170- if (current->fs->users != 1)
111171+ if (atomic_read(&current->fs->users) != 1)
111172 return -EINVAL;
111173
111174 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
111175diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
111176index c8eac43..4b5f08f 100644
111177--- a/kernel/utsname_sysctl.c
111178+++ b/kernel/utsname_sysctl.c
111179@@ -47,7 +47,7 @@ static void put_uts(struct ctl_table *table, int write, void *which)
111180 static int proc_do_uts_string(struct ctl_table *table, int write,
111181 void __user *buffer, size_t *lenp, loff_t *ppos)
111182 {
111183- struct ctl_table uts_table;
111184+ ctl_table_no_const uts_table;
111185 int r;
111186 memcpy(&uts_table, table, sizeof(uts_table));
111187 uts_table.data = get_uts(table, write);
111188diff --git a/kernel/watchdog.c b/kernel/watchdog.c
111189index a6ffa43..e48103b 100644
111190--- a/kernel/watchdog.c
111191+++ b/kernel/watchdog.c
111192@@ -655,7 +655,7 @@ void watchdog_nmi_enable_all(void) {}
111193 void watchdog_nmi_disable_all(void) {}
111194 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
111195
111196-static struct smp_hotplug_thread watchdog_threads = {
111197+static struct smp_hotplug_thread watchdog_threads __read_only = {
111198 .store = &softlockup_watchdog,
111199 .thread_should_run = watchdog_should_run,
111200 .thread_fn = watchdog,
111201diff --git a/kernel/workqueue.c b/kernel/workqueue.c
111202index a413acb..9c3d36a 100644
111203--- a/kernel/workqueue.c
111204+++ b/kernel/workqueue.c
111205@@ -4452,7 +4452,7 @@ static void rebind_workers(struct worker_pool *pool)
111206 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
111207 worker_flags |= WORKER_REBOUND;
111208 worker_flags &= ~WORKER_UNBOUND;
111209- ACCESS_ONCE(worker->flags) = worker_flags;
111210+ ACCESS_ONCE_RW(worker->flags) = worker_flags;
111211 }
111212
111213 spin_unlock_irq(&pool->lock);
111214diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
111215index e2894b2..23751b3 100644
111216--- a/lib/Kconfig.debug
111217+++ b/lib/Kconfig.debug
111218@@ -242,6 +242,7 @@ config PAGE_OWNER
111219 bool "Track page owner"
111220 depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
111221 select DEBUG_FS
111222+ depends on !GRKERNSEC_KMEM
111223 select STACKTRACE
111224 select PAGE_EXTENSION
111225 help
111226@@ -256,6 +257,7 @@ config PAGE_OWNER
111227
111228 config DEBUG_FS
111229 bool "Debug Filesystem"
111230+ depends on !GRKERNSEC_KMEM
111231 help
111232 debugfs is a virtual file system that kernel developers use to put
111233 debugging files into. Enable this option to be able to read and
111234@@ -488,6 +490,7 @@ config DEBUG_KMEMLEAK
111235 bool "Kernel memory leak detector"
111236 depends on DEBUG_KERNEL && HAVE_DEBUG_KMEMLEAK
111237 select DEBUG_FS
111238+ depends on !GRKERNSEC_KMEM
111239 select STACKTRACE if STACKTRACE_SUPPORT
111240 select KALLSYMS
111241 select CRC32
111242@@ -941,7 +944,7 @@ config DEBUG_MUTEXES
111243
111244 config DEBUG_WW_MUTEX_SLOWPATH
111245 bool "Wait/wound mutex debugging: Slowpath testing"
111246- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
111247+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
111248 select DEBUG_LOCK_ALLOC
111249 select DEBUG_SPINLOCK
111250 select DEBUG_MUTEXES
111251@@ -958,7 +961,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
111252
111253 config DEBUG_LOCK_ALLOC
111254 bool "Lock debugging: detect incorrect freeing of live locks"
111255- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
111256+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
111257 select DEBUG_SPINLOCK
111258 select DEBUG_MUTEXES
111259 select LOCKDEP
111260@@ -972,7 +975,7 @@ config DEBUG_LOCK_ALLOC
111261
111262 config PROVE_LOCKING
111263 bool "Lock debugging: prove locking correctness"
111264- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
111265+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
111266 select LOCKDEP
111267 select DEBUG_SPINLOCK
111268 select DEBUG_MUTEXES
111269@@ -1023,7 +1026,7 @@ config LOCKDEP
111270
111271 config LOCK_STAT
111272 bool "Lock usage statistics"
111273- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
111274+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
111275 select LOCKDEP
111276 select DEBUG_SPINLOCK
111277 select DEBUG_MUTEXES
111278@@ -1422,6 +1425,7 @@ config NOTIFIER_ERROR_INJECTION
111279 tristate "Notifier error injection"
111280 depends on DEBUG_KERNEL
111281 select DEBUG_FS
111282+ depends on !GRKERNSEC_KMEM
111283 help
111284 This option provides the ability to inject artificial errors to
111285 specified notifier chain callbacks. It is useful to test the error
111286@@ -1534,6 +1538,7 @@ config FAIL_IO_TIMEOUT
111287 config FAIL_MMC_REQUEST
111288 bool "Fault-injection capability for MMC IO"
111289 select DEBUG_FS
111290+ depends on !GRKERNSEC_KMEM
111291 depends on FAULT_INJECTION && MMC
111292 help
111293 Provide fault-injection capability for MMC IO.
111294@@ -1563,6 +1568,7 @@ config LATENCYTOP
111295 depends on DEBUG_KERNEL
111296 depends on STACKTRACE_SUPPORT
111297 depends on PROC_FS
111298+ depends on !GRKERNSEC_HIDESYM
111299 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC
111300 select KALLSYMS
111301 select KALLSYMS_ALL
111302@@ -1579,7 +1585,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
111303 config DEBUG_STRICT_USER_COPY_CHECKS
111304 bool "Strict user copy size checks"
111305 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
111306- depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
111307+ depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
111308 help
111309 Enabling this option turns a certain set of sanity checks for user
111310 copy operations into compile time failures.
111311@@ -1710,7 +1716,7 @@ endmenu # runtime tests
111312
111313 config PROVIDE_OHCI1394_DMA_INIT
111314 bool "Remote debugging over FireWire early on boot"
111315- depends on PCI && X86
111316+ depends on PCI && X86 && !GRKERNSEC
111317 help
111318 If you want to debug problems which hang or crash the kernel early
111319 on boot and the crashing machine has a FireWire port, you can use
111320diff --git a/lib/Makefile b/lib/Makefile
111321index 6897b52..466bda9 100644
111322--- a/lib/Makefile
111323+++ b/lib/Makefile
111324@@ -62,7 +62,7 @@ obj-$(CONFIG_BTREE) += btree.o
111325 obj-$(CONFIG_INTERVAL_TREE) += interval_tree.o
111326 obj-$(CONFIG_ASSOCIATIVE_ARRAY) += assoc_array.o
111327 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
111328-obj-$(CONFIG_DEBUG_LIST) += list_debug.o
111329+obj-y += list_debug.o
111330 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
111331
111332 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
111333diff --git a/lib/average.c b/lib/average.c
111334index 114d1be..ab0350c 100644
111335--- a/lib/average.c
111336+++ b/lib/average.c
111337@@ -55,7 +55,7 @@ struct ewma *ewma_add(struct ewma *avg, unsigned long val)
111338 {
111339 unsigned long internal = ACCESS_ONCE(avg->internal);
111340
111341- ACCESS_ONCE(avg->internal) = internal ?
111342+ ACCESS_ONCE_RW(avg->internal) = internal ?
111343 (((internal << avg->weight) - internal) +
111344 (val << avg->factor)) >> avg->weight :
111345 (val << avg->factor);
111346diff --git a/lib/bitmap.c b/lib/bitmap.c
111347index a578a01..2198e50 100644
111348--- a/lib/bitmap.c
111349+++ b/lib/bitmap.c
111350@@ -361,7 +361,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
111351 {
111352 int c, old_c, totaldigits, ndigits, nchunks, nbits;
111353 u32 chunk;
111354- const char __user __force *ubuf = (const char __user __force *)buf;
111355+ const char __user *ubuf = (const char __force_user *)buf;
111356
111357 bitmap_zero(maskp, nmaskbits);
111358
111359@@ -446,7 +446,7 @@ int bitmap_parse_user(const char __user *ubuf,
111360 {
111361 if (!access_ok(VERIFY_READ, ubuf, ulen))
111362 return -EFAULT;
111363- return __bitmap_parse((const char __force *)ubuf,
111364+ return __bitmap_parse((const char __force_kernel *)ubuf,
111365 ulen, 1, maskp, nmaskbits);
111366
111367 }
111368@@ -506,7 +506,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
111369 {
111370 unsigned a, b;
111371 int c, old_c, totaldigits;
111372- const char __user __force *ubuf = (const char __user __force *)buf;
111373+ const char __user *ubuf = (const char __force_user *)buf;
111374 int at_start, in_range;
111375
111376 totaldigits = c = 0;
111377@@ -602,7 +602,7 @@ int bitmap_parselist_user(const char __user *ubuf,
111378 {
111379 if (!access_ok(VERIFY_READ, ubuf, ulen))
111380 return -EFAULT;
111381- return __bitmap_parselist((const char __force *)ubuf,
111382+ return __bitmap_parselist((const char __force_kernel *)ubuf,
111383 ulen, 1, maskp, nmaskbits);
111384 }
111385 EXPORT_SYMBOL(bitmap_parselist_user);
111386diff --git a/lib/bug.c b/lib/bug.c
111387index cff145f..724a0b8 100644
111388--- a/lib/bug.c
111389+++ b/lib/bug.c
111390@@ -148,6 +148,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
111391 return BUG_TRAP_TYPE_NONE;
111392
111393 bug = find_bug(bugaddr);
111394+ if (!bug)
111395+ return BUG_TRAP_TYPE_NONE;
111396
111397 file = NULL;
111398 line = 0;
111399diff --git a/lib/debugobjects.c b/lib/debugobjects.c
111400index 547f7f9..a6d4ba0 100644
111401--- a/lib/debugobjects.c
111402+++ b/lib/debugobjects.c
111403@@ -289,7 +289,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
111404 if (limit > 4)
111405 return;
111406
111407- is_on_stack = object_is_on_stack(addr);
111408+ is_on_stack = object_starts_on_stack(addr);
111409 if (is_on_stack == onstack)
111410 return;
111411
111412diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c
111413index 0234361..41a411c 100644
111414--- a/lib/decompress_bunzip2.c
111415+++ b/lib/decompress_bunzip2.c
111416@@ -665,7 +665,8 @@ static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, long len,
111417
111418 /* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
111419 uncompressed data. Allocate intermediate buffer for block. */
111420- bd->dbufSize = 100000*(i-BZh0);
111421+ i -= BZh0;
111422+ bd->dbufSize = 100000 * i;
111423
111424 bd->dbuf = large_malloc(bd->dbufSize * sizeof(int));
111425 if (!bd->dbuf)
111426diff --git a/lib/decompress_unlzma.c b/lib/decompress_unlzma.c
111427index decb646..8d6441a 100644
111428--- a/lib/decompress_unlzma.c
111429+++ b/lib/decompress_unlzma.c
111430@@ -39,10 +39,10 @@
111431
111432 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
111433
111434-static long long INIT read_int(unsigned char *ptr, int size)
111435+static unsigned long long INIT read_int(unsigned char *ptr, int size)
111436 {
111437 int i;
111438- long long ret = 0;
111439+ unsigned long long ret = 0;
111440
111441 for (i = 0; i < size; i++)
111442 ret = (ret << 8) | ptr[size-i-1];
111443diff --git a/lib/div64.c b/lib/div64.c
111444index 19ea7ed..20cac21 100644
111445--- a/lib/div64.c
111446+++ b/lib/div64.c
111447@@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
111448 EXPORT_SYMBOL(__div64_32);
111449
111450 #ifndef div_s64_rem
111451-s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
111452+s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
111453 {
111454 u64 quotient;
111455
111456@@ -130,7 +130,7 @@ EXPORT_SYMBOL(div64_u64_rem);
111457 * 'http://www.hackersdelight.org/hdcodetxt/divDouble.c.txt'
111458 */
111459 #ifndef div64_u64
111460-u64 div64_u64(u64 dividend, u64 divisor)
111461+u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
111462 {
111463 u32 high = divisor >> 32;
111464 u64 quot;
111465diff --git a/lib/dma-debug.c b/lib/dma-debug.c
111466index dace71f..13da37b 100644
111467--- a/lib/dma-debug.c
111468+++ b/lib/dma-debug.c
111469@@ -982,7 +982,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
111470
111471 void dma_debug_add_bus(struct bus_type *bus)
111472 {
111473- struct notifier_block *nb;
111474+ notifier_block_no_const *nb;
111475
111476 if (dma_debug_disabled())
111477 return;
111478@@ -1164,7 +1164,7 @@ static void check_unmap(struct dma_debug_entry *ref)
111479
111480 static void check_for_stack(struct device *dev, void *addr)
111481 {
111482- if (object_is_on_stack(addr))
111483+ if (object_starts_on_stack(addr))
111484 err_printk(dev, NULL, "DMA-API: device driver maps memory from "
111485 "stack [addr=%p]\n", addr);
111486 }
111487diff --git a/lib/inflate.c b/lib/inflate.c
111488index 013a761..c28f3fc 100644
111489--- a/lib/inflate.c
111490+++ b/lib/inflate.c
111491@@ -269,7 +269,7 @@ static void free(void *where)
111492 malloc_ptr = free_mem_ptr;
111493 }
111494 #else
111495-#define malloc(a) kmalloc(a, GFP_KERNEL)
111496+#define malloc(a) kmalloc((a), GFP_KERNEL)
111497 #define free(a) kfree(a)
111498 #endif
111499
111500diff --git a/lib/ioremap.c b/lib/ioremap.c
111501index 86c8911..f5bfc34 100644
111502--- a/lib/ioremap.c
111503+++ b/lib/ioremap.c
111504@@ -75,7 +75,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
111505 unsigned long next;
111506
111507 phys_addr -= addr;
111508- pmd = pmd_alloc(&init_mm, pud, addr);
111509+ pmd = pmd_alloc_kernel(&init_mm, pud, addr);
111510 if (!pmd)
111511 return -ENOMEM;
111512 do {
111513@@ -101,7 +101,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
111514 unsigned long next;
111515
111516 phys_addr -= addr;
111517- pud = pud_alloc(&init_mm, pgd, addr);
111518+ pud = pud_alloc_kernel(&init_mm, pgd, addr);
111519 if (!pud)
111520 return -ENOMEM;
111521 do {
111522diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
111523index bd2bea9..6b3c95e 100644
111524--- a/lib/is_single_threaded.c
111525+++ b/lib/is_single_threaded.c
111526@@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
111527 struct task_struct *p, *t;
111528 bool ret;
111529
111530+ if (!mm)
111531+ return true;
111532+
111533 if (atomic_read(&task->signal->live) != 1)
111534 return false;
111535
111536diff --git a/lib/kobject.c b/lib/kobject.c
111537index 3e3a5c3..4a12109 100644
111538--- a/lib/kobject.c
111539+++ b/lib/kobject.c
111540@@ -935,9 +935,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
111541
111542
111543 static DEFINE_SPINLOCK(kobj_ns_type_lock);
111544-static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
111545+static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
111546
111547-int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
111548+int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
111549 {
111550 enum kobj_ns_type type = ops->type;
111551 int error;
111552diff --git a/lib/list_debug.c b/lib/list_debug.c
111553index c24c2f7..f0296f4 100644
111554--- a/lib/list_debug.c
111555+++ b/lib/list_debug.c
111556@@ -11,7 +11,9 @@
111557 #include <linux/bug.h>
111558 #include <linux/kernel.h>
111559 #include <linux/rculist.h>
111560+#include <linux/mm.h>
111561
111562+#ifdef CONFIG_DEBUG_LIST
111563 /*
111564 * Insert a new entry between two known consecutive entries.
111565 *
111566@@ -19,21 +21,40 @@
111567 * the prev/next entries already!
111568 */
111569
111570+static bool __list_add_debug(struct list_head *new,
111571+ struct list_head *prev,
111572+ struct list_head *next)
111573+{
111574+ if (unlikely(next->prev != prev)) {
111575+ printk(KERN_ERR "list_add corruption. next->prev should be "
111576+ "prev (%p), but was %p. (next=%p).\n",
111577+ prev, next->prev, next);
111578+ BUG();
111579+ return false;
111580+ }
111581+ if (unlikely(prev->next != next)) {
111582+ printk(KERN_ERR "list_add corruption. prev->next should be "
111583+ "next (%p), but was %p. (prev=%p).\n",
111584+ next, prev->next, prev);
111585+ BUG();
111586+ return false;
111587+ }
111588+ if (unlikely(new == prev || new == next)) {
111589+ printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
111590+ new, prev, next);
111591+ BUG();
111592+ return false;
111593+ }
111594+ return true;
111595+}
111596+
111597 void __list_add(struct list_head *new,
111598- struct list_head *prev,
111599- struct list_head *next)
111600+ struct list_head *prev,
111601+ struct list_head *next)
111602 {
111603- WARN(next->prev != prev,
111604- "list_add corruption. next->prev should be "
111605- "prev (%p), but was %p. (next=%p).\n",
111606- prev, next->prev, next);
111607- WARN(prev->next != next,
111608- "list_add corruption. prev->next should be "
111609- "next (%p), but was %p. (prev=%p).\n",
111610- next, prev->next, prev);
111611- WARN(new == prev || new == next,
111612- "list_add double add: new=%p, prev=%p, next=%p.\n",
111613- new, prev, next);
111614+ if (!__list_add_debug(new, prev, next))
111615+ return;
111616+
111617 next->prev = new;
111618 new->next = next;
111619 new->prev = prev;
111620@@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
111621 }
111622 EXPORT_SYMBOL(__list_add);
111623
111624-void __list_del_entry(struct list_head *entry)
111625+static bool __list_del_entry_debug(struct list_head *entry)
111626 {
111627 struct list_head *prev, *next;
111628
111629 prev = entry->prev;
111630 next = entry->next;
111631
111632- if (WARN(next == LIST_POISON1,
111633- "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
111634- entry, LIST_POISON1) ||
111635- WARN(prev == LIST_POISON2,
111636- "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
111637- entry, LIST_POISON2) ||
111638- WARN(prev->next != entry,
111639- "list_del corruption. prev->next should be %p, "
111640- "but was %p\n", entry, prev->next) ||
111641- WARN(next->prev != entry,
111642- "list_del corruption. next->prev should be %p, "
111643- "but was %p\n", entry, next->prev))
111644+ if (unlikely(next == LIST_POISON1)) {
111645+ printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
111646+ entry, LIST_POISON1);
111647+ BUG();
111648+ return false;
111649+ }
111650+ if (unlikely(prev == LIST_POISON2)) {
111651+ printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
111652+ entry, LIST_POISON2);
111653+ BUG();
111654+ return false;
111655+ }
111656+ if (unlikely(entry->prev->next != entry)) {
111657+ printk(KERN_ERR "list_del corruption. prev->next should be %p, "
111658+ "but was %p\n", entry, prev->next);
111659+ BUG();
111660+ return false;
111661+ }
111662+ if (unlikely(entry->next->prev != entry)) {
111663+ printk(KERN_ERR "list_del corruption. next->prev should be %p, "
111664+ "but was %p\n", entry, next->prev);
111665+ BUG();
111666+ return false;
111667+ }
111668+ return true;
111669+}
111670+
111671+void __list_del_entry(struct list_head *entry)
111672+{
111673+ if (!__list_del_entry_debug(entry))
111674 return;
111675
111676- __list_del(prev, next);
111677+ __list_del(entry->prev, entry->next);
111678 }
111679 EXPORT_SYMBOL(__list_del_entry);
111680
111681@@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
111682 void __list_add_rcu(struct list_head *new,
111683 struct list_head *prev, struct list_head *next)
111684 {
111685- WARN(next->prev != prev,
111686- "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
111687- prev, next->prev, next);
111688- WARN(prev->next != next,
111689- "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
111690- next, prev->next, prev);
111691+ if (!__list_add_debug(new, prev, next))
111692+ return;
111693+
111694 new->next = next;
111695 new->prev = prev;
111696 rcu_assign_pointer(list_next_rcu(prev), new);
111697 next->prev = new;
111698 }
111699 EXPORT_SYMBOL(__list_add_rcu);
111700+#endif
111701+
111702+void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
111703+{
111704+#ifdef CONFIG_DEBUG_LIST
111705+ if (!__list_add_debug(new, prev, next))
111706+ return;
111707+#endif
111708+
111709+ pax_open_kernel();
111710+ next->prev = new;
111711+ new->next = next;
111712+ new->prev = prev;
111713+ prev->next = new;
111714+ pax_close_kernel();
111715+}
111716+EXPORT_SYMBOL(__pax_list_add);
111717+
111718+void pax_list_del(struct list_head *entry)
111719+{
111720+#ifdef CONFIG_DEBUG_LIST
111721+ if (!__list_del_entry_debug(entry))
111722+ return;
111723+#endif
111724+
111725+ pax_open_kernel();
111726+ __list_del(entry->prev, entry->next);
111727+ entry->next = LIST_POISON1;
111728+ entry->prev = LIST_POISON2;
111729+ pax_close_kernel();
111730+}
111731+EXPORT_SYMBOL(pax_list_del);
111732+
111733+void pax_list_del_init(struct list_head *entry)
111734+{
111735+ pax_open_kernel();
111736+ __list_del(entry->prev, entry->next);
111737+ INIT_LIST_HEAD(entry);
111738+ pax_close_kernel();
111739+}
111740+EXPORT_SYMBOL(pax_list_del_init);
111741+
111742+void __pax_list_add_rcu(struct list_head *new,
111743+ struct list_head *prev, struct list_head *next)
111744+{
111745+#ifdef CONFIG_DEBUG_LIST
111746+ if (!__list_add_debug(new, prev, next))
111747+ return;
111748+#endif
111749+
111750+ pax_open_kernel();
111751+ new->next = next;
111752+ new->prev = prev;
111753+ rcu_assign_pointer(list_next_rcu(prev), new);
111754+ next->prev = new;
111755+ pax_close_kernel();
111756+}
111757+EXPORT_SYMBOL(__pax_list_add_rcu);
111758+
111759+void pax_list_del_rcu(struct list_head *entry)
111760+{
111761+#ifdef CONFIG_DEBUG_LIST
111762+ if (!__list_del_entry_debug(entry))
111763+ return;
111764+#endif
111765+
111766+ pax_open_kernel();
111767+ __list_del(entry->prev, entry->next);
111768+ entry->next = LIST_POISON1;
111769+ entry->prev = LIST_POISON2;
111770+ pax_close_kernel();
111771+}
111772+EXPORT_SYMBOL(pax_list_del_rcu);
111773diff --git a/lib/lockref.c b/lib/lockref.c
111774index 494994b..65caf94 100644
111775--- a/lib/lockref.c
111776+++ b/lib/lockref.c
111777@@ -48,13 +48,13 @@
111778 void lockref_get(struct lockref *lockref)
111779 {
111780 CMPXCHG_LOOP(
111781- new.count++;
111782+ __lockref_inc(&new);
111783 ,
111784 return;
111785 );
111786
111787 spin_lock(&lockref->lock);
111788- lockref->count++;
111789+ __lockref_inc(lockref);
111790 spin_unlock(&lockref->lock);
111791 }
111792 EXPORT_SYMBOL(lockref_get);
111793@@ -69,8 +69,8 @@ int lockref_get_not_zero(struct lockref *lockref)
111794 int retval;
111795
111796 CMPXCHG_LOOP(
111797- new.count++;
111798- if (old.count <= 0)
111799+ __lockref_inc(&new);
111800+ if (__lockref_read(&old) <= 0)
111801 return 0;
111802 ,
111803 return 1;
111804@@ -78,8 +78,8 @@ int lockref_get_not_zero(struct lockref *lockref)
111805
111806 spin_lock(&lockref->lock);
111807 retval = 0;
111808- if (lockref->count > 0) {
111809- lockref->count++;
111810+ if (__lockref_read(lockref) > 0) {
111811+ __lockref_inc(lockref);
111812 retval = 1;
111813 }
111814 spin_unlock(&lockref->lock);
111815@@ -96,17 +96,17 @@ EXPORT_SYMBOL(lockref_get_not_zero);
111816 int lockref_get_or_lock(struct lockref *lockref)
111817 {
111818 CMPXCHG_LOOP(
111819- new.count++;
111820- if (old.count <= 0)
111821+ __lockref_inc(&new);
111822+ if (__lockref_read(&old) <= 0)
111823 break;
111824 ,
111825 return 1;
111826 );
111827
111828 spin_lock(&lockref->lock);
111829- if (lockref->count <= 0)
111830+ if (__lockref_read(lockref) <= 0)
111831 return 0;
111832- lockref->count++;
111833+ __lockref_inc(lockref);
111834 spin_unlock(&lockref->lock);
111835 return 1;
111836 }
111837@@ -122,11 +122,11 @@ EXPORT_SYMBOL(lockref_get_or_lock);
111838 int lockref_put_return(struct lockref *lockref)
111839 {
111840 CMPXCHG_LOOP(
111841- new.count--;
111842- if (old.count <= 0)
111843+ __lockref_dec(&new);
111844+ if (__lockref_read(&old) <= 0)
111845 return -1;
111846 ,
111847- return new.count;
111848+ return __lockref_read(&new);
111849 );
111850 return -1;
111851 }
111852@@ -140,17 +140,17 @@ EXPORT_SYMBOL(lockref_put_return);
111853 int lockref_put_or_lock(struct lockref *lockref)
111854 {
111855 CMPXCHG_LOOP(
111856- new.count--;
111857- if (old.count <= 1)
111858+ __lockref_dec(&new);
111859+ if (__lockref_read(&old) <= 1)
111860 break;
111861 ,
111862 return 1;
111863 );
111864
111865 spin_lock(&lockref->lock);
111866- if (lockref->count <= 1)
111867+ if (__lockref_read(lockref) <= 1)
111868 return 0;
111869- lockref->count--;
111870+ __lockref_dec(lockref);
111871 spin_unlock(&lockref->lock);
111872 return 1;
111873 }
111874@@ -163,7 +163,7 @@ EXPORT_SYMBOL(lockref_put_or_lock);
111875 void lockref_mark_dead(struct lockref *lockref)
111876 {
111877 assert_spin_locked(&lockref->lock);
111878- lockref->count = -128;
111879+ __lockref_set(lockref, -128);
111880 }
111881 EXPORT_SYMBOL(lockref_mark_dead);
111882
111883@@ -177,8 +177,8 @@ int lockref_get_not_dead(struct lockref *lockref)
111884 int retval;
111885
111886 CMPXCHG_LOOP(
111887- new.count++;
111888- if (old.count < 0)
111889+ __lockref_inc(&new);
111890+ if (__lockref_read(&old) < 0)
111891 return 0;
111892 ,
111893 return 1;
111894@@ -186,8 +186,8 @@ int lockref_get_not_dead(struct lockref *lockref)
111895
111896 spin_lock(&lockref->lock);
111897 retval = 0;
111898- if (lockref->count >= 0) {
111899- lockref->count++;
111900+ if (__lockref_read(lockref) >= 0) {
111901+ __lockref_inc(lockref);
111902 retval = 1;
111903 }
111904 spin_unlock(&lockref->lock);
111905diff --git a/lib/nlattr.c b/lib/nlattr.c
111906index f5907d2..36072be 100644
111907--- a/lib/nlattr.c
111908+++ b/lib/nlattr.c
111909@@ -278,6 +278,8 @@ int nla_memcpy(void *dest, const struct nlattr *src, int count)
111910 {
111911 int minlen = min_t(int, count, nla_len(src));
111912
111913+ BUG_ON(minlen < 0);
111914+
111915 memcpy(dest, nla_data(src), minlen);
111916 if (count > minlen)
111917 memset(dest + minlen, 0, count - minlen);
111918diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
111919index 6111bcb..02e816b 100644
111920--- a/lib/percpu-refcount.c
111921+++ b/lib/percpu-refcount.c
111922@@ -31,7 +31,7 @@
111923 * atomic_long_t can't hit 0 before we've added up all the percpu refs.
111924 */
111925
111926-#define PERCPU_COUNT_BIAS (1LU << (BITS_PER_LONG - 1))
111927+#define PERCPU_COUNT_BIAS (1LU << (BITS_PER_LONG - 2))
111928
111929 static DECLARE_WAIT_QUEUE_HEAD(percpu_ref_switch_waitq);
111930
111931diff --git a/lib/radix-tree.c b/lib/radix-tree.c
111932index f9ebe1c..e985666 100644
111933--- a/lib/radix-tree.c
111934+++ b/lib/radix-tree.c
111935@@ -68,7 +68,7 @@ struct radix_tree_preload {
111936 /* nodes->private_data points to next preallocated node */
111937 struct radix_tree_node *nodes;
111938 };
111939-static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
111940+static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
111941
111942 static inline void *ptr_to_indirect(void *ptr)
111943 {
111944diff --git a/lib/random32.c b/lib/random32.c
111945index 0bee183..526f12f 100644
111946--- a/lib/random32.c
111947+++ b/lib/random32.c
111948@@ -47,7 +47,7 @@ static inline void prandom_state_selftest(void)
111949 }
111950 #endif
111951
111952-static DEFINE_PER_CPU(struct rnd_state, net_rand_state);
111953+static DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy;
111954
111955 /**
111956 * prandom_u32_state - seeded pseudo-random number generator.
111957diff --git a/lib/rbtree.c b/lib/rbtree.c
111958index 1356454..70ce6c6 100644
111959--- a/lib/rbtree.c
111960+++ b/lib/rbtree.c
111961@@ -412,7 +412,9 @@ static inline void dummy_copy(struct rb_node *old, struct rb_node *new) {}
111962 static inline void dummy_rotate(struct rb_node *old, struct rb_node *new) {}
111963
111964 static const struct rb_augment_callbacks dummy_callbacks = {
111965- dummy_propagate, dummy_copy, dummy_rotate
111966+ .propagate = dummy_propagate,
111967+ .copy = dummy_copy,
111968+ .rotate = dummy_rotate
111969 };
111970
111971 void rb_insert_color(struct rb_node *node, struct rb_root *root)
111972diff --git a/lib/show_mem.c b/lib/show_mem.c
111973index adc98e18..0ce83c2 100644
111974--- a/lib/show_mem.c
111975+++ b/lib/show_mem.c
111976@@ -49,6 +49,6 @@ void show_mem(unsigned int filter)
111977 quicklist_total_size());
111978 #endif
111979 #ifdef CONFIG_MEMORY_FAILURE
111980- printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
111981+ printk("%lu pages hwpoisoned\n", atomic_long_read_unchecked(&num_poisoned_pages));
111982 #endif
111983 }
111984diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
111985index e0af6ff..fcc9f15 100644
111986--- a/lib/strncpy_from_user.c
111987+++ b/lib/strncpy_from_user.c
111988@@ -22,7 +22,7 @@
111989 */
111990 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
111991 {
111992- const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
111993+ static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
111994 long res = 0;
111995
111996 /*
111997diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
111998index 3a5f2b3..102f1ff 100644
111999--- a/lib/strnlen_user.c
112000+++ b/lib/strnlen_user.c
112001@@ -26,7 +26,7 @@
112002 */
112003 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
112004 {
112005- const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
112006+ static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
112007 long align, res = 0;
112008 unsigned long c;
112009
112010diff --git a/lib/swiotlb.c b/lib/swiotlb.c
112011index 76f29ec..1a5316f 100644
112012--- a/lib/swiotlb.c
112013+++ b/lib/swiotlb.c
112014@@ -690,7 +690,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
112015
112016 void
112017 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
112018- dma_addr_t dev_addr)
112019+ dma_addr_t dev_addr, struct dma_attrs *attrs)
112020 {
112021 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
112022
112023diff --git a/lib/usercopy.c b/lib/usercopy.c
112024index 4f5b1dd..7cab418 100644
112025--- a/lib/usercopy.c
112026+++ b/lib/usercopy.c
112027@@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
112028 WARN(1, "Buffer overflow detected!\n");
112029 }
112030 EXPORT_SYMBOL(copy_from_user_overflow);
112031+
112032+void copy_to_user_overflow(void)
112033+{
112034+ WARN(1, "Buffer overflow detected!\n");
112035+}
112036+EXPORT_SYMBOL(copy_to_user_overflow);
112037diff --git a/lib/vsprintf.c b/lib/vsprintf.c
112038index da39c60..ac91239 100644
112039--- a/lib/vsprintf.c
112040+++ b/lib/vsprintf.c
112041@@ -16,6 +16,9 @@
112042 * - scnprintf and vscnprintf
112043 */
112044
112045+#ifdef CONFIG_GRKERNSEC_HIDESYM
112046+#define __INCLUDED_BY_HIDESYM 1
112047+#endif
112048 #include <stdarg.h>
112049 #include <linux/clk-provider.h>
112050 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
112051@@ -628,7 +631,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
112052 #ifdef CONFIG_KALLSYMS
112053 if (*fmt == 'B')
112054 sprint_backtrace(sym, value);
112055- else if (*fmt != 'f' && *fmt != 's')
112056+ else if (*fmt != 'f' && *fmt != 's' && *fmt != 'X')
112057 sprint_symbol(sym, value);
112058 else
112059 sprint_symbol_no_offset(sym, value);
112060@@ -1360,7 +1363,11 @@ char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
112061 }
112062 }
112063
112064-int kptr_restrict __read_mostly;
112065+#ifdef CONFIG_GRKERNSEC_HIDESYM
112066+int kptr_restrict __read_only = 2;
112067+#else
112068+int kptr_restrict __read_only;
112069+#endif
112070
112071 /*
112072 * Show a '%p' thing. A kernel extension is that the '%p' is followed
112073@@ -1371,8 +1378,10 @@ int kptr_restrict __read_mostly;
112074 *
112075 * - 'F' For symbolic function descriptor pointers with offset
112076 * - 'f' For simple symbolic function names without offset
112077+ * - 'X' For simple symbolic function names without offset approved for use with GRKERNSEC_HIDESYM
112078 * - 'S' For symbolic direct pointers with offset
112079 * - 's' For symbolic direct pointers without offset
112080+ * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
112081 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
112082 * - 'B' For backtraced symbolic direct pointers with offset
112083 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
112084@@ -1460,12 +1469,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
112085
112086 if (!ptr && *fmt != 'K') {
112087 /*
112088- * Print (null) with the same width as a pointer so it makes
112089+ * Print (nil) with the same width as a pointer so it makes
112090 * tabular output look nice.
112091 */
112092 if (spec.field_width == -1)
112093 spec.field_width = default_width;
112094- return string(buf, end, "(null)", spec);
112095+ return string(buf, end, "(nil)", spec);
112096 }
112097
112098 switch (*fmt) {
112099@@ -1475,6 +1484,14 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
112100 /* Fallthrough */
112101 case 'S':
112102 case 's':
112103+#ifdef CONFIG_GRKERNSEC_HIDESYM
112104+ break;
112105+#else
112106+ return symbol_string(buf, end, ptr, spec, fmt);
112107+#endif
112108+ case 'X':
112109+ ptr = dereference_function_descriptor(ptr);
112110+ case 'A':
112111 case 'B':
112112 return symbol_string(buf, end, ptr, spec, fmt);
112113 case 'R':
112114@@ -1539,6 +1556,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
112115 va_end(va);
112116 return buf;
112117 }
112118+ case 'P':
112119+ break;
112120 case 'K':
112121 /*
112122 * %pK cannot be used in IRQ context because its test
112123@@ -1598,6 +1617,22 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
112124 ((const struct file *)ptr)->f_path.dentry,
112125 spec, fmt);
112126 }
112127+
112128+#ifdef CONFIG_GRKERNSEC_HIDESYM
112129+ /* 'P' = approved pointers to copy to userland,
112130+ as in the /proc/kallsyms case, as we make it display nothing
112131+ for non-root users, and the real contents for root users
112132+ 'X' = approved simple symbols
112133+ Also ignore 'K' pointers, since we force their NULLing for non-root users
112134+ above
112135+ */
112136+ if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'X' && *fmt != 'K' && is_usercopy_object(buf)) {
112137+ printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
112138+ dump_stack();
112139+ ptr = NULL;
112140+ }
112141+#endif
112142+
112143 spec.flags |= SMALL;
112144 if (spec.field_width == -1) {
112145 spec.field_width = default_width;
112146@@ -2296,11 +2331,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
112147 typeof(type) value; \
112148 if (sizeof(type) == 8) { \
112149 args = PTR_ALIGN(args, sizeof(u32)); \
112150- *(u32 *)&value = *(u32 *)args; \
112151- *((u32 *)&value + 1) = *(u32 *)(args + 4); \
112152+ *(u32 *)&value = *(const u32 *)args; \
112153+ *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
112154 } else { \
112155 args = PTR_ALIGN(args, sizeof(type)); \
112156- value = *(typeof(type) *)args; \
112157+ value = *(const typeof(type) *)args; \
112158 } \
112159 args += sizeof(type); \
112160 value; \
112161@@ -2363,7 +2398,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
112162 case FORMAT_TYPE_STR: {
112163 const char *str_arg = args;
112164 args += strlen(str_arg) + 1;
112165- str = string(str, end, (char *)str_arg, spec);
112166+ str = string(str, end, str_arg, spec);
112167 break;
112168 }
112169
112170diff --git a/localversion-grsec b/localversion-grsec
112171new file mode 100644
112172index 0000000..7cd6065
112173--- /dev/null
112174+++ b/localversion-grsec
112175@@ -0,0 +1 @@
112176+-grsec
112177diff --git a/mm/Kconfig b/mm/Kconfig
112178index e79de2b..fba3116 100644
112179--- a/mm/Kconfig
112180+++ b/mm/Kconfig
112181@@ -342,10 +342,11 @@ config KSM
112182 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
112183
112184 config DEFAULT_MMAP_MIN_ADDR
112185- int "Low address space to protect from user allocation"
112186+ int "Low address space to protect from user allocation"
112187 depends on MMU
112188- default 4096
112189- help
112190+ default 32768 if ALPHA || ARM || PARISC || SPARC32
112191+ default 65536
112192+ help
112193 This is the portion of low virtual memory which should be protected
112194 from userspace allocation. Keeping a user from writing to low pages
112195 can help reduce the impact of kernel NULL pointer bugs.
112196@@ -377,8 +378,9 @@ config MEMORY_FAILURE
112197
112198 config HWPOISON_INJECT
112199 tristate "HWPoison pages injector"
112200- depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
112201+ depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
112202 select PROC_PAGE_MONITOR
112203+ depends on !GRKERNSEC
112204
112205 config NOMMU_INITIAL_TRIM_EXCESS
112206 int "Turn on mmap() excess space trimming before booting"
112207@@ -539,6 +541,7 @@ config MEM_SOFT_DIRTY
112208 bool "Track memory changes"
112209 depends on CHECKPOINT_RESTORE && HAVE_ARCH_SOFT_DIRTY && PROC_FS
112210 select PROC_PAGE_MONITOR
112211+ depends on !GRKERNSEC
112212 help
112213 This option enables memory changes tracking by introducing a
112214 soft-dirty bit on pte-s. This bit it set when someone writes
112215@@ -613,6 +616,7 @@ config ZSMALLOC_STAT
112216 bool "Export zsmalloc statistics"
112217 depends on ZSMALLOC
112218 select DEBUG_FS
112219+ depends on !GRKERNSEC_KMEM
112220 help
112221 This option enables code in the zsmalloc to collect various
112222 statistics about whats happening in zsmalloc and exports that
112223diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug
112224index 957d3da..1d34e20 100644
112225--- a/mm/Kconfig.debug
112226+++ b/mm/Kconfig.debug
112227@@ -10,6 +10,7 @@ config PAGE_EXTENSION
112228 config DEBUG_PAGEALLOC
112229 bool "Debug page memory allocations"
112230 depends on DEBUG_KERNEL
112231+ depends on !PAX_MEMORY_SANITIZE
112232 depends on !HIBERNATION || ARCH_SUPPORTS_DEBUG_PAGEALLOC && !PPC && !SPARC
112233 depends on !KMEMCHECK
112234 select PAGE_EXTENSION
112235diff --git a/mm/backing-dev.c b/mm/backing-dev.c
112236index dac5bf5..d8c02ce 100644
112237--- a/mm/backing-dev.c
112238+++ b/mm/backing-dev.c
112239@@ -12,7 +12,7 @@
112240 #include <linux/device.h>
112241 #include <trace/events/writeback.h>
112242
112243-static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
112244+static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
112245
112246 struct backing_dev_info noop_backing_dev_info = {
112247 .name = "noop",
112248@@ -855,7 +855,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name)
112249 return err;
112250
112251 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
112252- atomic_long_inc_return(&bdi_seq));
112253+ atomic_long_inc_return_unchecked(&bdi_seq));
112254 if (err) {
112255 bdi_destroy(bdi);
112256 return err;
112257diff --git a/mm/dmapool.c b/mm/dmapool.c
112258index fd5fe43..39ea317 100644
112259--- a/mm/dmapool.c
112260+++ b/mm/dmapool.c
112261@@ -386,7 +386,7 @@ static struct dma_page *pool_find_page(struct dma_pool *pool, dma_addr_t dma)
112262 list_for_each_entry(page, &pool->page_list, page_list) {
112263 if (dma < page->dma)
112264 continue;
112265- if (dma < (page->dma + pool->allocation))
112266+ if ((dma - page->dma) < pool->allocation)
112267 return page;
112268 }
112269 return NULL;
112270diff --git a/mm/filemap.c b/mm/filemap.c
112271index 1283fc8..a0347d5 100644
112272--- a/mm/filemap.c
112273+++ b/mm/filemap.c
112274@@ -2122,7 +2122,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
112275 struct address_space *mapping = file->f_mapping;
112276
112277 if (!mapping->a_ops->readpage)
112278- return -ENOEXEC;
112279+ return -ENODEV;
112280 file_accessed(file);
112281 vma->vm_ops = &generic_file_vm_ops;
112282 return 0;
112283@@ -2303,6 +2303,7 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from)
112284 pos = iocb->ki_pos;
112285
112286 if (limit != RLIM_INFINITY) {
112287+ gr_learn_resource(current, RLIMIT_FSIZE, iocb->ki_pos, 0);
112288 if (iocb->ki_pos >= limit) {
112289 send_sig(SIGXFSZ, current, 0);
112290 return -EFBIG;
112291diff --git a/mm/gup.c b/mm/gup.c
112292index 6297f6b..7652403 100644
112293--- a/mm/gup.c
112294+++ b/mm/gup.c
112295@@ -265,11 +265,6 @@ static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma,
112296 unsigned int fault_flags = 0;
112297 int ret;
112298
112299- /* For mm_populate(), just skip the stack guard page. */
112300- if ((*flags & FOLL_POPULATE) &&
112301- (stack_guard_page_start(vma, address) ||
112302- stack_guard_page_end(vma, address + PAGE_SIZE)))
112303- return -ENOENT;
112304 if (*flags & FOLL_WRITE)
112305 fault_flags |= FAULT_FLAG_WRITE;
112306 if (nonblocking)
112307@@ -435,14 +430,14 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
112308 if (!(gup_flags & FOLL_FORCE))
112309 gup_flags |= FOLL_NUMA;
112310
112311- do {
112312+ while (nr_pages) {
112313 struct page *page;
112314 unsigned int foll_flags = gup_flags;
112315 unsigned int page_increm;
112316
112317 /* first iteration or cross vma bound */
112318 if (!vma || start >= vma->vm_end) {
112319- vma = find_extend_vma(mm, start);
112320+ vma = find_vma(mm, start);
112321 if (!vma && in_gate_area(mm, start)) {
112322 int ret;
112323 ret = get_gate_page(mm, start & PAGE_MASK,
112324@@ -454,7 +449,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
112325 goto next_page;
112326 }
112327
112328- if (!vma || check_vma_flags(vma, gup_flags))
112329+ if (!vma || start < vma->vm_start || check_vma_flags(vma, gup_flags))
112330 return i ? : -EFAULT;
112331 if (is_vm_hugetlb_page(vma)) {
112332 i = follow_hugetlb_page(mm, vma, pages, vmas,
112333@@ -509,7 +504,7 @@ next_page:
112334 i += page_increm;
112335 start += page_increm * PAGE_SIZE;
112336 nr_pages -= page_increm;
112337- } while (nr_pages);
112338+ }
112339 return i;
112340 }
112341 EXPORT_SYMBOL(__get_user_pages);
112342diff --git a/mm/highmem.c b/mm/highmem.c
112343index 123bcd3..c2c85db 100644
112344--- a/mm/highmem.c
112345+++ b/mm/highmem.c
112346@@ -195,8 +195,9 @@ static void flush_all_zero_pkmaps(void)
112347 * So no dangers, even with speculative execution.
112348 */
112349 page = pte_page(pkmap_page_table[i]);
112350+ pax_open_kernel();
112351 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
112352-
112353+ pax_close_kernel();
112354 set_page_address(page, NULL);
112355 need_flush = 1;
112356 }
112357@@ -259,8 +260,11 @@ start:
112358 }
112359 }
112360 vaddr = PKMAP_ADDR(last_pkmap_nr);
112361+
112362+ pax_open_kernel();
112363 set_pte_at(&init_mm, vaddr,
112364 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
112365+ pax_close_kernel();
112366
112367 pkmap_count[last_pkmap_nr] = 1;
112368 set_page_address(page, (void *)vaddr);
112369diff --git a/mm/hugetlb.c b/mm/hugetlb.c
112370index 62c1ec5..ec431dc 100644
112371--- a/mm/hugetlb.c
112372+++ b/mm/hugetlb.c
112373@@ -2442,6 +2442,7 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
112374 struct ctl_table *table, int write,
112375 void __user *buffer, size_t *length, loff_t *ppos)
112376 {
112377+ ctl_table_no_const t;
112378 struct hstate *h = &default_hstate;
112379 unsigned long tmp = h->max_huge_pages;
112380 int ret;
112381@@ -2449,9 +2450,10 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
112382 if (!hugepages_supported())
112383 return -ENOTSUPP;
112384
112385- table->data = &tmp;
112386- table->maxlen = sizeof(unsigned long);
112387- ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
112388+ t = *table;
112389+ t.data = &tmp;
112390+ t.maxlen = sizeof(unsigned long);
112391+ ret = proc_doulongvec_minmax(&t, write, buffer, length, ppos);
112392 if (ret)
112393 goto out;
112394
112395@@ -2486,6 +2488,7 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
112396 struct hstate *h = &default_hstate;
112397 unsigned long tmp;
112398 int ret;
112399+ ctl_table_no_const hugetlb_table;
112400
112401 if (!hugepages_supported())
112402 return -ENOTSUPP;
112403@@ -2495,9 +2498,10 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
112404 if (write && hstate_is_gigantic(h))
112405 return -EINVAL;
112406
112407- table->data = &tmp;
112408- table->maxlen = sizeof(unsigned long);
112409- ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
112410+ hugetlb_table = *table;
112411+ hugetlb_table.data = &tmp;
112412+ hugetlb_table.maxlen = sizeof(unsigned long);
112413+ ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
112414 if (ret)
112415 goto out;
112416
112417@@ -2995,6 +2999,27 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
112418 i_mmap_unlock_write(mapping);
112419 }
112420
112421+#ifdef CONFIG_PAX_SEGMEXEC
112422+static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
112423+{
112424+ struct mm_struct *mm = vma->vm_mm;
112425+ struct vm_area_struct *vma_m;
112426+ unsigned long address_m;
112427+ pte_t *ptep_m;
112428+
112429+ vma_m = pax_find_mirror_vma(vma);
112430+ if (!vma_m)
112431+ return;
112432+
112433+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
112434+ address_m = address + SEGMEXEC_TASK_SIZE;
112435+ ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
112436+ get_page(page_m);
112437+ hugepage_add_anon_rmap(page_m, vma_m, address_m);
112438+ set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
112439+}
112440+#endif
112441+
112442 /*
112443 * Hugetlb_cow() should be called with page lock of the original hugepage held.
112444 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
112445@@ -3108,6 +3133,11 @@ retry_avoidcopy:
112446 make_huge_pte(vma, new_page, 1));
112447 page_remove_rmap(old_page);
112448 hugepage_add_new_anon_rmap(new_page, vma, address);
112449+
112450+#ifdef CONFIG_PAX_SEGMEXEC
112451+ pax_mirror_huge_pte(vma, address, new_page);
112452+#endif
112453+
112454 /* Make the old page be freed below */
112455 new_page = old_page;
112456 }
112457@@ -3269,6 +3299,10 @@ retry:
112458 && (vma->vm_flags & VM_SHARED)));
112459 set_huge_pte_at(mm, address, ptep, new_pte);
112460
112461+#ifdef CONFIG_PAX_SEGMEXEC
112462+ pax_mirror_huge_pte(vma, address, page);
112463+#endif
112464+
112465 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
112466 /* Optimization, do the COW without a second fault */
112467 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page, ptl);
112468@@ -3336,6 +3370,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
112469 struct address_space *mapping;
112470 int need_wait_lock = 0;
112471
112472+#ifdef CONFIG_PAX_SEGMEXEC
112473+ struct vm_area_struct *vma_m;
112474+#endif
112475+
112476 address &= huge_page_mask(h);
112477
112478 ptep = huge_pte_offset(mm, address);
112479@@ -3349,6 +3387,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
112480 VM_FAULT_SET_HINDEX(hstate_index(h));
112481 }
112482
112483+#ifdef CONFIG_PAX_SEGMEXEC
112484+ vma_m = pax_find_mirror_vma(vma);
112485+ if (vma_m) {
112486+ unsigned long address_m;
112487+
112488+ if (vma->vm_start > vma_m->vm_start) {
112489+ address_m = address;
112490+ address -= SEGMEXEC_TASK_SIZE;
112491+ vma = vma_m;
112492+ h = hstate_vma(vma);
112493+ } else
112494+ address_m = address + SEGMEXEC_TASK_SIZE;
112495+
112496+ if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
112497+ return VM_FAULT_OOM;
112498+ address_m &= HPAGE_MASK;
112499+ unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
112500+ }
112501+#endif
112502+
112503 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
112504 if (!ptep)
112505 return VM_FAULT_OOM;
112506diff --git a/mm/internal.h b/mm/internal.h
112507index 36b23f1..673a6c7 100644
112508--- a/mm/internal.h
112509+++ b/mm/internal.h
112510@@ -157,6 +157,7 @@ __find_buddy_index(unsigned long page_idx, unsigned int order)
112511 extern int __isolate_free_page(struct page *page, unsigned int order);
112512 extern void __free_pages_bootmem(struct page *page, unsigned long pfn,
112513 unsigned int order);
112514+extern void free_compound_page(struct page *page);
112515 extern void prep_compound_page(struct page *page, unsigned long order);
112516 #ifdef CONFIG_MEMORY_FAILURE
112517 extern bool is_free_buddy_page(struct page *page);
112518diff --git a/mm/kmemleak.c b/mm/kmemleak.c
112519index cf79f11..254224e 100644
112520--- a/mm/kmemleak.c
112521+++ b/mm/kmemleak.c
112522@@ -375,7 +375,7 @@ static void print_unreferenced(struct seq_file *seq,
112523
112524 for (i = 0; i < object->trace_len; i++) {
112525 void *ptr = (void *)object->trace[i];
112526- seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
112527+ seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
112528 }
112529 }
112530
112531@@ -1966,7 +1966,7 @@ static int __init kmemleak_late_init(void)
112532 return -ENOMEM;
112533 }
112534
112535- dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
112536+ dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
112537 &kmemleak_fops);
112538 if (!dentry)
112539 pr_warning("Failed to create the debugfs kmemleak file\n");
112540diff --git a/mm/maccess.c b/mm/maccess.c
112541index d53adf9..03a24bf 100644
112542--- a/mm/maccess.c
112543+++ b/mm/maccess.c
112544@@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
112545 set_fs(KERNEL_DS);
112546 pagefault_disable();
112547 ret = __copy_from_user_inatomic(dst,
112548- (__force const void __user *)src, size);
112549+ (const void __force_user *)src, size);
112550 pagefault_enable();
112551 set_fs(old_fs);
112552
112553@@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
112554
112555 set_fs(KERNEL_DS);
112556 pagefault_disable();
112557- ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
112558+ ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
112559 pagefault_enable();
112560 set_fs(old_fs);
112561
112562diff --git a/mm/madvise.c b/mm/madvise.c
112563index 64bb8a2..68e4be5 100644
112564--- a/mm/madvise.c
112565+++ b/mm/madvise.c
112566@@ -52,6 +52,10 @@ static long madvise_behavior(struct vm_area_struct *vma,
112567 pgoff_t pgoff;
112568 unsigned long new_flags = vma->vm_flags;
112569
112570+#ifdef CONFIG_PAX_SEGMEXEC
112571+ struct vm_area_struct *vma_m;
112572+#endif
112573+
112574 switch (behavior) {
112575 case MADV_NORMAL:
112576 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
112577@@ -127,6 +131,13 @@ success:
112578 /*
112579 * vm_flags is protected by the mmap_sem held in write mode.
112580 */
112581+
112582+#ifdef CONFIG_PAX_SEGMEXEC
112583+ vma_m = pax_find_mirror_vma(vma);
112584+ if (vma_m)
112585+ vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
112586+#endif
112587+
112588 vma->vm_flags = new_flags;
112589
112590 out:
112591@@ -278,11 +289,27 @@ static long madvise_dontneed(struct vm_area_struct *vma,
112592 struct vm_area_struct **prev,
112593 unsigned long start, unsigned long end)
112594 {
112595+
112596+#ifdef CONFIG_PAX_SEGMEXEC
112597+ struct vm_area_struct *vma_m;
112598+#endif
112599+
112600 *prev = vma;
112601 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
112602 return -EINVAL;
112603
112604 zap_page_range(vma, start, end - start, NULL);
112605+
112606+#ifdef CONFIG_PAX_SEGMEXEC
112607+ vma_m = pax_find_mirror_vma(vma);
112608+ if (vma_m) {
112609+ if (vma_m->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
112610+ return -EINVAL;
112611+
112612+ zap_page_range(vma_m, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
112613+ }
112614+#endif
112615+
112616 return 0;
112617 }
112618
112619@@ -485,6 +512,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
112620 if (end < start)
112621 return error;
112622
112623+#ifdef CONFIG_PAX_SEGMEXEC
112624+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
112625+ if (end > SEGMEXEC_TASK_SIZE)
112626+ return error;
112627+ } else
112628+#endif
112629+
112630+ if (end > TASK_SIZE)
112631+ return error;
112632+
112633 error = 0;
112634 if (end == start)
112635 return error;
112636diff --git a/mm/memory-failure.c b/mm/memory-failure.c
112637index 1f4446a..47abb4e 100644
112638--- a/mm/memory-failure.c
112639+++ b/mm/memory-failure.c
112640@@ -63,7 +63,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
112641
112642 int sysctl_memory_failure_recovery __read_mostly = 1;
112643
112644-atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
112645+atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
112646
112647 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
112648
112649@@ -200,7 +200,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
112650 pfn, t->comm, t->pid);
112651 si.si_signo = SIGBUS;
112652 si.si_errno = 0;
112653- si.si_addr = (void *)addr;
112654+ si.si_addr = (void __user *)addr;
112655 #ifdef __ARCH_SI_TRAPNO
112656 si.si_trapno = trapno;
112657 #endif
112658@@ -797,7 +797,7 @@ static struct page_state {
112659 unsigned long res;
112660 enum mf_action_page_type type;
112661 int (*action)(struct page *p, unsigned long pfn);
112662-} error_states[] = {
112663+} __do_const error_states[] = {
112664 { reserved, reserved, MF_MSG_KERNEL, me_kernel },
112665 /*
112666 * free pages are specially detected outside this table:
112667@@ -1100,7 +1100,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
112668 nr_pages = 1 << compound_order(hpage);
112669 else /* normal page or thp */
112670 nr_pages = 1;
112671- atomic_long_add(nr_pages, &num_poisoned_pages);
112672+ atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
112673
112674 /*
112675 * We need/can do nothing about count=0 pages.
112676@@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
112677 if (PageHWPoison(hpage)) {
112678 if ((hwpoison_filter(p) && TestClearPageHWPoison(p))
112679 || (p != hpage && TestSetPageHWPoison(hpage))) {
112680- atomic_long_sub(nr_pages, &num_poisoned_pages);
112681+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112682 unlock_page(hpage);
112683 return 0;
112684 }
112685@@ -1152,7 +1152,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
112686 else
112687 pr_err("MCE: %#lx: thp split failed\n", pfn);
112688 if (TestClearPageHWPoison(p))
112689- atomic_long_sub(nr_pages, &num_poisoned_pages);
112690+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112691 put_page(p);
112692 if (p != hpage)
112693 put_page(hpage);
112694@@ -1214,14 +1214,14 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
112695 */
112696 if (!PageHWPoison(p)) {
112697 printk(KERN_ERR "MCE %#lx: just unpoisoned\n", pfn);
112698- atomic_long_sub(nr_pages, &num_poisoned_pages);
112699+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112700 unlock_page(hpage);
112701 put_page(hpage);
112702 return 0;
112703 }
112704 if (hwpoison_filter(p)) {
112705 if (TestClearPageHWPoison(p))
112706- atomic_long_sub(nr_pages, &num_poisoned_pages);
112707+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112708 unlock_page(hpage);
112709 put_page(hpage);
112710 return 0;
112711@@ -1450,7 +1450,7 @@ int unpoison_memory(unsigned long pfn)
112712 return 0;
112713 }
112714 if (TestClearPageHWPoison(p))
112715- atomic_long_dec(&num_poisoned_pages);
112716+ atomic_long_dec_unchecked(&num_poisoned_pages);
112717 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
112718 return 0;
112719 }
112720@@ -1464,7 +1464,7 @@ int unpoison_memory(unsigned long pfn)
112721 */
112722 if (TestClearPageHWPoison(page)) {
112723 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
112724- atomic_long_sub(nr_pages, &num_poisoned_pages);
112725+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112726 freeit = 1;
112727 if (PageHuge(page))
112728 clear_page_hwpoison_huge_page(page);
112729@@ -1600,11 +1600,11 @@ static int soft_offline_huge_page(struct page *page, int flags)
112730 if (PageHuge(page)) {
112731 set_page_hwpoison_huge_page(hpage);
112732 dequeue_hwpoisoned_huge_page(hpage);
112733- atomic_long_add(1 << compound_order(hpage),
112734+ atomic_long_add_unchecked(1 << compound_order(hpage),
112735 &num_poisoned_pages);
112736 } else {
112737 SetPageHWPoison(page);
112738- atomic_long_inc(&num_poisoned_pages);
112739+ atomic_long_inc_unchecked(&num_poisoned_pages);
112740 }
112741 }
112742 return ret;
112743@@ -1643,7 +1643,7 @@ static int __soft_offline_page(struct page *page, int flags)
112744 put_page(page);
112745 pr_info("soft_offline: %#lx: invalidated\n", pfn);
112746 SetPageHWPoison(page);
112747- atomic_long_inc(&num_poisoned_pages);
112748+ atomic_long_inc_unchecked(&num_poisoned_pages);
112749 return 0;
112750 }
112751
112752@@ -1664,7 +1664,7 @@ static int __soft_offline_page(struct page *page, int flags)
112753 page_is_file_cache(page));
112754 list_add(&page->lru, &pagelist);
112755 if (!TestSetPageHWPoison(page))
112756- atomic_long_inc(&num_poisoned_pages);
112757+ atomic_long_inc_unchecked(&num_poisoned_pages);
112758 ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL,
112759 MIGRATE_SYNC, MR_MEMORY_FAILURE);
112760 if (ret) {
112761@@ -1680,7 +1680,7 @@ static int __soft_offline_page(struct page *page, int flags)
112762 if (ret > 0)
112763 ret = -EIO;
112764 if (TestClearPageHWPoison(page))
112765- atomic_long_dec(&num_poisoned_pages);
112766+ atomic_long_dec_unchecked(&num_poisoned_pages);
112767 }
112768 } else {
112769 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
112770@@ -1742,11 +1742,11 @@ int soft_offline_page(struct page *page, int flags)
112771 if (PageHuge(page)) {
112772 set_page_hwpoison_huge_page(hpage);
112773 if (!dequeue_hwpoisoned_huge_page(hpage))
112774- atomic_long_add(1 << compound_order(hpage),
112775+ atomic_long_add_unchecked(1 << compound_order(hpage),
112776 &num_poisoned_pages);
112777 } else {
112778 if (!TestSetPageHWPoison(page))
112779- atomic_long_inc(&num_poisoned_pages);
112780+ atomic_long_inc_unchecked(&num_poisoned_pages);
112781 }
112782 }
112783 return ret;
112784diff --git a/mm/memory.c b/mm/memory.c
112785index 388dcf9..82aa351 100644
112786--- a/mm/memory.c
112787+++ b/mm/memory.c
112788@@ -414,6 +414,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
112789 free_pte_range(tlb, pmd, addr);
112790 } while (pmd++, addr = next, addr != end);
112791
112792+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
112793 start &= PUD_MASK;
112794 if (start < floor)
112795 return;
112796@@ -429,6 +430,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
112797 pud_clear(pud);
112798 pmd_free_tlb(tlb, pmd, start);
112799 mm_dec_nr_pmds(tlb->mm);
112800+#endif
112801 }
112802
112803 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
112804@@ -448,6 +450,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
112805 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
112806 } while (pud++, addr = next, addr != end);
112807
112808+#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
112809 start &= PGDIR_MASK;
112810 if (start < floor)
112811 return;
112812@@ -462,6 +465,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
112813 pud = pud_offset(pgd, start);
112814 pgd_clear(pgd);
112815 pud_free_tlb(tlb, pud, start);
112816+#endif
112817+
112818 }
112819
112820 /*
112821@@ -690,7 +695,7 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
112822 /*
112823 * Choose text because data symbols depend on CONFIG_KALLSYMS_ALL=y
112824 */
112825- pr_alert("file:%pD fault:%pf mmap:%pf readpage:%pf\n",
112826+ pr_alert("file:%pD fault:%pX mmap:%pX readpage:%pX\n",
112827 vma->vm_file,
112828 vma->vm_ops ? vma->vm_ops->fault : NULL,
112829 vma->vm_file ? vma->vm_file->f_op->mmap : NULL,
112830@@ -1463,6 +1468,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
112831 page_add_file_rmap(page);
112832 set_pte_at(mm, addr, pte, mk_pte(page, prot));
112833
112834+#ifdef CONFIG_PAX_SEGMEXEC
112835+ pax_mirror_file_pte(vma, addr, page, ptl);
112836+#endif
112837+
112838 retval = 0;
112839 pte_unmap_unlock(pte, ptl);
112840 return retval;
112841@@ -1507,9 +1516,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
112842 if (!page_count(page))
112843 return -EINVAL;
112844 if (!(vma->vm_flags & VM_MIXEDMAP)) {
112845+
112846+#ifdef CONFIG_PAX_SEGMEXEC
112847+ struct vm_area_struct *vma_m;
112848+#endif
112849+
112850 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
112851 BUG_ON(vma->vm_flags & VM_PFNMAP);
112852 vma->vm_flags |= VM_MIXEDMAP;
112853+
112854+#ifdef CONFIG_PAX_SEGMEXEC
112855+ vma_m = pax_find_mirror_vma(vma);
112856+ if (vma_m)
112857+ vma_m->vm_flags |= VM_MIXEDMAP;
112858+#endif
112859+
112860 }
112861 return insert_page(vma, addr, page, vma->vm_page_prot);
112862 }
112863@@ -1592,6 +1613,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
112864 unsigned long pfn)
112865 {
112866 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
112867+ BUG_ON(vma->vm_mirror);
112868
112869 if (addr < vma->vm_start || addr >= vma->vm_end)
112870 return -EFAULT;
112871@@ -1839,7 +1861,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
112872
112873 BUG_ON(pud_huge(*pud));
112874
112875- pmd = pmd_alloc(mm, pud, addr);
112876+ pmd = (mm == &init_mm) ?
112877+ pmd_alloc_kernel(mm, pud, addr) :
112878+ pmd_alloc(mm, pud, addr);
112879 if (!pmd)
112880 return -ENOMEM;
112881 do {
112882@@ -1859,7 +1883,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
112883 unsigned long next;
112884 int err;
112885
112886- pud = pud_alloc(mm, pgd, addr);
112887+ pud = (mm == &init_mm) ?
112888+ pud_alloc_kernel(mm, pgd, addr) :
112889+ pud_alloc(mm, pgd, addr);
112890 if (!pud)
112891 return -ENOMEM;
112892 do {
112893@@ -2040,6 +2066,196 @@ static inline int wp_page_reuse(struct mm_struct *mm,
112894 return VM_FAULT_WRITE;
112895 }
112896
112897+#ifdef CONFIG_PAX_SEGMEXEC
112898+static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
112899+{
112900+ struct mm_struct *mm = vma->vm_mm;
112901+ spinlock_t *ptl;
112902+ pte_t *pte, entry;
112903+
112904+ pte = pte_offset_map_lock(mm, pmd, address, &ptl);
112905+ entry = *pte;
112906+ if (pte_none(entry))
112907+ ;
112908+ else if (!pte_present(entry)) {
112909+ swp_entry_t swapentry;
112910+
112911+ swapentry = pte_to_swp_entry(entry);
112912+ if (!non_swap_entry(swapentry))
112913+ dec_mm_counter_fast(mm, MM_SWAPENTS);
112914+ else if (is_migration_entry(swapentry)) {
112915+ if (PageAnon(migration_entry_to_page(swapentry)))
112916+ dec_mm_counter_fast(mm, MM_ANONPAGES);
112917+ else
112918+ dec_mm_counter_fast(mm, MM_FILEPAGES);
112919+ }
112920+ free_swap_and_cache(swapentry);
112921+ pte_clear_not_present_full(mm, address, pte, 0);
112922+ } else {
112923+ struct page *page;
112924+
112925+ flush_cache_page(vma, address, pte_pfn(entry));
112926+ entry = ptep_clear_flush(vma, address, pte);
112927+ BUG_ON(pte_dirty(entry));
112928+ page = vm_normal_page(vma, address, entry);
112929+ if (page) {
112930+ update_hiwater_rss(mm);
112931+ if (PageAnon(page))
112932+ dec_mm_counter_fast(mm, MM_ANONPAGES);
112933+ else
112934+ dec_mm_counter_fast(mm, MM_FILEPAGES);
112935+ page_remove_rmap(page);
112936+ page_cache_release(page);
112937+ }
112938+ }
112939+ pte_unmap_unlock(pte, ptl);
112940+}
112941+
112942+/* PaX: if vma is mirrored, synchronize the mirror's PTE
112943+ *
112944+ * the ptl of the lower mapped page is held on entry and is not released on exit
112945+ * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
112946+ */
112947+static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
112948+{
112949+ struct mm_struct *mm = vma->vm_mm;
112950+ unsigned long address_m;
112951+ spinlock_t *ptl_m;
112952+ struct vm_area_struct *vma_m;
112953+ pmd_t *pmd_m;
112954+ pte_t *pte_m, entry_m;
112955+
112956+ BUG_ON(!page_m || !PageAnon(page_m));
112957+
112958+ vma_m = pax_find_mirror_vma(vma);
112959+ if (!vma_m)
112960+ return;
112961+
112962+ BUG_ON(!PageLocked(page_m));
112963+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
112964+ address_m = address + SEGMEXEC_TASK_SIZE;
112965+ pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
112966+ pte_m = pte_offset_map(pmd_m, address_m);
112967+ ptl_m = pte_lockptr(mm, pmd_m);
112968+ if (ptl != ptl_m) {
112969+ spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
112970+ if (!pte_none(*pte_m))
112971+ goto out;
112972+ }
112973+
112974+ entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
112975+ page_cache_get(page_m);
112976+ page_add_anon_rmap(page_m, vma_m, address_m);
112977+ inc_mm_counter_fast(mm, MM_ANONPAGES);
112978+ set_pte_at(mm, address_m, pte_m, entry_m);
112979+ update_mmu_cache(vma_m, address_m, pte_m);
112980+out:
112981+ if (ptl != ptl_m)
112982+ spin_unlock(ptl_m);
112983+ pte_unmap(pte_m);
112984+ unlock_page(page_m);
112985+}
112986+
112987+void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
112988+{
112989+ struct mm_struct *mm = vma->vm_mm;
112990+ unsigned long address_m;
112991+ spinlock_t *ptl_m;
112992+ struct vm_area_struct *vma_m;
112993+ pmd_t *pmd_m;
112994+ pte_t *pte_m, entry_m;
112995+
112996+ BUG_ON(!page_m || PageAnon(page_m));
112997+
112998+ vma_m = pax_find_mirror_vma(vma);
112999+ if (!vma_m)
113000+ return;
113001+
113002+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
113003+ address_m = address + SEGMEXEC_TASK_SIZE;
113004+ pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
113005+ pte_m = pte_offset_map(pmd_m, address_m);
113006+ ptl_m = pte_lockptr(mm, pmd_m);
113007+ if (ptl != ptl_m) {
113008+ spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
113009+ if (!pte_none(*pte_m))
113010+ goto out;
113011+ }
113012+
113013+ entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
113014+ page_cache_get(page_m);
113015+ page_add_file_rmap(page_m);
113016+ inc_mm_counter_fast(mm, MM_FILEPAGES);
113017+ set_pte_at(mm, address_m, pte_m, entry_m);
113018+ update_mmu_cache(vma_m, address_m, pte_m);
113019+out:
113020+ if (ptl != ptl_m)
113021+ spin_unlock(ptl_m);
113022+ pte_unmap(pte_m);
113023+}
113024+
113025+static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
113026+{
113027+ struct mm_struct *mm = vma->vm_mm;
113028+ unsigned long address_m;
113029+ spinlock_t *ptl_m;
113030+ struct vm_area_struct *vma_m;
113031+ pmd_t *pmd_m;
113032+ pte_t *pte_m, entry_m;
113033+
113034+ vma_m = pax_find_mirror_vma(vma);
113035+ if (!vma_m)
113036+ return;
113037+
113038+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
113039+ address_m = address + SEGMEXEC_TASK_SIZE;
113040+ pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
113041+ pte_m = pte_offset_map(pmd_m, address_m);
113042+ ptl_m = pte_lockptr(mm, pmd_m);
113043+ if (ptl != ptl_m) {
113044+ spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
113045+ if (!pte_none(*pte_m))
113046+ goto out;
113047+ }
113048+
113049+ entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
113050+ set_pte_at(mm, address_m, pte_m, entry_m);
113051+out:
113052+ if (ptl != ptl_m)
113053+ spin_unlock(ptl_m);
113054+ pte_unmap(pte_m);
113055+}
113056+
113057+static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
113058+{
113059+ struct page *page_m;
113060+ pte_t entry;
113061+
113062+ if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
113063+ goto out;
113064+
113065+ entry = *pte;
113066+ page_m = vm_normal_page(vma, address, entry);
113067+ if (!page_m)
113068+ pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
113069+ else if (PageAnon(page_m)) {
113070+ if (pax_find_mirror_vma(vma)) {
113071+ pte_unmap_unlock(pte, ptl);
113072+ lock_page(page_m);
113073+ pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
113074+ if (pte_same(entry, *pte))
113075+ pax_mirror_anon_pte(vma, address, page_m, ptl);
113076+ else
113077+ unlock_page(page_m);
113078+ }
113079+ } else
113080+ pax_mirror_file_pte(vma, address, page_m, ptl);
113081+
113082+out:
113083+ pte_unmap_unlock(pte, ptl);
113084+}
113085+#endif
113086+
113087 /*
113088 * Handle the case of a page which we actually need to copy to a new page.
113089 *
113090@@ -2094,6 +2310,12 @@ static int wp_page_copy(struct mm_struct *mm, struct vm_area_struct *vma,
113091 */
113092 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
113093 if (likely(pte_same(*page_table, orig_pte))) {
113094+
113095+#ifdef CONFIG_PAX_SEGMEXEC
113096+ if (pax_find_mirror_vma(vma))
113097+ BUG_ON(!trylock_page(new_page));
113098+#endif
113099+
113100 if (old_page) {
113101 if (!PageAnon(old_page)) {
113102 dec_mm_counter_fast(mm, MM_FILEPAGES);
113103@@ -2148,6 +2370,10 @@ static int wp_page_copy(struct mm_struct *mm, struct vm_area_struct *vma,
113104 page_remove_rmap(old_page);
113105 }
113106
113107+#ifdef CONFIG_PAX_SEGMEXEC
113108+ pax_mirror_anon_pte(vma, address, new_page, ptl);
113109+#endif
113110+
113111 /* Free the old page.. */
113112 new_page = old_page;
113113 page_copied = 1;
113114@@ -2579,6 +2805,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
113115 swap_free(entry);
113116 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
113117 try_to_free_swap(page);
113118+
113119+#ifdef CONFIG_PAX_SEGMEXEC
113120+ if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
113121+#endif
113122+
113123 unlock_page(page);
113124 if (page != swapcache) {
113125 /*
113126@@ -2602,6 +2833,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
113127
113128 /* No need to invalidate - it was non-present before */
113129 update_mmu_cache(vma, address, page_table);
113130+
113131+#ifdef CONFIG_PAX_SEGMEXEC
113132+ pax_mirror_anon_pte(vma, address, page, ptl);
113133+#endif
113134+
113135 unlock:
113136 pte_unmap_unlock(page_table, ptl);
113137 out:
113138@@ -2621,40 +2857,6 @@ out_release:
113139 }
113140
113141 /*
113142- * This is like a special single-page "expand_{down|up}wards()",
113143- * except we must first make sure that 'address{-|+}PAGE_SIZE'
113144- * doesn't hit another vma.
113145- */
113146-static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
113147-{
113148- address &= PAGE_MASK;
113149- if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
113150- struct vm_area_struct *prev = vma->vm_prev;
113151-
113152- /*
113153- * Is there a mapping abutting this one below?
113154- *
113155- * That's only ok if it's the same stack mapping
113156- * that has gotten split..
113157- */
113158- if (prev && prev->vm_end == address)
113159- return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
113160-
113161- return expand_downwards(vma, address - PAGE_SIZE);
113162- }
113163- if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
113164- struct vm_area_struct *next = vma->vm_next;
113165-
113166- /* As VM_GROWSDOWN but s/below/above/ */
113167- if (next && next->vm_start == address + PAGE_SIZE)
113168- return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
113169-
113170- return expand_upwards(vma, address + PAGE_SIZE);
113171- }
113172- return 0;
113173-}
113174-
113175-/*
113176 * We enter with non-exclusive mmap_sem (to exclude vma changes,
113177 * but allow concurrent faults), and pte mapped but not yet locked.
113178 * We return with mmap_sem still held, but pte unmapped and unlocked.
113179@@ -2664,31 +2866,29 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
113180 unsigned int flags)
113181 {
113182 struct mem_cgroup *memcg;
113183- struct page *page;
113184+ struct page *page = NULL;
113185 spinlock_t *ptl;
113186 pte_t entry;
113187
113188- pte_unmap(page_table);
113189-
113190 /* File mapping without ->vm_ops ? */
113191- if (vma->vm_flags & VM_SHARED)
113192+ if (vma->vm_flags & VM_SHARED) {
113193+ pte_unmap(page_table);
113194 return VM_FAULT_SIGBUS;
113195+ }
113196
113197- /* Check if we need to add a guard page to the stack */
113198- if (check_stack_guard_page(vma, address) < 0)
113199- return VM_FAULT_SIGSEGV;
113200-
113201- /* Use the zero-page for reads */
113202 if (!(flags & FAULT_FLAG_WRITE) && !mm_forbids_zeropage(mm)) {
113203 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
113204 vma->vm_page_prot));
113205- page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
113206+ ptl = pte_lockptr(mm, pmd);
113207+ spin_lock(ptl);
113208 if (!pte_none(*page_table))
113209 goto unlock;
113210 goto setpte;
113211 }
113212
113213 /* Allocate our own private page. */
113214+ pte_unmap(page_table);
113215+
113216 if (unlikely(anon_vma_prepare(vma)))
113217 goto oom;
113218 page = alloc_zeroed_user_highpage_movable(vma, address);
113219@@ -2713,6 +2913,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
113220 if (!pte_none(*page_table))
113221 goto release;
113222
113223+#ifdef CONFIG_PAX_SEGMEXEC
113224+ if (pax_find_mirror_vma(vma))
113225+ BUG_ON(!trylock_page(page));
113226+#endif
113227+
113228 inc_mm_counter_fast(mm, MM_ANONPAGES);
113229 page_add_new_anon_rmap(page, vma, address);
113230 mem_cgroup_commit_charge(page, memcg, false);
113231@@ -2722,6 +2927,12 @@ setpte:
113232
113233 /* No need to invalidate - it was non-present before */
113234 update_mmu_cache(vma, address, page_table);
113235+
113236+#ifdef CONFIG_PAX_SEGMEXEC
113237+ if (page)
113238+ pax_mirror_anon_pte(vma, address, page, ptl);
113239+#endif
113240+
113241 unlock:
113242 pte_unmap_unlock(page_table, ptl);
113243 return 0;
113244@@ -2954,6 +3165,11 @@ static int do_read_fault(struct mm_struct *mm, struct vm_area_struct *vma,
113245 return ret;
113246 }
113247 do_set_pte(vma, address, fault_page, pte, false, false);
113248+
113249+#ifdef CONFIG_PAX_SEGMEXEC
113250+ pax_mirror_file_pte(vma, address, fault_page, ptl);
113251+#endif
113252+
113253 unlock_page(fault_page);
113254 unlock_out:
113255 pte_unmap_unlock(pte, ptl);
113256@@ -3005,7 +3221,18 @@ static int do_cow_fault(struct mm_struct *mm, struct vm_area_struct *vma,
113257 }
113258 goto uncharge_out;
113259 }
113260+
113261+#ifdef CONFIG_PAX_SEGMEXEC
113262+ if (pax_find_mirror_vma(vma))
113263+ BUG_ON(!trylock_page(new_page));
113264+#endif
113265+
113266 do_set_pte(vma, address, new_page, pte, true, true);
113267+
113268+#ifdef CONFIG_PAX_SEGMEXEC
113269+ pax_mirror_anon_pte(vma, address, new_page, ptl);
113270+#endif
113271+
113272 mem_cgroup_commit_charge(new_page, memcg, false);
113273 lru_cache_add_active_or_unevictable(new_page, vma);
113274 pte_unmap_unlock(pte, ptl);
113275@@ -3063,6 +3290,11 @@ static int do_shared_fault(struct mm_struct *mm, struct vm_area_struct *vma,
113276 return ret;
113277 }
113278 do_set_pte(vma, address, fault_page, pte, true, false);
113279+
113280+#ifdef CONFIG_PAX_SEGMEXEC
113281+ pax_mirror_file_pte(vma, address, fault_page, ptl);
113282+#endif
113283+
113284 pte_unmap_unlock(pte, ptl);
113285
113286 if (set_page_dirty(fault_page))
113287@@ -3288,6 +3520,12 @@ static int handle_pte_fault(struct mm_struct *mm,
113288 if (flags & FAULT_FLAG_WRITE)
113289 flush_tlb_fix_spurious_fault(vma, address);
113290 }
113291+
113292+#ifdef CONFIG_PAX_SEGMEXEC
113293+ pax_mirror_pte(vma, address, pte, pmd, ptl);
113294+ return 0;
113295+#endif
113296+
113297 unlock:
113298 pte_unmap_unlock(pte, ptl);
113299 return 0;
113300@@ -3307,9 +3545,41 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
113301 pmd_t *pmd;
113302 pte_t *pte;
113303
113304+#ifdef CONFIG_PAX_SEGMEXEC
113305+ struct vm_area_struct *vma_m;
113306+#endif
113307+
113308 if (unlikely(is_vm_hugetlb_page(vma)))
113309 return hugetlb_fault(mm, vma, address, flags);
113310
113311+#ifdef CONFIG_PAX_SEGMEXEC
113312+ vma_m = pax_find_mirror_vma(vma);
113313+ if (vma_m) {
113314+ unsigned long address_m;
113315+ pgd_t *pgd_m;
113316+ pud_t *pud_m;
113317+ pmd_t *pmd_m;
113318+
113319+ if (vma->vm_start > vma_m->vm_start) {
113320+ address_m = address;
113321+ address -= SEGMEXEC_TASK_SIZE;
113322+ vma = vma_m;
113323+ } else
113324+ address_m = address + SEGMEXEC_TASK_SIZE;
113325+
113326+ pgd_m = pgd_offset(mm, address_m);
113327+ pud_m = pud_alloc(mm, pgd_m, address_m);
113328+ if (!pud_m)
113329+ return VM_FAULT_OOM;
113330+ pmd_m = pmd_alloc(mm, pud_m, address_m);
113331+ if (!pmd_m)
113332+ return VM_FAULT_OOM;
113333+ if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
113334+ return VM_FAULT_OOM;
113335+ pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
113336+ }
113337+#endif
113338+
113339 pgd = pgd_offset(mm, address);
113340 pud = pud_alloc(mm, pgd, address);
113341 if (!pud)
113342@@ -3444,6 +3714,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
113343 spin_unlock(&mm->page_table_lock);
113344 return 0;
113345 }
113346+
113347+int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
113348+{
113349+ pud_t *new = pud_alloc_one(mm, address);
113350+ if (!new)
113351+ return -ENOMEM;
113352+
113353+ smp_wmb(); /* See comment in __pte_alloc */
113354+
113355+ spin_lock(&mm->page_table_lock);
113356+ if (pgd_present(*pgd)) /* Another has populated it */
113357+ pud_free(mm, new);
113358+ else
113359+ pgd_populate_kernel(mm, pgd, new);
113360+ spin_unlock(&mm->page_table_lock);
113361+ return 0;
113362+}
113363 #endif /* __PAGETABLE_PUD_FOLDED */
113364
113365 #ifndef __PAGETABLE_PMD_FOLDED
113366@@ -3476,6 +3763,32 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
113367 spin_unlock(&mm->page_table_lock);
113368 return 0;
113369 }
113370+
113371+int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
113372+{
113373+ pmd_t *new = pmd_alloc_one(mm, address);
113374+ if (!new)
113375+ return -ENOMEM;
113376+
113377+ smp_wmb(); /* See comment in __pte_alloc */
113378+
113379+ spin_lock(&mm->page_table_lock);
113380+#ifndef __ARCH_HAS_4LEVEL_HACK
113381+ if (!pud_present(*pud)) {
113382+ mm_inc_nr_pmds(mm);
113383+ pud_populate_kernel(mm, pud, new);
113384+ } else /* Another has populated it */
113385+ pmd_free(mm, new);
113386+#else
113387+ if (!pgd_present(*pud)) {
113388+ mm_inc_nr_pmds(mm);
113389+ pgd_populate_kernel(mm, pud, new);
113390+ } else /* Another has populated it */
113391+ pmd_free(mm, new);
113392+#endif /* __ARCH_HAS_4LEVEL_HACK */
113393+ spin_unlock(&mm->page_table_lock);
113394+ return 0;
113395+}
113396 #endif /* __PAGETABLE_PMD_FOLDED */
113397
113398 static int __follow_pte(struct mm_struct *mm, unsigned long address,
113399@@ -3585,8 +3898,8 @@ out:
113400 return ret;
113401 }
113402
113403-int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
113404- void *buf, int len, int write)
113405+ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
113406+ void *buf, size_t len, int write)
113407 {
113408 resource_size_t phys_addr;
113409 unsigned long prot = 0;
113410@@ -3612,8 +3925,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
113411 * Access another process' address space as given in mm. If non-NULL, use the
113412 * given task for page fault accounting.
113413 */
113414-static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
113415- unsigned long addr, void *buf, int len, int write)
113416+static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
113417+ unsigned long addr, void *buf, size_t len, int write)
113418 {
113419 struct vm_area_struct *vma;
113420 void *old_buf = buf;
113421@@ -3621,7 +3934,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
113422 down_read(&mm->mmap_sem);
113423 /* ignore errors, just check how much was successfully transferred */
113424 while (len) {
113425- int bytes, ret, offset;
113426+ ssize_t bytes, ret, offset;
113427 void *maddr;
113428 struct page *page = NULL;
113429
113430@@ -3682,8 +3995,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
113431 *
113432 * The caller must hold a reference on @mm.
113433 */
113434-int access_remote_vm(struct mm_struct *mm, unsigned long addr,
113435- void *buf, int len, int write)
113436+ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
113437+ void *buf, size_t len, int write)
113438 {
113439 return __access_remote_vm(NULL, mm, addr, buf, len, write);
113440 }
113441@@ -3693,11 +4006,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
113442 * Source/target buffer must be kernel space,
113443 * Do not walk the page table directly, use get_user_pages
113444 */
113445-int access_process_vm(struct task_struct *tsk, unsigned long addr,
113446- void *buf, int len, int write)
113447+ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
113448+ void *buf, size_t len, int write)
113449 {
113450 struct mm_struct *mm;
113451- int ret;
113452+ ssize_t ret;
113453
113454 mm = get_task_mm(tsk);
113455 if (!mm)
113456diff --git a/mm/mempolicy.c b/mm/mempolicy.c
113457index 99d4c1d..a577817 100644
113458--- a/mm/mempolicy.c
113459+++ b/mm/mempolicy.c
113460@@ -703,6 +703,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
113461 unsigned long vmstart;
113462 unsigned long vmend;
113463
113464+#ifdef CONFIG_PAX_SEGMEXEC
113465+ struct vm_area_struct *vma_m;
113466+#endif
113467+
113468 vma = find_vma(mm, start);
113469 if (!vma || vma->vm_start > start)
113470 return -EFAULT;
113471@@ -746,6 +750,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
113472 err = vma_replace_policy(vma, new_pol);
113473 if (err)
113474 goto out;
113475+
113476+#ifdef CONFIG_PAX_SEGMEXEC
113477+ vma_m = pax_find_mirror_vma(vma);
113478+ if (vma_m) {
113479+ err = vma_replace_policy(vma_m, new_pol);
113480+ if (err)
113481+ goto out;
113482+ }
113483+#endif
113484+
113485 }
113486
113487 out:
113488@@ -1161,6 +1175,17 @@ static long do_mbind(unsigned long start, unsigned long len,
113489
113490 if (end < start)
113491 return -EINVAL;
113492+
113493+#ifdef CONFIG_PAX_SEGMEXEC
113494+ if (mm->pax_flags & MF_PAX_SEGMEXEC) {
113495+ if (end > SEGMEXEC_TASK_SIZE)
113496+ return -EINVAL;
113497+ } else
113498+#endif
113499+
113500+ if (end > TASK_SIZE)
113501+ return -EINVAL;
113502+
113503 if (end == start)
113504 return 0;
113505
113506@@ -1386,8 +1411,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
113507 */
113508 tcred = __task_cred(task);
113509 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
113510- !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
113511- !capable(CAP_SYS_NICE)) {
113512+ !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
113513 rcu_read_unlock();
113514 err = -EPERM;
113515 goto out_put;
113516@@ -1418,6 +1442,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
113517 goto out;
113518 }
113519
113520+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
113521+ if (mm != current->mm &&
113522+ (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
113523+ mmput(mm);
113524+ err = -EPERM;
113525+ goto out;
113526+ }
113527+#endif
113528+
113529 err = do_migrate_pages(mm, old, new,
113530 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
113531
113532diff --git a/mm/migrate.c b/mm/migrate.c
113533index fcb6204..b3f1a44 100644
113534--- a/mm/migrate.c
113535+++ b/mm/migrate.c
113536@@ -1501,8 +1501,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
113537 */
113538 tcred = __task_cred(task);
113539 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
113540- !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
113541- !capable(CAP_SYS_NICE)) {
113542+ !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
113543 rcu_read_unlock();
113544 err = -EPERM;
113545 goto out;
113546diff --git a/mm/mlock.c b/mm/mlock.c
113547index 6fd2cf1..cbae765 100644
113548--- a/mm/mlock.c
113549+++ b/mm/mlock.c
113550@@ -14,6 +14,7 @@
113551 #include <linux/pagevec.h>
113552 #include <linux/mempolicy.h>
113553 #include <linux/syscalls.h>
113554+#include <linux/security.h>
113555 #include <linux/sched.h>
113556 #include <linux/export.h>
113557 #include <linux/rmap.h>
113558@@ -557,7 +558,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
113559 {
113560 unsigned long nstart, end, tmp;
113561 struct vm_area_struct * vma, * prev;
113562- int error;
113563+ int error = 0;
113564
113565 VM_BUG_ON(start & ~PAGE_MASK);
113566 VM_BUG_ON(len != PAGE_ALIGN(len));
113567@@ -566,6 +567,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
113568 return -EINVAL;
113569 if (end == start)
113570 return 0;
113571+ if (end > TASK_SIZE)
113572+ return -EINVAL;
113573+
113574 vma = find_vma(current->mm, start);
113575 if (!vma || vma->vm_start > start)
113576 return -ENOMEM;
113577@@ -577,6 +581,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
113578 for (nstart = start ; ; ) {
113579 vm_flags_t newflags;
113580
113581+#ifdef CONFIG_PAX_SEGMEXEC
113582+ if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
113583+ break;
113584+#endif
113585+
113586 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
113587
113588 newflags = vma->vm_flags & ~VM_LOCKED;
113589@@ -627,6 +636,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
113590 locked += current->mm->locked_vm;
113591
113592 /* check against resource limits */
113593+ gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
113594 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
113595 error = do_mlock(start, len, 1);
113596
113597@@ -668,6 +678,11 @@ static int do_mlockall(int flags)
113598 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
113599 vm_flags_t newflags;
113600
113601+#ifdef CONFIG_PAX_SEGMEXEC
113602+ if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
113603+ break;
113604+#endif
113605+
113606 newflags = vma->vm_flags & ~VM_LOCKED;
113607 if (flags & MCL_CURRENT)
113608 newflags |= VM_LOCKED;
113609@@ -699,8 +714,10 @@ SYSCALL_DEFINE1(mlockall, int, flags)
113610 lock_limit >>= PAGE_SHIFT;
113611
113612 ret = -ENOMEM;
113613+
113614+ gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
113615+
113616 down_write(&current->mm->mmap_sem);
113617-
113618 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
113619 capable(CAP_IPC_LOCK))
113620 ret = do_mlockall(flags);
113621diff --git a/mm/mm_init.c b/mm/mm_init.c
113622index fdadf91..5f527d1 100644
113623--- a/mm/mm_init.c
113624+++ b/mm/mm_init.c
113625@@ -170,7 +170,7 @@ static int __meminit mm_compute_batch_notifier(struct notifier_block *self,
113626 return NOTIFY_OK;
113627 }
113628
113629-static struct notifier_block compute_batch_nb __meminitdata = {
113630+static struct notifier_block compute_batch_nb __meminitconst = {
113631 .notifier_call = mm_compute_batch_notifier,
113632 .priority = IPC_CALLBACK_PRI, /* use lowest priority */
113633 };
113634diff --git a/mm/mmap.c b/mm/mmap.c
113635index aa632ad..13456342 100644
113636--- a/mm/mmap.c
113637+++ b/mm/mmap.c
113638@@ -41,6 +41,7 @@
113639 #include <linux/notifier.h>
113640 #include <linux/memory.h>
113641 #include <linux/printk.h>
113642+#include <linux/random.h>
113643
113644 #include <asm/uaccess.h>
113645 #include <asm/cacheflush.h>
113646@@ -57,6 +58,16 @@
113647 #define arch_rebalance_pgtables(addr, len) (addr)
113648 #endif
113649
113650+static inline void verify_mm_writelocked(struct mm_struct *mm)
113651+{
113652+#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
113653+ if (unlikely(down_read_trylock(&mm->mmap_sem))) {
113654+ up_read(&mm->mmap_sem);
113655+ BUG();
113656+ }
113657+#endif
113658+}
113659+
113660 static void unmap_region(struct mm_struct *mm,
113661 struct vm_area_struct *vma, struct vm_area_struct *prev,
113662 unsigned long start, unsigned long end);
113663@@ -76,16 +87,25 @@ static void unmap_region(struct mm_struct *mm,
113664 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
113665 *
113666 */
113667-pgprot_t protection_map[16] = {
113668+pgprot_t protection_map[16] __read_only = {
113669 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
113670 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
113671 };
113672
113673-pgprot_t vm_get_page_prot(unsigned long vm_flags)
113674+pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
113675 {
113676- return __pgprot(pgprot_val(protection_map[vm_flags &
113677+ pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
113678 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
113679 pgprot_val(arch_vm_get_page_prot(vm_flags)));
113680+
113681+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
113682+ if (!(__supported_pte_mask & _PAGE_NX) &&
113683+ (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
113684+ (vm_flags & (VM_READ | VM_WRITE)))
113685+ prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
113686+#endif
113687+
113688+ return prot;
113689 }
113690 EXPORT_SYMBOL(vm_get_page_prot);
113691
113692@@ -114,6 +134,7 @@ unsigned long sysctl_overcommit_kbytes __read_mostly;
113693 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
113694 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
113695 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
113696+unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
113697 /*
113698 * Make sure vm_committed_as in one cacheline and not cacheline shared with
113699 * other variables. It can be updated by several CPUs frequently.
113700@@ -271,6 +292,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
113701 struct vm_area_struct *next = vma->vm_next;
113702
113703 might_sleep();
113704+ BUG_ON(vma->vm_mirror);
113705 if (vma->vm_ops && vma->vm_ops->close)
113706 vma->vm_ops->close(vma);
113707 if (vma->vm_file)
113708@@ -284,6 +306,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len);
113709
113710 SYSCALL_DEFINE1(brk, unsigned long, brk)
113711 {
113712+ unsigned long rlim;
113713 unsigned long retval;
113714 unsigned long newbrk, oldbrk;
113715 struct mm_struct *mm = current->mm;
113716@@ -314,7 +337,13 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
113717 * segment grow beyond its set limit the in case where the limit is
113718 * not page aligned -Ram Gupta
113719 */
113720- if (check_data_rlimit(rlimit(RLIMIT_DATA), brk, mm->start_brk,
113721+ rlim = rlimit(RLIMIT_DATA);
113722+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
113723+ /* force a minimum 16MB brk heap on setuid/setgid binaries */
113724+ if (rlim < PAGE_SIZE && (get_dumpable(mm) != SUID_DUMP_USER) && gr_is_global_nonroot(current_uid()))
113725+ rlim = 4096 * PAGE_SIZE;
113726+#endif
113727+ if (check_data_rlimit(rlim, brk, mm->start_brk,
113728 mm->end_data, mm->start_data))
113729 goto out;
113730
113731@@ -967,6 +996,12 @@ static int
113732 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
113733 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
113734 {
113735+
113736+#ifdef CONFIG_PAX_SEGMEXEC
113737+ if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
113738+ return 0;
113739+#endif
113740+
113741 if (is_mergeable_vma(vma, file, vm_flags) &&
113742 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
113743 if (vma->vm_pgoff == vm_pgoff)
113744@@ -986,6 +1021,12 @@ static int
113745 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
113746 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
113747 {
113748+
113749+#ifdef CONFIG_PAX_SEGMEXEC
113750+ if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
113751+ return 0;
113752+#endif
113753+
113754 if (is_mergeable_vma(vma, file, vm_flags) &&
113755 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
113756 pgoff_t vm_pglen;
113757@@ -1035,6 +1076,13 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113758 struct vm_area_struct *area, *next;
113759 int err;
113760
113761+#ifdef CONFIG_PAX_SEGMEXEC
113762+ unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
113763+ struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
113764+
113765+ BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
113766+#endif
113767+
113768 /*
113769 * We later require that vma->vm_flags == vm_flags,
113770 * so this tests vma->vm_flags & VM_SPECIAL, too.
113771@@ -1050,6 +1098,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113772 if (next && next->vm_end == end) /* cases 6, 7, 8 */
113773 next = next->vm_next;
113774
113775+#ifdef CONFIG_PAX_SEGMEXEC
113776+ if (prev)
113777+ prev_m = pax_find_mirror_vma(prev);
113778+ if (area)
113779+ area_m = pax_find_mirror_vma(area);
113780+ if (next)
113781+ next_m = pax_find_mirror_vma(next);
113782+#endif
113783+
113784 /*
113785 * Can it merge with the predecessor?
113786 */
113787@@ -1069,9 +1126,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113788 /* cases 1, 6 */
113789 err = vma_adjust(prev, prev->vm_start,
113790 next->vm_end, prev->vm_pgoff, NULL);
113791- } else /* cases 2, 5, 7 */
113792+
113793+#ifdef CONFIG_PAX_SEGMEXEC
113794+ if (!err && prev_m)
113795+ err = vma_adjust(prev_m, prev_m->vm_start,
113796+ next_m->vm_end, prev_m->vm_pgoff, NULL);
113797+#endif
113798+
113799+ } else { /* cases 2, 5, 7 */
113800 err = vma_adjust(prev, prev->vm_start,
113801 end, prev->vm_pgoff, NULL);
113802+
113803+#ifdef CONFIG_PAX_SEGMEXEC
113804+ if (!err && prev_m)
113805+ err = vma_adjust(prev_m, prev_m->vm_start,
113806+ end_m, prev_m->vm_pgoff, NULL);
113807+#endif
113808+
113809+ }
113810 if (err)
113811 return NULL;
113812 khugepaged_enter_vma_merge(prev, vm_flags);
113813@@ -1085,12 +1157,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113814 mpol_equal(policy, vma_policy(next)) &&
113815 can_vma_merge_before(next, vm_flags,
113816 anon_vma, file, pgoff+pglen)) {
113817- if (prev && addr < prev->vm_end) /* case 4 */
113818+ if (prev && addr < prev->vm_end) { /* case 4 */
113819 err = vma_adjust(prev, prev->vm_start,
113820 addr, prev->vm_pgoff, NULL);
113821- else /* cases 3, 8 */
113822+
113823+#ifdef CONFIG_PAX_SEGMEXEC
113824+ if (!err && prev_m)
113825+ err = vma_adjust(prev_m, prev_m->vm_start,
113826+ addr_m, prev_m->vm_pgoff, NULL);
113827+#endif
113828+
113829+ } else { /* cases 3, 8 */
113830 err = vma_adjust(area, addr, next->vm_end,
113831 next->vm_pgoff - pglen, NULL);
113832+
113833+#ifdef CONFIG_PAX_SEGMEXEC
113834+ if (!err && area_m)
113835+ err = vma_adjust(area_m, addr_m, next_m->vm_end,
113836+ next_m->vm_pgoff - pglen, NULL);
113837+#endif
113838+
113839+ }
113840 if (err)
113841 return NULL;
113842 khugepaged_enter_vma_merge(area, vm_flags);
113843@@ -1199,8 +1286,10 @@ none:
113844 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
113845 struct file *file, long pages)
113846 {
113847- const unsigned long stack_flags
113848- = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
113849+
113850+#ifdef CONFIG_PAX_RANDMMAP
113851+ if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
113852+#endif
113853
113854 mm->total_vm += pages;
113855
113856@@ -1208,7 +1297,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
113857 mm->shared_vm += pages;
113858 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
113859 mm->exec_vm += pages;
113860- } else if (flags & stack_flags)
113861+ } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
113862 mm->stack_vm += pages;
113863 }
113864 #endif /* CONFIG_PROC_FS */
113865@@ -1238,6 +1327,7 @@ static inline int mlock_future_check(struct mm_struct *mm,
113866 locked += mm->locked_vm;
113867 lock_limit = rlimit(RLIMIT_MEMLOCK);
113868 lock_limit >>= PAGE_SHIFT;
113869+ gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
113870 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
113871 return -EAGAIN;
113872 }
113873@@ -1267,7 +1357,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
113874 * (the exception is when the underlying filesystem is noexec
113875 * mounted, in which case we dont add PROT_EXEC.)
113876 */
113877- if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
113878+ if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
113879 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
113880 prot |= PROT_EXEC;
113881
113882@@ -1290,7 +1380,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
113883 /* Obtain the address to map to. we verify (or select) it and ensure
113884 * that it represents a valid section of the address space.
113885 */
113886- addr = get_unmapped_area(file, addr, len, pgoff, flags);
113887+ addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
113888 if (addr & ~PAGE_MASK)
113889 return addr;
113890
113891@@ -1301,6 +1391,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
113892 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
113893 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
113894
113895+#ifdef CONFIG_PAX_MPROTECT
113896+ if (mm->pax_flags & MF_PAX_MPROTECT) {
113897+
113898+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
113899+ if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
113900+ mm->binfmt->handle_mmap)
113901+ mm->binfmt->handle_mmap(file);
113902+#endif
113903+
113904+#ifndef CONFIG_PAX_MPROTECT_COMPAT
113905+ if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
113906+ gr_log_rwxmmap(file);
113907+
113908+#ifdef CONFIG_PAX_EMUPLT
113909+ vm_flags &= ~VM_EXEC;
113910+#else
113911+ return -EPERM;
113912+#endif
113913+
113914+ }
113915+
113916+ if (!(vm_flags & VM_EXEC))
113917+ vm_flags &= ~VM_MAYEXEC;
113918+#else
113919+ if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
113920+ vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
113921+#endif
113922+ else
113923+ vm_flags &= ~VM_MAYWRITE;
113924+ }
113925+#endif
113926+
113927+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
113928+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
113929+ vm_flags &= ~VM_PAGEEXEC;
113930+#endif
113931+
113932 if (flags & MAP_LOCKED)
113933 if (!can_do_mlock())
113934 return -EPERM;
113935@@ -1388,6 +1515,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
113936 vm_flags |= VM_NORESERVE;
113937 }
113938
113939+ if (!gr_acl_handle_mmap(file, prot))
113940+ return -EACCES;
113941+
113942 addr = mmap_region(file, addr, len, vm_flags, pgoff);
113943 if (!IS_ERR_VALUE(addr) &&
113944 ((vm_flags & VM_LOCKED) ||
113945@@ -1481,7 +1611,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
113946 vm_flags_t vm_flags = vma->vm_flags;
113947
113948 /* If it was private or non-writable, the write bit is already clear */
113949- if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
113950+ if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
113951 return 0;
113952
113953 /* The backer wishes to know when pages are first written to? */
113954@@ -1532,7 +1662,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
113955 struct rb_node **rb_link, *rb_parent;
113956 unsigned long charged = 0;
113957
113958+#ifdef CONFIG_PAX_SEGMEXEC
113959+ struct vm_area_struct *vma_m = NULL;
113960+#endif
113961+
113962+ /*
113963+ * mm->mmap_sem is required to protect against another thread
113964+ * changing the mappings in case we sleep.
113965+ */
113966+ verify_mm_writelocked(mm);
113967+
113968 /* Check against address space limit. */
113969+
113970+#ifdef CONFIG_PAX_RANDMMAP
113971+ if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
113972+#endif
113973+
113974 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
113975 unsigned long nr_pages;
113976
113977@@ -1555,6 +1700,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
113978 &rb_parent)) {
113979 if (do_munmap(mm, addr, len))
113980 return -ENOMEM;
113981+ BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
113982 }
113983
113984 /*
113985@@ -1586,6 +1732,16 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
113986 goto unacct_error;
113987 }
113988
113989+#ifdef CONFIG_PAX_SEGMEXEC
113990+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
113991+ vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
113992+ if (!vma_m) {
113993+ error = -ENOMEM;
113994+ goto free_vma;
113995+ }
113996+ }
113997+#endif
113998+
113999 vma->vm_mm = mm;
114000 vma->vm_start = addr;
114001 vma->vm_end = addr + len;
114002@@ -1616,6 +1772,13 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
114003 if (error)
114004 goto unmap_and_free_vma;
114005
114006+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
114007+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
114008+ vma->vm_flags |= VM_PAGEEXEC;
114009+ vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
114010+ }
114011+#endif
114012+
114013 /* Can addr have changed??
114014 *
114015 * Answer: Yes, several device drivers can do it in their
114016@@ -1634,6 +1797,12 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
114017 }
114018
114019 vma_link(mm, vma, prev, rb_link, rb_parent);
114020+
114021+#ifdef CONFIG_PAX_SEGMEXEC
114022+ if (vma_m)
114023+ BUG_ON(pax_mirror_vma(vma_m, vma));
114024+#endif
114025+
114026 /* Once vma denies write, undo our temporary denial count */
114027 if (file) {
114028 if (vm_flags & VM_SHARED)
114029@@ -1646,6 +1815,7 @@ out:
114030 perf_event_mmap(vma);
114031
114032 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
114033+ track_exec_limit(mm, addr, addr + len, vm_flags);
114034 if (vm_flags & VM_LOCKED) {
114035 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
114036 vma == get_gate_vma(current->mm)))
114037@@ -1683,6 +1853,12 @@ allow_write_and_free_vma:
114038 if (vm_flags & VM_DENYWRITE)
114039 allow_write_access(file);
114040 free_vma:
114041+
114042+#ifdef CONFIG_PAX_SEGMEXEC
114043+ if (vma_m)
114044+ kmem_cache_free(vm_area_cachep, vma_m);
114045+#endif
114046+
114047 kmem_cache_free(vm_area_cachep, vma);
114048 unacct_error:
114049 if (charged)
114050@@ -1690,7 +1866,63 @@ unacct_error:
114051 return error;
114052 }
114053
114054-unsigned long unmapped_area(struct vm_unmapped_area_info *info)
114055+#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
114056+unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
114057+{
114058+ if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
114059+ return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
114060+
114061+ return 0;
114062+}
114063+#endif
114064+
114065+bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
114066+{
114067+ if (!vma) {
114068+#ifdef CONFIG_STACK_GROWSUP
114069+ if (addr > sysctl_heap_stack_gap)
114070+ vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
114071+ else
114072+ vma = find_vma(current->mm, 0);
114073+ if (vma && (vma->vm_flags & VM_GROWSUP))
114074+ return false;
114075+#endif
114076+ return true;
114077+ }
114078+
114079+ if (addr + len > vma->vm_start)
114080+ return false;
114081+
114082+ if (vma->vm_flags & VM_GROWSDOWN)
114083+ return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
114084+#ifdef CONFIG_STACK_GROWSUP
114085+ else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
114086+ return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
114087+#endif
114088+ else if (offset)
114089+ return offset <= vma->vm_start - addr - len;
114090+
114091+ return true;
114092+}
114093+
114094+unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
114095+{
114096+ if (vma->vm_start < len)
114097+ return -ENOMEM;
114098+
114099+ if (!(vma->vm_flags & VM_GROWSDOWN)) {
114100+ if (offset <= vma->vm_start - len)
114101+ return vma->vm_start - len - offset;
114102+ else
114103+ return -ENOMEM;
114104+ }
114105+
114106+ if (sysctl_heap_stack_gap <= vma->vm_start - len)
114107+ return vma->vm_start - len - sysctl_heap_stack_gap;
114108+ return -ENOMEM;
114109+}
114110+
114111+unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
114112 {
114113 /*
114114 * We implement the search by looking for an rbtree node that
114115@@ -1738,11 +1970,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
114116 }
114117 }
114118
114119- gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
114120+ gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
114121 check_current:
114122 /* Check if current node has a suitable gap */
114123 if (gap_start > high_limit)
114124 return -ENOMEM;
114125+
114126+ if (gap_end - gap_start > info->threadstack_offset)
114127+ gap_start += info->threadstack_offset;
114128+ else
114129+ gap_start = gap_end;
114130+
114131+ if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
114132+ if (gap_end - gap_start > sysctl_heap_stack_gap)
114133+ gap_start += sysctl_heap_stack_gap;
114134+ else
114135+ gap_start = gap_end;
114136+ }
114137+ if (vma->vm_flags & VM_GROWSDOWN) {
114138+ if (gap_end - gap_start > sysctl_heap_stack_gap)
114139+ gap_end -= sysctl_heap_stack_gap;
114140+ else
114141+ gap_end = gap_start;
114142+ }
114143 if (gap_end >= low_limit && gap_end - gap_start >= length)
114144 goto found;
114145
114146@@ -1792,7 +2042,7 @@ found:
114147 return gap_start;
114148 }
114149
114150-unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
114151+unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
114152 {
114153 struct mm_struct *mm = current->mm;
114154 struct vm_area_struct *vma;
114155@@ -1846,6 +2096,24 @@ check_current:
114156 gap_end = vma->vm_start;
114157 if (gap_end < low_limit)
114158 return -ENOMEM;
114159+
114160+ if (gap_end - gap_start > info->threadstack_offset)
114161+ gap_end -= info->threadstack_offset;
114162+ else
114163+ gap_end = gap_start;
114164+
114165+ if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
114166+ if (gap_end - gap_start > sysctl_heap_stack_gap)
114167+ gap_start += sysctl_heap_stack_gap;
114168+ else
114169+ gap_start = gap_end;
114170+ }
114171+ if (vma->vm_flags & VM_GROWSDOWN) {
114172+ if (gap_end - gap_start > sysctl_heap_stack_gap)
114173+ gap_end -= sysctl_heap_stack_gap;
114174+ else
114175+ gap_end = gap_start;
114176+ }
114177 if (gap_start <= high_limit && gap_end - gap_start >= length)
114178 goto found;
114179
114180@@ -1909,6 +2177,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
114181 struct mm_struct *mm = current->mm;
114182 struct vm_area_struct *vma;
114183 struct vm_unmapped_area_info info;
114184+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
114185
114186 if (len > TASK_SIZE - mmap_min_addr)
114187 return -ENOMEM;
114188@@ -1916,11 +2185,15 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
114189 if (flags & MAP_FIXED)
114190 return addr;
114191
114192+#ifdef CONFIG_PAX_RANDMMAP
114193+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
114194+#endif
114195+
114196 if (addr) {
114197 addr = PAGE_ALIGN(addr);
114198 vma = find_vma(mm, addr);
114199 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
114200- (!vma || addr + len <= vma->vm_start))
114201+ check_heap_stack_gap(vma, addr, len, offset))
114202 return addr;
114203 }
114204
114205@@ -1929,6 +2202,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
114206 info.low_limit = mm->mmap_base;
114207 info.high_limit = TASK_SIZE;
114208 info.align_mask = 0;
114209+ info.threadstack_offset = offset;
114210 return vm_unmapped_area(&info);
114211 }
114212 #endif
114213@@ -1947,6 +2221,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
114214 struct mm_struct *mm = current->mm;
114215 unsigned long addr = addr0;
114216 struct vm_unmapped_area_info info;
114217+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
114218
114219 /* requested length too big for entire address space */
114220 if (len > TASK_SIZE - mmap_min_addr)
114221@@ -1955,12 +2230,16 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
114222 if (flags & MAP_FIXED)
114223 return addr;
114224
114225+#ifdef CONFIG_PAX_RANDMMAP
114226+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
114227+#endif
114228+
114229 /* requesting a specific address */
114230 if (addr) {
114231 addr = PAGE_ALIGN(addr);
114232 vma = find_vma(mm, addr);
114233 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
114234- (!vma || addr + len <= vma->vm_start))
114235+ check_heap_stack_gap(vma, addr, len, offset))
114236 return addr;
114237 }
114238
114239@@ -1969,6 +2248,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
114240 info.low_limit = max(PAGE_SIZE, mmap_min_addr);
114241 info.high_limit = mm->mmap_base;
114242 info.align_mask = 0;
114243+ info.threadstack_offset = offset;
114244 addr = vm_unmapped_area(&info);
114245
114246 /*
114247@@ -1981,6 +2261,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
114248 VM_BUG_ON(addr != -ENOMEM);
114249 info.flags = 0;
114250 info.low_limit = TASK_UNMAPPED_BASE;
114251+
114252+#ifdef CONFIG_PAX_RANDMMAP
114253+ if (mm->pax_flags & MF_PAX_RANDMMAP)
114254+ info.low_limit += mm->delta_mmap;
114255+#endif
114256+
114257 info.high_limit = TASK_SIZE;
114258 addr = vm_unmapped_area(&info);
114259 }
114260@@ -2081,6 +2367,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
114261 return vma;
114262 }
114263
114264+#ifdef CONFIG_PAX_SEGMEXEC
114265+struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
114266+{
114267+ struct vm_area_struct *vma_m;
114268+
114269+ BUG_ON(!vma || vma->vm_start >= vma->vm_end);
114270+ if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
114271+ BUG_ON(vma->vm_mirror);
114272+ return NULL;
114273+ }
114274+ BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
114275+ vma_m = vma->vm_mirror;
114276+ BUG_ON(!vma_m || vma_m->vm_mirror != vma);
114277+ BUG_ON(vma->vm_file != vma_m->vm_file);
114278+ BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
114279+ BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
114280+ BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
114281+ BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
114282+ return vma_m;
114283+}
114284+#endif
114285+
114286 /*
114287 * Verify that the stack growth is acceptable and
114288 * update accounting. This is shared with both the
114289@@ -2098,8 +2406,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
114290
114291 /* Stack limit test */
114292 actual_size = size;
114293- if (size && (vma->vm_flags & (VM_GROWSUP | VM_GROWSDOWN)))
114294- actual_size -= PAGE_SIZE;
114295+ gr_learn_resource(current, RLIMIT_STACK, actual_size, 1);
114296 if (actual_size > READ_ONCE(rlim[RLIMIT_STACK].rlim_cur))
114297 return -ENOMEM;
114298
114299@@ -2110,6 +2417,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
114300 locked = mm->locked_vm + grow;
114301 limit = READ_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
114302 limit >>= PAGE_SHIFT;
114303+ gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
114304 if (locked > limit && !capable(CAP_IPC_LOCK))
114305 return -ENOMEM;
114306 }
114307@@ -2139,37 +2447,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
114308 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
114309 * vma is the last one with address > vma->vm_end. Have to extend vma.
114310 */
114311+#ifndef CONFIG_IA64
114312+static
114313+#endif
114314 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
114315 {
114316 int error;
114317+ bool locknext;
114318
114319 if (!(vma->vm_flags & VM_GROWSUP))
114320 return -EFAULT;
114321
114322+ /* Also guard against wrapping around to address 0. */
114323+ if (address < PAGE_ALIGN(address+1))
114324+ address = PAGE_ALIGN(address+1);
114325+ else
114326+ return -ENOMEM;
114327+
114328 /*
114329 * We must make sure the anon_vma is allocated
114330 * so that the anon_vma locking is not a noop.
114331 */
114332 if (unlikely(anon_vma_prepare(vma)))
114333 return -ENOMEM;
114334+ locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
114335+ if (locknext && anon_vma_prepare(vma->vm_next))
114336+ return -ENOMEM;
114337 vma_lock_anon_vma(vma);
114338+ if (locknext)
114339+ vma_lock_anon_vma(vma->vm_next);
114340
114341 /*
114342 * vma->vm_start/vm_end cannot change under us because the caller
114343 * is required to hold the mmap_sem in read mode. We need the
114344- * anon_vma lock to serialize against concurrent expand_stacks.
114345- * Also guard against wrapping around to address 0.
114346+ * anon_vma locks to serialize against concurrent expand_stacks
114347+ * and expand_upwards.
114348 */
114349- if (address < PAGE_ALIGN(address+4))
114350- address = PAGE_ALIGN(address+4);
114351- else {
114352- vma_unlock_anon_vma(vma);
114353- return -ENOMEM;
114354- }
114355 error = 0;
114356
114357 /* Somebody else might have raced and expanded it already */
114358- if (address > vma->vm_end) {
114359+ 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)
114360+ error = -ENOMEM;
114361+ else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
114362 unsigned long size, grow;
114363
114364 size = address - vma->vm_start;
114365@@ -2204,6 +2523,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
114366 }
114367 }
114368 }
114369+ if (locknext)
114370+ vma_unlock_anon_vma(vma->vm_next);
114371 vma_unlock_anon_vma(vma);
114372 khugepaged_enter_vma_merge(vma, vma->vm_flags);
114373 validate_mm(vma->vm_mm);
114374@@ -2218,6 +2539,8 @@ int expand_downwards(struct vm_area_struct *vma,
114375 unsigned long address)
114376 {
114377 int error;
114378+ bool lockprev = false;
114379+ struct vm_area_struct *prev;
114380
114381 /*
114382 * We must make sure the anon_vma is allocated
114383@@ -2231,6 +2554,15 @@ int expand_downwards(struct vm_area_struct *vma,
114384 if (error)
114385 return error;
114386
114387+ prev = vma->vm_prev;
114388+#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
114389+ lockprev = prev && (prev->vm_flags & VM_GROWSUP);
114390+#endif
114391+ if (lockprev && anon_vma_prepare(prev))
114392+ return -ENOMEM;
114393+ if (lockprev)
114394+ vma_lock_anon_vma(prev);
114395+
114396 vma_lock_anon_vma(vma);
114397
114398 /*
114399@@ -2240,9 +2572,17 @@ int expand_downwards(struct vm_area_struct *vma,
114400 */
114401
114402 /* Somebody else might have raced and expanded it already */
114403- if (address < vma->vm_start) {
114404+ if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
114405+ error = -ENOMEM;
114406+ else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
114407 unsigned long size, grow;
114408
114409+#ifdef CONFIG_PAX_SEGMEXEC
114410+ struct vm_area_struct *vma_m;
114411+
114412+ vma_m = pax_find_mirror_vma(vma);
114413+#endif
114414+
114415 size = vma->vm_end - address;
114416 grow = (vma->vm_start - address) >> PAGE_SHIFT;
114417
114418@@ -2267,13 +2607,27 @@ int expand_downwards(struct vm_area_struct *vma,
114419 vma->vm_pgoff -= grow;
114420 anon_vma_interval_tree_post_update_vma(vma);
114421 vma_gap_update(vma);
114422+
114423+#ifdef CONFIG_PAX_SEGMEXEC
114424+ if (vma_m) {
114425+ anon_vma_interval_tree_pre_update_vma(vma_m);
114426+ vma_m->vm_start -= grow << PAGE_SHIFT;
114427+ vma_m->vm_pgoff -= grow;
114428+ anon_vma_interval_tree_post_update_vma(vma_m);
114429+ vma_gap_update(vma_m);
114430+ }
114431+#endif
114432+
114433 spin_unlock(&vma->vm_mm->page_table_lock);
114434
114435+ track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
114436 perf_event_mmap(vma);
114437 }
114438 }
114439 }
114440 vma_unlock_anon_vma(vma);
114441+ if (lockprev)
114442+ vma_unlock_anon_vma(prev);
114443 khugepaged_enter_vma_merge(vma, vma->vm_flags);
114444 validate_mm(vma->vm_mm);
114445 return error;
114446@@ -2373,6 +2727,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
114447 do {
114448 long nrpages = vma_pages(vma);
114449
114450+#ifdef CONFIG_PAX_SEGMEXEC
114451+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
114452+ vma = remove_vma(vma);
114453+ continue;
114454+ }
114455+#endif
114456+
114457 if (vma->vm_flags & VM_ACCOUNT)
114458 nr_accounted += nrpages;
114459 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
114460@@ -2417,6 +2778,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
114461 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
114462 vma->vm_prev = NULL;
114463 do {
114464+
114465+#ifdef CONFIG_PAX_SEGMEXEC
114466+ if (vma->vm_mirror) {
114467+ BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
114468+ vma->vm_mirror->vm_mirror = NULL;
114469+ vma->vm_mirror->vm_flags &= ~VM_EXEC;
114470+ vma->vm_mirror = NULL;
114471+ }
114472+#endif
114473+
114474 vma_rb_erase(vma, &mm->mm_rb);
114475 mm->map_count--;
114476 tail_vma = vma;
114477@@ -2444,14 +2815,33 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114478 struct vm_area_struct *new;
114479 int err = -ENOMEM;
114480
114481+#ifdef CONFIG_PAX_SEGMEXEC
114482+ struct vm_area_struct *vma_m, *new_m = NULL;
114483+ unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
114484+#endif
114485+
114486 if (is_vm_hugetlb_page(vma) && (addr &
114487 ~(huge_page_mask(hstate_vma(vma)))))
114488 return -EINVAL;
114489
114490+#ifdef CONFIG_PAX_SEGMEXEC
114491+ vma_m = pax_find_mirror_vma(vma);
114492+#endif
114493+
114494 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
114495 if (!new)
114496 goto out_err;
114497
114498+#ifdef CONFIG_PAX_SEGMEXEC
114499+ if (vma_m) {
114500+ new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
114501+ if (!new_m) {
114502+ kmem_cache_free(vm_area_cachep, new);
114503+ goto out_err;
114504+ }
114505+ }
114506+#endif
114507+
114508 /* most fields are the same, copy all, and then fixup */
114509 *new = *vma;
114510
114511@@ -2464,6 +2854,22 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114512 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
114513 }
114514
114515+#ifdef CONFIG_PAX_SEGMEXEC
114516+ if (vma_m) {
114517+ *new_m = *vma_m;
114518+ INIT_LIST_HEAD(&new_m->anon_vma_chain);
114519+ new_m->vm_mirror = new;
114520+ new->vm_mirror = new_m;
114521+
114522+ if (new_below)
114523+ new_m->vm_end = addr_m;
114524+ else {
114525+ new_m->vm_start = addr_m;
114526+ new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
114527+ }
114528+ }
114529+#endif
114530+
114531 err = vma_dup_policy(vma, new);
114532 if (err)
114533 goto out_free_vma;
114534@@ -2484,6 +2890,38 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114535 else
114536 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
114537
114538+#ifdef CONFIG_PAX_SEGMEXEC
114539+ if (!err && vma_m) {
114540+ struct mempolicy *pol = vma_policy(new);
114541+
114542+ if (anon_vma_clone(new_m, vma_m))
114543+ goto out_free_mpol;
114544+
114545+ mpol_get(pol);
114546+ set_vma_policy(new_m, pol);
114547+
114548+ if (new_m->vm_file)
114549+ get_file(new_m->vm_file);
114550+
114551+ if (new_m->vm_ops && new_m->vm_ops->open)
114552+ new_m->vm_ops->open(new_m);
114553+
114554+ if (new_below)
114555+ err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
114556+ ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
114557+ else
114558+ err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
114559+
114560+ if (err) {
114561+ if (new_m->vm_ops && new_m->vm_ops->close)
114562+ new_m->vm_ops->close(new_m);
114563+ if (new_m->vm_file)
114564+ fput(new_m->vm_file);
114565+ mpol_put(pol);
114566+ }
114567+ }
114568+#endif
114569+
114570 /* Success. */
114571 if (!err)
114572 return 0;
114573@@ -2493,10 +2931,18 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114574 new->vm_ops->close(new);
114575 if (new->vm_file)
114576 fput(new->vm_file);
114577- unlink_anon_vmas(new);
114578 out_free_mpol:
114579 mpol_put(vma_policy(new));
114580 out_free_vma:
114581+
114582+#ifdef CONFIG_PAX_SEGMEXEC
114583+ if (new_m) {
114584+ unlink_anon_vmas(new_m);
114585+ kmem_cache_free(vm_area_cachep, new_m);
114586+ }
114587+#endif
114588+
114589+ unlink_anon_vmas(new);
114590 kmem_cache_free(vm_area_cachep, new);
114591 out_err:
114592 return err;
114593@@ -2509,6 +2955,15 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114594 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114595 unsigned long addr, int new_below)
114596 {
114597+
114598+#ifdef CONFIG_PAX_SEGMEXEC
114599+ if (mm->pax_flags & MF_PAX_SEGMEXEC) {
114600+ BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
114601+ if (mm->map_count >= sysctl_max_map_count-1)
114602+ return -ENOMEM;
114603+ } else
114604+#endif
114605+
114606 if (mm->map_count >= sysctl_max_map_count)
114607 return -ENOMEM;
114608
114609@@ -2520,11 +2975,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114610 * work. This now handles partial unmappings.
114611 * Jeremy Fitzhardinge <jeremy@goop.org>
114612 */
114613+#ifdef CONFIG_PAX_SEGMEXEC
114614 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
114615 {
114616+ int ret = __do_munmap(mm, start, len);
114617+ if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
114618+ return ret;
114619+
114620+ return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
114621+}
114622+
114623+int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
114624+#else
114625+int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
114626+#endif
114627+{
114628 unsigned long end;
114629 struct vm_area_struct *vma, *prev, *last;
114630
114631+ /*
114632+ * mm->mmap_sem is required to protect against another thread
114633+ * changing the mappings in case we sleep.
114634+ */
114635+ verify_mm_writelocked(mm);
114636+
114637 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
114638 return -EINVAL;
114639
114640@@ -2602,6 +3076,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
114641 /* Fix up all other VM information */
114642 remove_vma_list(mm, vma);
114643
114644+ track_exec_limit(mm, start, end, 0UL);
114645+
114646 return 0;
114647 }
114648
114649@@ -2610,6 +3086,13 @@ int vm_munmap(unsigned long start, size_t len)
114650 int ret;
114651 struct mm_struct *mm = current->mm;
114652
114653+
114654+#ifdef CONFIG_PAX_SEGMEXEC
114655+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
114656+ (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
114657+ return -EINVAL;
114658+#endif
114659+
114660 down_write(&mm->mmap_sem);
114661 ret = do_munmap(mm, start, len);
114662 up_write(&mm->mmap_sem);
114663@@ -2656,6 +3139,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
114664 down_write(&mm->mmap_sem);
114665 vma = find_vma(mm, start);
114666
114667+#ifdef CONFIG_PAX_SEGMEXEC
114668+ if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
114669+ goto out;
114670+#endif
114671+
114672 if (!vma || !(vma->vm_flags & VM_SHARED))
114673 goto out;
114674
114675@@ -2692,16 +3180,6 @@ out:
114676 return ret;
114677 }
114678
114679-static inline void verify_mm_writelocked(struct mm_struct *mm)
114680-{
114681-#ifdef CONFIG_DEBUG_VM
114682- if (unlikely(down_read_trylock(&mm->mmap_sem))) {
114683- WARN_ON(1);
114684- up_read(&mm->mmap_sem);
114685- }
114686-#endif
114687-}
114688-
114689 /*
114690 * this is really a simplified "do_mmap". it only handles
114691 * anonymous maps. eventually we may be able to do some
114692@@ -2715,6 +3193,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114693 struct rb_node **rb_link, *rb_parent;
114694 pgoff_t pgoff = addr >> PAGE_SHIFT;
114695 int error;
114696+ unsigned long charged;
114697
114698 len = PAGE_ALIGN(len);
114699 if (!len)
114700@@ -2722,10 +3201,24 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114701
114702 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
114703
114704+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
114705+ if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
114706+ flags &= ~VM_EXEC;
114707+
114708+#ifdef CONFIG_PAX_MPROTECT
114709+ if (mm->pax_flags & MF_PAX_MPROTECT)
114710+ flags &= ~VM_MAYEXEC;
114711+#endif
114712+
114713+ }
114714+#endif
114715+
114716 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
114717 if (error & ~PAGE_MASK)
114718 return error;
114719
114720+ charged = len >> PAGE_SHIFT;
114721+
114722 error = mlock_future_check(mm, mm->def_flags, len);
114723 if (error)
114724 return error;
114725@@ -2743,16 +3236,17 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114726 &rb_parent)) {
114727 if (do_munmap(mm, addr, len))
114728 return -ENOMEM;
114729+ BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
114730 }
114731
114732 /* Check against address space limits *after* clearing old maps... */
114733- if (!may_expand_vm(mm, len >> PAGE_SHIFT))
114734+ if (!may_expand_vm(mm, charged))
114735 return -ENOMEM;
114736
114737 if (mm->map_count > sysctl_max_map_count)
114738 return -ENOMEM;
114739
114740- if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
114741+ if (security_vm_enough_memory_mm(mm, charged))
114742 return -ENOMEM;
114743
114744 /* Can we just expand an old private anonymous mapping? */
114745@@ -2766,7 +3260,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114746 */
114747 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
114748 if (!vma) {
114749- vm_unacct_memory(len >> PAGE_SHIFT);
114750+ vm_unacct_memory(charged);
114751 return -ENOMEM;
114752 }
114753
114754@@ -2780,10 +3274,11 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114755 vma_link(mm, vma, prev, rb_link, rb_parent);
114756 out:
114757 perf_event_mmap(vma);
114758- mm->total_vm += len >> PAGE_SHIFT;
114759+ mm->total_vm += charged;
114760 if (flags & VM_LOCKED)
114761- mm->locked_vm += (len >> PAGE_SHIFT);
114762+ mm->locked_vm += charged;
114763 vma->vm_flags |= VM_SOFTDIRTY;
114764+ track_exec_limit(mm, addr, addr + len, flags);
114765 return addr;
114766 }
114767
114768@@ -2845,6 +3340,7 @@ void exit_mmap(struct mm_struct *mm)
114769 while (vma) {
114770 if (vma->vm_flags & VM_ACCOUNT)
114771 nr_accounted += vma_pages(vma);
114772+ vma->vm_mirror = NULL;
114773 vma = remove_vma(vma);
114774 }
114775 vm_unacct_memory(nr_accounted);
114776@@ -2859,6 +3355,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
114777 struct vm_area_struct *prev;
114778 struct rb_node **rb_link, *rb_parent;
114779
114780+#ifdef CONFIG_PAX_SEGMEXEC
114781+ struct vm_area_struct *vma_m = NULL;
114782+#endif
114783+
114784+ if (security_mmap_addr(vma->vm_start))
114785+ return -EPERM;
114786+
114787 /*
114788 * The vm_pgoff of a purely anonymous vma should be irrelevant
114789 * until its first write fault, when page's anon_vma and index
114790@@ -2882,7 +3385,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
114791 security_vm_enough_memory_mm(mm, vma_pages(vma)))
114792 return -ENOMEM;
114793
114794+#ifdef CONFIG_PAX_SEGMEXEC
114795+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
114796+ vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
114797+ if (!vma_m)
114798+ return -ENOMEM;
114799+ }
114800+#endif
114801+
114802 vma_link(mm, vma, prev, rb_link, rb_parent);
114803+
114804+#ifdef CONFIG_PAX_SEGMEXEC
114805+ if (vma_m)
114806+ BUG_ON(pax_mirror_vma(vma_m, vma));
114807+#endif
114808+
114809 return 0;
114810 }
114811
114812@@ -2901,6 +3418,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
114813 struct rb_node **rb_link, *rb_parent;
114814 bool faulted_in_anon_vma = true;
114815
114816+ BUG_ON(vma->vm_mirror);
114817+
114818 /*
114819 * If anonymous vma has not yet been faulted, update new pgoff
114820 * to match new location, to increase its chance of merging.
114821@@ -2965,6 +3484,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
114822 return NULL;
114823 }
114824
114825+#ifdef CONFIG_PAX_SEGMEXEC
114826+long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
114827+{
114828+ struct vm_area_struct *prev_m;
114829+ struct rb_node **rb_link_m, *rb_parent_m;
114830+ struct mempolicy *pol_m;
114831+
114832+ BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
114833+ BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
114834+ BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
114835+ *vma_m = *vma;
114836+ INIT_LIST_HEAD(&vma_m->anon_vma_chain);
114837+ if (anon_vma_clone(vma_m, vma))
114838+ return -ENOMEM;
114839+ pol_m = vma_policy(vma_m);
114840+ mpol_get(pol_m);
114841+ set_vma_policy(vma_m, pol_m);
114842+ vma_m->vm_start += SEGMEXEC_TASK_SIZE;
114843+ vma_m->vm_end += SEGMEXEC_TASK_SIZE;
114844+ vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
114845+ vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
114846+ if (vma_m->vm_file)
114847+ get_file(vma_m->vm_file);
114848+ if (vma_m->vm_ops && vma_m->vm_ops->open)
114849+ vma_m->vm_ops->open(vma_m);
114850+ BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
114851+ vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
114852+ vma_m->vm_mirror = vma;
114853+ vma->vm_mirror = vma_m;
114854+ return 0;
114855+}
114856+#endif
114857+
114858 /*
114859 * Return true if the calling process may expand its vm space by the passed
114860 * number of pages
114861@@ -2976,6 +3528,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
114862
114863 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
114864
114865+ gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
114866 if (cur + npages > lim)
114867 return 0;
114868 return 1;
114869@@ -3058,6 +3611,22 @@ static struct vm_area_struct *__install_special_mapping(
114870 vma->vm_start = addr;
114871 vma->vm_end = addr + len;
114872
114873+#ifdef CONFIG_PAX_MPROTECT
114874+ if (mm->pax_flags & MF_PAX_MPROTECT) {
114875+#ifndef CONFIG_PAX_MPROTECT_COMPAT
114876+ if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
114877+ return ERR_PTR(-EPERM);
114878+ if (!(vm_flags & VM_EXEC))
114879+ vm_flags &= ~VM_MAYEXEC;
114880+#else
114881+ if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
114882+ vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
114883+#endif
114884+ else
114885+ vm_flags &= ~VM_MAYWRITE;
114886+ }
114887+#endif
114888+
114889 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND | VM_SOFTDIRTY;
114890 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
114891
114892diff --git a/mm/mprotect.c b/mm/mprotect.c
114893index e7d6f11..6116007 100644
114894--- a/mm/mprotect.c
114895+++ b/mm/mprotect.c
114896@@ -24,10 +24,18 @@
114897 #include <linux/migrate.h>
114898 #include <linux/perf_event.h>
114899 #include <linux/ksm.h>
114900+#include <linux/sched/sysctl.h>
114901+
114902+#ifdef CONFIG_PAX_MPROTECT
114903+#include <linux/elf.h>
114904+#include <linux/binfmts.h>
114905+#endif
114906+
114907 #include <asm/uaccess.h>
114908 #include <asm/pgtable.h>
114909 #include <asm/cacheflush.h>
114910 #include <asm/tlbflush.h>
114911+#include <asm/mmu_context.h>
114912
114913 #include "internal.h"
114914
114915@@ -254,6 +262,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
114916 return pages;
114917 }
114918
114919+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
114920+/* called while holding the mmap semaphor for writing except stack expansion */
114921+void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
114922+{
114923+ unsigned long oldlimit, newlimit = 0UL;
114924+
114925+ if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
114926+ return;
114927+
114928+ spin_lock(&mm->page_table_lock);
114929+ oldlimit = mm->context.user_cs_limit;
114930+ if ((prot & VM_EXEC) && oldlimit < end)
114931+ /* USER_CS limit moved up */
114932+ newlimit = end;
114933+ else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
114934+ /* USER_CS limit moved down */
114935+ newlimit = start;
114936+
114937+ if (newlimit) {
114938+ mm->context.user_cs_limit = newlimit;
114939+
114940+#ifdef CONFIG_SMP
114941+ wmb();
114942+ cpumask_clear(&mm->context.cpu_user_cs_mask);
114943+ cpumask_set_cpu(smp_processor_id(), &mm->context.cpu_user_cs_mask);
114944+#endif
114945+
114946+ set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
114947+ }
114948+ spin_unlock(&mm->page_table_lock);
114949+ if (newlimit == end) {
114950+ struct vm_area_struct *vma = find_vma(mm, oldlimit);
114951+
114952+ for (; vma && vma->vm_start < end; vma = vma->vm_next)
114953+ if (is_vm_hugetlb_page(vma))
114954+ hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
114955+ else
114956+ change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
114957+ }
114958+}
114959+#endif
114960+
114961 int
114962 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
114963 unsigned long start, unsigned long end, unsigned long newflags)
114964@@ -266,11 +316,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
114965 int error;
114966 int dirty_accountable = 0;
114967
114968+#ifdef CONFIG_PAX_SEGMEXEC
114969+ struct vm_area_struct *vma_m = NULL;
114970+ unsigned long start_m, end_m;
114971+
114972+ start_m = start + SEGMEXEC_TASK_SIZE;
114973+ end_m = end + SEGMEXEC_TASK_SIZE;
114974+#endif
114975+
114976 if (newflags == oldflags) {
114977 *pprev = vma;
114978 return 0;
114979 }
114980
114981+ if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
114982+ struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
114983+
114984+ if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
114985+ return -ENOMEM;
114986+
114987+ if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
114988+ return -ENOMEM;
114989+ }
114990+
114991 /*
114992 * If we make a private mapping writable we increase our commit;
114993 * but (without finer accounting) cannot reduce our commit if we
114994@@ -287,6 +355,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
114995 }
114996 }
114997
114998+#ifdef CONFIG_PAX_SEGMEXEC
114999+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
115000+ if (start != vma->vm_start) {
115001+ error = split_vma(mm, vma, start, 1);
115002+ if (error)
115003+ goto fail;
115004+ BUG_ON(!*pprev || (*pprev)->vm_next == vma);
115005+ *pprev = (*pprev)->vm_next;
115006+ }
115007+
115008+ if (end != vma->vm_end) {
115009+ error = split_vma(mm, vma, end, 0);
115010+ if (error)
115011+ goto fail;
115012+ }
115013+
115014+ if (pax_find_mirror_vma(vma)) {
115015+ error = __do_munmap(mm, start_m, end_m - start_m);
115016+ if (error)
115017+ goto fail;
115018+ } else {
115019+ vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
115020+ if (!vma_m) {
115021+ error = -ENOMEM;
115022+ goto fail;
115023+ }
115024+ vma->vm_flags = newflags;
115025+ error = pax_mirror_vma(vma_m, vma);
115026+ if (error) {
115027+ vma->vm_flags = oldflags;
115028+ goto fail;
115029+ }
115030+ }
115031+ }
115032+#endif
115033+
115034 /*
115035 * First try to merge with previous and/or next vma.
115036 */
115037@@ -317,7 +421,19 @@ success:
115038 * vm_flags and vm_page_prot are protected by the mmap_sem
115039 * held in write mode.
115040 */
115041+
115042+#ifdef CONFIG_PAX_SEGMEXEC
115043+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
115044+ pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
115045+#endif
115046+
115047 vma->vm_flags = newflags;
115048+
115049+#ifdef CONFIG_PAX_MPROTECT
115050+ if (mm->binfmt && mm->binfmt->handle_mprotect)
115051+ mm->binfmt->handle_mprotect(vma, newflags);
115052+#endif
115053+
115054 dirty_accountable = vma_wants_writenotify(vma);
115055 vma_set_page_prot(vma);
115056
115057@@ -362,6 +478,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
115058 end = start + len;
115059 if (end <= start)
115060 return -ENOMEM;
115061+
115062+#ifdef CONFIG_PAX_SEGMEXEC
115063+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
115064+ if (end > SEGMEXEC_TASK_SIZE)
115065+ return -EINVAL;
115066+ } else
115067+#endif
115068+
115069+ if (end > TASK_SIZE)
115070+ return -EINVAL;
115071+
115072 if (!arch_validate_prot(prot))
115073 return -EINVAL;
115074
115075@@ -369,7 +496,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
115076 /*
115077 * Does the application expect PROT_READ to imply PROT_EXEC:
115078 */
115079- if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
115080+ if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
115081 prot |= PROT_EXEC;
115082
115083 vm_flags = calc_vm_prot_bits(prot);
115084@@ -401,6 +528,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
115085 if (start > vma->vm_start)
115086 prev = vma;
115087
115088+#ifdef CONFIG_PAX_MPROTECT
115089+ if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
115090+ current->mm->binfmt->handle_mprotect(vma, vm_flags);
115091+#endif
115092+
115093 for (nstart = start ; ; ) {
115094 unsigned long newflags;
115095
115096@@ -411,6 +543,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
115097
115098 /* newflags >> 4 shift VM_MAY% in place of VM_% */
115099 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
115100+ if (prot & (PROT_WRITE | PROT_EXEC))
115101+ gr_log_rwxmprotect(vma);
115102+
115103+ error = -EACCES;
115104+ goto out;
115105+ }
115106+
115107+ if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
115108 error = -EACCES;
115109 goto out;
115110 }
115111@@ -425,6 +565,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
115112 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
115113 if (error)
115114 goto out;
115115+
115116+ track_exec_limit(current->mm, nstart, tmp, vm_flags);
115117+
115118 nstart = tmp;
115119
115120 if (nstart < prev->vm_end)
115121diff --git a/mm/mremap.c b/mm/mremap.c
115122index a7c93ec..69c2949 100644
115123--- a/mm/mremap.c
115124+++ b/mm/mremap.c
115125@@ -143,6 +143,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
115126 continue;
115127 pte = ptep_get_and_clear(mm, old_addr, old_pte);
115128 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
115129+
115130+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
115131+ if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
115132+ pte = pte_exprotect(pte);
115133+#endif
115134+
115135 pte = move_soft_dirty_pte(pte);
115136 set_pte_at(mm, new_addr, new_pte, pte);
115137 }
115138@@ -355,6 +361,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
115139 if (is_vm_hugetlb_page(vma))
115140 return ERR_PTR(-EINVAL);
115141
115142+#ifdef CONFIG_PAX_SEGMEXEC
115143+ if (pax_find_mirror_vma(vma))
115144+ return ERR_PTR(-EINVAL);
115145+#endif
115146+
115147 /* We can't remap across vm area boundaries */
115148 if (old_len > vma->vm_end - addr)
115149 return ERR_PTR(-EFAULT);
115150@@ -401,20 +412,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
115151 unsigned long ret = -EINVAL;
115152 unsigned long charged = 0;
115153 unsigned long map_flags;
115154+ unsigned long pax_task_size = TASK_SIZE;
115155
115156 if (new_addr & ~PAGE_MASK)
115157 goto out;
115158
115159- if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
115160+#ifdef CONFIG_PAX_SEGMEXEC
115161+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
115162+ pax_task_size = SEGMEXEC_TASK_SIZE;
115163+#endif
115164+
115165+ pax_task_size -= PAGE_SIZE;
115166+
115167+ if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
115168 goto out;
115169
115170 /* Check if the location we're moving into overlaps the
115171 * old location at all, and fail if it does.
115172 */
115173- if ((new_addr <= addr) && (new_addr+new_len) > addr)
115174- goto out;
115175-
115176- if ((addr <= new_addr) && (addr+old_len) > new_addr)
115177+ if (addr + old_len > new_addr && new_addr + new_len > addr)
115178 goto out;
115179
115180 ret = do_munmap(mm, new_addr, new_len);
115181@@ -483,6 +499,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
115182 unsigned long ret = -EINVAL;
115183 unsigned long charged = 0;
115184 bool locked = false;
115185+ unsigned long pax_task_size = TASK_SIZE;
115186
115187 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
115188 return ret;
115189@@ -504,6 +521,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
115190 if (!new_len)
115191 return ret;
115192
115193+#ifdef CONFIG_PAX_SEGMEXEC
115194+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
115195+ pax_task_size = SEGMEXEC_TASK_SIZE;
115196+#endif
115197+
115198+ pax_task_size -= PAGE_SIZE;
115199+
115200+ if (new_len > pax_task_size || addr > pax_task_size-new_len ||
115201+ old_len > pax_task_size || addr > pax_task_size-old_len)
115202+ return ret;
115203+
115204 down_write(&current->mm->mmap_sem);
115205
115206 if (flags & MREMAP_FIXED) {
115207@@ -554,6 +582,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
115208 new_addr = addr;
115209 }
115210 ret = addr;
115211+ track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
115212 goto out;
115213 }
115214 }
115215@@ -577,7 +606,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
115216 goto out;
115217 }
115218
115219+ map_flags = vma->vm_flags;
115220 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
115221+ if (!(ret & ~PAGE_MASK)) {
115222+ track_exec_limit(current->mm, addr, addr + old_len, 0UL);
115223+ track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
115224+ }
115225 }
115226 out:
115227 if (ret & ~PAGE_MASK)
115228diff --git a/mm/nommu.c b/mm/nommu.c
115229index 58ea364..7b01d28 100644
115230--- a/mm/nommu.c
115231+++ b/mm/nommu.c
115232@@ -56,7 +56,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
115233 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
115234 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
115235 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
115236-int heap_stack_gap = 0;
115237
115238 atomic_long_t mmap_pages_allocated;
115239
115240@@ -863,15 +862,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
115241 EXPORT_SYMBOL(find_vma);
115242
115243 /*
115244- * find a VMA
115245- * - we don't extend stack VMAs under NOMMU conditions
115246- */
115247-struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
115248-{
115249- return find_vma(mm, addr);
115250-}
115251-
115252-/*
115253 * expand a stack to a given address
115254 * - not supported under NOMMU conditions
115255 */
115256@@ -1535,6 +1525,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
115257
115258 /* most fields are the same, copy all, and then fixup */
115259 *new = *vma;
115260+ INIT_LIST_HEAD(&new->anon_vma_chain);
115261 *region = *vma->vm_region;
115262 new->vm_region = region;
115263
115264@@ -1935,8 +1926,8 @@ void filemap_map_pages(struct vm_area_struct *vma, struct vm_fault *vmf)
115265 }
115266 EXPORT_SYMBOL(filemap_map_pages);
115267
115268-static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
115269- unsigned long addr, void *buf, int len, int write)
115270+static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
115271+ unsigned long addr, void *buf, size_t len, int write)
115272 {
115273 struct vm_area_struct *vma;
115274
115275@@ -1977,8 +1968,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
115276 *
115277 * The caller must hold a reference on @mm.
115278 */
115279-int access_remote_vm(struct mm_struct *mm, unsigned long addr,
115280- void *buf, int len, int write)
115281+ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
115282+ void *buf, size_t len, int write)
115283 {
115284 return __access_remote_vm(NULL, mm, addr, buf, len, write);
115285 }
115286@@ -1987,7 +1978,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
115287 * Access another process' address space.
115288 * - source/target buffer must be kernel space
115289 */
115290-int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
115291+ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
115292 {
115293 struct mm_struct *mm;
115294
115295diff --git a/mm/page-writeback.c b/mm/page-writeback.c
115296index 5cccc12..1872e56 100644
115297--- a/mm/page-writeback.c
115298+++ b/mm/page-writeback.c
115299@@ -852,7 +852,7 @@ static long long pos_ratio_polynom(unsigned long setpoint,
115300 * card's wb_dirty may rush to many times higher than wb_setpoint.
115301 * - the wb dirty thresh drops quickly due to change of JBOD workload
115302 */
115303-static void wb_position_ratio(struct dirty_throttle_control *dtc)
115304+static void __intentional_overflow(-1) wb_position_ratio(struct dirty_throttle_control *dtc)
115305 {
115306 struct bdi_writeback *wb = dtc->wb;
115307 unsigned long write_bw = wb->avg_write_bandwidth;
115308diff --git a/mm/page_alloc.c b/mm/page_alloc.c
115309index 5b5240b..2bc0996 100644
115310--- a/mm/page_alloc.c
115311+++ b/mm/page_alloc.c
115312@@ -62,6 +62,7 @@
115313 #include <linux/sched/rt.h>
115314 #include <linux/page_owner.h>
115315 #include <linux/kthread.h>
115316+#include <linux/random.h>
115317
115318 #include <asm/sections.h>
115319 #include <asm/tlbflush.h>
115320@@ -427,7 +428,7 @@ out:
115321 * This usage means that zero-order pages may not be compound.
115322 */
115323
115324-static void free_compound_page(struct page *page)
115325+void free_compound_page(struct page *page)
115326 {
115327 __free_pages_ok(page, compound_order(page));
115328 }
115329@@ -536,7 +537,7 @@ static inline void clear_page_guard(struct zone *zone, struct page *page,
115330 __mod_zone_freepage_state(zone, (1 << order), migratetype);
115331 }
115332 #else
115333-struct page_ext_operations debug_guardpage_ops = { NULL, };
115334+struct page_ext_operations debug_guardpage_ops = { .need = NULL, .init = NULL };
115335 static inline void set_page_guard(struct zone *zone, struct page *page,
115336 unsigned int order, int migratetype) {}
115337 static inline void clear_page_guard(struct zone *zone, struct page *page,
115338@@ -908,6 +909,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
115339 bool compound = PageCompound(page);
115340 int i, bad = 0;
115341
115342+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115343+ unsigned long index = 1UL << order;
115344+#endif
115345+
115346 VM_BUG_ON_PAGE(PageTail(page), page);
115347 VM_BUG_ON_PAGE(compound && compound_order(page) != order, page);
115348
115349@@ -934,6 +939,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
115350 debug_check_no_obj_freed(page_address(page),
115351 PAGE_SIZE << order);
115352 }
115353+
115354+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115355+ for (; index; --index)
115356+ sanitize_highpage(page + index - 1);
115357+#endif
115358+
115359 arch_free_page(page, order);
115360 kernel_map_pages(page, 1 << order, 0);
115361
115362@@ -957,6 +968,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
115363 local_irq_restore(flags);
115364 }
115365
115366+#ifdef CONFIG_PAX_LATENT_ENTROPY
115367+bool __meminitdata extra_latent_entropy;
115368+
115369+static int __init setup_pax_extra_latent_entropy(char *str)
115370+{
115371+ extra_latent_entropy = true;
115372+ return 0;
115373+}
115374+early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
115375+
115376+volatile u64 latent_entropy __latent_entropy;
115377+EXPORT_SYMBOL(latent_entropy);
115378+#endif
115379+
115380 static void __init __free_pages_boot_core(struct page *page,
115381 unsigned long pfn, unsigned int order)
115382 {
115383@@ -973,6 +998,19 @@ static void __init __free_pages_boot_core(struct page *page,
115384 __ClearPageReserved(p);
115385 set_page_count(p, 0);
115386
115387+#ifdef CONFIG_PAX_LATENT_ENTROPY
115388+ if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
115389+ u64 hash = 0;
115390+ size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
115391+ const u64 *data = lowmem_page_address(page);
115392+
115393+ for (index = 0; index < end; index++)
115394+ hash ^= hash + data[index];
115395+ latent_entropy ^= hash;
115396+ add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
115397+ }
115398+#endif
115399+
115400 page_zone(page)->managed_pages += nr_pages;
115401 set_page_refcounted(page);
115402 __free_pages(page, order);
115403@@ -1029,7 +1067,6 @@ static inline bool __meminit meminit_pfn_in_nid(unsigned long pfn, int node,
115404 }
115405 #endif
115406
115407-
115408 void __init __free_pages_bootmem(struct page *page, unsigned long pfn,
115409 unsigned int order)
115410 {
115411@@ -1333,9 +1370,11 @@ static int prep_new_page(struct page *page, unsigned int order, gfp_t gfp_flags,
115412 kernel_map_pages(page, 1 << order, 1);
115413 kasan_alloc_pages(page, order);
115414
115415+#ifndef CONFIG_PAX_MEMORY_SANITIZE
115416 if (gfp_flags & __GFP_ZERO)
115417 for (i = 0; i < (1 << order); i++)
115418 clear_highpage(page + i);
115419+#endif
115420
115421 if (order && (gfp_flags & __GFP_COMP))
115422 prep_compound_page(page, order);
115423@@ -2116,7 +2155,7 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
115424 }
115425
115426 __mod_zone_page_state(zone, NR_ALLOC_BATCH, -(1 << order));
115427- if (atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]) <= 0 &&
115428+ if (atomic_long_read_unchecked(&zone->vm_stat[NR_ALLOC_BATCH]) <= 0 &&
115429 !test_bit(ZONE_FAIR_DEPLETED, &zone->flags))
115430 set_bit(ZONE_FAIR_DEPLETED, &zone->flags);
115431
115432@@ -2435,7 +2474,7 @@ static void reset_alloc_batches(struct zone *preferred_zone)
115433 do {
115434 mod_zone_page_state(zone, NR_ALLOC_BATCH,
115435 high_wmark_pages(zone) - low_wmark_pages(zone) -
115436- atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]));
115437+ atomic_long_read_unchecked(&zone->vm_stat[NR_ALLOC_BATCH]));
115438 clear_bit(ZONE_FAIR_DEPLETED, &zone->flags);
115439 } while (zone++ != preferred_zone);
115440 }
115441@@ -6184,7 +6223,7 @@ static void __setup_per_zone_wmarks(void)
115442
115443 __mod_zone_page_state(zone, NR_ALLOC_BATCH,
115444 high_wmark_pages(zone) - low_wmark_pages(zone) -
115445- atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]));
115446+ atomic_long_read_unchecked(&zone->vm_stat[NR_ALLOC_BATCH]));
115447
115448 setup_zone_migrate_reserve(zone);
115449 spin_unlock_irqrestore(&zone->lock, flags);
115450diff --git a/mm/percpu.c b/mm/percpu.c
115451index 2dd7448..9bb6305 100644
115452--- a/mm/percpu.c
115453+++ b/mm/percpu.c
115454@@ -131,7 +131,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
115455 static unsigned int pcpu_high_unit_cpu __read_mostly;
115456
115457 /* the address of the first chunk which starts with the kernel static area */
115458-void *pcpu_base_addr __read_mostly;
115459+void *pcpu_base_addr __read_only;
115460 EXPORT_SYMBOL_GPL(pcpu_base_addr);
115461
115462 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
115463diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
115464index e88d071..d80e01a 100644
115465--- a/mm/process_vm_access.c
115466+++ b/mm/process_vm_access.c
115467@@ -13,6 +13,7 @@
115468 #include <linux/uio.h>
115469 #include <linux/sched.h>
115470 #include <linux/highmem.h>
115471+#include <linux/security.h>
115472 #include <linux/ptrace.h>
115473 #include <linux/slab.h>
115474 #include <linux/syscalls.h>
115475@@ -154,19 +155,19 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter,
115476 ssize_t iov_len;
115477 size_t total_len = iov_iter_count(iter);
115478
115479+ return -ENOSYS; // PaX: until properly audited
115480+
115481 /*
115482 * Work out how many pages of struct pages we're going to need
115483 * when eventually calling get_user_pages
115484 */
115485 for (i = 0; i < riovcnt; i++) {
115486 iov_len = rvec[i].iov_len;
115487- if (iov_len > 0) {
115488- nr_pages_iov = ((unsigned long)rvec[i].iov_base
115489- + iov_len)
115490- / PAGE_SIZE - (unsigned long)rvec[i].iov_base
115491- / PAGE_SIZE + 1;
115492- nr_pages = max(nr_pages, nr_pages_iov);
115493- }
115494+ if (iov_len <= 0)
115495+ continue;
115496+ nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
115497+ (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
115498+ nr_pages = max(nr_pages, nr_pages_iov);
115499 }
115500
115501 if (nr_pages == 0)
115502@@ -194,6 +195,11 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter,
115503 goto free_proc_pages;
115504 }
115505
115506+ if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
115507+ rc = -EPERM;
115508+ goto put_task_struct;
115509+ }
115510+
115511 mm = mm_access(task, PTRACE_MODE_ATTACH);
115512 if (!mm || IS_ERR(mm)) {
115513 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
115514diff --git a/mm/rmap.c b/mm/rmap.c
115515index 171b687..1a4b7e8 100644
115516--- a/mm/rmap.c
115517+++ b/mm/rmap.c
115518@@ -168,6 +168,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
115519 struct anon_vma *anon_vma = vma->anon_vma;
115520 struct anon_vma_chain *avc;
115521
115522+#ifdef CONFIG_PAX_SEGMEXEC
115523+ struct anon_vma_chain *avc_m = NULL;
115524+#endif
115525+
115526 might_sleep();
115527 if (unlikely(!anon_vma)) {
115528 struct mm_struct *mm = vma->vm_mm;
115529@@ -177,6 +181,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
115530 if (!avc)
115531 goto out_enomem;
115532
115533+#ifdef CONFIG_PAX_SEGMEXEC
115534+ avc_m = anon_vma_chain_alloc(GFP_KERNEL);
115535+ if (!avc_m)
115536+ goto out_enomem_free_avc;
115537+#endif
115538+
115539 anon_vma = find_mergeable_anon_vma(vma);
115540 allocated = NULL;
115541 if (!anon_vma) {
115542@@ -190,6 +200,19 @@ int anon_vma_prepare(struct vm_area_struct *vma)
115543 /* page_table_lock to protect against threads */
115544 spin_lock(&mm->page_table_lock);
115545 if (likely(!vma->anon_vma)) {
115546+
115547+#ifdef CONFIG_PAX_SEGMEXEC
115548+ struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
115549+
115550+ if (vma_m) {
115551+ BUG_ON(vma_m->anon_vma);
115552+ vma_m->anon_vma = anon_vma;
115553+ anon_vma_chain_link(vma_m, avc_m, anon_vma);
115554+ anon_vma->degree++;
115555+ avc_m = NULL;
115556+ }
115557+#endif
115558+
115559 vma->anon_vma = anon_vma;
115560 anon_vma_chain_link(vma, avc, anon_vma);
115561 /* vma reference or self-parent link for new root */
115562@@ -202,12 +225,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
115563
115564 if (unlikely(allocated))
115565 put_anon_vma(allocated);
115566+
115567+#ifdef CONFIG_PAX_SEGMEXEC
115568+ if (unlikely(avc_m))
115569+ anon_vma_chain_free(avc_m);
115570+#endif
115571+
115572 if (unlikely(avc))
115573 anon_vma_chain_free(avc);
115574 }
115575 return 0;
115576
115577 out_enomem_free_avc:
115578+
115579+#ifdef CONFIG_PAX_SEGMEXEC
115580+ if (avc_m)
115581+ anon_vma_chain_free(avc_m);
115582+#endif
115583+
115584 anon_vma_chain_free(avc);
115585 out_enomem:
115586 return -ENOMEM;
115587@@ -251,7 +286,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
115588 * good chance of avoiding scanning the whole hierarchy when it searches where
115589 * page is mapped.
115590 */
115591-int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
115592+int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
115593 {
115594 struct anon_vma_chain *avc, *pavc;
115595 struct anon_vma *root = NULL;
115596@@ -305,7 +340,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
115597 * the corresponding VMA in the parent process is attached to.
115598 * Returns 0 on success, non-zero on failure.
115599 */
115600-int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
115601+int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
115602 {
115603 struct anon_vma_chain *avc;
115604 struct anon_vma *anon_vma;
115605@@ -425,8 +460,10 @@ static void anon_vma_ctor(void *data)
115606 void __init anon_vma_init(void)
115607 {
115608 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
115609- 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
115610- anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
115611+ 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
115612+ anon_vma_ctor);
115613+ anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
115614+ SLAB_PANIC|SLAB_NO_SANITIZE);
115615 }
115616
115617 /*
115618diff --git a/mm/shmem.c b/mm/shmem.c
115619index dbe0c1e..22c16c7 100644
115620--- a/mm/shmem.c
115621+++ b/mm/shmem.c
115622@@ -33,7 +33,7 @@
115623 #include <linux/swap.h>
115624 #include <linux/uio.h>
115625
115626-static struct vfsmount *shm_mnt;
115627+struct vfsmount *shm_mnt;
115628
115629 #ifdef CONFIG_SHMEM
115630 /*
115631@@ -80,7 +80,7 @@ static struct vfsmount *shm_mnt;
115632 #define BOGO_DIRENT_SIZE 20
115633
115634 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
115635-#define SHORT_SYMLINK_LEN 128
115636+#define SHORT_SYMLINK_LEN 64
115637
115638 /*
115639 * shmem_fallocate communicates with shmem_fault or shmem_writepage via
115640@@ -2549,6 +2549,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
115641 static int shmem_xattr_validate(const char *name)
115642 {
115643 struct { const char *prefix; size_t len; } arr[] = {
115644+
115645+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
115646+ { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
115647+#endif
115648+
115649 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
115650 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
115651 };
115652@@ -2604,6 +2609,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
115653 if (err)
115654 return err;
115655
115656+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
115657+ if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
115658+ if (strcmp(name, XATTR_NAME_PAX_FLAGS))
115659+ return -EOPNOTSUPP;
115660+ if (size > 8)
115661+ return -EINVAL;
115662+ }
115663+#endif
115664+
115665 return simple_xattr_set(&info->xattrs, name, value, size, flags);
115666 }
115667
115668@@ -2987,8 +3001,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
115669 int err = -ENOMEM;
115670
115671 /* Round up to L1_CACHE_BYTES to resist false sharing */
115672- sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
115673- L1_CACHE_BYTES), GFP_KERNEL);
115674+ sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
115675 if (!sbinfo)
115676 return -ENOMEM;
115677
115678diff --git a/mm/slab.c b/mm/slab.c
115679index ae36028..eb6af9e 100644
115680--- a/mm/slab.c
115681+++ b/mm/slab.c
115682@@ -116,6 +116,7 @@
115683 #include <linux/kmemcheck.h>
115684 #include <linux/memory.h>
115685 #include <linux/prefetch.h>
115686+#include <linux/vmalloc.h>
115687
115688 #include <net/sock.h>
115689
115690@@ -314,10 +315,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
115691 if ((x)->max_freeable < i) \
115692 (x)->max_freeable = i; \
115693 } while (0)
115694-#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
115695-#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
115696-#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
115697-#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
115698+#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
115699+#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
115700+#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
115701+#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
115702+#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
115703+#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
115704 #else
115705 #define STATS_INC_ACTIVE(x) do { } while (0)
115706 #define STATS_DEC_ACTIVE(x) do { } while (0)
115707@@ -334,6 +337,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
115708 #define STATS_INC_ALLOCMISS(x) do { } while (0)
115709 #define STATS_INC_FREEHIT(x) do { } while (0)
115710 #define STATS_INC_FREEMISS(x) do { } while (0)
115711+#define STATS_INC_SANITIZED(x) do { } while (0)
115712+#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
115713 #endif
115714
115715 #if DEBUG
115716@@ -450,7 +455,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct page *page,
115717 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
115718 */
115719 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
115720- const struct page *page, void *obj)
115721+ const struct page *page, const void *obj)
115722 {
115723 u32 offset = (obj - page->s_mem);
115724 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
115725@@ -1452,7 +1457,7 @@ void __init kmem_cache_init(void)
115726 * structures first. Without this, further allocations will bug.
115727 */
115728 kmalloc_caches[INDEX_NODE] = create_kmalloc_cache("kmalloc-node",
115729- kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
115730+ kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
115731 slab_state = PARTIAL_NODE;
115732 setup_kmalloc_cache_index_table();
115733
115734@@ -2074,7 +2079,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
115735
115736 cachep = find_mergeable(size, align, flags, name, ctor);
115737 if (cachep) {
115738- cachep->refcount++;
115739+ atomic_inc(&cachep->refcount);
115740
115741 /*
115742 * Adjust the object sizes so that we clear
115743@@ -3379,6 +3384,20 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
115744 struct array_cache *ac = cpu_cache_get(cachep);
115745
115746 check_irq_off();
115747+
115748+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115749+ if (cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))
115750+ STATS_INC_NOT_SANITIZED(cachep);
115751+ else {
115752+ memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
115753+
115754+ if (cachep->ctor)
115755+ cachep->ctor(objp);
115756+
115757+ STATS_INC_SANITIZED(cachep);
115758+ }
115759+#endif
115760+
115761 kmemleak_free_recursive(objp, cachep->flags);
115762 objp = cache_free_debugcheck(cachep, objp, caller);
115763
115764@@ -3491,7 +3510,7 @@ __do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller)
115765 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
115766 }
115767
115768-void *__kmalloc_node(size_t size, gfp_t flags, int node)
115769+void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t flags, int node)
115770 {
115771 return __do_kmalloc_node(size, flags, node, _RET_IP_);
115772 }
115773@@ -3511,7 +3530,7 @@ EXPORT_SYMBOL(__kmalloc_node_track_caller);
115774 * @flags: the type of memory to allocate (see kmalloc).
115775 * @caller: function caller for debug tracking of the caller
115776 */
115777-static __always_inline void *__do_kmalloc(size_t size, gfp_t flags,
115778+static __always_inline void * __size_overflow(1) __do_kmalloc(size_t size, gfp_t flags,
115779 unsigned long caller)
115780 {
115781 struct kmem_cache *cachep;
115782@@ -3584,6 +3603,7 @@ void kfree(const void *objp)
115783
115784 if (unlikely(ZERO_OR_NULL_PTR(objp)))
115785 return;
115786+ VM_BUG_ON(!virt_addr_valid(objp));
115787 local_irq_save(flags);
115788 kfree_debugcheck(objp);
115789 c = virt_to_cache(objp);
115790@@ -4003,14 +4023,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
115791 }
115792 /* cpu stats */
115793 {
115794- unsigned long allochit = atomic_read(&cachep->allochit);
115795- unsigned long allocmiss = atomic_read(&cachep->allocmiss);
115796- unsigned long freehit = atomic_read(&cachep->freehit);
115797- unsigned long freemiss = atomic_read(&cachep->freemiss);
115798+ unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
115799+ unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
115800+ unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
115801+ unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
115802
115803 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
115804 allochit, allocmiss, freehit, freemiss);
115805 }
115806+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115807+ {
115808+ unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
115809+ unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
115810+
115811+ seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
115812+ }
115813+#endif
115814 #endif
115815 }
115816
115817@@ -4218,13 +4246,80 @@ static const struct file_operations proc_slabstats_operations = {
115818 static int __init slab_proc_init(void)
115819 {
115820 #ifdef CONFIG_DEBUG_SLAB_LEAK
115821- proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
115822+ proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
115823 #endif
115824 return 0;
115825 }
115826 module_init(slab_proc_init);
115827 #endif
115828
115829+bool is_usercopy_object(const void *ptr)
115830+{
115831+ struct page *page;
115832+ struct kmem_cache *cachep;
115833+
115834+ if (ZERO_OR_NULL_PTR(ptr))
115835+ return false;
115836+
115837+ if (!slab_is_available())
115838+ return false;
115839+
115840+ if (is_vmalloc_addr(ptr)
115841+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
115842+ && !object_starts_on_stack(ptr)
115843+#endif
115844+ ) {
115845+ struct vm_struct *vm = find_vm_area(ptr);
115846+ if (vm && (vm->flags & VM_USERCOPY))
115847+ return true;
115848+ return false;
115849+ }
115850+
115851+ if (!virt_addr_valid(ptr))
115852+ return false;
115853+
115854+ page = virt_to_head_page(ptr);
115855+
115856+ if (!PageSlab(page))
115857+ return false;
115858+
115859+ cachep = page->slab_cache;
115860+ return cachep->flags & SLAB_USERCOPY;
115861+}
115862+
115863+#ifdef CONFIG_PAX_USERCOPY
115864+const char *check_heap_object(const void *ptr, unsigned long n)
115865+{
115866+ struct page *page;
115867+ struct kmem_cache *cachep;
115868+ unsigned int objnr;
115869+ unsigned long offset;
115870+
115871+ if (ZERO_OR_NULL_PTR(ptr))
115872+ return "<null>";
115873+
115874+ if (!virt_addr_valid(ptr))
115875+ return NULL;
115876+
115877+ page = virt_to_head_page(ptr);
115878+
115879+ if (!PageSlab(page))
115880+ return NULL;
115881+
115882+ cachep = page->slab_cache;
115883+ if (!(cachep->flags & SLAB_USERCOPY))
115884+ return cachep->name;
115885+
115886+ objnr = obj_to_index(cachep, page, ptr);
115887+ BUG_ON(objnr >= cachep->num);
115888+ offset = ptr - index_to_obj(cachep, page, objnr) - obj_offset(cachep);
115889+ if (offset <= cachep->object_size && n <= cachep->object_size - offset)
115890+ return NULL;
115891+
115892+ return cachep->name;
115893+}
115894+#endif
115895+
115896 /**
115897 * ksize - get the actual amount of memory allocated for a given object
115898 * @objp: Pointer to the object
115899diff --git a/mm/slab.h b/mm/slab.h
115900index 8da63e4..50c423b 100644
115901--- a/mm/slab.h
115902+++ b/mm/slab.h
115903@@ -22,7 +22,7 @@ struct kmem_cache {
115904 unsigned int align; /* Alignment as calculated */
115905 unsigned long flags; /* Active flags on the slab */
115906 const char *name; /* Slab name for sysfs */
115907- int refcount; /* Use counter */
115908+ atomic_t refcount; /* Use counter */
115909 void (*ctor)(void *); /* Called on object slot creation */
115910 struct list_head list; /* List of all slab caches on the system */
115911 };
115912@@ -66,6 +66,20 @@ extern struct list_head slab_caches;
115913 /* The slab cache that manages slab cache information */
115914 extern struct kmem_cache *kmem_cache;
115915
115916+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115917+#ifdef CONFIG_X86_64
115918+#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
115919+#else
115920+#define PAX_MEMORY_SANITIZE_VALUE '\xff'
115921+#endif
115922+enum pax_sanitize_mode {
115923+ PAX_SANITIZE_SLAB_OFF = 0,
115924+ PAX_SANITIZE_SLAB_FAST,
115925+ PAX_SANITIZE_SLAB_FULL,
115926+};
115927+extern enum pax_sanitize_mode pax_sanitize_slab;
115928+#endif
115929+
115930 unsigned long calculate_alignment(unsigned long flags,
115931 unsigned long align, unsigned long size);
115932
115933@@ -115,7 +129,8 @@ static inline unsigned long kmem_cache_flags(unsigned long object_size,
115934
115935 /* Legal flag mask for kmem_cache_create(), for various configurations */
115936 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
115937- SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
115938+ SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
115939+ SLAB_USERCOPY | SLAB_NO_SANITIZE)
115940
115941 #if defined(CONFIG_DEBUG_SLAB)
115942 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
115943@@ -316,6 +331,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
115944 return s;
115945
115946 page = virt_to_head_page(x);
115947+
115948+ BUG_ON(!PageSlab(page));
115949+
115950 cachep = page->slab_cache;
115951 if (slab_equal_or_root(cachep, s))
115952 return cachep;
115953diff --git a/mm/slab_common.c b/mm/slab_common.c
115954index 8683110..916e2c5 100644
115955--- a/mm/slab_common.c
115956+++ b/mm/slab_common.c
115957@@ -25,11 +25,35 @@
115958
115959 #include "slab.h"
115960
115961-enum slab_state slab_state;
115962+enum slab_state slab_state __read_only;
115963 LIST_HEAD(slab_caches);
115964 DEFINE_MUTEX(slab_mutex);
115965 struct kmem_cache *kmem_cache;
115966
115967+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115968+enum pax_sanitize_mode pax_sanitize_slab __read_only = PAX_SANITIZE_SLAB_FAST;
115969+static int __init pax_sanitize_slab_setup(char *str)
115970+{
115971+ if (!str)
115972+ return 0;
115973+
115974+ if (!strcmp(str, "0") || !strcmp(str, "off")) {
115975+ pr_info("PaX slab sanitization: %s\n", "disabled");
115976+ pax_sanitize_slab = PAX_SANITIZE_SLAB_OFF;
115977+ } else if (!strcmp(str, "1") || !strcmp(str, "fast")) {
115978+ pr_info("PaX slab sanitization: %s\n", "fast");
115979+ pax_sanitize_slab = PAX_SANITIZE_SLAB_FAST;
115980+ } else if (!strcmp(str, "full")) {
115981+ pr_info("PaX slab sanitization: %s\n", "full");
115982+ pax_sanitize_slab = PAX_SANITIZE_SLAB_FULL;
115983+ } else
115984+ pr_err("PaX slab sanitization: unsupported option '%s'\n", str);
115985+
115986+ return 0;
115987+}
115988+early_param("pax_sanitize_slab", pax_sanitize_slab_setup);
115989+#endif
115990+
115991 /*
115992 * Set of flags that will prevent slab merging
115993 */
115994@@ -43,7 +67,7 @@ struct kmem_cache *kmem_cache;
115995 * Merge control. If this is set then no merging of slab caches will occur.
115996 * (Could be removed. This was introduced to pacify the merge skeptics.)
115997 */
115998-static int slab_nomerge;
115999+static int slab_nomerge = 1;
116000
116001 static int __init setup_slab_nomerge(char *str)
116002 {
116003@@ -216,7 +240,7 @@ int slab_unmergeable(struct kmem_cache *s)
116004 /*
116005 * We may have set a slab to be unmergeable during bootstrap.
116006 */
116007- if (s->refcount < 0)
116008+ if (atomic_read(&s->refcount) < 0)
116009 return 1;
116010
116011 return 0;
116012@@ -320,7 +344,7 @@ do_kmem_cache_create(const char *name, size_t object_size, size_t size,
116013 if (err)
116014 goto out_free_cache;
116015
116016- s->refcount = 1;
116017+ atomic_set(&s->refcount, 1);
116018 list_add(&s->list, &slab_caches);
116019 out:
116020 if (err)
116021@@ -385,6 +409,13 @@ kmem_cache_create(const char *name, size_t size, size_t align,
116022 */
116023 flags &= CACHE_CREATE_MASK;
116024
116025+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116026+ if (pax_sanitize_slab == PAX_SANITIZE_SLAB_OFF || (flags & SLAB_DESTROY_BY_RCU))
116027+ flags |= SLAB_NO_SANITIZE;
116028+ else if (pax_sanitize_slab == PAX_SANITIZE_SLAB_FULL)
116029+ flags &= ~SLAB_NO_SANITIZE;
116030+#endif
116031+
116032 s = __kmem_cache_alias(name, size, align, flags, ctor);
116033 if (s)
116034 goto out_unlock;
116035@@ -455,7 +486,7 @@ static void do_kmem_cache_release(struct list_head *release,
116036 rcu_barrier();
116037
116038 list_for_each_entry_safe(s, s2, release, list) {
116039-#ifdef SLAB_SUPPORTS_SYSFS
116040+#if defined(SLAB_SUPPORTS_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116041 sysfs_slab_remove(s);
116042 #else
116043 slab_kmem_cache_release(s);
116044@@ -624,8 +655,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
116045
116046 mutex_lock(&slab_mutex);
116047
116048- s->refcount--;
116049- if (s->refcount)
116050+ if (!atomic_dec_and_test(&s->refcount))
116051 goto out_unlock;
116052
116053 for_each_memcg_cache_safe(c, c2, s) {
116054@@ -690,7 +720,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
116055 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
116056 name, size, err);
116057
116058- s->refcount = -1; /* Exempt from merging for now */
116059+ atomic_set(&s->refcount, -1); /* Exempt from merging for now */
116060 }
116061
116062 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
116063@@ -703,7 +733,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
116064
116065 create_boot_cache(s, name, size, flags);
116066 list_add(&s->list, &slab_caches);
116067- s->refcount = 1;
116068+ atomic_set(&s->refcount, 1);
116069 return s;
116070 }
116071
116072@@ -715,6 +745,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
116073 EXPORT_SYMBOL(kmalloc_dma_caches);
116074 #endif
116075
116076+#ifdef CONFIG_PAX_USERCOPY_SLABS
116077+struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
116078+EXPORT_SYMBOL(kmalloc_usercopy_caches);
116079+#endif
116080+
116081 /*
116082 * Conversion table for small slabs sizes / 8 to the index in the
116083 * kmalloc array. This is necessary for slabs < 192 since we have non power
116084@@ -779,6 +814,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
116085 return kmalloc_dma_caches[index];
116086
116087 #endif
116088+
116089+#ifdef CONFIG_PAX_USERCOPY_SLABS
116090+ if (unlikely((flags & GFP_USERCOPY)))
116091+ return kmalloc_usercopy_caches[index];
116092+
116093+#endif
116094+
116095 return kmalloc_caches[index];
116096 }
116097
116098@@ -871,7 +913,7 @@ void __init create_kmalloc_caches(unsigned long flags)
116099
116100 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
116101 if (!kmalloc_caches[i])
116102- new_kmalloc_cache(i, flags);
116103+ new_kmalloc_cache(i, SLAB_USERCOPY | flags);
116104
116105 /*
116106 * Caches that are not of the two-to-the-power-of size.
116107@@ -879,9 +921,9 @@ void __init create_kmalloc_caches(unsigned long flags)
116108 * earlier power of two caches
116109 */
116110 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
116111- new_kmalloc_cache(1, flags);
116112+ new_kmalloc_cache(1, SLAB_USERCOPY | flags);
116113 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
116114- new_kmalloc_cache(2, flags);
116115+ new_kmalloc_cache(2, SLAB_USERCOPY | flags);
116116 }
116117
116118 /* Kmalloc array is now usable */
116119@@ -902,6 +944,23 @@ void __init create_kmalloc_caches(unsigned long flags)
116120 }
116121 }
116122 #endif
116123+
116124+#ifdef CONFIG_PAX_USERCOPY_SLABS
116125+ for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
116126+ struct kmem_cache *s = kmalloc_caches[i];
116127+
116128+ if (s) {
116129+ int size = kmalloc_size(i);
116130+ char *n = kasprintf(GFP_NOWAIT,
116131+ "usercopy-kmalloc-%d", size);
116132+
116133+ BUG_ON(!n);
116134+ kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
116135+ size, SLAB_USERCOPY | flags);
116136+ }
116137+ }
116138+#endif
116139+
116140 }
116141 #endif /* !CONFIG_SLOB */
116142
116143@@ -961,6 +1020,9 @@ static void print_slabinfo_header(struct seq_file *m)
116144 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
116145 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
116146 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
116147+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116148+ seq_puts(m, " : pax <sanitized> <not_sanitized>");
116149+#endif
116150 #endif
116151 seq_putc(m, '\n');
116152 }
116153@@ -1090,7 +1152,7 @@ static int __init slab_proc_init(void)
116154 module_init(slab_proc_init);
116155 #endif /* CONFIG_SLABINFO */
116156
116157-static __always_inline void *__do_krealloc(const void *p, size_t new_size,
116158+static __always_inline void * __size_overflow(2) __do_krealloc(const void *p, size_t new_size,
116159 gfp_t flags)
116160 {
116161 void *ret;
116162diff --git a/mm/slob.c b/mm/slob.c
116163index 4765f65..5dec45e 100644
116164--- a/mm/slob.c
116165+++ b/mm/slob.c
116166@@ -67,6 +67,7 @@
116167 #include <linux/rcupdate.h>
116168 #include <linux/list.h>
116169 #include <linux/kmemleak.h>
116170+#include <linux/vmalloc.h>
116171
116172 #include <trace/events/kmem.h>
116173
116174@@ -157,7 +158,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
116175 /*
116176 * Return the size of a slob block.
116177 */
116178-static slobidx_t slob_units(slob_t *s)
116179+static slobidx_t slob_units(const slob_t *s)
116180 {
116181 if (s->units > 0)
116182 return s->units;
116183@@ -167,7 +168,7 @@ static slobidx_t slob_units(slob_t *s)
116184 /*
116185 * Return the next free slob block pointer after this one.
116186 */
116187-static slob_t *slob_next(slob_t *s)
116188+static slob_t *slob_next(const slob_t *s)
116189 {
116190 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
116191 slobidx_t next;
116192@@ -182,14 +183,14 @@ static slob_t *slob_next(slob_t *s)
116193 /*
116194 * Returns true if s is the last free block in its page.
116195 */
116196-static int slob_last(slob_t *s)
116197+static int slob_last(const slob_t *s)
116198 {
116199 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
116200 }
116201
116202-static void *slob_new_pages(gfp_t gfp, int order, int node)
116203+static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
116204 {
116205- void *page;
116206+ struct page *page;
116207
116208 #ifdef CONFIG_NUMA
116209 if (node != NUMA_NO_NODE)
116210@@ -201,14 +202,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
116211 if (!page)
116212 return NULL;
116213
116214- return page_address(page);
116215+ __SetPageSlab(page);
116216+ return page;
116217 }
116218
116219-static void slob_free_pages(void *b, int order)
116220+static void slob_free_pages(struct page *sp, int order)
116221 {
116222 if (current->reclaim_state)
116223 current->reclaim_state->reclaimed_slab += 1 << order;
116224- free_pages((unsigned long)b, order);
116225+ __ClearPageSlab(sp);
116226+ page_mapcount_reset(sp);
116227+ sp->private = 0;
116228+ __free_pages(sp, order);
116229 }
116230
116231 /*
116232@@ -313,15 +318,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
116233
116234 /* Not enough space: must allocate a new page */
116235 if (!b) {
116236- b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
116237- if (!b)
116238+ sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
116239+ if (!sp)
116240 return NULL;
116241- sp = virt_to_page(b);
116242- __SetPageSlab(sp);
116243+ b = page_address(sp);
116244
116245 spin_lock_irqsave(&slob_lock, flags);
116246 sp->units = SLOB_UNITS(PAGE_SIZE);
116247 sp->freelist = b;
116248+ sp->private = 0;
116249 INIT_LIST_HEAD(&sp->lru);
116250 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
116251 set_slob_page_free(sp, slob_list);
116252@@ -337,7 +342,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
116253 /*
116254 * slob_free: entry point into the slob allocator.
116255 */
116256-static void slob_free(void *block, int size)
116257+static void slob_free(struct kmem_cache *c, void *block, int size)
116258 {
116259 struct page *sp;
116260 slob_t *prev, *next, *b = (slob_t *)block;
116261@@ -359,12 +364,15 @@ static void slob_free(void *block, int size)
116262 if (slob_page_free(sp))
116263 clear_slob_page_free(sp);
116264 spin_unlock_irqrestore(&slob_lock, flags);
116265- __ClearPageSlab(sp);
116266- page_mapcount_reset(sp);
116267- slob_free_pages(b, 0);
116268+ slob_free_pages(sp, 0);
116269 return;
116270 }
116271
116272+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116273+ if (pax_sanitize_slab && !(c && (c->flags & SLAB_NO_SANITIZE)))
116274+ memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
116275+#endif
116276+
116277 if (!slob_page_free(sp)) {
116278 /* This slob page is about to become partially free. Easy! */
116279 sp->units = units;
116280@@ -424,11 +432,10 @@ out:
116281 */
116282
116283 static __always_inline void *
116284-__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
116285+__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
116286 {
116287- unsigned int *m;
116288- int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
116289- void *ret;
116290+ slob_t *m;
116291+ void *ret = NULL;
116292
116293 gfp &= gfp_allowed_mask;
116294
116295@@ -442,27 +449,45 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
116296
116297 if (!m)
116298 return NULL;
116299- *m = size;
116300+ BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
116301+ BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
116302+ m[0].units = size;
116303+ m[1].units = align;
116304 ret = (void *)m + align;
116305
116306 trace_kmalloc_node(caller, ret,
116307 size, size + align, gfp, node);
116308 } else {
116309 unsigned int order = get_order(size);
116310+ struct page *page;
116311
116312 if (likely(order))
116313 gfp |= __GFP_COMP;
116314- ret = slob_new_pages(gfp, order, node);
116315+ page = slob_new_pages(gfp, order, node);
116316+ if (page) {
116317+ ret = page_address(page);
116318+ page->private = size;
116319+ }
116320
116321 trace_kmalloc_node(caller, ret,
116322 size, PAGE_SIZE << order, gfp, node);
116323 }
116324
116325- kmemleak_alloc(ret, size, 1, gfp);
116326 return ret;
116327 }
116328
116329-void *__kmalloc(size_t size, gfp_t gfp)
116330+static __always_inline void *
116331+__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
116332+{
116333+ int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
116334+ void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
116335+
116336+ if (!ZERO_OR_NULL_PTR(ret))
116337+ kmemleak_alloc(ret, size, 1, gfp);
116338+ return ret;
116339+}
116340+
116341+void * __size_overflow(1) __kmalloc(size_t size, gfp_t gfp)
116342 {
116343 return __do_kmalloc_node(size, gfp, NUMA_NO_NODE, _RET_IP_);
116344 }
116345@@ -491,34 +516,123 @@ void kfree(const void *block)
116346 return;
116347 kmemleak_free(block);
116348
116349+ VM_BUG_ON(!virt_addr_valid(block));
116350 sp = virt_to_page(block);
116351- if (PageSlab(sp)) {
116352+ VM_BUG_ON(!PageSlab(sp));
116353+ if (!sp->private) {
116354 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
116355- unsigned int *m = (unsigned int *)(block - align);
116356- slob_free(m, *m + align);
116357- } else
116358+ slob_t *m = (slob_t *)(block - align);
116359+ slob_free(NULL, m, m[0].units + align);
116360+ } else {
116361+ __ClearPageSlab(sp);
116362+ page_mapcount_reset(sp);
116363+ sp->private = 0;
116364 __free_pages(sp, compound_order(sp));
116365+ }
116366 }
116367 EXPORT_SYMBOL(kfree);
116368
116369+bool is_usercopy_object(const void *ptr)
116370+{
116371+ if (!slab_is_available())
116372+ return false;
116373+
116374+ if (is_vmalloc_addr(ptr)
116375+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
116376+ && !object_starts_on_stack(ptr)
116377+#endif
116378+ ) {
116379+ struct vm_struct *vm = find_vm_area(ptr);
116380+ if (vm && (vm->flags & VM_USERCOPY))
116381+ return true;
116382+ return false;
116383+ }
116384+
116385+ // PAX: TODO
116386+
116387+ return false;
116388+}
116389+
116390+#ifdef CONFIG_PAX_USERCOPY
116391+const char *check_heap_object(const void *ptr, unsigned long n)
116392+{
116393+ struct page *page;
116394+ const slob_t *free;
116395+ const void *base;
116396+ unsigned long flags;
116397+
116398+ if (ZERO_OR_NULL_PTR(ptr))
116399+ return "<null>";
116400+
116401+ if (!virt_addr_valid(ptr))
116402+ return NULL;
116403+
116404+ page = virt_to_head_page(ptr);
116405+ if (!PageSlab(page))
116406+ return NULL;
116407+
116408+ if (page->private) {
116409+ base = page;
116410+ if (base <= ptr && n <= page->private - (ptr - base))
116411+ return NULL;
116412+ return "<slob>";
116413+ }
116414+
116415+ /* some tricky double walking to find the chunk */
116416+ spin_lock_irqsave(&slob_lock, flags);
116417+ base = (void *)((unsigned long)ptr & PAGE_MASK);
116418+ free = page->freelist;
116419+
116420+ while (!slob_last(free) && (void *)free <= ptr) {
116421+ base = free + slob_units(free);
116422+ free = slob_next(free);
116423+ }
116424+
116425+ while (base < (void *)free) {
116426+ slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
116427+ int size = SLOB_UNIT * SLOB_UNITS(m + align);
116428+ int offset;
116429+
116430+ if (ptr < base + align)
116431+ break;
116432+
116433+ offset = ptr - base - align;
116434+ if (offset >= m) {
116435+ base += size;
116436+ continue;
116437+ }
116438+
116439+ if (n > m - offset)
116440+ break;
116441+
116442+ spin_unlock_irqrestore(&slob_lock, flags);
116443+ return NULL;
116444+ }
116445+
116446+ spin_unlock_irqrestore(&slob_lock, flags);
116447+ return "<slob>";
116448+}
116449+#endif
116450+
116451 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
116452 size_t ksize(const void *block)
116453 {
116454 struct page *sp;
116455 int align;
116456- unsigned int *m;
116457+ slob_t *m;
116458
116459 BUG_ON(!block);
116460 if (unlikely(block == ZERO_SIZE_PTR))
116461 return 0;
116462
116463 sp = virt_to_page(block);
116464- if (unlikely(!PageSlab(sp)))
116465- return PAGE_SIZE << compound_order(sp);
116466+ VM_BUG_ON(!PageSlab(sp));
116467+ if (sp->private)
116468+ return sp->private;
116469
116470 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
116471- m = (unsigned int *)(block - align);
116472- return SLOB_UNITS(*m) * SLOB_UNIT;
116473+ m = (slob_t *)(block - align);
116474+ return SLOB_UNITS(m[0].units) * SLOB_UNIT;
116475 }
116476 EXPORT_SYMBOL(ksize);
116477
116478@@ -534,23 +648,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
116479
116480 static void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
116481 {
116482- void *b;
116483+ void *b = NULL;
116484
116485 flags &= gfp_allowed_mask;
116486
116487 lockdep_trace_alloc(flags);
116488
116489+#ifdef CONFIG_PAX_USERCOPY_SLABS
116490+ b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
116491+#else
116492 if (c->size < PAGE_SIZE) {
116493 b = slob_alloc(c->size, flags, c->align, node);
116494 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
116495 SLOB_UNITS(c->size) * SLOB_UNIT,
116496 flags, node);
116497 } else {
116498- b = slob_new_pages(flags, get_order(c->size), node);
116499+ struct page *sp;
116500+
116501+ sp = slob_new_pages(flags, get_order(c->size), node);
116502+ if (sp) {
116503+ b = page_address(sp);
116504+ sp->private = c->size;
116505+ }
116506 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
116507 PAGE_SIZE << get_order(c->size),
116508 flags, node);
116509 }
116510+#endif
116511
116512 if (b && c->ctor)
116513 c->ctor(b);
116514@@ -566,7 +690,7 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags)
116515 EXPORT_SYMBOL(kmem_cache_alloc);
116516
116517 #ifdef CONFIG_NUMA
116518-void *__kmalloc_node(size_t size, gfp_t gfp, int node)
116519+void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t gfp, int node)
116520 {
116521 return __do_kmalloc_node(size, gfp, node, _RET_IP_);
116522 }
116523@@ -579,12 +703,16 @@ void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t gfp, int node)
116524 EXPORT_SYMBOL(kmem_cache_alloc_node);
116525 #endif
116526
116527-static void __kmem_cache_free(void *b, int size)
116528+static void __kmem_cache_free(struct kmem_cache *c, void *b, int size)
116529 {
116530- if (size < PAGE_SIZE)
116531- slob_free(b, size);
116532+ struct page *sp;
116533+
116534+ sp = virt_to_page(b);
116535+ BUG_ON(!PageSlab(sp));
116536+ if (!sp->private)
116537+ slob_free(c, b, size);
116538 else
116539- slob_free_pages(b, get_order(size));
116540+ slob_free_pages(sp, get_order(size));
116541 }
116542
116543 static void kmem_rcu_free(struct rcu_head *head)
116544@@ -592,22 +720,36 @@ static void kmem_rcu_free(struct rcu_head *head)
116545 struct slob_rcu *slob_rcu = (struct slob_rcu *)head;
116546 void *b = (void *)slob_rcu - (slob_rcu->size - sizeof(struct slob_rcu));
116547
116548- __kmem_cache_free(b, slob_rcu->size);
116549+ __kmem_cache_free(NULL, b, slob_rcu->size);
116550 }
116551
116552 void kmem_cache_free(struct kmem_cache *c, void *b)
116553 {
116554+ int size = c->size;
116555+
116556+#ifdef CONFIG_PAX_USERCOPY_SLABS
116557+ if (size + c->align < PAGE_SIZE) {
116558+ size += c->align;
116559+ b -= c->align;
116560+ }
116561+#endif
116562+
116563 kmemleak_free_recursive(b, c->flags);
116564 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
116565 struct slob_rcu *slob_rcu;
116566- slob_rcu = b + (c->size - sizeof(struct slob_rcu));
116567- slob_rcu->size = c->size;
116568+ slob_rcu = b + (size - sizeof(struct slob_rcu));
116569+ slob_rcu->size = size;
116570 call_rcu(&slob_rcu->head, kmem_rcu_free);
116571 } else {
116572- __kmem_cache_free(b, c->size);
116573+ __kmem_cache_free(c, b, size);
116574 }
116575
116576+#ifdef CONFIG_PAX_USERCOPY_SLABS
116577+ trace_kfree(_RET_IP_, b);
116578+#else
116579 trace_kmem_cache_free(_RET_IP_, b);
116580+#endif
116581+
116582 }
116583 EXPORT_SYMBOL(kmem_cache_free);
116584
116585diff --git a/mm/slub.c b/mm/slub.c
116586index f68c0e5..eb77178 100644
116587--- a/mm/slub.c
116588+++ b/mm/slub.c
116589@@ -34,6 +34,7 @@
116590 #include <linux/stacktrace.h>
116591 #include <linux/prefetch.h>
116592 #include <linux/memcontrol.h>
116593+#include <linux/vmalloc.h>
116594
116595 #include <trace/events/kmem.h>
116596
116597@@ -198,7 +199,7 @@ struct track {
116598
116599 enum track_item { TRACK_ALLOC, TRACK_FREE };
116600
116601-#ifdef CONFIG_SYSFS
116602+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116603 static int sysfs_slab_add(struct kmem_cache *);
116604 static int sysfs_slab_alias(struct kmem_cache *, const char *);
116605 static void memcg_propagate_slab_attrs(struct kmem_cache *s);
116606@@ -556,7 +557,7 @@ static void print_track(const char *s, struct track *t)
116607 if (!t->addr)
116608 return;
116609
116610- pr_err("INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
116611+ pr_err("INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
116612 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
116613 #ifdef CONFIG_STACKTRACE
116614 {
116615@@ -2707,6 +2708,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
116616
116617 slab_free_hook(s, x);
116618
116619+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116620+ if (!(s->flags & SLAB_NO_SANITIZE)) {
116621+ memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
116622+ if (s->ctor)
116623+ s->ctor(x);
116624+ }
116625+#endif
116626+
116627 redo:
116628 /*
116629 * Determine the currently cpus per cpu slab.
116630@@ -3048,6 +3057,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
116631 s->inuse = size;
116632
116633 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
116634+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116635+ (!(flags & SLAB_NO_SANITIZE)) ||
116636+#endif
116637 s->ctor)) {
116638 /*
116639 * Relocate free pointer after the object if it is not
116640@@ -3302,7 +3314,7 @@ static int __init setup_slub_min_objects(char *str)
116641
116642 __setup("slub_min_objects=", setup_slub_min_objects);
116643
116644-void *__kmalloc(size_t size, gfp_t flags)
116645+void * __size_overflow(1) __kmalloc(size_t size, gfp_t flags)
116646 {
116647 struct kmem_cache *s;
116648 void *ret;
116649@@ -3340,7 +3352,7 @@ static void *kmalloc_large_node(size_t size, gfp_t flags, int node)
116650 return ptr;
116651 }
116652
116653-void *__kmalloc_node(size_t size, gfp_t flags, int node)
116654+void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t flags, int node)
116655 {
116656 struct kmem_cache *s;
116657 void *ret;
116658@@ -3388,6 +3400,70 @@ static size_t __ksize(const void *object)
116659 return slab_ksize(page->slab_cache);
116660 }
116661
116662+bool is_usercopy_object(const void *ptr)
116663+{
116664+ struct page *page;
116665+ struct kmem_cache *s;
116666+
116667+ if (ZERO_OR_NULL_PTR(ptr))
116668+ return false;
116669+
116670+ if (!slab_is_available())
116671+ return false;
116672+
116673+ if (is_vmalloc_addr(ptr)
116674+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
116675+ && !object_starts_on_stack(ptr)
116676+#endif
116677+ ) {
116678+ struct vm_struct *vm = find_vm_area(ptr);
116679+ if (vm && (vm->flags & VM_USERCOPY))
116680+ return true;
116681+ return false;
116682+ }
116683+
116684+ if (!virt_addr_valid(ptr))
116685+ return false;
116686+
116687+ page = virt_to_head_page(ptr);
116688+
116689+ if (!PageSlab(page))
116690+ return false;
116691+
116692+ s = page->slab_cache;
116693+ return s->flags & SLAB_USERCOPY;
116694+}
116695+
116696+#ifdef CONFIG_PAX_USERCOPY
116697+const char *check_heap_object(const void *ptr, unsigned long n)
116698+{
116699+ struct page *page;
116700+ struct kmem_cache *s;
116701+ unsigned long offset;
116702+
116703+ if (ZERO_OR_NULL_PTR(ptr))
116704+ return "<null>";
116705+
116706+ if (!virt_addr_valid(ptr))
116707+ return NULL;
116708+
116709+ page = virt_to_head_page(ptr);
116710+
116711+ if (!PageSlab(page))
116712+ return NULL;
116713+
116714+ s = page->slab_cache;
116715+ if (!(s->flags & SLAB_USERCOPY))
116716+ return s->name;
116717+
116718+ offset = (ptr - page_address(page)) % s->size;
116719+ if (offset <= s->object_size && n <= s->object_size - offset)
116720+ return NULL;
116721+
116722+ return s->name;
116723+}
116724+#endif
116725+
116726 size_t ksize(const void *object)
116727 {
116728 size_t size = __ksize(object);
116729@@ -3408,6 +3484,7 @@ void kfree(const void *x)
116730 if (unlikely(ZERO_OR_NULL_PTR(x)))
116731 return;
116732
116733+ VM_BUG_ON(!virt_addr_valid(x));
116734 page = virt_to_head_page(x);
116735 if (unlikely(!PageSlab(page))) {
116736 BUG_ON(!PageCompound(page));
116737@@ -3725,7 +3802,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
116738
116739 s = find_mergeable(size, align, flags, name, ctor);
116740 if (s) {
116741- s->refcount++;
116742+ atomic_inc(&s->refcount);
116743
116744 /*
116745 * Adjust the object sizes so that we clear
116746@@ -3741,7 +3818,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
116747 }
116748
116749 if (sysfs_slab_alias(s, name)) {
116750- s->refcount--;
116751+ atomic_dec(&s->refcount);
116752 s = NULL;
116753 }
116754 }
116755@@ -3858,7 +3935,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
116756 }
116757 #endif
116758
116759-#ifdef CONFIG_SYSFS
116760+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116761 static int count_inuse(struct page *page)
116762 {
116763 return page->inuse;
116764@@ -4139,7 +4216,11 @@ static int list_locations(struct kmem_cache *s, char *buf,
116765 len += sprintf(buf + len, "%7ld ", l->count);
116766
116767 if (l->addr)
116768+#ifdef CONFIG_GRKERNSEC_HIDESYM
116769+ len += sprintf(buf + len, "%pS", NULL);
116770+#else
116771 len += sprintf(buf + len, "%pS", (void *)l->addr);
116772+#endif
116773 else
116774 len += sprintf(buf + len, "<not-available>");
116775
116776@@ -4237,12 +4318,12 @@ static void __init resiliency_test(void)
116777 validate_slab_cache(kmalloc_caches[9]);
116778 }
116779 #else
116780-#ifdef CONFIG_SYSFS
116781+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116782 static void resiliency_test(void) {};
116783 #endif
116784 #endif
116785
116786-#ifdef CONFIG_SYSFS
116787+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116788 enum slab_stat_type {
116789 SL_ALL, /* All slabs */
116790 SL_PARTIAL, /* Only partially allocated slabs */
116791@@ -4479,13 +4560,17 @@ static ssize_t ctor_show(struct kmem_cache *s, char *buf)
116792 {
116793 if (!s->ctor)
116794 return 0;
116795+#ifdef CONFIG_GRKERNSEC_HIDESYM
116796+ return sprintf(buf, "%pS\n", NULL);
116797+#else
116798 return sprintf(buf, "%pS\n", s->ctor);
116799+#endif
116800 }
116801 SLAB_ATTR_RO(ctor);
116802
116803 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
116804 {
116805- return sprintf(buf, "%d\n", s->refcount < 0 ? 0 : s->refcount - 1);
116806+ return sprintf(buf, "%d\n", atomic_read(&s->refcount) < 0 ? 0 : atomic_read(&s->refcount) - 1);
116807 }
116808 SLAB_ATTR_RO(aliases);
116809
116810@@ -4573,6 +4658,22 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
116811 SLAB_ATTR_RO(cache_dma);
116812 #endif
116813
116814+#ifdef CONFIG_PAX_USERCOPY_SLABS
116815+static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
116816+{
116817+ return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
116818+}
116819+SLAB_ATTR_RO(usercopy);
116820+#endif
116821+
116822+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116823+static ssize_t sanitize_show(struct kmem_cache *s, char *buf)
116824+{
116825+ return sprintf(buf, "%d\n", !(s->flags & SLAB_NO_SANITIZE));
116826+}
116827+SLAB_ATTR_RO(sanitize);
116828+#endif
116829+
116830 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
116831 {
116832 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
116833@@ -4628,7 +4729,7 @@ static ssize_t trace_store(struct kmem_cache *s, const char *buf,
116834 * as well as cause other issues like converting a mergeable
116835 * cache into an umergeable one.
116836 */
116837- if (s->refcount > 1)
116838+ if (atomic_read(&s->refcount) > 1)
116839 return -EINVAL;
116840
116841 s->flags &= ~SLAB_TRACE;
116842@@ -4748,7 +4849,7 @@ static ssize_t failslab_show(struct kmem_cache *s, char *buf)
116843 static ssize_t failslab_store(struct kmem_cache *s, const char *buf,
116844 size_t length)
116845 {
116846- if (s->refcount > 1)
116847+ if (atomic_read(&s->refcount) > 1)
116848 return -EINVAL;
116849
116850 s->flags &= ~SLAB_FAILSLAB;
116851@@ -4915,6 +5016,12 @@ static struct attribute *slab_attrs[] = {
116852 #ifdef CONFIG_ZONE_DMA
116853 &cache_dma_attr.attr,
116854 #endif
116855+#ifdef CONFIG_PAX_USERCOPY_SLABS
116856+ &usercopy_attr.attr,
116857+#endif
116858+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116859+ &sanitize_attr.attr,
116860+#endif
116861 #ifdef CONFIG_NUMA
116862 &remote_node_defrag_ratio_attr.attr,
116863 #endif
116864@@ -5156,6 +5263,7 @@ static char *create_unique_id(struct kmem_cache *s)
116865 return name;
116866 }
116867
116868+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116869 static int sysfs_slab_add(struct kmem_cache *s)
116870 {
116871 int err;
116872@@ -5229,6 +5337,7 @@ void sysfs_slab_remove(struct kmem_cache *s)
116873 kobject_del(&s->kobj);
116874 kobject_put(&s->kobj);
116875 }
116876+#endif
116877
116878 /*
116879 * Need to buffer aliases during bootup until sysfs becomes
116880@@ -5242,6 +5351,7 @@ struct saved_alias {
116881
116882 static struct saved_alias *alias_list;
116883
116884+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116885 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
116886 {
116887 struct saved_alias *al;
116888@@ -5264,6 +5374,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
116889 alias_list = al;
116890 return 0;
116891 }
116892+#endif
116893
116894 static int __init slab_sysfs_init(void)
116895 {
116896diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
116897index 4cba9c2..b4f9fcc 100644
116898--- a/mm/sparse-vmemmap.c
116899+++ b/mm/sparse-vmemmap.c
116900@@ -131,7 +131,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
116901 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
116902 if (!p)
116903 return NULL;
116904- pud_populate(&init_mm, pud, p);
116905+ pud_populate_kernel(&init_mm, pud, p);
116906 }
116907 return pud;
116908 }
116909@@ -143,7 +143,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
116910 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
116911 if (!p)
116912 return NULL;
116913- pgd_populate(&init_mm, pgd, p);
116914+ pgd_populate_kernel(&init_mm, pgd, p);
116915 }
116916 return pgd;
116917 }
116918diff --git a/mm/sparse.c b/mm/sparse.c
116919index d1b48b6..6e8590e 100644
116920--- a/mm/sparse.c
116921+++ b/mm/sparse.c
116922@@ -750,7 +750,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
116923
116924 for (i = 0; i < PAGES_PER_SECTION; i++) {
116925 if (PageHWPoison(&memmap[i])) {
116926- atomic_long_sub(1, &num_poisoned_pages);
116927+ atomic_long_sub_unchecked(1, &num_poisoned_pages);
116928 ClearPageHWPoison(&memmap[i]);
116929 }
116930 }
116931diff --git a/mm/swap.c b/mm/swap.c
116932index a3a0a2f..915d436 100644
116933--- a/mm/swap.c
116934+++ b/mm/swap.c
116935@@ -85,6 +85,8 @@ static void __put_compound_page(struct page *page)
116936 if (!PageHuge(page))
116937 __page_cache_release(page);
116938 dtor = get_compound_page_dtor(page);
116939+ if (!PageHuge(page))
116940+ BUG_ON(dtor != free_compound_page);
116941 (*dtor)(page);
116942 }
116943
116944diff --git a/mm/swapfile.c b/mm/swapfile.c
116945index 41e4581..6c452c9 100644
116946--- a/mm/swapfile.c
116947+++ b/mm/swapfile.c
116948@@ -84,7 +84,7 @@ static DEFINE_MUTEX(swapon_mutex);
116949
116950 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
116951 /* Activity counter to indicate that a swapon or swapoff has occurred */
116952-static atomic_t proc_poll_event = ATOMIC_INIT(0);
116953+static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
116954
116955 static inline unsigned char swap_count(unsigned char ent)
116956 {
116957@@ -1944,7 +1944,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
116958 spin_unlock(&swap_lock);
116959
116960 err = 0;
116961- atomic_inc(&proc_poll_event);
116962+ atomic_inc_unchecked(&proc_poll_event);
116963 wake_up_interruptible(&proc_poll_wait);
116964
116965 out_dput:
116966@@ -1961,8 +1961,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
116967
116968 poll_wait(file, &proc_poll_wait, wait);
116969
116970- if (seq->poll_event != atomic_read(&proc_poll_event)) {
116971- seq->poll_event = atomic_read(&proc_poll_event);
116972+ if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
116973+ seq->poll_event = atomic_read_unchecked(&proc_poll_event);
116974 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
116975 }
116976
116977@@ -2060,7 +2060,7 @@ static int swaps_open(struct inode *inode, struct file *file)
116978 return ret;
116979
116980 seq = file->private_data;
116981- seq->poll_event = atomic_read(&proc_poll_event);
116982+ seq->poll_event = atomic_read_unchecked(&proc_poll_event);
116983 return 0;
116984 }
116985
116986@@ -2520,7 +2520,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
116987 (frontswap_map) ? "FS" : "");
116988
116989 mutex_unlock(&swapon_mutex);
116990- atomic_inc(&proc_poll_event);
116991+ atomic_inc_unchecked(&proc_poll_event);
116992 wake_up_interruptible(&proc_poll_wait);
116993
116994 if (S_ISREG(inode->i_mode))
116995diff --git a/mm/util.c b/mm/util.c
116996index 68ff8a5..40c7a70 100644
116997--- a/mm/util.c
116998+++ b/mm/util.c
116999@@ -233,6 +233,12 @@ struct task_struct *task_of_stack(struct task_struct *task,
117000 void arch_pick_mmap_layout(struct mm_struct *mm)
117001 {
117002 mm->mmap_base = TASK_UNMAPPED_BASE;
117003+
117004+#ifdef CONFIG_PAX_RANDMMAP
117005+ if (mm->pax_flags & MF_PAX_RANDMMAP)
117006+ mm->mmap_base += mm->delta_mmap;
117007+#endif
117008+
117009 mm->get_unmapped_area = arch_get_unmapped_area;
117010 }
117011 #endif
117012@@ -434,6 +440,9 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen)
117013 if (!mm->arg_end)
117014 goto out_mm; /* Shh! No looking before we're done */
117015
117016+ if (gr_acl_handle_procpidmem(task))
117017+ goto out_mm;
117018+
117019 len = mm->arg_end - mm->arg_start;
117020
117021 if (len > buflen)
117022diff --git a/mm/vmalloc.c b/mm/vmalloc.c
117023index 2faaa29..c816cf4 100644
117024--- a/mm/vmalloc.c
117025+++ b/mm/vmalloc.c
117026@@ -40,20 +40,65 @@ struct vfree_deferred {
117027 struct work_struct wq;
117028 };
117029 static DEFINE_PER_CPU(struct vfree_deferred, vfree_deferred);
117030+static DEFINE_PER_CPU(struct vfree_deferred, vunmap_deferred);
117031+
117032+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
117033+struct stack_deferred_llist {
117034+ struct llist_head list;
117035+ void *stack;
117036+ void *lowmem_stack;
117037+};
117038+
117039+struct stack_deferred {
117040+ struct stack_deferred_llist list;
117041+ struct work_struct wq;
117042+};
117043+
117044+static DEFINE_PER_CPU(struct stack_deferred, stack_deferred);
117045+#endif
117046
117047 static void __vunmap(const void *, int);
117048
117049-static void free_work(struct work_struct *w)
117050+static void vfree_work(struct work_struct *w)
117051 {
117052 struct vfree_deferred *p = container_of(w, struct vfree_deferred, wq);
117053 struct llist_node *llnode = llist_del_all(&p->list);
117054 while (llnode) {
117055- void *p = llnode;
117056+ void *x = llnode;
117057 llnode = llist_next(llnode);
117058- __vunmap(p, 1);
117059+ __vunmap(x, 1);
117060 }
117061 }
117062
117063+static void vunmap_work(struct work_struct *w)
117064+{
117065+ struct vfree_deferred *p = container_of(w, struct vfree_deferred, wq);
117066+ struct llist_node *llnode = llist_del_all(&p->list);
117067+ while (llnode) {
117068+ void *x = llnode;
117069+ llnode = llist_next(llnode);
117070+ __vunmap(x, 0);
117071+ }
117072+}
117073+
117074+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
117075+static void unmap_work(struct work_struct *w)
117076+{
117077+ struct stack_deferred *p = container_of(w, struct stack_deferred, wq);
117078+ struct llist_node *llnode = llist_del_all(&p->list.list);
117079+ while (llnode) {
117080+ struct stack_deferred_llist *x =
117081+ llist_entry((struct llist_head *)llnode,
117082+ struct stack_deferred_llist, list);
117083+ void *stack = ACCESS_ONCE(x->stack);
117084+ void *lowmem_stack = ACCESS_ONCE(x->lowmem_stack);
117085+ llnode = llist_next(llnode);
117086+ __vunmap(stack, 0);
117087+ free_kmem_pages((unsigned long)lowmem_stack, THREAD_SIZE_ORDER);
117088+ }
117089+}
117090+#endif
117091+
117092 /*** Page table manipulation functions ***/
117093
117094 static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
117095@@ -61,10 +106,23 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
117096 pte_t *pte;
117097
117098 pte = pte_offset_kernel(pmd, addr);
117099+ pax_open_kernel();
117100 do {
117101- pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
117102- WARN_ON(!pte_none(ptent) && !pte_present(ptent));
117103+
117104+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
117105+ if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
117106+ BUG_ON(!pte_exec(*pte));
117107+ set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
117108+ continue;
117109+ }
117110+#endif
117111+
117112+ {
117113+ pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
117114+ WARN_ON(!pte_none(ptent) && !pte_present(ptent));
117115+ }
117116 } while (pte++, addr += PAGE_SIZE, addr != end);
117117+ pax_close_kernel();
117118 }
117119
117120 static void vunmap_pmd_range(pud_t *pud, unsigned long addr, unsigned long end)
117121@@ -127,16 +185,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
117122 pte = pte_alloc_kernel(pmd, addr);
117123 if (!pte)
117124 return -ENOMEM;
117125+
117126+ pax_open_kernel();
117127 do {
117128 struct page *page = pages[*nr];
117129
117130- if (WARN_ON(!pte_none(*pte)))
117131+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
117132+ if (pgprot_val(prot) & _PAGE_NX)
117133+#endif
117134+
117135+ if (!pte_none(*pte)) {
117136+ pax_close_kernel();
117137+ WARN_ON(1);
117138 return -EBUSY;
117139- if (WARN_ON(!page))
117140+ }
117141+ if (!page) {
117142+ pax_close_kernel();
117143+ WARN_ON(1);
117144 return -ENOMEM;
117145+ }
117146 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
117147 (*nr)++;
117148 } while (pte++, addr += PAGE_SIZE, addr != end);
117149+ pax_close_kernel();
117150 return 0;
117151 }
117152
117153@@ -146,7 +217,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
117154 pmd_t *pmd;
117155 unsigned long next;
117156
117157- pmd = pmd_alloc(&init_mm, pud, addr);
117158+ pmd = pmd_alloc_kernel(&init_mm, pud, addr);
117159 if (!pmd)
117160 return -ENOMEM;
117161 do {
117162@@ -163,7 +234,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
117163 pud_t *pud;
117164 unsigned long next;
117165
117166- pud = pud_alloc(&init_mm, pgd, addr);
117167+ pud = pud_alloc_kernel(&init_mm, pgd, addr);
117168 if (!pud)
117169 return -ENOMEM;
117170 do {
117171@@ -223,6 +294,12 @@ int is_vmalloc_or_module_addr(const void *x)
117172 if (addr >= MODULES_VADDR && addr < MODULES_END)
117173 return 1;
117174 #endif
117175+
117176+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
117177+ if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
117178+ return 1;
117179+#endif
117180+
117181 return is_vmalloc_addr(x);
117182 }
117183
117184@@ -243,8 +320,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
117185
117186 if (!pgd_none(*pgd)) {
117187 pud_t *pud = pud_offset(pgd, addr);
117188+#ifdef CONFIG_X86
117189+ if (!pud_large(*pud))
117190+#endif
117191 if (!pud_none(*pud)) {
117192 pmd_t *pmd = pmd_offset(pud, addr);
117193+#ifdef CONFIG_X86
117194+ if (!pmd_large(*pmd))
117195+#endif
117196 if (!pmd_none(*pmd)) {
117197 pte_t *ptep, pte;
117198
117199@@ -346,7 +429,7 @@ static void purge_vmap_area_lazy(void);
117200 * Allocate a region of KVA of the specified size and alignment, within the
117201 * vstart and vend.
117202 */
117203-static struct vmap_area *alloc_vmap_area(unsigned long size,
117204+static struct vmap_area * __size_overflow(1) alloc_vmap_area(unsigned long size,
117205 unsigned long align,
117206 unsigned long vstart, unsigned long vend,
117207 int node, gfp_t gfp_mask)
117208@@ -1202,13 +1285,27 @@ void __init vmalloc_init(void)
117209 for_each_possible_cpu(i) {
117210 struct vmap_block_queue *vbq;
117211 struct vfree_deferred *p;
117212+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
117213+ struct stack_deferred *p2;
117214+#endif
117215
117216 vbq = &per_cpu(vmap_block_queue, i);
117217 spin_lock_init(&vbq->lock);
117218 INIT_LIST_HEAD(&vbq->free);
117219+
117220 p = &per_cpu(vfree_deferred, i);
117221 init_llist_head(&p->list);
117222- INIT_WORK(&p->wq, free_work);
117223+ INIT_WORK(&p->wq, vfree_work);
117224+
117225+ p = &per_cpu(vunmap_deferred, i);
117226+ init_llist_head(&p->list);
117227+ INIT_WORK(&p->wq, vunmap_work);
117228+
117229+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
117230+ p2 = &per_cpu(stack_deferred, i);
117231+ init_llist_head(&p2->list.list);
117232+ INIT_WORK(&p2->wq, unmap_work);
117233+#endif
117234 }
117235
117236 /* Import existing vmlist entries. */
117237@@ -1333,6 +1430,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
117238 struct vm_struct *area;
117239
117240 BUG_ON(in_interrupt());
117241+
117242+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
117243+ if (flags & VM_KERNEXEC) {
117244+ if (start != VMALLOC_START || end != VMALLOC_END)
117245+ return NULL;
117246+ start = (unsigned long)MODULES_EXEC_VADDR;
117247+ end = (unsigned long)MODULES_EXEC_END;
117248+ }
117249+#endif
117250+
117251 if (flags & VM_IOREMAP)
117252 align = 1ul << clamp_t(int, fls_long(size),
117253 PAGE_SHIFT, IOREMAP_MAX_ORDER);
117254@@ -1531,13 +1638,36 @@ EXPORT_SYMBOL(vfree);
117255 */
117256 void vunmap(const void *addr)
117257 {
117258- BUG_ON(in_interrupt());
117259- might_sleep();
117260- if (addr)
117261+ if (!addr)
117262+ return;
117263+ if (unlikely(in_interrupt())) {
117264+ struct vfree_deferred *p = this_cpu_ptr(&vunmap_deferred);
117265+ if (llist_add((struct llist_node *)addr, &p->list))
117266+ schedule_work(&p->wq);
117267+ } else {
117268+ might_sleep();
117269 __vunmap(addr, 0);
117270+ }
117271 }
117272 EXPORT_SYMBOL(vunmap);
117273
117274+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
117275+void unmap_process_stacks(struct task_struct *task)
117276+{
117277+ if (unlikely(in_interrupt())) {
117278+ struct stack_deferred *p = this_cpu_ptr(&stack_deferred);
117279+ struct stack_deferred_llist *list = task->stack;
117280+ list->stack = task->stack;
117281+ list->lowmem_stack = task->lowmem_stack;
117282+ if (llist_add((struct llist_node *)&list->list, &p->list.list))
117283+ schedule_work(&p->wq);
117284+ } else {
117285+ __vunmap(task->stack, 0);
117286+ free_kmem_pages((unsigned long)task->lowmem_stack, THREAD_SIZE_ORDER);
117287+ }
117288+}
117289+#endif
117290+
117291 /**
117292 * vmap - map an array of pages into virtually contiguous space
117293 * @pages: array of page pointers
117294@@ -1558,6 +1688,11 @@ void *vmap(struct page **pages, unsigned int count,
117295 if (count > totalram_pages)
117296 return NULL;
117297
117298+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
117299+ if (!(pgprot_val(prot) & _PAGE_NX))
117300+ flags |= VM_KERNEXEC;
117301+#endif
117302+
117303 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
117304 __builtin_return_address(0));
117305 if (!area)
117306@@ -1662,6 +1797,14 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
117307 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
117308 goto fail;
117309
117310+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
117311+ if (!(pgprot_val(prot) & _PAGE_NX)) {
117312+ vm_flags |= VM_KERNEXEC;
117313+ start = VMALLOC_START;
117314+ end = VMALLOC_END;
117315+ }
117316+#endif
117317+
117318 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED |
117319 vm_flags, start, end, node, gfp_mask, caller);
117320 if (!area)
117321@@ -1715,6 +1858,14 @@ static void *__vmalloc_node(unsigned long size, unsigned long align,
117322 gfp_mask, prot, 0, node, caller);
117323 }
117324
117325+void *vmalloc_usercopy(unsigned long size)
117326+{
117327+ return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END,
117328+ GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL,
117329+ VM_USERCOPY, NUMA_NO_NODE,
117330+ __builtin_return_address(0));
117331+}
117332+
117333 void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
117334 {
117335 return __vmalloc_node(size, 1, gfp_mask, prot, NUMA_NO_NODE,
117336@@ -1838,10 +1989,9 @@ EXPORT_SYMBOL(vzalloc_node);
117337 * For tight control over page level allocator and protection flags
117338 * use __vmalloc() instead.
117339 */
117340-
117341 void *vmalloc_exec(unsigned long size)
117342 {
117343- return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
117344+ return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
117345 NUMA_NO_NODE, __builtin_return_address(0));
117346 }
117347
117348@@ -2148,6 +2298,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
117349 {
117350 struct vm_struct *area;
117351
117352+ BUG_ON(vma->vm_mirror);
117353+
117354 size = PAGE_ALIGN(size);
117355
117356 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
117357@@ -2630,7 +2782,11 @@ static int s_show(struct seq_file *m, void *p)
117358 v->addr, v->addr + v->size, v->size);
117359
117360 if (v->caller)
117361+#ifdef CONFIG_GRKERNSEC_HIDESYM
117362+ seq_printf(m, " %pK", v->caller);
117363+#else
117364 seq_printf(m, " %pS", v->caller);
117365+#endif
117366
117367 if (v->nr_pages)
117368 seq_printf(m, " pages=%d", v->nr_pages);
117369diff --git a/mm/vmstat.c b/mm/vmstat.c
117370index 4f5cd97..9fb715a 100644
117371--- a/mm/vmstat.c
117372+++ b/mm/vmstat.c
117373@@ -27,6 +27,7 @@
117374 #include <linux/mm_inline.h>
117375 #include <linux/page_ext.h>
117376 #include <linux/page_owner.h>
117377+#include <linux/grsecurity.h>
117378
117379 #include "internal.h"
117380
117381@@ -86,7 +87,7 @@ void vm_events_fold_cpu(int cpu)
117382 *
117383 * vm_stat contains the global counters
117384 */
117385-atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
117386+atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
117387 EXPORT_SYMBOL(vm_stat);
117388
117389 #ifdef CONFIG_SMP
117390@@ -438,7 +439,7 @@ static int fold_diff(int *diff)
117391
117392 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
117393 if (diff[i]) {
117394- atomic_long_add(diff[i], &vm_stat[i]);
117395+ atomic_long_add_unchecked(diff[i], &vm_stat[i]);
117396 changes++;
117397 }
117398 return changes;
117399@@ -476,7 +477,7 @@ static int refresh_cpu_vm_stats(void)
117400 v = this_cpu_xchg(p->vm_stat_diff[i], 0);
117401 if (v) {
117402
117403- atomic_long_add(v, &zone->vm_stat[i]);
117404+ atomic_long_add_unchecked(v, &zone->vm_stat[i]);
117405 global_diff[i] += v;
117406 #ifdef CONFIG_NUMA
117407 /* 3 seconds idle till flush */
117408@@ -540,7 +541,7 @@ void cpu_vm_stats_fold(int cpu)
117409
117410 v = p->vm_stat_diff[i];
117411 p->vm_stat_diff[i] = 0;
117412- atomic_long_add(v, &zone->vm_stat[i]);
117413+ atomic_long_add_unchecked(v, &zone->vm_stat[i]);
117414 global_diff[i] += v;
117415 }
117416 }
117417@@ -560,8 +561,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
117418 if (pset->vm_stat_diff[i]) {
117419 int v = pset->vm_stat_diff[i];
117420 pset->vm_stat_diff[i] = 0;
117421- atomic_long_add(v, &zone->vm_stat[i]);
117422- atomic_long_add(v, &vm_stat[i]);
117423+ atomic_long_add_unchecked(v, &zone->vm_stat[i]);
117424+ atomic_long_add_unchecked(v, &vm_stat[i]);
117425 }
117426 }
117427 #endif
117428@@ -1293,10 +1294,22 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos)
117429 stat_items_size += sizeof(struct vm_event_state);
117430 #endif
117431
117432- v = kmalloc(stat_items_size, GFP_KERNEL);
117433+ v = kzalloc(stat_items_size, GFP_KERNEL);
117434 m->private = v;
117435 if (!v)
117436 return ERR_PTR(-ENOMEM);
117437+
117438+#ifdef CONFIG_GRKERNSEC_PROC_ADD
117439+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
117440+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
117441+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
117442+ && !in_group_p(grsec_proc_gid)
117443+#endif
117444+ )
117445+ return (unsigned long *)m->private + *pos;
117446+#endif
117447+#endif
117448+
117449 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
117450 v[i] = global_page_state(i);
117451 v += NR_VM_ZONE_STAT_ITEMS;
117452@@ -1528,10 +1541,16 @@ static int __init setup_vmstat(void)
117453 cpu_notifier_register_done();
117454 #endif
117455 #ifdef CONFIG_PROC_FS
117456- proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
117457- proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
117458- proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
117459- proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
117460+ {
117461+ mode_t gr_mode = S_IRUGO;
117462+#ifdef CONFIG_GRKERNSEC_PROC_ADD
117463+ gr_mode = S_IRUSR;
117464+#endif
117465+ proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
117466+ proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
117467+ proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
117468+ proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
117469+ }
117470 #endif
117471 return 0;
117472 }
117473diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
117474index d2cd9de..501c186 100644
117475--- a/net/8021q/vlan.c
117476+++ b/net/8021q/vlan.c
117477@@ -491,7 +491,7 @@ out:
117478 return NOTIFY_DONE;
117479 }
117480
117481-static struct notifier_block vlan_notifier_block __read_mostly = {
117482+static struct notifier_block vlan_notifier_block = {
117483 .notifier_call = vlan_device_event,
117484 };
117485
117486@@ -566,8 +566,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
117487 err = -EPERM;
117488 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
117489 break;
117490- if ((args.u.name_type >= 0) &&
117491- (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
117492+ if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
117493 struct vlan_net *vn;
117494
117495 vn = net_generic(net, vlan_net_id);
117496diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
117497index c92b52f..006c052 100644
117498--- a/net/8021q/vlan_netlink.c
117499+++ b/net/8021q/vlan_netlink.c
117500@@ -245,7 +245,7 @@ static struct net *vlan_get_link_net(const struct net_device *dev)
117501 return dev_net(real_dev);
117502 }
117503
117504-struct rtnl_link_ops vlan_link_ops __read_mostly = {
117505+struct rtnl_link_ops vlan_link_ops = {
117506 .kind = "vlan",
117507 .maxtype = IFLA_VLAN_MAX,
117508 .policy = vlan_policy,
117509diff --git a/net/9p/mod.c b/net/9p/mod.c
117510index 6ab36ae..6f1841b 100644
117511--- a/net/9p/mod.c
117512+++ b/net/9p/mod.c
117513@@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
117514 void v9fs_register_trans(struct p9_trans_module *m)
117515 {
117516 spin_lock(&v9fs_trans_lock);
117517- list_add_tail(&m->list, &v9fs_trans_list);
117518+ pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
117519 spin_unlock(&v9fs_trans_lock);
117520 }
117521 EXPORT_SYMBOL(v9fs_register_trans);
117522@@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
117523 void v9fs_unregister_trans(struct p9_trans_module *m)
117524 {
117525 spin_lock(&v9fs_trans_lock);
117526- list_del_init(&m->list);
117527+ pax_list_del_init((struct list_head *)&m->list);
117528 spin_unlock(&v9fs_trans_lock);
117529 }
117530 EXPORT_SYMBOL(v9fs_unregister_trans);
117531diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
117532index bced8c0..ef253b7 100644
117533--- a/net/9p/trans_fd.c
117534+++ b/net/9p/trans_fd.c
117535@@ -428,7 +428,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
117536 oldfs = get_fs();
117537 set_fs(get_ds());
117538 /* The cast to a user pointer is valid due to the set_fs() */
117539- ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
117540+ ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
117541 set_fs(oldfs);
117542
117543 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
117544diff --git a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
117545index af46bc4..f9adfcd 100644
117546--- a/net/appletalk/atalk_proc.c
117547+++ b/net/appletalk/atalk_proc.c
117548@@ -256,7 +256,7 @@ int __init atalk_proc_init(void)
117549 struct proc_dir_entry *p;
117550 int rc = -ENOMEM;
117551
117552- atalk_proc_dir = proc_mkdir("atalk", init_net.proc_net);
117553+ atalk_proc_dir = proc_mkdir_restrict("atalk", init_net.proc_net);
117554 if (!atalk_proc_dir)
117555 goto out;
117556
117557diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
117558index 876fbe8..8bbea9f 100644
117559--- a/net/atm/atm_misc.c
117560+++ b/net/atm/atm_misc.c
117561@@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
117562 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
117563 return 1;
117564 atm_return(vcc, truesize);
117565- atomic_inc(&vcc->stats->rx_drop);
117566+ atomic_inc_unchecked(&vcc->stats->rx_drop);
117567 return 0;
117568 }
117569 EXPORT_SYMBOL(atm_charge);
117570@@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
117571 }
117572 }
117573 atm_return(vcc, guess);
117574- atomic_inc(&vcc->stats->rx_drop);
117575+ atomic_inc_unchecked(&vcc->stats->rx_drop);
117576 return NULL;
117577 }
117578 EXPORT_SYMBOL(atm_alloc_charge);
117579@@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
117580
117581 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
117582 {
117583-#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
117584+#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
117585 __SONET_ITEMS
117586 #undef __HANDLE_ITEM
117587 }
117588@@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
117589
117590 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
117591 {
117592-#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
117593+#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
117594 __SONET_ITEMS
117595 #undef __HANDLE_ITEM
117596 }
117597diff --git a/net/atm/lec.c b/net/atm/lec.c
117598index cd3b379..977a3c9 100644
117599--- a/net/atm/lec.c
117600+++ b/net/atm/lec.c
117601@@ -111,9 +111,9 @@ static inline void lec_arp_put(struct lec_arp_table *entry)
117602 }
117603
117604 static struct lane2_ops lane2_ops = {
117605- lane2_resolve, /* resolve, spec 3.1.3 */
117606- lane2_associate_req, /* associate_req, spec 3.1.4 */
117607- NULL /* associate indicator, spec 3.1.5 */
117608+ .resolve = lane2_resolve,
117609+ .associate_req = lane2_associate_req,
117610+ .associate_indicator = NULL
117611 };
117612
117613 static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
117614diff --git a/net/atm/lec.h b/net/atm/lec.h
117615index 4149db1..f2ab682 100644
117616--- a/net/atm/lec.h
117617+++ b/net/atm/lec.h
117618@@ -48,7 +48,7 @@ struct lane2_ops {
117619 const u8 *tlvs, u32 sizeoftlvs);
117620 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
117621 const u8 *tlvs, u32 sizeoftlvs);
117622-};
117623+} __no_const;
117624
117625 /*
117626 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
117627diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c
117628index d1b2d9a..d549f7f 100644
117629--- a/net/atm/mpoa_caches.c
117630+++ b/net/atm/mpoa_caches.c
117631@@ -535,30 +535,30 @@ static void eg_destroy_cache(struct mpoa_client *mpc)
117632
117633
117634 static struct in_cache_ops ingress_ops = {
117635- in_cache_add_entry, /* add_entry */
117636- in_cache_get, /* get */
117637- in_cache_get_with_mask, /* get_with_mask */
117638- in_cache_get_by_vcc, /* get_by_vcc */
117639- in_cache_put, /* put */
117640- in_cache_remove_entry, /* remove_entry */
117641- cache_hit, /* cache_hit */
117642- clear_count_and_expired, /* clear_count */
117643- check_resolving_entries, /* check_resolving */
117644- refresh_entries, /* refresh */
117645- in_destroy_cache /* destroy_cache */
117646+ .add_entry = in_cache_add_entry,
117647+ .get = in_cache_get,
117648+ .get_with_mask = in_cache_get_with_mask,
117649+ .get_by_vcc = in_cache_get_by_vcc,
117650+ .put = in_cache_put,
117651+ .remove_entry = in_cache_remove_entry,
117652+ .cache_hit = cache_hit,
117653+ .clear_count = clear_count_and_expired,
117654+ .check_resolving = check_resolving_entries,
117655+ .refresh = refresh_entries,
117656+ .destroy_cache = in_destroy_cache
117657 };
117658
117659 static struct eg_cache_ops egress_ops = {
117660- eg_cache_add_entry, /* add_entry */
117661- eg_cache_get_by_cache_id, /* get_by_cache_id */
117662- eg_cache_get_by_tag, /* get_by_tag */
117663- eg_cache_get_by_vcc, /* get_by_vcc */
117664- eg_cache_get_by_src_ip, /* get_by_src_ip */
117665- eg_cache_put, /* put */
117666- eg_cache_remove_entry, /* remove_entry */
117667- update_eg_cache_entry, /* update */
117668- clear_expired, /* clear_expired */
117669- eg_destroy_cache /* destroy_cache */
117670+ .add_entry = eg_cache_add_entry,
117671+ .get_by_cache_id = eg_cache_get_by_cache_id,
117672+ .get_by_tag = eg_cache_get_by_tag,
117673+ .get_by_vcc = eg_cache_get_by_vcc,
117674+ .get_by_src_ip = eg_cache_get_by_src_ip,
117675+ .put = eg_cache_put,
117676+ .remove_entry = eg_cache_remove_entry,
117677+ .update = update_eg_cache_entry,
117678+ .clear_expired = clear_expired,
117679+ .destroy_cache = eg_destroy_cache
117680 };
117681
117682
117683diff --git a/net/atm/proc.c b/net/atm/proc.c
117684index bbb6461..cf04016 100644
117685--- a/net/atm/proc.c
117686+++ b/net/atm/proc.c
117687@@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
117688 const struct k_atm_aal_stats *stats)
117689 {
117690 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
117691- atomic_read(&stats->tx), atomic_read(&stats->tx_err),
117692- atomic_read(&stats->rx), atomic_read(&stats->rx_err),
117693- atomic_read(&stats->rx_drop));
117694+ atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
117695+ atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
117696+ atomic_read_unchecked(&stats->rx_drop));
117697 }
117698
117699 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
117700diff --git a/net/atm/resources.c b/net/atm/resources.c
117701index 0447d5d..3cf4728 100644
117702--- a/net/atm/resources.c
117703+++ b/net/atm/resources.c
117704@@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
117705 static void copy_aal_stats(struct k_atm_aal_stats *from,
117706 struct atm_aal_stats *to)
117707 {
117708-#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
117709+#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
117710 __AAL_STAT_ITEMS
117711 #undef __HANDLE_ITEM
117712 }
117713@@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
117714 static void subtract_aal_stats(struct k_atm_aal_stats *from,
117715 struct atm_aal_stats *to)
117716 {
117717-#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
117718+#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
117719 __AAL_STAT_ITEMS
117720 #undef __HANDLE_ITEM
117721 }
117722diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
117723index 919a5ce..cc6b444 100644
117724--- a/net/ax25/sysctl_net_ax25.c
117725+++ b/net/ax25/sysctl_net_ax25.c
117726@@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
117727 {
117728 char path[sizeof("net/ax25/") + IFNAMSIZ];
117729 int k;
117730- struct ctl_table *table;
117731+ ctl_table_no_const *table;
117732
117733 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
117734 if (!table)
117735diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
117736index 753383c..32d12d9 100644
117737--- a/net/batman-adv/bat_iv_ogm.c
117738+++ b/net/batman-adv/bat_iv_ogm.c
117739@@ -343,7 +343,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
117740
117741 /* randomize initial seqno to avoid collision */
117742 get_random_bytes(&random_seqno, sizeof(random_seqno));
117743- atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
117744+ atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
117745
117746 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
117747 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
117748@@ -947,9 +947,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
117749 batadv_ogm_packet->tvlv_len = htons(tvlv_len);
117750
117751 /* change sequence number to network order */
117752- seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
117753+ seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
117754 batadv_ogm_packet->seqno = htonl(seqno);
117755- atomic_inc(&hard_iface->bat_iv.ogm_seqno);
117756+ atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
117757
117758 batadv_iv_ogm_slide_own_bcast_window(hard_iface);
117759
117760@@ -1626,7 +1626,7 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset,
117761 return;
117762
117763 /* could be changed by schedule_own_packet() */
117764- if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
117765+ if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
117766
117767 if (ogm_packet->flags & BATADV_DIRECTLINK)
117768 has_directlink_flag = true;
117769diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
117770index c0f0d01..725928a 100644
117771--- a/net/batman-adv/fragmentation.c
117772+++ b/net/batman-adv/fragmentation.c
117773@@ -465,7 +465,7 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
117774 frag_header.packet_type = BATADV_UNICAST_FRAG;
117775 frag_header.version = BATADV_COMPAT_VERSION;
117776 frag_header.ttl = BATADV_TTL;
117777- frag_header.seqno = htons(atomic_inc_return(&bat_priv->frag_seqno));
117778+ frag_header.seqno = htons(atomic_inc_return_unchecked(&bat_priv->frag_seqno));
117779 frag_header.reserved = 0;
117780 frag_header.no = 0;
117781 frag_header.total_size = htons(skb->len);
117782diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
117783index 51cda3a..a5db59e 100644
117784--- a/net/batman-adv/soft-interface.c
117785+++ b/net/batman-adv/soft-interface.c
117786@@ -330,7 +330,7 @@ send:
117787 primary_if->net_dev->dev_addr);
117788
117789 /* set broadcast sequence number */
117790- seqno = atomic_inc_return(&bat_priv->bcast_seqno);
117791+ seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
117792 bcast_packet->seqno = htonl(seqno);
117793
117794 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
117795@@ -798,7 +798,7 @@ static int batadv_softif_init_late(struct net_device *dev)
117796 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
117797
117798 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
117799- atomic_set(&bat_priv->bcast_seqno, 1);
117800+ atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
117801 atomic_set(&bat_priv->tt.vn, 0);
117802 atomic_set(&bat_priv->tt.local_changes, 0);
117803 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
117804@@ -812,7 +812,7 @@ static int batadv_softif_init_late(struct net_device *dev)
117805
117806 /* randomize initial seqno to avoid collision */
117807 get_random_bytes(&random_seqno, sizeof(random_seqno));
117808- atomic_set(&bat_priv->frag_seqno, random_seqno);
117809+ atomic_set_unchecked(&bat_priv->frag_seqno, random_seqno);
117810
117811 bat_priv->primary_if = NULL;
117812 bat_priv->num_ifaces = 0;
117813@@ -1020,7 +1020,7 @@ int batadv_softif_is_valid(const struct net_device *net_dev)
117814 return 0;
117815 }
117816
117817-struct rtnl_link_ops batadv_link_ops __read_mostly = {
117818+struct rtnl_link_ops batadv_link_ops = {
117819 .kind = "batadv",
117820 .priv_size = sizeof(struct batadv_priv),
117821 .setup = batadv_softif_init_early,
117822diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
117823index 55610a8..aba2ae8 100644
117824--- a/net/batman-adv/types.h
117825+++ b/net/batman-adv/types.h
117826@@ -81,7 +81,7 @@ enum batadv_dhcp_recipient {
117827 struct batadv_hard_iface_bat_iv {
117828 unsigned char *ogm_buff;
117829 int ogm_buff_len;
117830- atomic_t ogm_seqno;
117831+ atomic_unchecked_t ogm_seqno;
117832 };
117833
117834 /**
117835@@ -786,7 +786,7 @@ struct batadv_priv {
117836 atomic_t bonding;
117837 atomic_t fragmentation;
117838 atomic_t packet_size_max;
117839- atomic_t frag_seqno;
117840+ atomic_unchecked_t frag_seqno;
117841 #ifdef CONFIG_BATMAN_ADV_BLA
117842 atomic_t bridge_loop_avoidance;
117843 #endif
117844@@ -805,7 +805,7 @@ struct batadv_priv {
117845 #endif
117846 uint32_t isolation_mark;
117847 uint32_t isolation_mark_mask;
117848- atomic_t bcast_seqno;
117849+ atomic_unchecked_t bcast_seqno;
117850 atomic_t bcast_queue_left;
117851 atomic_t batman_queue_left;
117852 char num_ifaces;
117853diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
117854index f2d30d1..0573933 100644
117855--- a/net/bluetooth/hci_sock.c
117856+++ b/net/bluetooth/hci_sock.c
117857@@ -1253,7 +1253,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
117858 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
117859 }
117860
117861- len = min_t(unsigned int, len, sizeof(uf));
117862+ len = min((size_t)len, sizeof(uf));
117863 if (copy_from_user(&uf, optval, len)) {
117864 err = -EFAULT;
117865 break;
117866diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
117867index 45fffa4..c5ad848 100644
117868--- a/net/bluetooth/l2cap_core.c
117869+++ b/net/bluetooth/l2cap_core.c
117870@@ -3537,8 +3537,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
117871 break;
117872
117873 case L2CAP_CONF_RFC:
117874- if (olen == sizeof(rfc))
117875- memcpy(&rfc, (void *)val, olen);
117876+ if (olen != sizeof(rfc))
117877+ break;
117878+
117879+ memcpy(&rfc, (void *)val, olen);
117880
117881 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
117882 rfc.mode != chan->mode)
117883diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
117884index 2442877..24ddcd1 100644
117885--- a/net/bluetooth/l2cap_sock.c
117886+++ b/net/bluetooth/l2cap_sock.c
117887@@ -633,7 +633,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
117888 struct sock *sk = sock->sk;
117889 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
117890 struct l2cap_options opts;
117891- int len, err = 0;
117892+ int err = 0;
117893+ size_t len = optlen;
117894 u32 opt;
117895
117896 BT_DBG("sk %p", sk);
117897@@ -660,7 +661,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
117898 opts.max_tx = chan->max_tx;
117899 opts.txwin_size = chan->tx_win;
117900
117901- len = min_t(unsigned int, sizeof(opts), optlen);
117902+ len = min(sizeof(opts), len);
117903 if (copy_from_user((char *) &opts, optval, len)) {
117904 err = -EFAULT;
117905 break;
117906@@ -747,7 +748,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
117907 struct bt_security sec;
117908 struct bt_power pwr;
117909 struct l2cap_conn *conn;
117910- int len, err = 0;
117911+ int err = 0;
117912+ size_t len = optlen;
117913 u32 opt;
117914
117915 BT_DBG("sk %p", sk);
117916@@ -771,7 +773,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
117917
117918 sec.level = BT_SECURITY_LOW;
117919
117920- len = min_t(unsigned int, sizeof(sec), optlen);
117921+ len = min(sizeof(sec), len);
117922 if (copy_from_user((char *) &sec, optval, len)) {
117923 err = -EFAULT;
117924 break;
117925@@ -867,7 +869,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
117926
117927 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
117928
117929- len = min_t(unsigned int, sizeof(pwr), optlen);
117930+ len = min(sizeof(pwr), len);
117931 if (copy_from_user((char *) &pwr, optval, len)) {
117932 err = -EFAULT;
117933 break;
117934diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
117935index 7511df7..a670df3 100644
117936--- a/net/bluetooth/rfcomm/sock.c
117937+++ b/net/bluetooth/rfcomm/sock.c
117938@@ -690,7 +690,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
117939 struct sock *sk = sock->sk;
117940 struct bt_security sec;
117941 int err = 0;
117942- size_t len;
117943+ size_t len = optlen;
117944 u32 opt;
117945
117946 BT_DBG("sk %p", sk);
117947@@ -712,7 +712,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
117948
117949 sec.level = BT_SECURITY_LOW;
117950
117951- len = min_t(unsigned int, sizeof(sec), optlen);
117952+ len = min(sizeof(sec), len);
117953 if (copy_from_user((char *) &sec, optval, len)) {
117954 err = -EFAULT;
117955 break;
117956diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
117957index 8e385a0..a5bdd8e 100644
117958--- a/net/bluetooth/rfcomm/tty.c
117959+++ b/net/bluetooth/rfcomm/tty.c
117960@@ -752,7 +752,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
117961 BT_DBG("tty %p id %d", tty, tty->index);
117962
117963 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
117964- dev->channel, dev->port.count);
117965+ dev->channel, atomic_read(&dev->port.count));
117966
117967 err = tty_port_open(&dev->port, tty, filp);
117968 if (err)
117969@@ -775,7 +775,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
117970 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
117971
117972 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
117973- dev->port.count);
117974+ atomic_read(&dev->port.count));
117975
117976 tty_port_close(&dev->port, tty, filp);
117977 }
117978diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
117979index 4d74a06..f37f9c2 100644
117980--- a/net/bridge/br_netlink.c
117981+++ b/net/bridge/br_netlink.c
117982@@ -835,7 +835,7 @@ static struct rtnl_af_ops br_af_ops __read_mostly = {
117983 .get_link_af_size = br_get_link_af_size,
117984 };
117985
117986-struct rtnl_link_ops br_link_ops __read_mostly = {
117987+struct rtnl_link_ops br_link_ops = {
117988 .kind = "bridge",
117989 .priv_size = sizeof(struct net_bridge),
117990 .setup = br_dev_setup,
117991diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
117992index 18ca4b2..7e8d731 100644
117993--- a/net/bridge/netfilter/ebtables.c
117994+++ b/net/bridge/netfilter/ebtables.c
117995@@ -1533,7 +1533,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
117996 tmp.valid_hooks = t->table->valid_hooks;
117997 }
117998 mutex_unlock(&ebt_mutex);
117999- if (copy_to_user(user, &tmp, *len) != 0) {
118000+ if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
118001 BUGPRINT("c2u Didn't work\n");
118002 ret = -EFAULT;
118003 break;
118004@@ -2339,7 +2339,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
118005 goto out;
118006 tmp.valid_hooks = t->valid_hooks;
118007
118008- if (copy_to_user(user, &tmp, *len) != 0) {
118009+ if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
118010 ret = -EFAULT;
118011 break;
118012 }
118013@@ -2350,7 +2350,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
118014 tmp.entries_size = t->table->entries_size;
118015 tmp.valid_hooks = t->table->valid_hooks;
118016
118017- if (copy_to_user(user, &tmp, *len) != 0) {
118018+ if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
118019 ret = -EFAULT;
118020 break;
118021 }
118022diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
118023index f5afda1..dcf770a 100644
118024--- a/net/caif/cfctrl.c
118025+++ b/net/caif/cfctrl.c
118026@@ -10,6 +10,7 @@
118027 #include <linux/spinlock.h>
118028 #include <linux/slab.h>
118029 #include <linux/pkt_sched.h>
118030+#include <linux/sched.h>
118031 #include <net/caif/caif_layer.h>
118032 #include <net/caif/cfpkt.h>
118033 #include <net/caif/cfctrl.h>
118034@@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
118035 memset(&dev_info, 0, sizeof(dev_info));
118036 dev_info.id = 0xff;
118037 cfsrvl_init(&this->serv, 0, &dev_info, false);
118038- atomic_set(&this->req_seq_no, 1);
118039- atomic_set(&this->rsp_seq_no, 1);
118040+ atomic_set_unchecked(&this->req_seq_no, 1);
118041+ atomic_set_unchecked(&this->rsp_seq_no, 1);
118042 this->serv.layer.receive = cfctrl_recv;
118043 sprintf(this->serv.layer.name, "ctrl");
118044 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
118045@@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
118046 struct cfctrl_request_info *req)
118047 {
118048 spin_lock_bh(&ctrl->info_list_lock);
118049- atomic_inc(&ctrl->req_seq_no);
118050- req->sequence_no = atomic_read(&ctrl->req_seq_no);
118051+ atomic_inc_unchecked(&ctrl->req_seq_no);
118052+ req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
118053 list_add_tail(&req->list, &ctrl->list);
118054 spin_unlock_bh(&ctrl->info_list_lock);
118055 }
118056@@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
118057 if (p != first)
118058 pr_warn("Requests are not received in order\n");
118059
118060- atomic_set(&ctrl->rsp_seq_no,
118061+ atomic_set_unchecked(&ctrl->rsp_seq_no,
118062 p->sequence_no);
118063 list_del(&p->list);
118064 goto out;
118065diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c
118066index 67a4a36..8d28068 100644
118067--- a/net/caif/chnl_net.c
118068+++ b/net/caif/chnl_net.c
118069@@ -515,7 +515,7 @@ static const struct nla_policy ipcaif_policy[IFLA_CAIF_MAX + 1] = {
118070 };
118071
118072
118073-static struct rtnl_link_ops ipcaif_link_ops __read_mostly = {
118074+static struct rtnl_link_ops ipcaif_link_ops = {
118075 .kind = "caif",
118076 .priv_size = sizeof(struct chnl_net),
118077 .setup = ipcaif_net_setup,
118078diff --git a/net/can/af_can.c b/net/can/af_can.c
118079index 166d436..2920816 100644
118080--- a/net/can/af_can.c
118081+++ b/net/can/af_can.c
118082@@ -890,7 +890,7 @@ static const struct net_proto_family can_family_ops = {
118083 };
118084
118085 /* notifier block for netdevice event */
118086-static struct notifier_block can_netdev_notifier __read_mostly = {
118087+static struct notifier_block can_netdev_notifier = {
118088 .notifier_call = can_notifier,
118089 };
118090
118091diff --git a/net/can/bcm.c b/net/can/bcm.c
118092index a1ba687..aafaec5 100644
118093--- a/net/can/bcm.c
118094+++ b/net/can/bcm.c
118095@@ -1620,7 +1620,7 @@ static int __init bcm_module_init(void)
118096 }
118097
118098 /* create /proc/net/can-bcm directory */
118099- proc_dir = proc_mkdir("can-bcm", init_net.proc_net);
118100+ proc_dir = proc_mkdir_restrict("can-bcm", init_net.proc_net);
118101 return 0;
118102 }
118103
118104diff --git a/net/can/gw.c b/net/can/gw.c
118105index 4551687..4e82e9b 100644
118106--- a/net/can/gw.c
118107+++ b/net/can/gw.c
118108@@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
118109 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
118110
118111 static HLIST_HEAD(cgw_list);
118112-static struct notifier_block notifier;
118113
118114 static struct kmem_cache *cgw_cache __read_mostly;
118115
118116@@ -992,6 +991,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
118117 return err;
118118 }
118119
118120+static struct notifier_block notifier = {
118121+ .notifier_call = cgw_notifier
118122+};
118123+
118124 static __init int cgw_module_init(void)
118125 {
118126 /* sanitize given module parameter */
118127@@ -1007,7 +1010,6 @@ static __init int cgw_module_init(void)
118128 return -ENOMEM;
118129
118130 /* set notifier */
118131- notifier.notifier_call = cgw_notifier;
118132 register_netdevice_notifier(&notifier);
118133
118134 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
118135diff --git a/net/can/proc.c b/net/can/proc.c
118136index 1a19b98..df2b4ec 100644
118137--- a/net/can/proc.c
118138+++ b/net/can/proc.c
118139@@ -514,7 +514,7 @@ static void can_remove_proc_readentry(const char *name)
118140 void can_init_proc(void)
118141 {
118142 /* create /proc/net/can directory */
118143- can_dir = proc_mkdir("can", init_net.proc_net);
118144+ can_dir = proc_mkdir_restrict("can", init_net.proc_net);
118145
118146 if (!can_dir) {
118147 printk(KERN_INFO "can: failed to create /proc/net/can . "
118148diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
118149index e3be1d2..254c555 100644
118150--- a/net/ceph/messenger.c
118151+++ b/net/ceph/messenger.c
118152@@ -189,7 +189,7 @@ static void con_fault(struct ceph_connection *con);
118153 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
118154
118155 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
118156-static atomic_t addr_str_seq = ATOMIC_INIT(0);
118157+static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
118158
118159 static struct page *zero_page; /* used in certain error cases */
118160
118161@@ -200,7 +200,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
118162 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
118163 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
118164
118165- i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
118166+ i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
118167 s = addr_str[i];
118168
118169 switch (ss->ss_family) {
118170diff --git a/net/compat.c b/net/compat.c
118171index 5cfd26a..7e43828 100644
118172--- a/net/compat.c
118173+++ b/net/compat.c
118174@@ -98,20 +98,20 @@ int get_compat_msghdr(struct msghdr *kmsg,
118175
118176 #define CMSG_COMPAT_FIRSTHDR(msg) \
118177 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
118178- (struct compat_cmsghdr __user *)((msg)->msg_control) : \
118179+ (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
118180 (struct compat_cmsghdr __user *)NULL)
118181
118182 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
118183 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
118184 (ucmlen) <= (unsigned long) \
118185 ((mhdr)->msg_controllen - \
118186- ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
118187+ ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
118188
118189 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
118190 struct compat_cmsghdr __user *cmsg, int cmsg_len)
118191 {
118192 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
118193- if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
118194+ if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
118195 msg->msg_controllen)
118196 return NULL;
118197 return (struct compat_cmsghdr __user *)ptr;
118198@@ -201,7 +201,7 @@ Efault:
118199
118200 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
118201 {
118202- struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
118203+ struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
118204 struct compat_cmsghdr cmhdr;
118205 struct compat_timeval ctv;
118206 struct compat_timespec cts[3];
118207@@ -257,7 +257,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
118208
118209 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
118210 {
118211- struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
118212+ struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
118213 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
118214 int fdnum = scm->fp->count;
118215 struct file **fp = scm->fp->fp;
118216@@ -345,7 +345,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
118217 return -EFAULT;
118218 old_fs = get_fs();
118219 set_fs(KERNEL_DS);
118220- err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
118221+ err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
118222 set_fs(old_fs);
118223
118224 return err;
118225@@ -406,7 +406,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
118226 len = sizeof(ktime);
118227 old_fs = get_fs();
118228 set_fs(KERNEL_DS);
118229- err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
118230+ err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
118231 set_fs(old_fs);
118232
118233 if (!err) {
118234@@ -549,7 +549,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
118235 case MCAST_JOIN_GROUP:
118236 case MCAST_LEAVE_GROUP:
118237 {
118238- struct compat_group_req __user *gr32 = (void *)optval;
118239+ struct compat_group_req __user *gr32 = (void __user *)optval;
118240 struct group_req __user *kgr =
118241 compat_alloc_user_space(sizeof(struct group_req));
118242 u32 interface;
118243@@ -570,7 +570,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
118244 case MCAST_BLOCK_SOURCE:
118245 case MCAST_UNBLOCK_SOURCE:
118246 {
118247- struct compat_group_source_req __user *gsr32 = (void *)optval;
118248+ struct compat_group_source_req __user *gsr32 = (void __user *)optval;
118249 struct group_source_req __user *kgsr = compat_alloc_user_space(
118250 sizeof(struct group_source_req));
118251 u32 interface;
118252@@ -591,7 +591,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
118253 }
118254 case MCAST_MSFILTER:
118255 {
118256- struct compat_group_filter __user *gf32 = (void *)optval;
118257+ struct compat_group_filter __user *gf32 = (void __user *)optval;
118258 struct group_filter __user *kgf;
118259 u32 interface, fmode, numsrc;
118260
118261@@ -629,7 +629,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
118262 char __user *optval, int __user *optlen,
118263 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
118264 {
118265- struct compat_group_filter __user *gf32 = (void *)optval;
118266+ struct compat_group_filter __user *gf32 = (void __user *)optval;
118267 struct group_filter __user *kgf;
118268 int __user *koptlen;
118269 u32 interface, fmode, numsrc;
118270@@ -773,7 +773,7 @@ COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args)
118271
118272 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
118273 return -EINVAL;
118274- if (copy_from_user(a, args, nas[call]))
118275+ if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
118276 return -EFAULT;
118277 a0 = a[0];
118278 a1 = a[1];
118279diff --git a/net/core/datagram.c b/net/core/datagram.c
118280index 617088a..0364f4f 100644
118281--- a/net/core/datagram.c
118282+++ b/net/core/datagram.c
118283@@ -338,7 +338,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
118284 }
118285
118286 kfree_skb(skb);
118287- atomic_inc(&sk->sk_drops);
118288+ atomic_inc_unchecked(&sk->sk_drops);
118289 sk_mem_reclaim_partial(sk);
118290
118291 return err;
118292diff --git a/net/core/dev.c b/net/core/dev.c
118293index a8e4dd4..aab06f7 100644
118294--- a/net/core/dev.c
118295+++ b/net/core/dev.c
118296@@ -1721,7 +1721,7 @@ int __dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
118297 {
118298 if (skb_orphan_frags(skb, GFP_ATOMIC) ||
118299 unlikely(!is_skb_forwardable(dev, skb))) {
118300- atomic_long_inc(&dev->rx_dropped);
118301+ atomic_long_inc_unchecked(&dev->rx_dropped);
118302 kfree_skb(skb);
118303 return NET_RX_DROP;
118304 }
118305@@ -3125,7 +3125,7 @@ recursion_alert:
118306 drop:
118307 rcu_read_unlock_bh();
118308
118309- atomic_long_inc(&dev->tx_dropped);
118310+ atomic_long_inc_unchecked(&dev->tx_dropped);
118311 kfree_skb_list(skb);
118312 return rc;
118313 out:
118314@@ -3477,7 +3477,7 @@ drop:
118315
118316 local_irq_restore(flags);
118317
118318- atomic_long_inc(&skb->dev->rx_dropped);
118319+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
118320 kfree_skb(skb);
118321 return NET_RX_DROP;
118322 }
118323@@ -3554,7 +3554,7 @@ int netif_rx_ni(struct sk_buff *skb)
118324 }
118325 EXPORT_SYMBOL(netif_rx_ni);
118326
118327-static void net_tx_action(struct softirq_action *h)
118328+static __latent_entropy void net_tx_action(void)
118329 {
118330 struct softnet_data *sd = this_cpu_ptr(&softnet_data);
118331
118332@@ -3892,7 +3892,7 @@ ncls:
118333 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
118334 } else {
118335 drop:
118336- atomic_long_inc(&skb->dev->rx_dropped);
118337+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
118338 kfree_skb(skb);
118339 /* Jamal, now you will not able to escape explaining
118340 * me how you were going to use this. :-)
118341@@ -4783,7 +4783,7 @@ out_unlock:
118342 return work;
118343 }
118344
118345-static void net_rx_action(struct softirq_action *h)
118346+static __latent_entropy void net_rx_action(void)
118347 {
118348 struct softnet_data *sd = this_cpu_ptr(&softnet_data);
118349 unsigned long time_limit = jiffies + 2;
118350@@ -6843,8 +6843,8 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
118351 } else {
118352 netdev_stats_to_stats64(storage, &dev->stats);
118353 }
118354- storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
118355- storage->tx_dropped += atomic_long_read(&dev->tx_dropped);
118356+ storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
118357+ storage->tx_dropped += atomic_long_read_unchecked(&dev->tx_dropped);
118358 return storage;
118359 }
118360 EXPORT_SYMBOL(dev_get_stats);
118361diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
118362index b94b1d2..da3ed7c 100644
118363--- a/net/core/dev_ioctl.c
118364+++ b/net/core/dev_ioctl.c
118365@@ -368,8 +368,13 @@ void dev_load(struct net *net, const char *name)
118366 no_module = !dev;
118367 if (no_module && capable(CAP_NET_ADMIN))
118368 no_module = request_module("netdev-%s", name);
118369- if (no_module && capable(CAP_SYS_MODULE))
118370+ if (no_module && capable(CAP_SYS_MODULE)) {
118371+#ifdef CONFIG_GRKERNSEC_MODHARDEN
118372+ ___request_module(true, "grsec_modharden_netdev", "%s", name);
118373+#else
118374 request_module("%s", name);
118375+#endif
118376+ }
118377 }
118378 EXPORT_SYMBOL(dev_load);
118379
118380diff --git a/net/core/ethtool.c b/net/core/ethtool.c
118381index b495ab1..29edf74 100644
118382--- a/net/core/ethtool.c
118383+++ b/net/core/ethtool.c
118384@@ -1284,7 +1284,7 @@ static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
118385
118386 gstrings.len = ret;
118387
118388- data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
118389+ data = kcalloc(gstrings.len, ETH_GSTRING_LEN, GFP_USER);
118390 if (!data)
118391 return -ENOMEM;
118392
118393diff --git a/net/core/filter.c b/net/core/filter.c
118394index be3098f..51ee477 100644
118395--- a/net/core/filter.c
118396+++ b/net/core/filter.c
118397@@ -582,7 +582,11 @@ do_pass:
118398
118399 /* Unknown instruction. */
118400 default:
118401- goto err;
118402+ WARN(1, KERN_ALERT "Unknown sock filter code:%u jt:%u tf:%u k:%u\n",
118403+ fp->code, fp->jt, fp->jf, fp->k);
118404+ kfree(addrs);
118405+ BUG();
118406+ return -EINVAL;
118407 }
118408
118409 insn++;
118410@@ -626,7 +630,7 @@ static int check_load_and_stores(const struct sock_filter *filter, int flen)
118411 u16 *masks, memvalid = 0; /* One bit per cell, 16 cells */
118412 int pc, ret = 0;
118413
118414- BUILD_BUG_ON(BPF_MEMWORDS > 16);
118415+ BUILD_BUG_ON(BPF_MEMWORDS != 16);
118416
118417 masks = kmalloc_array(flen, sizeof(*masks), GFP_KERNEL);
118418 if (!masks)
118419@@ -1055,7 +1059,7 @@ int bpf_prog_create(struct bpf_prog **pfp, struct sock_fprog_kern *fprog)
118420 if (!fp)
118421 return -ENOMEM;
118422
118423- memcpy(fp->insns, fprog->filter, fsize);
118424+ memcpy(fp->insns, (void __force_kernel *)fprog->filter, fsize);
118425
118426 fp->len = fprog->len;
118427 /* Since unattached filters are not copied back to user
118428@@ -1701,9 +1705,13 @@ int sk_get_filter(struct sock *sk, struct sock_filter __user *ubuf,
118429 goto out;
118430
118431 /* We're copying the filter that has been originally attached,
118432- * so no conversion/decode needed anymore.
118433+ * so no conversion/decode needed anymore. eBPF programs that
118434+ * have no original program cannot be dumped through this.
118435 */
118436+ ret = -EACCES;
118437 fprog = filter->prog->orig_prog;
118438+ if (!fprog)
118439+ goto out;
118440
118441 ret = fprog->len;
118442 if (!len)
118443diff --git a/net/core/flow.c b/net/core/flow.c
118444index 1033725..340f65d 100644
118445--- a/net/core/flow.c
118446+++ b/net/core/flow.c
118447@@ -65,7 +65,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
118448 static int flow_entry_valid(struct flow_cache_entry *fle,
118449 struct netns_xfrm *xfrm)
118450 {
118451- if (atomic_read(&xfrm->flow_cache_genid) != fle->genid)
118452+ if (atomic_read_unchecked(&xfrm->flow_cache_genid) != fle->genid)
118453 return 0;
118454 if (fle->object && !fle->object->ops->check(fle->object))
118455 return 0;
118456@@ -242,7 +242,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
118457 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
118458 fcp->hash_count++;
118459 }
118460- } else if (likely(fle->genid == atomic_read(&net->xfrm.flow_cache_genid))) {
118461+ } else if (likely(fle->genid == atomic_read_unchecked(&net->xfrm.flow_cache_genid))) {
118462 flo = fle->object;
118463 if (!flo)
118464 goto ret_object;
118465@@ -263,7 +263,7 @@ nocache:
118466 }
118467 flo = resolver(net, key, family, dir, flo, ctx);
118468 if (fle) {
118469- fle->genid = atomic_read(&net->xfrm.flow_cache_genid);
118470+ fle->genid = atomic_read_unchecked(&net->xfrm.flow_cache_genid);
118471 if (!IS_ERR(flo))
118472 fle->object = flo;
118473 else
118474diff --git a/net/core/neighbour.c b/net/core/neighbour.c
118475index 84195da..035c7a7 100644
118476--- a/net/core/neighbour.c
118477+++ b/net/core/neighbour.c
118478@@ -2821,7 +2821,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
118479 void __user *buffer, size_t *lenp, loff_t *ppos)
118480 {
118481 int size, ret;
118482- struct ctl_table tmp = *ctl;
118483+ ctl_table_no_const tmp = *ctl;
118484
118485 tmp.extra1 = &zero;
118486 tmp.extra2 = &unres_qlen_max;
118487@@ -2883,7 +2883,7 @@ static int neigh_proc_dointvec_zero_intmax(struct ctl_table *ctl, int write,
118488 void __user *buffer,
118489 size_t *lenp, loff_t *ppos)
118490 {
118491- struct ctl_table tmp = *ctl;
118492+ ctl_table_no_const tmp = *ctl;
118493 int ret;
118494
118495 tmp.extra1 = &zero;
118496diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
118497index 2bf8329..2eb1423 100644
118498--- a/net/core/net-procfs.c
118499+++ b/net/core/net-procfs.c
118500@@ -79,7 +79,13 @@ static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
118501 struct rtnl_link_stats64 temp;
118502 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
118503
118504- seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
118505+ if (gr_proc_is_restricted())
118506+ seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
118507+ "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
118508+ dev->name, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL,
118509+ 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL);
118510+ else
118511+ seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
118512 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
118513 dev->name, stats->rx_bytes, stats->rx_packets,
118514 stats->rx_errors,
118515@@ -166,7 +172,7 @@ static int softnet_seq_show(struct seq_file *seq, void *v)
118516 return 0;
118517 }
118518
118519-static const struct seq_operations dev_seq_ops = {
118520+const struct seq_operations dev_seq_ops = {
118521 .start = dev_seq_start,
118522 .next = dev_seq_next,
118523 .stop = dev_seq_stop,
118524@@ -196,7 +202,7 @@ static const struct seq_operations softnet_seq_ops = {
118525
118526 static int softnet_seq_open(struct inode *inode, struct file *file)
118527 {
118528- return seq_open(file, &softnet_seq_ops);
118529+ return seq_open_restrict(file, &softnet_seq_ops);
118530 }
118531
118532 static const struct file_operations softnet_seq_fops = {
118533@@ -283,8 +289,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
118534 else
118535 seq_printf(seq, "%04x", ntohs(pt->type));
118536
118537+#ifdef CONFIG_GRKERNSEC_HIDESYM
118538+ seq_printf(seq, " %-8s %pf\n",
118539+ pt->dev ? pt->dev->name : "", NULL);
118540+#else
118541 seq_printf(seq, " %-8s %pf\n",
118542 pt->dev ? pt->dev->name : "", pt->func);
118543+#endif
118544 }
118545
118546 return 0;
118547diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
118548index 18b34d7..faecc1d 100644
118549--- a/net/core/net-sysfs.c
118550+++ b/net/core/net-sysfs.c
118551@@ -288,7 +288,7 @@ static ssize_t carrier_changes_show(struct device *dev,
118552 {
118553 struct net_device *netdev = to_net_dev(dev);
118554 return sprintf(buf, fmt_dec,
118555- atomic_read(&netdev->carrier_changes));
118556+ atomic_read_unchecked(&netdev->carrier_changes));
118557 }
118558 static DEVICE_ATTR_RO(carrier_changes);
118559
118560diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
118561index 2c2eb1b..a53be3e 100644
118562--- a/net/core/net_namespace.c
118563+++ b/net/core/net_namespace.c
118564@@ -775,7 +775,7 @@ static int __register_pernet_operations(struct list_head *list,
118565 int error;
118566 LIST_HEAD(net_exit_list);
118567
118568- list_add_tail(&ops->list, list);
118569+ pax_list_add_tail((struct list_head *)&ops->list, list);
118570 if (ops->init || (ops->id && ops->size)) {
118571 for_each_net(net) {
118572 error = ops_init(ops, net);
118573@@ -788,7 +788,7 @@ static int __register_pernet_operations(struct list_head *list,
118574
118575 out_undo:
118576 /* If I have an error cleanup all namespaces I initialized */
118577- list_del(&ops->list);
118578+ pax_list_del((struct list_head *)&ops->list);
118579 ops_exit_list(ops, &net_exit_list);
118580 ops_free_list(ops, &net_exit_list);
118581 return error;
118582@@ -799,7 +799,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
118583 struct net *net;
118584 LIST_HEAD(net_exit_list);
118585
118586- list_del(&ops->list);
118587+ pax_list_del((struct list_head *)&ops->list);
118588 for_each_net(net)
118589 list_add_tail(&net->exit_list, &net_exit_list);
118590 ops_exit_list(ops, &net_exit_list);
118591@@ -933,7 +933,7 @@ int register_pernet_device(struct pernet_operations *ops)
118592 mutex_lock(&net_mutex);
118593 error = register_pernet_operations(&pernet_list, ops);
118594 if (!error && (first_device == &pernet_list))
118595- first_device = &ops->list;
118596+ first_device = (struct list_head *)&ops->list;
118597 mutex_unlock(&net_mutex);
118598 return error;
118599 }
118600diff --git a/net/core/netpoll.c b/net/core/netpoll.c
118601index c126a87..10ad89d 100644
118602--- a/net/core/netpoll.c
118603+++ b/net/core/netpoll.c
118604@@ -377,7 +377,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
118605 struct udphdr *udph;
118606 struct iphdr *iph;
118607 struct ethhdr *eth;
118608- static atomic_t ip_ident;
118609+ static atomic_unchecked_t ip_ident;
118610 struct ipv6hdr *ip6h;
118611
118612 udp_len = len + sizeof(*udph);
118613@@ -448,7 +448,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
118614 put_unaligned(0x45, (unsigned char *)iph);
118615 iph->tos = 0;
118616 put_unaligned(htons(ip_len), &(iph->tot_len));
118617- iph->id = htons(atomic_inc_return(&ip_ident));
118618+ iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
118619 iph->frag_off = 0;
118620 iph->ttl = 64;
118621 iph->protocol = IPPROTO_UDP;
118622diff --git a/net/core/pktgen.c b/net/core/pktgen.c
118623index 1cbd209..9553598 100644
118624--- a/net/core/pktgen.c
118625+++ b/net/core/pktgen.c
118626@@ -3828,7 +3828,7 @@ static int __net_init pg_net_init(struct net *net)
118627 pn->net = net;
118628 INIT_LIST_HEAD(&pn->pktgen_threads);
118629 pn->pktgen_exiting = false;
118630- pn->proc_dir = proc_mkdir(PG_PROC_DIR, pn->net->proc_net);
118631+ pn->proc_dir = proc_mkdir_restrict(PG_PROC_DIR, pn->net->proc_net);
118632 if (!pn->proc_dir) {
118633 pr_warn("cannot create /proc/net/%s\n", PG_PROC_DIR);
118634 return -ENODEV;
118635diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
118636index 0861018..1fd388b 100644
118637--- a/net/core/rtnetlink.c
118638+++ b/net/core/rtnetlink.c
118639@@ -61,7 +61,7 @@ struct rtnl_link {
118640 rtnl_doit_func doit;
118641 rtnl_dumpit_func dumpit;
118642 rtnl_calcit_func calcit;
118643-};
118644+} __no_const;
118645
118646 static DEFINE_MUTEX(rtnl_mutex);
118647
118648@@ -307,10 +307,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
118649 * to use the ops for creating device. So do not
118650 * fill up dellink as well. That disables rtnl_dellink.
118651 */
118652- if (ops->setup && !ops->dellink)
118653- ops->dellink = unregister_netdevice_queue;
118654+ if (ops->setup && !ops->dellink) {
118655+ pax_open_kernel();
118656+ *(void **)&ops->dellink = unregister_netdevice_queue;
118657+ pax_close_kernel();
118658+ }
118659
118660- list_add_tail(&ops->list, &link_ops);
118661+ pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
118662 return 0;
118663 }
118664 EXPORT_SYMBOL_GPL(__rtnl_link_register);
118665@@ -357,7 +360,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
118666 for_each_net(net) {
118667 __rtnl_kill_links(net, ops);
118668 }
118669- list_del(&ops->list);
118670+ pax_list_del((struct list_head *)&ops->list);
118671 }
118672 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
118673
118674@@ -1082,7 +1085,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
118675 (dev->ifalias &&
118676 nla_put_string(skb, IFLA_IFALIAS, dev->ifalias)) ||
118677 nla_put_u32(skb, IFLA_CARRIER_CHANGES,
118678- atomic_read(&dev->carrier_changes)))
118679+ atomic_read_unchecked(&dev->carrier_changes)))
118680 goto nla_put_failure;
118681
118682 if (1) {
118683diff --git a/net/core/scm.c b/net/core/scm.c
118684index 3b6899b..20d20e7 100644
118685--- a/net/core/scm.c
118686+++ b/net/core/scm.c
118687@@ -209,9 +209,9 @@ EXPORT_SYMBOL(__scm_send);
118688 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
118689 {
118690 struct cmsghdr __user *cm
118691- = (__force struct cmsghdr __user *)msg->msg_control;
118692+ = (struct cmsghdr __force_user *)msg->msg_control;
118693 struct cmsghdr cmhdr;
118694- int cmlen = CMSG_LEN(len);
118695+ size_t cmlen = CMSG_LEN(len);
118696 int err;
118697
118698 if (MSG_CMSG_COMPAT & msg->msg_flags)
118699@@ -232,7 +232,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
118700 err = -EFAULT;
118701 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
118702 goto out;
118703- if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
118704+ if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
118705 goto out;
118706 cmlen = CMSG_SPACE(len);
118707 if (msg->msg_controllen < cmlen)
118708@@ -248,7 +248,7 @@ EXPORT_SYMBOL(put_cmsg);
118709 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
118710 {
118711 struct cmsghdr __user *cm
118712- = (__force struct cmsghdr __user*)msg->msg_control;
118713+ = (struct cmsghdr __force_user *)msg->msg_control;
118714
118715 int fdmax = 0;
118716 int fdnum = scm->fp->count;
118717@@ -268,7 +268,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
118718 if (fdnum < fdmax)
118719 fdmax = fdnum;
118720
118721- for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
118722+ for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
118723 i++, cmfptr++)
118724 {
118725 struct socket *sock;
118726@@ -297,7 +297,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
118727
118728 if (i > 0)
118729 {
118730- int cmlen = CMSG_LEN(i*sizeof(int));
118731+ size_t cmlen = CMSG_LEN(i*sizeof(int));
118732 err = put_user(SOL_SOCKET, &cm->cmsg_level);
118733 if (!err)
118734 err = put_user(SCM_RIGHTS, &cm->cmsg_type);
118735@@ -305,6 +305,8 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
118736 err = put_user(cmlen, &cm->cmsg_len);
118737 if (!err) {
118738 cmlen = CMSG_SPACE(i*sizeof(int));
118739+ if (msg->msg_controllen < cmlen)
118740+ cmlen = msg->msg_controllen;
118741 msg->msg_control += cmlen;
118742 msg->msg_controllen -= cmlen;
118743 }
118744diff --git a/net/core/skbuff.c b/net/core/skbuff.c
118745index 7b84330..e0f5a86 100644
118746--- a/net/core/skbuff.c
118747+++ b/net/core/skbuff.c
118748@@ -2103,7 +2103,7 @@ EXPORT_SYMBOL(__skb_checksum);
118749 __wsum skb_checksum(const struct sk_buff *skb, int offset,
118750 int len, __wsum csum)
118751 {
118752- const struct skb_checksum_ops ops = {
118753+ static const struct skb_checksum_ops ops = {
118754 .update = csum_partial_ext,
118755 .combine = csum_block_add_ext,
118756 };
118757@@ -3317,12 +3317,14 @@ void __init skb_init(void)
118758 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
118759 sizeof(struct sk_buff),
118760 0,
118761- SLAB_HWCACHE_ALIGN|SLAB_PANIC,
118762+ SLAB_HWCACHE_ALIGN|SLAB_PANIC|
118763+ SLAB_NO_SANITIZE,
118764 NULL);
118765 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
118766 sizeof(struct sk_buff_fclones),
118767 0,
118768- SLAB_HWCACHE_ALIGN|SLAB_PANIC,
118769+ SLAB_HWCACHE_ALIGN|SLAB_PANIC|
118770+ SLAB_NO_SANITIZE,
118771 NULL);
118772 }
118773
118774diff --git a/net/core/sock.c b/net/core/sock.c
118775index 193901d..33094ab 100644
118776--- a/net/core/sock.c
118777+++ b/net/core/sock.c
118778@@ -441,7 +441,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
118779 struct sk_buff_head *list = &sk->sk_receive_queue;
118780
118781 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
118782- atomic_inc(&sk->sk_drops);
118783+ atomic_inc_unchecked(&sk->sk_drops);
118784 trace_sock_rcvqueue_full(sk, skb);
118785 return -ENOMEM;
118786 }
118787@@ -451,7 +451,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
118788 return err;
118789
118790 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
118791- atomic_inc(&sk->sk_drops);
118792+ atomic_inc_unchecked(&sk->sk_drops);
118793 return -ENOBUFS;
118794 }
118795
118796@@ -484,7 +484,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
118797 skb->dev = NULL;
118798
118799 if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) {
118800- atomic_inc(&sk->sk_drops);
118801+ atomic_inc_unchecked(&sk->sk_drops);
118802 goto discard_and_relse;
118803 }
118804 if (nested)
118805@@ -502,7 +502,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
118806 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
118807 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
118808 bh_unlock_sock(sk);
118809- atomic_inc(&sk->sk_drops);
118810+ atomic_inc_unchecked(&sk->sk_drops);
118811 goto discard_and_relse;
118812 }
118813
118814@@ -908,6 +908,7 @@ set_rcvbuf:
118815 }
118816 break;
118817
118818+#ifndef GRKERNSEC_BPF_HARDEN
118819 case SO_ATTACH_BPF:
118820 ret = -EINVAL;
118821 if (optlen == sizeof(u32)) {
118822@@ -920,7 +921,7 @@ set_rcvbuf:
118823 ret = sk_attach_bpf(ufd, sk);
118824 }
118825 break;
118826-
118827+#endif
118828 case SO_DETACH_FILTER:
118829 ret = sk_detach_filter(sk);
118830 break;
118831@@ -1022,12 +1023,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
118832 struct timeval tm;
118833 } v;
118834
118835- int lv = sizeof(int);
118836- int len;
118837+ unsigned int lv = sizeof(int);
118838+ unsigned int len;
118839
118840 if (get_user(len, optlen))
118841 return -EFAULT;
118842- if (len < 0)
118843+ if (len > INT_MAX)
118844 return -EINVAL;
118845
118846 memset(&v, 0, sizeof(v));
118847@@ -1165,11 +1166,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
118848
118849 case SO_PEERNAME:
118850 {
118851- char address[128];
118852+ char address[_K_SS_MAXSIZE];
118853
118854 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
118855 return -ENOTCONN;
118856- if (lv < len)
118857+ if (lv < len || sizeof address < len)
118858 return -EINVAL;
118859 if (copy_to_user(optval, address, len))
118860 return -EFAULT;
118861@@ -1257,7 +1258,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
118862
118863 if (len > lv)
118864 len = lv;
118865- if (copy_to_user(optval, &v, len))
118866+ if (len > sizeof(v) || copy_to_user(optval, &v, len))
118867 return -EFAULT;
118868 lenout:
118869 if (put_user(len, optlen))
118870@@ -1550,7 +1551,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
118871 newsk->sk_err = 0;
118872 newsk->sk_priority = 0;
118873 newsk->sk_incoming_cpu = raw_smp_processor_id();
118874- atomic64_set(&newsk->sk_cookie, 0);
118875+ atomic64_set_unchecked(&newsk->sk_cookie, 0);
118876 /*
118877 * Before updating sk_refcnt, we must commit prior changes to memory
118878 * (Documentation/RCU/rculist_nulls.txt for details)
118879@@ -2359,7 +2360,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
118880 */
118881 smp_wmb();
118882 atomic_set(&sk->sk_refcnt, 1);
118883- atomic_set(&sk->sk_drops, 0);
118884+ atomic_set_unchecked(&sk->sk_drops, 0);
118885 }
118886 EXPORT_SYMBOL(sock_init_data);
118887
118888@@ -2487,6 +2488,7 @@ void sock_enable_timestamp(struct sock *sk, int flag)
118889 int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
118890 int level, int type)
118891 {
118892+ struct sock_extended_err ee;
118893 struct sock_exterr_skb *serr;
118894 struct sk_buff *skb;
118895 int copied, err;
118896@@ -2508,7 +2510,8 @@ int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
118897 sock_recv_timestamp(msg, sk, skb);
118898
118899 serr = SKB_EXT_ERR(skb);
118900- put_cmsg(msg, level, type, sizeof(serr->ee), &serr->ee);
118901+ ee = serr->ee;
118902+ put_cmsg(msg, level, type, sizeof ee, &ee);
118903
118904 msg->msg_flags |= MSG_ERRQUEUE;
118905 err = copied;
118906diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
118907index 817622f..2577b26 100644
118908--- a/net/core/sock_diag.c
118909+++ b/net/core/sock_diag.c
118910@@ -12,7 +12,7 @@
118911 #include <linux/inet_diag.h>
118912 #include <linux/sock_diag.h>
118913
118914-static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
118915+static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
118916 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
118917 static DEFINE_MUTEX(sock_diag_table_mutex);
118918 static struct workqueue_struct *broadcast_wq;
118919@@ -20,12 +20,12 @@ static struct workqueue_struct *broadcast_wq;
118920 static u64 sock_gen_cookie(struct sock *sk)
118921 {
118922 while (1) {
118923- u64 res = atomic64_read(&sk->sk_cookie);
118924+ u64 res = atomic64_read_unchecked(&sk->sk_cookie);
118925
118926 if (res)
118927 return res;
118928- res = atomic64_inc_return(&sock_net(sk)->cookie_gen);
118929- atomic64_cmpxchg(&sk->sk_cookie, 0, res);
118930+ res = atomic64_inc_return_unchecked(&sock_net(sk)->cookie_gen);
118931+ atomic64_cmpxchg_unchecked(&sk->sk_cookie, 0, res);
118932 }
118933 }
118934
118935@@ -190,8 +190,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
118936 mutex_lock(&sock_diag_table_mutex);
118937 if (sock_diag_handlers[hndl->family])
118938 err = -EBUSY;
118939- else
118940+ else {
118941+ pax_open_kernel();
118942 sock_diag_handlers[hndl->family] = hndl;
118943+ pax_close_kernel();
118944+ }
118945 mutex_unlock(&sock_diag_table_mutex);
118946
118947 return err;
118948@@ -207,7 +210,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
118949
118950 mutex_lock(&sock_diag_table_mutex);
118951 BUG_ON(sock_diag_handlers[family] != hnld);
118952+ pax_open_kernel();
118953 sock_diag_handlers[family] = NULL;
118954+ pax_close_kernel();
118955 mutex_unlock(&sock_diag_table_mutex);
118956 }
118957 EXPORT_SYMBOL_GPL(sock_diag_unregister);
118958diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
118959index 95b6139..3048623 100644
118960--- a/net/core/sysctl_net_core.c
118961+++ b/net/core/sysctl_net_core.c
118962@@ -35,7 +35,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
118963 {
118964 unsigned int orig_size, size;
118965 int ret, i;
118966- struct ctl_table tmp = {
118967+ ctl_table_no_const tmp = {
118968 .data = &size,
118969 .maxlen = sizeof(size),
118970 .mode = table->mode
118971@@ -203,7 +203,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
118972 void __user *buffer, size_t *lenp, loff_t *ppos)
118973 {
118974 char id[IFNAMSIZ];
118975- struct ctl_table tbl = {
118976+ ctl_table_no_const tbl = {
118977 .data = id,
118978 .maxlen = IFNAMSIZ,
118979 };
118980@@ -221,7 +221,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
118981 static int proc_do_rss_key(struct ctl_table *table, int write,
118982 void __user *buffer, size_t *lenp, loff_t *ppos)
118983 {
118984- struct ctl_table fake_table;
118985+ ctl_table_no_const fake_table;
118986 char buf[NETDEV_RSS_KEY_LEN * 3];
118987
118988 snprintf(buf, sizeof(buf), "%*phC", NETDEV_RSS_KEY_LEN, netdev_rss_key);
118989@@ -285,7 +285,7 @@ static struct ctl_table net_core_table[] = {
118990 .mode = 0444,
118991 .proc_handler = proc_do_rss_key,
118992 },
118993-#ifdef CONFIG_BPF_JIT
118994+#if defined(CONFIG_BPF_JIT) && !defined(CONFIG_GRKERNSEC_BPF_HARDEN)
118995 {
118996 .procname = "bpf_jit_enable",
118997 .data = &bpf_jit_enable,
118998@@ -409,13 +409,12 @@ static struct ctl_table netns_core_table[] = {
118999
119000 static __net_init int sysctl_core_net_init(struct net *net)
119001 {
119002- struct ctl_table *tbl;
119003+ ctl_table_no_const *tbl = NULL;
119004
119005 net->core.sysctl_somaxconn = SOMAXCONN;
119006
119007- tbl = netns_core_table;
119008 if (!net_eq(net, &init_net)) {
119009- tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
119010+ tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
119011 if (tbl == NULL)
119012 goto err_dup;
119013
119014@@ -425,17 +424,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
119015 if (net->user_ns != &init_user_ns) {
119016 tbl[0].procname = NULL;
119017 }
119018- }
119019-
119020- net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
119021+ net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
119022+ } else
119023+ net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
119024 if (net->core.sysctl_hdr == NULL)
119025 goto err_reg;
119026
119027 return 0;
119028
119029 err_reg:
119030- if (tbl != netns_core_table)
119031- kfree(tbl);
119032+ kfree(tbl);
119033 err_dup:
119034 return -ENOMEM;
119035 }
119036@@ -450,7 +448,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
119037 kfree(tbl);
119038 }
119039
119040-static __net_initdata struct pernet_operations sysctl_core_ops = {
119041+static __net_initconst struct pernet_operations sysctl_core_ops = {
119042 .init = sysctl_core_net_init,
119043 .exit = sysctl_core_net_exit,
119044 };
119045diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
119046index 675cf94..9279a75 100644
119047--- a/net/decnet/af_decnet.c
119048+++ b/net/decnet/af_decnet.c
119049@@ -466,6 +466,7 @@ static struct proto dn_proto = {
119050 .sysctl_rmem = sysctl_decnet_rmem,
119051 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
119052 .obj_size = sizeof(struct dn_sock),
119053+ .slab_flags = SLAB_USERCOPY,
119054 };
119055
119056 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp, int kern)
119057diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
119058index b2c26b0..41f803e 100644
119059--- a/net/decnet/dn_dev.c
119060+++ b/net/decnet/dn_dev.c
119061@@ -201,7 +201,7 @@ static struct dn_dev_sysctl_table {
119062 .extra1 = &min_t3,
119063 .extra2 = &max_t3
119064 },
119065- {0}
119066+ { }
119067 },
119068 };
119069
119070diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
119071index 5325b54..a0d4d69 100644
119072--- a/net/decnet/sysctl_net_decnet.c
119073+++ b/net/decnet/sysctl_net_decnet.c
119074@@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
119075
119076 if (len > *lenp) len = *lenp;
119077
119078- if (copy_to_user(buffer, addr, len))
119079+ if (len > sizeof addr || copy_to_user(buffer, addr, len))
119080 return -EFAULT;
119081
119082 *lenp = len;
119083@@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
119084
119085 if (len > *lenp) len = *lenp;
119086
119087- if (copy_to_user(buffer, devname, len))
119088+ if (len > sizeof devname || copy_to_user(buffer, devname, len))
119089 return -EFAULT;
119090
119091 *lenp = len;
119092diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
119093index b445d49..13e8538 100644
119094--- a/net/dsa/dsa.c
119095+++ b/net/dsa/dsa.c
119096@@ -851,7 +851,7 @@ static struct packet_type dsa_pack_type __read_mostly = {
119097 .func = dsa_switch_rcv,
119098 };
119099
119100-static struct notifier_block dsa_netdevice_nb __read_mostly = {
119101+static struct notifier_block dsa_netdevice_nb = {
119102 .notifier_call = dsa_slave_netdevice_event,
119103 };
119104
119105diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c
119106index a2c7e4c..3dc9f67 100644
119107--- a/net/hsr/hsr_netlink.c
119108+++ b/net/hsr/hsr_netlink.c
119109@@ -102,7 +102,7 @@ nla_put_failure:
119110 return -EMSGSIZE;
119111 }
119112
119113-static struct rtnl_link_ops hsr_link_ops __read_mostly = {
119114+static struct rtnl_link_ops hsr_link_ops = {
119115 .kind = "hsr",
119116 .maxtype = IFLA_HSR_MAX,
119117 .policy = hsr_policy,
119118diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
119119index f20a387..2058892 100644
119120--- a/net/ieee802154/6lowpan/core.c
119121+++ b/net/ieee802154/6lowpan/core.c
119122@@ -191,7 +191,7 @@ static void lowpan_dellink(struct net_device *dev, struct list_head *head)
119123 dev_put(real_dev);
119124 }
119125
119126-static struct rtnl_link_ops lowpan_link_ops __read_mostly = {
119127+static struct rtnl_link_ops lowpan_link_ops = {
119128 .kind = "lowpan",
119129 .priv_size = sizeof(struct lowpan_dev_info),
119130 .setup = lowpan_setup,
119131diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
119132index 214d44a..dcb7f86 100644
119133--- a/net/ieee802154/6lowpan/reassembly.c
119134+++ b/net/ieee802154/6lowpan/reassembly.c
119135@@ -435,14 +435,13 @@ static struct ctl_table lowpan_frags_ctl_table[] = {
119136
119137 static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
119138 {
119139- struct ctl_table *table;
119140+ ctl_table_no_const *table = NULL;
119141 struct ctl_table_header *hdr;
119142 struct netns_ieee802154_lowpan *ieee802154_lowpan =
119143 net_ieee802154_lowpan(net);
119144
119145- table = lowpan_frags_ns_ctl_table;
119146 if (!net_eq(net, &init_net)) {
119147- table = kmemdup(table, sizeof(lowpan_frags_ns_ctl_table),
119148+ table = kmemdup(lowpan_frags_ns_ctl_table, sizeof(lowpan_frags_ns_ctl_table),
119149 GFP_KERNEL);
119150 if (table == NULL)
119151 goto err_alloc;
119152@@ -457,9 +456,9 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
119153 /* Don't export sysctls to unprivileged users */
119154 if (net->user_ns != &init_user_ns)
119155 table[0].procname = NULL;
119156- }
119157-
119158- hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
119159+ hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
119160+ } else
119161+ hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", lowpan_frags_ns_ctl_table);
119162 if (hdr == NULL)
119163 goto err_reg;
119164
119165@@ -467,8 +466,7 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
119166 return 0;
119167
119168 err_reg:
119169- if (!net_eq(net, &init_net))
119170- kfree(table);
119171+ kfree(table);
119172 err_alloc:
119173 return -ENOMEM;
119174 }
119175diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
119176index 9532ee8..020410a 100644
119177--- a/net/ipv4/af_inet.c
119178+++ b/net/ipv4/af_inet.c
119179@@ -1392,7 +1392,7 @@ int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)
119180 return ip_recv_error(sk, msg, len, addr_len);
119181 #if IS_ENABLED(CONFIG_IPV6)
119182 if (sk->sk_family == AF_INET6)
119183- return pingv6_ops.ipv6_recv_error(sk, msg, len, addr_len);
119184+ return pingv6_ops->ipv6_recv_error(sk, msg, len, addr_len);
119185 #endif
119186 return -EINVAL;
119187 }
119188diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
119189index 2d9cb17..20ae904 100644
119190--- a/net/ipv4/devinet.c
119191+++ b/net/ipv4/devinet.c
119192@@ -69,7 +69,8 @@
119193
119194 static struct ipv4_devconf ipv4_devconf = {
119195 .data = {
119196- [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 1,
119197+ [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 0,
119198+ [IPV4_DEVCONF_RP_FILTER - 1] = 1,
119199 [IPV4_DEVCONF_SEND_REDIRECTS - 1] = 1,
119200 [IPV4_DEVCONF_SECURE_REDIRECTS - 1] = 1,
119201 [IPV4_DEVCONF_SHARED_MEDIA - 1] = 1,
119202@@ -80,7 +81,8 @@ static struct ipv4_devconf ipv4_devconf = {
119203
119204 static struct ipv4_devconf ipv4_devconf_dflt = {
119205 .data = {
119206- [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 1,
119207+ [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 0,
119208+ [IPV4_DEVCONF_RP_FILTER - 1] = 1,
119209 [IPV4_DEVCONF_SEND_REDIRECTS - 1] = 1,
119210 [IPV4_DEVCONF_SECURE_REDIRECTS - 1] = 1,
119211 [IPV4_DEVCONF_SHARED_MEDIA - 1] = 1,
119212@@ -1579,7 +1581,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
119213 idx = 0;
119214 head = &net->dev_index_head[h];
119215 rcu_read_lock();
119216- cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
119217+ cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
119218 net->dev_base_seq;
119219 hlist_for_each_entry_rcu(dev, head, index_hlist) {
119220 if (idx < s_idx)
119221@@ -1905,7 +1907,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
119222 idx = 0;
119223 head = &net->dev_index_head[h];
119224 rcu_read_lock();
119225- cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
119226+ cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
119227 net->dev_base_seq;
119228 hlist_for_each_entry_rcu(dev, head, index_hlist) {
119229 if (idx < s_idx)
119230@@ -2146,7 +2148,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
119231 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
119232 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
119233
119234-static struct devinet_sysctl_table {
119235+static const struct devinet_sysctl_table {
119236 struct ctl_table_header *sysctl_header;
119237 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
119238 } devinet_sysctl = {
119239@@ -2280,7 +2282,7 @@ static __net_init int devinet_init_net(struct net *net)
119240 int err;
119241 struct ipv4_devconf *all, *dflt;
119242 #ifdef CONFIG_SYSCTL
119243- struct ctl_table *tbl = ctl_forward_entry;
119244+ ctl_table_no_const *tbl = NULL;
119245 struct ctl_table_header *forw_hdr;
119246 #endif
119247
119248@@ -2298,7 +2300,7 @@ static __net_init int devinet_init_net(struct net *net)
119249 goto err_alloc_dflt;
119250
119251 #ifdef CONFIG_SYSCTL
119252- tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
119253+ tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
119254 if (!tbl)
119255 goto err_alloc_ctl;
119256
119257@@ -2318,7 +2320,10 @@ static __net_init int devinet_init_net(struct net *net)
119258 goto err_reg_dflt;
119259
119260 err = -ENOMEM;
119261- forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
119262+ if (!net_eq(net, &init_net))
119263+ forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
119264+ else
119265+ forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
119266 if (!forw_hdr)
119267 goto err_reg_ctl;
119268 net->ipv4.forw_hdr = forw_hdr;
119269@@ -2334,8 +2339,7 @@ err_reg_ctl:
119270 err_reg_dflt:
119271 __devinet_sysctl_unregister(all);
119272 err_reg_all:
119273- if (tbl != ctl_forward_entry)
119274- kfree(tbl);
119275+ kfree(tbl);
119276 err_alloc_ctl:
119277 #endif
119278 if (dflt != &ipv4_devconf_dflt)
119279diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
119280index 6bbc549..28d74951 100644
119281--- a/net/ipv4/fib_frontend.c
119282+++ b/net/ipv4/fib_frontend.c
119283@@ -1083,12 +1083,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
119284 #ifdef CONFIG_IP_ROUTE_MULTIPATH
119285 fib_sync_up(dev, RTNH_F_DEAD);
119286 #endif
119287- atomic_inc(&net->ipv4.dev_addr_genid);
119288+ atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
119289 rt_cache_flush(dev_net(dev));
119290 break;
119291 case NETDEV_DOWN:
119292 fib_del_ifaddr(ifa, NULL);
119293- atomic_inc(&net->ipv4.dev_addr_genid);
119294+ atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
119295 if (!ifa->ifa_dev->ifa_list) {
119296 /* Last address was deleted from this interface.
119297 * Disable IP.
119298@@ -1127,7 +1127,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
119299 #ifdef CONFIG_IP_ROUTE_MULTIPATH
119300 fib_sync_up(dev, RTNH_F_DEAD);
119301 #endif
119302- atomic_inc(&net->ipv4.dev_addr_genid);
119303+ atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
119304 rt_cache_flush(net);
119305 break;
119306 case NETDEV_DOWN:
119307diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
119308index 3a06586..1020c5b 100644
119309--- a/net/ipv4/fib_semantics.c
119310+++ b/net/ipv4/fib_semantics.c
119311@@ -755,7 +755,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
119312 nh->nh_saddr = inet_select_addr(nh->nh_dev,
119313 nh->nh_gw,
119314 nh->nh_parent->fib_scope);
119315- nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
119316+ nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
119317
119318 return nh->nh_saddr;
119319 }
119320diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
119321index 1349571..e136d6e 100644
119322--- a/net/ipv4/inet_connection_sock.c
119323+++ b/net/ipv4/inet_connection_sock.c
119324@@ -728,8 +728,8 @@ struct sock *inet_csk_clone_lock(const struct sock *sk,
119325 newsk->sk_write_space = sk_stream_write_space;
119326
119327 newsk->sk_mark = inet_rsk(req)->ir_mark;
119328- atomic64_set(&newsk->sk_cookie,
119329- atomic64_read(&inet_rsk(req)->ir_cookie));
119330+ atomic64_set_unchecked(&newsk->sk_cookie,
119331+ atomic64_read_unchecked(&inet_rsk(req)->ir_cookie));
119332
119333 newicsk->icsk_retransmits = 0;
119334 newicsk->icsk_backoff = 0;
119335diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
119336index 0cb9165..8589720 100644
119337--- a/net/ipv4/inet_hashtables.c
119338+++ b/net/ipv4/inet_hashtables.c
119339@@ -19,6 +19,7 @@
119340 #include <linux/slab.h>
119341 #include <linux/wait.h>
119342 #include <linux/vmalloc.h>
119343+#include <linux/security.h>
119344
119345 #include <net/inet_connection_sock.h>
119346 #include <net/inet_hashtables.h>
119347@@ -54,6 +55,8 @@ u32 sk_ehashfn(const struct sock *sk)
119348 sk->sk_daddr, sk->sk_dport);
119349 }
119350
119351+extern void gr_update_task_in_ip_table(const struct inet_sock *inet);
119352+
119353 /*
119354 * Allocate and initialize a new local port bind bucket.
119355 * The bindhash mutex for snum's hash chain must be held here.
119356@@ -566,6 +569,8 @@ ok:
119357 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
119358 spin_unlock(&head->lock);
119359
119360+ gr_update_task_in_ip_table(inet_sk(sk));
119361+
119362 if (tw) {
119363 inet_twsk_deschedule(tw);
119364 while (twrefcnt) {
119365diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
119366index 2ffbd16..6e94995 100644
119367--- a/net/ipv4/inet_timewait_sock.c
119368+++ b/net/ipv4/inet_timewait_sock.c
119369@@ -214,7 +214,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk,
119370 tw->tw_ipv6only = 0;
119371 tw->tw_transparent = inet->transparent;
119372 tw->tw_prot = sk->sk_prot_creator;
119373- atomic64_set(&tw->tw_cookie, atomic64_read(&sk->sk_cookie));
119374+ atomic64_set_unchecked(&tw->tw_cookie, atomic64_read_unchecked(&sk->sk_cookie));
119375 twsk_net_set(tw, sock_net(sk));
119376 setup_timer(&tw->tw_timer, tw_timer_handler, (unsigned long)tw);
119377 /*
119378diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
119379index 241afd7..31b95d5 100644
119380--- a/net/ipv4/inetpeer.c
119381+++ b/net/ipv4/inetpeer.c
119382@@ -461,7 +461,7 @@ relookup:
119383 if (p) {
119384 p->daddr = *daddr;
119385 atomic_set(&p->refcnt, 1);
119386- atomic_set(&p->rid, 0);
119387+ atomic_set_unchecked(&p->rid, 0);
119388 p->metrics[RTAX_LOCK-1] = INETPEER_METRICS_NEW;
119389 p->rate_tokens = 0;
119390 /* 60*HZ is arbitrary, but chosen enough high so that the first
119391diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
119392index 921138f..1e011ff 100644
119393--- a/net/ipv4/ip_fragment.c
119394+++ b/net/ipv4/ip_fragment.c
119395@@ -276,7 +276,7 @@ static int ip_frag_too_far(struct ipq *qp)
119396 return 0;
119397
119398 start = qp->rid;
119399- end = atomic_inc_return(&peer->rid);
119400+ end = atomic_inc_return_unchecked(&peer->rid);
119401 qp->rid = end;
119402
119403 rc = qp->q.fragments && (end - start) > max;
119404@@ -780,12 +780,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
119405
119406 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
119407 {
119408- struct ctl_table *table;
119409+ ctl_table_no_const *table = NULL;
119410 struct ctl_table_header *hdr;
119411
119412- table = ip4_frags_ns_ctl_table;
119413 if (!net_eq(net, &init_net)) {
119414- table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
119415+ table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
119416 if (!table)
119417 goto err_alloc;
119418
119419@@ -799,9 +798,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
119420 /* Don't export sysctls to unprivileged users */
119421 if (net->user_ns != &init_user_ns)
119422 table[0].procname = NULL;
119423- }
119424+ hdr = register_net_sysctl(net, "net/ipv4", table);
119425+ } else
119426+ hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
119427
119428- hdr = register_net_sysctl(net, "net/ipv4", table);
119429 if (!hdr)
119430 goto err_reg;
119431
119432@@ -809,8 +809,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
119433 return 0;
119434
119435 err_reg:
119436- if (!net_eq(net, &init_net))
119437- kfree(table);
119438+ kfree(table);
119439 err_alloc:
119440 return -ENOMEM;
119441 }
119442diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
119443index 5fd7064..d13d75f 100644
119444--- a/net/ipv4/ip_gre.c
119445+++ b/net/ipv4/ip_gre.c
119446@@ -115,7 +115,7 @@ static bool log_ecn_error = true;
119447 module_param(log_ecn_error, bool, 0644);
119448 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
119449
119450-static struct rtnl_link_ops ipgre_link_ops __read_mostly;
119451+static struct rtnl_link_ops ipgre_link_ops;
119452 static int ipgre_tunnel_init(struct net_device *dev);
119453
119454 static int ipgre_net_id __read_mostly;
119455@@ -819,7 +819,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
119456 [IFLA_GRE_ENCAP_DPORT] = { .type = NLA_U16 },
119457 };
119458
119459-static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
119460+static struct rtnl_link_ops ipgre_link_ops = {
119461 .kind = "gre",
119462 .maxtype = IFLA_GRE_MAX,
119463 .policy = ipgre_policy,
119464@@ -834,7 +834,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
119465 .get_link_net = ip_tunnel_get_link_net,
119466 };
119467
119468-static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
119469+static struct rtnl_link_ops ipgre_tap_ops = {
119470 .kind = "gretap",
119471 .maxtype = IFLA_GRE_MAX,
119472 .policy = ipgre_policy,
119473diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
119474index 2db4c87..4db9282 100644
119475--- a/net/ipv4/ip_input.c
119476+++ b/net/ipv4/ip_input.c
119477@@ -147,6 +147,10 @@
119478 #include <linux/mroute.h>
119479 #include <linux/netlink.h>
119480
119481+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119482+extern int grsec_enable_blackhole;
119483+#endif
119484+
119485 /*
119486 * Process Router Attention IP option (RFC 2113)
119487 */
119488@@ -223,6 +227,9 @@ static int ip_local_deliver_finish(struct sock *sk, struct sk_buff *skb)
119489 if (!raw) {
119490 if (xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
119491 IP_INC_STATS_BH(net, IPSTATS_MIB_INUNKNOWNPROTOS);
119492+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119493+ if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
119494+#endif
119495 icmp_send(skb, ICMP_DEST_UNREACH,
119496 ICMP_PROT_UNREACH, 0);
119497 }
119498diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
119499index c3c359a..504edc6 100644
119500--- a/net/ipv4/ip_sockglue.c
119501+++ b/net/ipv4/ip_sockglue.c
119502@@ -1295,7 +1295,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
119503 len = min_t(unsigned int, len, opt->optlen);
119504 if (put_user(len, optlen))
119505 return -EFAULT;
119506- if (copy_to_user(optval, opt->__data, len))
119507+ if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
119508+ copy_to_user(optval, opt->__data, len))
119509 return -EFAULT;
119510 return 0;
119511 }
119512@@ -1432,7 +1433,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
119513 if (sk->sk_type != SOCK_STREAM)
119514 return -ENOPROTOOPT;
119515
119516- msg.msg_control = (__force void *) optval;
119517+ msg.msg_control = (__force_kernel void *) optval;
119518 msg.msg_controllen = len;
119519 msg.msg_flags = flags;
119520
119521diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
119522index 0c15208..a3a76c5 100644
119523--- a/net/ipv4/ip_vti.c
119524+++ b/net/ipv4/ip_vti.c
119525@@ -45,7 +45,7 @@
119526 #include <net/net_namespace.h>
119527 #include <net/netns/generic.h>
119528
119529-static struct rtnl_link_ops vti_link_ops __read_mostly;
119530+static struct rtnl_link_ops vti_link_ops;
119531
119532 static int vti_net_id __read_mostly;
119533 static int vti_tunnel_init(struct net_device *dev);
119534@@ -525,7 +525,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
119535 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
119536 };
119537
119538-static struct rtnl_link_ops vti_link_ops __read_mostly = {
119539+static struct rtnl_link_ops vti_link_ops = {
119540 .kind = "vti",
119541 .maxtype = IFLA_VTI_MAX,
119542 .policy = vti_policy,
119543diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
119544index 8e7328c..9bd7ed3 100644
119545--- a/net/ipv4/ipconfig.c
119546+++ b/net/ipv4/ipconfig.c
119547@@ -333,7 +333,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
119548
119549 mm_segment_t oldfs = get_fs();
119550 set_fs(get_ds());
119551- res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
119552+ res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
119553 set_fs(oldfs);
119554 return res;
119555 }
119556@@ -344,7 +344,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
119557
119558 mm_segment_t oldfs = get_fs();
119559 set_fs(get_ds());
119560- res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
119561+ res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
119562 set_fs(oldfs);
119563 return res;
119564 }
119565@@ -355,7 +355,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
119566
119567 mm_segment_t oldfs = get_fs();
119568 set_fs(get_ds());
119569- res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
119570+ res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
119571 set_fs(oldfs);
119572 return res;
119573 }
119574diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
119575index 254238d..82c19a2 100644
119576--- a/net/ipv4/ipip.c
119577+++ b/net/ipv4/ipip.c
119578@@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
119579 static int ipip_net_id __read_mostly;
119580
119581 static int ipip_tunnel_init(struct net_device *dev);
119582-static struct rtnl_link_ops ipip_link_ops __read_mostly;
119583+static struct rtnl_link_ops ipip_link_ops;
119584
119585 static int ipip_err(struct sk_buff *skb, u32 info)
119586 {
119587@@ -488,7 +488,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
119588 [IFLA_IPTUN_ENCAP_DPORT] = { .type = NLA_U16 },
119589 };
119590
119591-static struct rtnl_link_ops ipip_link_ops __read_mostly = {
119592+static struct rtnl_link_ops ipip_link_ops = {
119593 .kind = "ipip",
119594 .maxtype = IFLA_IPTUN_MAX,
119595 .policy = ipip_policy,
119596diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
119597index 92305a1..0a5b349 100644
119598--- a/net/ipv4/netfilter/arp_tables.c
119599+++ b/net/ipv4/netfilter/arp_tables.c
119600@@ -896,14 +896,14 @@ static int compat_table_info(const struct xt_table_info *info,
119601 #endif
119602
119603 static int get_info(struct net *net, void __user *user,
119604- const int *len, int compat)
119605+ int len, int compat)
119606 {
119607 char name[XT_TABLE_MAXNAMELEN];
119608 struct xt_table *t;
119609 int ret;
119610
119611- if (*len != sizeof(struct arpt_getinfo)) {
119612- duprintf("length %u != %Zu\n", *len,
119613+ if (len != sizeof(struct arpt_getinfo)) {
119614+ duprintf("length %u != %Zu\n", len,
119615 sizeof(struct arpt_getinfo));
119616 return -EINVAL;
119617 }
119618@@ -940,7 +940,7 @@ static int get_info(struct net *net, void __user *user,
119619 info.size = private->size;
119620 strcpy(info.name, name);
119621
119622- if (copy_to_user(user, &info, *len) != 0)
119623+ if (copy_to_user(user, &info, len) != 0)
119624 ret = -EFAULT;
119625 else
119626 ret = 0;
119627@@ -1705,7 +1705,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
119628
119629 switch (cmd) {
119630 case ARPT_SO_GET_INFO:
119631- ret = get_info(sock_net(sk), user, len, 1);
119632+ ret = get_info(sock_net(sk), user, *len, 1);
119633 break;
119634 case ARPT_SO_GET_ENTRIES:
119635 ret = compat_get_entries(sock_net(sk), user, len);
119636@@ -1750,7 +1750,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
119637
119638 switch (cmd) {
119639 case ARPT_SO_GET_INFO:
119640- ret = get_info(sock_net(sk), user, len, 0);
119641+ ret = get_info(sock_net(sk), user, *len, 0);
119642 break;
119643
119644 case ARPT_SO_GET_ENTRIES:
119645diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
119646index 6c72fbb..ce47b05 100644
119647--- a/net/ipv4/netfilter/ip_tables.c
119648+++ b/net/ipv4/netfilter/ip_tables.c
119649@@ -1073,14 +1073,14 @@ static int compat_table_info(const struct xt_table_info *info,
119650 #endif
119651
119652 static int get_info(struct net *net, void __user *user,
119653- const int *len, int compat)
119654+ int len, int compat)
119655 {
119656 char name[XT_TABLE_MAXNAMELEN];
119657 struct xt_table *t;
119658 int ret;
119659
119660- if (*len != sizeof(struct ipt_getinfo)) {
119661- duprintf("length %u != %zu\n", *len,
119662+ if (len != sizeof(struct ipt_getinfo)) {
119663+ duprintf("length %u != %zu\n", len,
119664 sizeof(struct ipt_getinfo));
119665 return -EINVAL;
119666 }
119667@@ -1117,7 +1117,7 @@ static int get_info(struct net *net, void __user *user,
119668 info.size = private->size;
119669 strcpy(info.name, name);
119670
119671- if (copy_to_user(user, &info, *len) != 0)
119672+ if (copy_to_user(user, &info, len) != 0)
119673 ret = -EFAULT;
119674 else
119675 ret = 0;
119676@@ -1968,7 +1968,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
119677
119678 switch (cmd) {
119679 case IPT_SO_GET_INFO:
119680- ret = get_info(sock_net(sk), user, len, 1);
119681+ ret = get_info(sock_net(sk), user, *len, 1);
119682 break;
119683 case IPT_SO_GET_ENTRIES:
119684 ret = compat_get_entries(sock_net(sk), user, len);
119685@@ -2015,7 +2015,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
119686
119687 switch (cmd) {
119688 case IPT_SO_GET_INFO:
119689- ret = get_info(sock_net(sk), user, len, 0);
119690+ ret = get_info(sock_net(sk), user, *len, 0);
119691 break;
119692
119693 case IPT_SO_GET_ENTRIES:
119694diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
119695index 45cb16a..cef4ecd 100644
119696--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
119697+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
119698@@ -730,7 +730,7 @@ static int clusterip_net_init(struct net *net)
119699 spin_lock_init(&cn->lock);
119700
119701 #ifdef CONFIG_PROC_FS
119702- cn->procdir = proc_mkdir("ipt_CLUSTERIP", net->proc_net);
119703+ cn->procdir = proc_mkdir_restrict("ipt_CLUSTERIP", net->proc_net);
119704 if (!cn->procdir) {
119705 pr_err("Unable to proc dir entry\n");
119706 return -ENOMEM;
119707diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
119708index 05ff44b..da00000 100644
119709--- a/net/ipv4/ping.c
119710+++ b/net/ipv4/ping.c
119711@@ -59,7 +59,7 @@ struct ping_table {
119712 };
119713
119714 static struct ping_table ping_table;
119715-struct pingv6_ops pingv6_ops;
119716+struct pingv6_ops *pingv6_ops;
119717 EXPORT_SYMBOL_GPL(pingv6_ops);
119718
119719 static u16 ping_port_rover;
119720@@ -359,7 +359,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
119721 return -ENODEV;
119722 }
119723 }
119724- has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
119725+ has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
119726 scoped);
119727 rcu_read_unlock();
119728
119729@@ -567,7 +567,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
119730 }
119731 #if IS_ENABLED(CONFIG_IPV6)
119732 } else if (skb->protocol == htons(ETH_P_IPV6)) {
119733- harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
119734+ harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
119735 #endif
119736 }
119737
119738@@ -585,7 +585,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
119739 info, (u8 *)icmph);
119740 #if IS_ENABLED(CONFIG_IPV6)
119741 } else if (family == AF_INET6) {
119742- pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
119743+ pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
119744 info, (u8 *)icmph);
119745 #endif
119746 }
119747@@ -918,10 +918,10 @@ int ping_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
119748 }
119749
119750 if (inet6_sk(sk)->rxopt.all)
119751- pingv6_ops.ip6_datagram_recv_common_ctl(sk, msg, skb);
119752+ pingv6_ops->ip6_datagram_recv_common_ctl(sk, msg, skb);
119753 if (skb->protocol == htons(ETH_P_IPV6) &&
119754 inet6_sk(sk)->rxopt.all)
119755- pingv6_ops.ip6_datagram_recv_specific_ctl(sk, msg, skb);
119756+ pingv6_ops->ip6_datagram_recv_specific_ctl(sk, msg, skb);
119757 else if (skb->protocol == htons(ETH_P_IP) && isk->cmsg_flags)
119758 ip_cmsg_recv(msg, skb);
119759 #endif
119760@@ -1116,7 +1116,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
119761 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
119762 0, sock_i_ino(sp),
119763 atomic_read(&sp->sk_refcnt), sp,
119764- atomic_read(&sp->sk_drops));
119765+ atomic_read_unchecked(&sp->sk_drops));
119766 }
119767
119768 static int ping_v4_seq_show(struct seq_file *seq, void *v)
119769diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
119770index 561cd4b..a32a155 100644
119771--- a/net/ipv4/raw.c
119772+++ b/net/ipv4/raw.c
119773@@ -323,7 +323,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
119774 int raw_rcv(struct sock *sk, struct sk_buff *skb)
119775 {
119776 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
119777- atomic_inc(&sk->sk_drops);
119778+ atomic_inc_unchecked(&sk->sk_drops);
119779 kfree_skb(skb);
119780 return NET_RX_DROP;
119781 }
119782@@ -771,16 +771,20 @@ static int raw_init(struct sock *sk)
119783
119784 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
119785 {
119786+ struct icmp_filter filter;
119787+
119788 if (optlen > sizeof(struct icmp_filter))
119789 optlen = sizeof(struct icmp_filter);
119790- if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
119791+ if (copy_from_user(&filter, optval, optlen))
119792 return -EFAULT;
119793+ raw_sk(sk)->filter = filter;
119794 return 0;
119795 }
119796
119797 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
119798 {
119799 int len, ret = -EFAULT;
119800+ struct icmp_filter filter;
119801
119802 if (get_user(len, optlen))
119803 goto out;
119804@@ -790,8 +794,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
119805 if (len > sizeof(struct icmp_filter))
119806 len = sizeof(struct icmp_filter);
119807 ret = -EFAULT;
119808- if (put_user(len, optlen) ||
119809- copy_to_user(optval, &raw_sk(sk)->filter, len))
119810+ filter = raw_sk(sk)->filter;
119811+ if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
119812 goto out;
119813 ret = 0;
119814 out: return ret;
119815@@ -1020,7 +1024,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
119816 0, 0L, 0,
119817 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
119818 0, sock_i_ino(sp),
119819- atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
119820+ atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
119821 }
119822
119823 static int raw_seq_show(struct seq_file *seq, void *v)
119824diff --git a/net/ipv4/route.c b/net/ipv4/route.c
119825index e681b85..8a43a65 100644
119826--- a/net/ipv4/route.c
119827+++ b/net/ipv4/route.c
119828@@ -227,7 +227,7 @@ static const struct seq_operations rt_cache_seq_ops = {
119829
119830 static int rt_cache_seq_open(struct inode *inode, struct file *file)
119831 {
119832- return seq_open(file, &rt_cache_seq_ops);
119833+ return seq_open_restrict(file, &rt_cache_seq_ops);
119834 }
119835
119836 static const struct file_operations rt_cache_seq_fops = {
119837@@ -318,7 +318,7 @@ static const struct seq_operations rt_cpu_seq_ops = {
119838
119839 static int rt_cpu_seq_open(struct inode *inode, struct file *file)
119840 {
119841- return seq_open(file, &rt_cpu_seq_ops);
119842+ return seq_open_restrict(file, &rt_cpu_seq_ops);
119843 }
119844
119845 static const struct file_operations rt_cpu_seq_fops = {
119846@@ -356,7 +356,7 @@ static int rt_acct_proc_show(struct seq_file *m, void *v)
119847
119848 static int rt_acct_proc_open(struct inode *inode, struct file *file)
119849 {
119850- return single_open(file, rt_acct_proc_show, NULL);
119851+ return single_open_restrict(file, rt_acct_proc_show, NULL);
119852 }
119853
119854 static const struct file_operations rt_acct_proc_fops = {
119855@@ -458,7 +458,7 @@ static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst,
119856
119857 #define IP_IDENTS_SZ 2048u
119858
119859-static atomic_t *ip_idents __read_mostly;
119860+static atomic_unchecked_t ip_idents[IP_IDENTS_SZ] __read_mostly;
119861 static u32 *ip_tstamps __read_mostly;
119862
119863 /* In order to protect privacy, we add a perturbation to identifiers
119864@@ -468,7 +468,7 @@ static u32 *ip_tstamps __read_mostly;
119865 u32 ip_idents_reserve(u32 hash, int segs)
119866 {
119867 u32 *p_tstamp = ip_tstamps + hash % IP_IDENTS_SZ;
119868- atomic_t *p_id = ip_idents + hash % IP_IDENTS_SZ;
119869+ atomic_unchecked_t *p_id = ip_idents + hash % IP_IDENTS_SZ;
119870 u32 old = ACCESS_ONCE(*p_tstamp);
119871 u32 now = (u32)jiffies;
119872 u32 delta = 0;
119873@@ -476,7 +476,7 @@ u32 ip_idents_reserve(u32 hash, int segs)
119874 if (old != now && cmpxchg(p_tstamp, old, now) == old)
119875 delta = prandom_u32_max(now - old);
119876
119877- return atomic_add_return(segs + delta, p_id) - segs;
119878+ return atomic_add_return_unchecked(segs + delta, p_id) - segs;
119879 }
119880 EXPORT_SYMBOL(ip_idents_reserve);
119881
119882@@ -2640,34 +2640,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
119883 .maxlen = sizeof(int),
119884 .mode = 0200,
119885 .proc_handler = ipv4_sysctl_rtcache_flush,
119886+ .extra1 = &init_net,
119887 },
119888 { },
119889 };
119890
119891 static __net_init int sysctl_route_net_init(struct net *net)
119892 {
119893- struct ctl_table *tbl;
119894+ ctl_table_no_const *tbl = NULL;
119895
119896- tbl = ipv4_route_flush_table;
119897 if (!net_eq(net, &init_net)) {
119898- tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
119899+ tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
119900 if (!tbl)
119901 goto err_dup;
119902
119903 /* Don't export sysctls to unprivileged users */
119904 if (net->user_ns != &init_user_ns)
119905 tbl[0].procname = NULL;
119906- }
119907- tbl[0].extra1 = net;
119908+ tbl[0].extra1 = net;
119909+ net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
119910+ } else
119911+ net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
119912
119913- net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
119914 if (!net->ipv4.route_hdr)
119915 goto err_reg;
119916 return 0;
119917
119918 err_reg:
119919- if (tbl != ipv4_route_flush_table)
119920- kfree(tbl);
119921+ kfree(tbl);
119922 err_dup:
119923 return -ENOMEM;
119924 }
119925@@ -2690,8 +2690,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
119926
119927 static __net_init int rt_genid_init(struct net *net)
119928 {
119929- atomic_set(&net->ipv4.rt_genid, 0);
119930- atomic_set(&net->fnhe_genid, 0);
119931+ atomic_set_unchecked(&net->ipv4.rt_genid, 0);
119932+ atomic_set_unchecked(&net->fnhe_genid, 0);
119933 get_random_bytes(&net->ipv4.dev_addr_genid,
119934 sizeof(net->ipv4.dev_addr_genid));
119935 return 0;
119936@@ -2735,11 +2735,7 @@ int __init ip_rt_init(void)
119937 int rc = 0;
119938 int cpu;
119939
119940- ip_idents = kmalloc(IP_IDENTS_SZ * sizeof(*ip_idents), GFP_KERNEL);
119941- if (!ip_idents)
119942- panic("IP: failed to allocate ip_idents\n");
119943-
119944- prandom_bytes(ip_idents, IP_IDENTS_SZ * sizeof(*ip_idents));
119945+ prandom_bytes(ip_idents, sizeof(ip_idents));
119946
119947 ip_tstamps = kcalloc(IP_IDENTS_SZ, sizeof(*ip_tstamps), GFP_KERNEL);
119948 if (!ip_tstamps)
119949diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
119950index 0330ab2..4745d2c 100644
119951--- a/net/ipv4/sysctl_net_ipv4.c
119952+++ b/net/ipv4/sysctl_net_ipv4.c
119953@@ -66,7 +66,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
119954 container_of(table->data, struct net, ipv4.ip_local_ports.range);
119955 int ret;
119956 int range[2];
119957- struct ctl_table tmp = {
119958+ ctl_table_no_const tmp = {
119959 .data = &range,
119960 .maxlen = sizeof(range),
119961 .mode = table->mode,
119962@@ -124,7 +124,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
119963 int ret;
119964 gid_t urange[2];
119965 kgid_t low, high;
119966- struct ctl_table tmp = {
119967+ ctl_table_no_const tmp = {
119968 .data = &urange,
119969 .maxlen = sizeof(urange),
119970 .mode = table->mode,
119971@@ -155,7 +155,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
119972 void __user *buffer, size_t *lenp, loff_t *ppos)
119973 {
119974 char val[TCP_CA_NAME_MAX];
119975- struct ctl_table tbl = {
119976+ ctl_table_no_const tbl = {
119977 .data = val,
119978 .maxlen = TCP_CA_NAME_MAX,
119979 };
119980@@ -174,7 +174,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
119981 void __user *buffer, size_t *lenp,
119982 loff_t *ppos)
119983 {
119984- struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
119985+ ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
119986 int ret;
119987
119988 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
119989@@ -191,7 +191,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
119990 void __user *buffer, size_t *lenp,
119991 loff_t *ppos)
119992 {
119993- struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
119994+ ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
119995 int ret;
119996
119997 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
119998@@ -210,7 +210,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
119999 void __user *buffer, size_t *lenp,
120000 loff_t *ppos)
120001 {
120002- struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
120003+ ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
120004 struct tcp_fastopen_context *ctxt;
120005 int ret;
120006 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
120007@@ -915,13 +915,12 @@ static struct ctl_table ipv4_net_table[] = {
120008
120009 static __net_init int ipv4_sysctl_init_net(struct net *net)
120010 {
120011- struct ctl_table *table;
120012+ ctl_table_no_const *table = NULL;
120013
120014- table = ipv4_net_table;
120015 if (!net_eq(net, &init_net)) {
120016 int i;
120017
120018- table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
120019+ table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
120020 if (!table)
120021 goto err_alloc;
120022
120023@@ -930,7 +929,10 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
120024 table[i].data += (void *)net - (void *)&init_net;
120025 }
120026
120027- net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
120028+ if (!net_eq(net, &init_net))
120029+ net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
120030+ else
120031+ net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
120032 if (!net->ipv4.ipv4_hdr)
120033 goto err_reg;
120034
120035diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
120036index 728f5b3..dc51cbe 100644
120037--- a/net/ipv4/tcp_input.c
120038+++ b/net/ipv4/tcp_input.c
120039@@ -767,7 +767,7 @@ static void tcp_update_pacing_rate(struct sock *sk)
120040 * without any lock. We want to make sure compiler wont store
120041 * intermediate values in this location.
120042 */
120043- ACCESS_ONCE(sk->sk_pacing_rate) = min_t(u64, rate,
120044+ ACCESS_ONCE_RW(sk->sk_pacing_rate) = min_t(u64, rate,
120045 sk->sk_max_pacing_rate);
120046 }
120047
120048@@ -4608,7 +4608,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
120049 * simplifies code)
120050 */
120051 static void
120052-tcp_collapse(struct sock *sk, struct sk_buff_head *list,
120053+__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
120054 struct sk_buff *head, struct sk_buff *tail,
120055 u32 start, u32 end)
120056 {
120057@@ -5603,6 +5603,7 @@ discard:
120058 tcp_paws_reject(&tp->rx_opt, 0))
120059 goto discard_and_undo;
120060
120061+#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
120062 if (th->syn) {
120063 /* We see SYN without ACK. It is attempt of
120064 * simultaneous connect with crossed SYNs.
120065@@ -5653,6 +5654,7 @@ discard:
120066 goto discard;
120067 #endif
120068 }
120069+#endif
120070 /* "fifth, if neither of the SYN or RST bits is set then
120071 * drop the segment and return."
120072 */
120073@@ -5699,7 +5701,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
120074 goto discard;
120075
120076 if (th->syn) {
120077- if (th->fin)
120078+ if (th->fin || th->urg || th->psh)
120079 goto discard;
120080 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
120081 return 1;
120082@@ -6026,7 +6028,7 @@ struct request_sock *inet_reqsk_alloc(const struct request_sock_ops *ops,
120083
120084 kmemcheck_annotate_bitfield(ireq, flags);
120085 ireq->opt = NULL;
120086- atomic64_set(&ireq->ir_cookie, 0);
120087+ atomic64_set_unchecked(&ireq->ir_cookie, 0);
120088 ireq->ireq_state = TCP_NEW_SYN_RECV;
120089 write_pnet(&ireq->ireq_net, sock_net(sk_listener));
120090 ireq->ireq_family = sk_listener->sk_family;
120091diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
120092index 0ea2e1c..a4d1c48 100644
120093--- a/net/ipv4/tcp_ipv4.c
120094+++ b/net/ipv4/tcp_ipv4.c
120095@@ -89,6 +89,10 @@ int sysctl_tcp_tw_reuse __read_mostly;
120096 int sysctl_tcp_low_latency __read_mostly;
120097 EXPORT_SYMBOL(sysctl_tcp_low_latency);
120098
120099+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120100+extern int grsec_enable_blackhole;
120101+#endif
120102+
120103 #ifdef CONFIG_TCP_MD5SIG
120104 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
120105 __be32 daddr, __be32 saddr, const struct tcphdr *th);
120106@@ -1427,6 +1431,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
120107 return 0;
120108
120109 reset:
120110+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120111+ if (!grsec_enable_blackhole)
120112+#endif
120113 tcp_v4_send_reset(rsk, skb);
120114 discard:
120115 kfree_skb(skb);
120116@@ -1591,12 +1598,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
120117 TCP_SKB_CB(skb)->sacked = 0;
120118
120119 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
120120- if (!sk)
120121+ if (!sk) {
120122+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120123+ ret = 1;
120124+#endif
120125 goto no_tcp_socket;
120126-
120127+ }
120128 process:
120129- if (sk->sk_state == TCP_TIME_WAIT)
120130+ if (sk->sk_state == TCP_TIME_WAIT) {
120131+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120132+ ret = 2;
120133+#endif
120134 goto do_time_wait;
120135+ }
120136
120137 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
120138 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
120139@@ -1653,6 +1667,10 @@ csum_error:
120140 bad_packet:
120141 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
120142 } else {
120143+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120144+ if (!grsec_enable_blackhole || (ret == 1 &&
120145+ (skb->dev->flags & IFF_LOOPBACK)))
120146+#endif
120147 tcp_v4_send_reset(NULL, skb);
120148 }
120149
120150diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
120151index 4bc00cb..d024adf 100644
120152--- a/net/ipv4/tcp_minisocks.c
120153+++ b/net/ipv4/tcp_minisocks.c
120154@@ -27,6 +27,10 @@
120155 #include <net/inet_common.h>
120156 #include <net/xfrm.h>
120157
120158+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120159+extern int grsec_enable_blackhole;
120160+#endif
120161+
120162 int sysctl_tcp_syncookies __read_mostly = 1;
120163 EXPORT_SYMBOL(sysctl_tcp_syncookies);
120164
120165@@ -782,7 +786,10 @@ embryonic_reset:
120166 * avoid becoming vulnerable to outside attack aiming at
120167 * resetting legit local connections.
120168 */
120169- req->rsk_ops->send_reset(sk, skb);
120170+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120171+ if (!grsec_enable_blackhole)
120172+#endif
120173+ req->rsk_ops->send_reset(sk, skb);
120174 } else if (fastopen) { /* received a valid RST pkt */
120175 reqsk_fastopen_remove(sk, req, true);
120176 tcp_reset(sk);
120177diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
120178index ebf5ff5..4d1ff32 100644
120179--- a/net/ipv4/tcp_probe.c
120180+++ b/net/ipv4/tcp_probe.c
120181@@ -236,7 +236,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
120182 if (cnt + width >= len)
120183 break;
120184
120185- if (copy_to_user(buf + cnt, tbuf, width))
120186+ if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
120187 return -EFAULT;
120188 cnt += width;
120189 }
120190diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
120191index 5b752f5..9594bb2 100644
120192--- a/net/ipv4/tcp_timer.c
120193+++ b/net/ipv4/tcp_timer.c
120194@@ -22,6 +22,10 @@
120195 #include <linux/gfp.h>
120196 #include <net/tcp.h>
120197
120198+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120199+extern int grsec_lastack_retries;
120200+#endif
120201+
120202 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
120203 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
120204 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
120205@@ -195,6 +199,13 @@ static int tcp_write_timeout(struct sock *sk)
120206 }
120207 }
120208
120209+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120210+ if ((sk->sk_state == TCP_LAST_ACK) &&
120211+ (grsec_lastack_retries > 0) &&
120212+ (grsec_lastack_retries < retry_until))
120213+ retry_until = grsec_lastack_retries;
120214+#endif
120215+
120216 if (retransmits_timed_out(sk, retry_until,
120217 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
120218 /* Has it gone just too far? */
120219diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
120220index 1b8c5ba..e1f0542 100644
120221--- a/net/ipv4/udp.c
120222+++ b/net/ipv4/udp.c
120223@@ -87,6 +87,7 @@
120224 #include <linux/types.h>
120225 #include <linux/fcntl.h>
120226 #include <linux/module.h>
120227+#include <linux/security.h>
120228 #include <linux/socket.h>
120229 #include <linux/sockios.h>
120230 #include <linux/igmp.h>
120231@@ -115,6 +116,10 @@
120232 #include <net/busy_poll.h>
120233 #include "udp_impl.h"
120234
120235+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120236+extern int grsec_enable_blackhole;
120237+#endif
120238+
120239 struct udp_table udp_table __read_mostly;
120240 EXPORT_SYMBOL(udp_table);
120241
120242@@ -608,6 +613,9 @@ static inline bool __udp_is_mcast_sock(struct net *net, struct sock *sk,
120243 return true;
120244 }
120245
120246+extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
120247+extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
120248+
120249 /*
120250 * This routine is called by the ICMP module when it gets some
120251 * sort of error condition. If err < 0 then the socket should
120252@@ -944,9 +952,18 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
120253 dport = usin->sin_port;
120254 if (dport == 0)
120255 return -EINVAL;
120256+
120257+ err = gr_search_udp_sendmsg(sk, usin);
120258+ if (err)
120259+ return err;
120260 } else {
120261 if (sk->sk_state != TCP_ESTABLISHED)
120262 return -EDESTADDRREQ;
120263+
120264+ err = gr_search_udp_sendmsg(sk, NULL);
120265+ if (err)
120266+ return err;
120267+
120268 daddr = inet->inet_daddr;
120269 dport = inet->inet_dport;
120270 /* Open fast path for connected socket.
120271@@ -1193,7 +1210,7 @@ static unsigned int first_packet_length(struct sock *sk)
120272 IS_UDPLITE(sk));
120273 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
120274 IS_UDPLITE(sk));
120275- atomic_inc(&sk->sk_drops);
120276+ atomic_inc_unchecked(&sk->sk_drops);
120277 __skb_unlink(skb, rcvq);
120278 __skb_queue_tail(&list_kill, skb);
120279 }
120280@@ -1273,6 +1290,10 @@ try_again:
120281 if (!skb)
120282 goto out;
120283
120284+ err = gr_search_udp_recvmsg(sk, skb);
120285+ if (err)
120286+ goto out_free;
120287+
120288 ulen = skb->len - sizeof(struct udphdr);
120289 copied = len;
120290 if (copied > ulen)
120291@@ -1305,7 +1326,7 @@ try_again:
120292 if (unlikely(err)) {
120293 trace_kfree_skb(skb, udp_recvmsg);
120294 if (!peeked) {
120295- atomic_inc(&sk->sk_drops);
120296+ atomic_inc_unchecked(&sk->sk_drops);
120297 UDP_INC_STATS_USER(sock_net(sk),
120298 UDP_MIB_INERRORS, is_udplite);
120299 }
120300@@ -1599,7 +1620,7 @@ csum_error:
120301 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
120302 drop:
120303 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
120304- atomic_inc(&sk->sk_drops);
120305+ atomic_inc_unchecked(&sk->sk_drops);
120306 kfree_skb(skb);
120307 return -1;
120308 }
120309@@ -1617,7 +1638,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
120310 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
120311
120312 if (!skb1) {
120313- atomic_inc(&sk->sk_drops);
120314+ atomic_inc_unchecked(&sk->sk_drops);
120315 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
120316 IS_UDPLITE(sk));
120317 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
120318@@ -1823,6 +1844,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
120319 goto csum_error;
120320
120321 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
120322+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120323+ if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
120324+#endif
120325 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
120326
120327 /*
120328@@ -2427,7 +2451,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
120329 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
120330 0, sock_i_ino(sp),
120331 atomic_read(&sp->sk_refcnt), sp,
120332- atomic_read(&sp->sk_drops));
120333+ atomic_read_unchecked(&sp->sk_drops));
120334 }
120335
120336 int udp4_seq_show(struct seq_file *seq, void *v)
120337diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
120338index bff6974..c63736c 100644
120339--- a/net/ipv4/xfrm4_policy.c
120340+++ b/net/ipv4/xfrm4_policy.c
120341@@ -186,11 +186,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
120342 fl4->flowi4_tos = iph->tos;
120343 }
120344
120345-static inline int xfrm4_garbage_collect(struct dst_ops *ops)
120346+static int xfrm4_garbage_collect(struct dst_ops *ops)
120347 {
120348 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
120349
120350- xfrm4_policy_afinfo.garbage_collect(net);
120351+ xfrm_garbage_collect_deferred(net);
120352 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
120353 }
120354
120355@@ -268,19 +268,18 @@ static struct ctl_table xfrm4_policy_table[] = {
120356
120357 static int __net_init xfrm4_net_init(struct net *net)
120358 {
120359- struct ctl_table *table;
120360+ ctl_table_no_const *table = NULL;
120361 struct ctl_table_header *hdr;
120362
120363- table = xfrm4_policy_table;
120364 if (!net_eq(net, &init_net)) {
120365- table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
120366+ table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
120367 if (!table)
120368 goto err_alloc;
120369
120370 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
120371- }
120372-
120373- hdr = register_net_sysctl(net, "net/ipv4", table);
120374+ hdr = register_net_sysctl(net, "net/ipv4", table);
120375+ } else
120376+ hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
120377 if (!hdr)
120378 goto err_reg;
120379
120380@@ -288,8 +287,7 @@ static int __net_init xfrm4_net_init(struct net *net)
120381 return 0;
120382
120383 err_reg:
120384- if (!net_eq(net, &init_net))
120385- kfree(table);
120386+ kfree(table);
120387 err_alloc:
120388 return -ENOMEM;
120389 }
120390diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
120391index 21c2c81..373c1ba 100644
120392--- a/net/ipv6/addrconf.c
120393+++ b/net/ipv6/addrconf.c
120394@@ -178,7 +178,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {
120395 .hop_limit = IPV6_DEFAULT_HOPLIMIT,
120396 .mtu6 = IPV6_MIN_MTU,
120397 .accept_ra = 1,
120398- .accept_redirects = 1,
120399+ .accept_redirects = 0,
120400 .autoconf = 1,
120401 .force_mld_version = 0,
120402 .mldv1_unsolicited_report_interval = 10 * HZ,
120403@@ -219,7 +219,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
120404 .hop_limit = IPV6_DEFAULT_HOPLIMIT,
120405 .mtu6 = IPV6_MIN_MTU,
120406 .accept_ra = 1,
120407- .accept_redirects = 1,
120408+ .accept_redirects = 0,
120409 .autoconf = 1,
120410 .force_mld_version = 0,
120411 .mldv1_unsolicited_report_interval = 10 * HZ,
120412@@ -620,7 +620,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
120413 idx = 0;
120414 head = &net->dev_index_head[h];
120415 rcu_read_lock();
120416- cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
120417+ cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
120418 net->dev_base_seq;
120419 hlist_for_each_entry_rcu(dev, head, index_hlist) {
120420 if (idx < s_idx)
120421@@ -2508,7 +2508,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
120422 p.iph.ihl = 5;
120423 p.iph.protocol = IPPROTO_IPV6;
120424 p.iph.ttl = 64;
120425- ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
120426+ ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
120427
120428 if (ops->ndo_do_ioctl) {
120429 mm_segment_t oldfs = get_fs();
120430@@ -3774,16 +3774,23 @@ static const struct file_operations if6_fops = {
120431 .release = seq_release_net,
120432 };
120433
120434+extern void register_ipv6_seq_ops_addr(struct seq_operations *addr);
120435+extern void unregister_ipv6_seq_ops_addr(void);
120436+
120437 static int __net_init if6_proc_net_init(struct net *net)
120438 {
120439- if (!proc_create("if_inet6", S_IRUGO, net->proc_net, &if6_fops))
120440+ register_ipv6_seq_ops_addr(&if6_seq_ops);
120441+ if (!proc_create("if_inet6", S_IRUGO, net->proc_net, &if6_fops)) {
120442+ unregister_ipv6_seq_ops_addr();
120443 return -ENOMEM;
120444+ }
120445 return 0;
120446 }
120447
120448 static void __net_exit if6_proc_net_exit(struct net *net)
120449 {
120450 remove_proc_entry("if_inet6", net->proc_net);
120451+ unregister_ipv6_seq_ops_addr();
120452 }
120453
120454 static struct pernet_operations if6_proc_net_ops = {
120455@@ -4402,7 +4409,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
120456 s_ip_idx = ip_idx = cb->args[2];
120457
120458 rcu_read_lock();
120459- cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
120460+ cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
120461 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
120462 idx = 0;
120463 head = &net->dev_index_head[h];
120464@@ -5059,7 +5066,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
120465 rt_genid_bump_ipv6(net);
120466 break;
120467 }
120468- atomic_inc(&net->ipv6.dev_addr_genid);
120469+ atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
120470 }
120471
120472 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
120473@@ -5079,7 +5086,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
120474 int *valp = ctl->data;
120475 int val = *valp;
120476 loff_t pos = *ppos;
120477- struct ctl_table lctl;
120478+ ctl_table_no_const lctl;
120479 int ret;
120480
120481 /*
120482@@ -5104,7 +5111,7 @@ int addrconf_sysctl_mtu(struct ctl_table *ctl, int write,
120483 {
120484 struct inet6_dev *idev = ctl->extra1;
120485 int min_mtu = IPV6_MIN_MTU;
120486- struct ctl_table lctl;
120487+ ctl_table_no_const lctl;
120488
120489 lctl = *ctl;
120490 lctl.extra1 = &min_mtu;
120491@@ -5179,7 +5186,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
120492 int *valp = ctl->data;
120493 int val = *valp;
120494 loff_t pos = *ppos;
120495- struct ctl_table lctl;
120496+ ctl_table_no_const lctl;
120497 int ret;
120498
120499 /*
120500@@ -5244,7 +5251,7 @@ static int addrconf_sysctl_stable_secret(struct ctl_table *ctl, int write,
120501 int err;
120502 struct in6_addr addr;
120503 char str[IPV6_MAX_STRLEN];
120504- struct ctl_table lctl = *ctl;
120505+ ctl_table_no_const lctl = *ctl;
120506 struct net *net = ctl->extra2;
120507 struct ipv6_stable_secret *secret = ctl->data;
120508
120509diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
120510index 7de52b6..ce7fb94 100644
120511--- a/net/ipv6/af_inet6.c
120512+++ b/net/ipv6/af_inet6.c
120513@@ -770,7 +770,7 @@ static int __net_init inet6_net_init(struct net *net)
120514 net->ipv6.sysctl.idgen_retries = 3;
120515 net->ipv6.sysctl.idgen_delay = 1 * HZ;
120516 net->ipv6.sysctl.flowlabel_state_ranges = 1;
120517- atomic_set(&net->ipv6.fib6_sernum, 1);
120518+ atomic_set_unchecked(&net->ipv6.fib6_sernum, 1);
120519
120520 err = ipv6_init_mibs(net);
120521 if (err)
120522diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
120523index b10a889..e881e1f 100644
120524--- a/net/ipv6/datagram.c
120525+++ b/net/ipv6/datagram.c
120526@@ -977,5 +977,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
120527 0,
120528 sock_i_ino(sp),
120529 atomic_read(&sp->sk_refcnt), sp,
120530- atomic_read(&sp->sk_drops));
120531+ atomic_read_unchecked(&sp->sk_drops));
120532 }
120533diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
120534index 713d743..8eec687 100644
120535--- a/net/ipv6/icmp.c
120536+++ b/net/ipv6/icmp.c
120537@@ -1004,7 +1004,7 @@ static struct ctl_table ipv6_icmp_table_template[] = {
120538
120539 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
120540 {
120541- struct ctl_table *table;
120542+ ctl_table_no_const *table;
120543
120544 table = kmemdup(ipv6_icmp_table_template,
120545 sizeof(ipv6_icmp_table_template),
120546diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
120547index 548c623..bc8ec4f 100644
120548--- a/net/ipv6/ip6_fib.c
120549+++ b/net/ipv6/ip6_fib.c
120550@@ -99,9 +99,9 @@ static int fib6_new_sernum(struct net *net)
120551 int new, old;
120552
120553 do {
120554- old = atomic_read(&net->ipv6.fib6_sernum);
120555+ old = atomic_read_unchecked(&net->ipv6.fib6_sernum);
120556 new = old < INT_MAX ? old + 1 : 1;
120557- } while (atomic_cmpxchg(&net->ipv6.fib6_sernum,
120558+ } while (atomic_cmpxchg_unchecked(&net->ipv6.fib6_sernum,
120559 old, new) != old);
120560 return new;
120561 }
120562diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
120563index 69f4f68..1f97524 100644
120564--- a/net/ipv6/ip6_gre.c
120565+++ b/net/ipv6/ip6_gre.c
120566@@ -71,8 +71,8 @@ struct ip6gre_net {
120567 struct net_device *fb_tunnel_dev;
120568 };
120569
120570-static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
120571-static struct rtnl_link_ops ip6gre_tap_ops __read_mostly;
120572+static struct rtnl_link_ops ip6gre_link_ops;
120573+static struct rtnl_link_ops ip6gre_tap_ops;
120574 static int ip6gre_tunnel_init(struct net_device *dev);
120575 static void ip6gre_tunnel_setup(struct net_device *dev);
120576 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
120577@@ -1281,7 +1281,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
120578 }
120579
120580
120581-static struct inet6_protocol ip6gre_protocol __read_mostly = {
120582+static struct inet6_protocol ip6gre_protocol = {
120583 .handler = ip6gre_rcv,
120584 .err_handler = ip6gre_err,
120585 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
120586@@ -1640,7 +1640,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
120587 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
120588 };
120589
120590-static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
120591+static struct rtnl_link_ops ip6gre_link_ops = {
120592 .kind = "ip6gre",
120593 .maxtype = IFLA_GRE_MAX,
120594 .policy = ip6gre_policy,
120595@@ -1655,7 +1655,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
120596 .get_link_net = ip6_tnl_get_link_net,
120597 };
120598
120599-static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
120600+static struct rtnl_link_ops ip6gre_tap_ops = {
120601 .kind = "ip6gretap",
120602 .maxtype = IFLA_GRE_MAX,
120603 .policy = ip6gre_policy,
120604diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
120605index d5f7716..b4b3821 100644
120606--- a/net/ipv6/ip6_output.c
120607+++ b/net/ipv6/ip6_output.c
120608@@ -28,6 +28,7 @@
120609
120610 #include <linux/errno.h>
120611 #include <linux/kernel.h>
120612+#include <linux/overflow-arith.h>
120613 #include <linux/string.h>
120614 #include <linux/socket.h>
120615 #include <linux/net.h>
120616@@ -581,7 +582,10 @@ int ip6_fragment(struct sock *sk, struct sk_buff *skb,
120617 if (np->frag_size)
120618 mtu = np->frag_size;
120619 }
120620- mtu -= hlen + sizeof(struct frag_hdr);
120621+
120622+ if (overflow_usub(mtu, hlen + sizeof(struct frag_hdr), &mtu) ||
120623+ mtu <= 7)
120624+ goto fail_toobig;
120625
120626 frag_id = ipv6_select_ident(net, &ipv6_hdr(skb)->daddr,
120627 &ipv6_hdr(skb)->saddr);
120628diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
120629index 2e67b66..b816b34 100644
120630--- a/net/ipv6/ip6_tunnel.c
120631+++ b/net/ipv6/ip6_tunnel.c
120632@@ -80,7 +80,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
120633
120634 static int ip6_tnl_dev_init(struct net_device *dev);
120635 static void ip6_tnl_dev_setup(struct net_device *dev);
120636-static struct rtnl_link_ops ip6_link_ops __read_mostly;
120637+static struct rtnl_link_ops ip6_link_ops;
120638
120639 static int ip6_tnl_net_id __read_mostly;
120640 struct ip6_tnl_net {
120641@@ -1776,7 +1776,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
120642 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
120643 };
120644
120645-static struct rtnl_link_ops ip6_link_ops __read_mostly = {
120646+static struct rtnl_link_ops ip6_link_ops = {
120647 .kind = "ip6tnl",
120648 .maxtype = IFLA_IPTUN_MAX,
120649 .policy = ip6_tnl_policy,
120650diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
120651index 0224c03..c5ec3d9 100644
120652--- a/net/ipv6/ip6_vti.c
120653+++ b/net/ipv6/ip6_vti.c
120654@@ -62,7 +62,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
120655
120656 static int vti6_dev_init(struct net_device *dev);
120657 static void vti6_dev_setup(struct net_device *dev);
120658-static struct rtnl_link_ops vti6_link_ops __read_mostly;
120659+static struct rtnl_link_ops vti6_link_ops;
120660
120661 static int vti6_net_id __read_mostly;
120662 struct vti6_net {
120663@@ -1019,7 +1019,7 @@ static const struct nla_policy vti6_policy[IFLA_VTI_MAX + 1] = {
120664 [IFLA_VTI_OKEY] = { .type = NLA_U32 },
120665 };
120666
120667-static struct rtnl_link_ops vti6_link_ops __read_mostly = {
120668+static struct rtnl_link_ops vti6_link_ops = {
120669 .kind = "vti6",
120670 .maxtype = IFLA_VTI_MAX,
120671 .policy = vti6_policy,
120672diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
120673index 63e6956..ebbbcf6 100644
120674--- a/net/ipv6/ipv6_sockglue.c
120675+++ b/net/ipv6/ipv6_sockglue.c
120676@@ -1015,7 +1015,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
120677 if (sk->sk_type != SOCK_STREAM)
120678 return -ENOPROTOOPT;
120679
120680- msg.msg_control = optval;
120681+ msg.msg_control = (void __force_kernel *)optval;
120682 msg.msg_controllen = len;
120683 msg.msg_flags = flags;
120684
120685diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
120686index 3c35ced..2e6882f 100644
120687--- a/net/ipv6/netfilter/ip6_tables.c
120688+++ b/net/ipv6/netfilter/ip6_tables.c
120689@@ -1086,14 +1086,14 @@ static int compat_table_info(const struct xt_table_info *info,
120690 #endif
120691
120692 static int get_info(struct net *net, void __user *user,
120693- const int *len, int compat)
120694+ int len, int compat)
120695 {
120696 char name[XT_TABLE_MAXNAMELEN];
120697 struct xt_table *t;
120698 int ret;
120699
120700- if (*len != sizeof(struct ip6t_getinfo)) {
120701- duprintf("length %u != %zu\n", *len,
120702+ if (len != sizeof(struct ip6t_getinfo)) {
120703+ duprintf("length %u != %zu\n", len,
120704 sizeof(struct ip6t_getinfo));
120705 return -EINVAL;
120706 }
120707@@ -1130,7 +1130,7 @@ static int get_info(struct net *net, void __user *user,
120708 info.size = private->size;
120709 strcpy(info.name, name);
120710
120711- if (copy_to_user(user, &info, *len) != 0)
120712+ if (copy_to_user(user, &info, len) != 0)
120713 ret = -EFAULT;
120714 else
120715 ret = 0;
120716@@ -1978,7 +1978,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
120717
120718 switch (cmd) {
120719 case IP6T_SO_GET_INFO:
120720- ret = get_info(sock_net(sk), user, len, 1);
120721+ ret = get_info(sock_net(sk), user, *len, 1);
120722 break;
120723 case IP6T_SO_GET_ENTRIES:
120724 ret = compat_get_entries(sock_net(sk), user, len);
120725@@ -2025,7 +2025,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
120726
120727 switch (cmd) {
120728 case IP6T_SO_GET_INFO:
120729- ret = get_info(sock_net(sk), user, len, 0);
120730+ ret = get_info(sock_net(sk), user, *len, 0);
120731 break;
120732
120733 case IP6T_SO_GET_ENTRIES:
120734diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
120735index 6d02498..55e564f 100644
120736--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
120737+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
120738@@ -96,12 +96,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
120739
120740 static int nf_ct_frag6_sysctl_register(struct net *net)
120741 {
120742- struct ctl_table *table;
120743+ ctl_table_no_const *table = NULL;
120744 struct ctl_table_header *hdr;
120745
120746- table = nf_ct_frag6_sysctl_table;
120747 if (!net_eq(net, &init_net)) {
120748- table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
120749+ table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
120750 GFP_KERNEL);
120751 if (table == NULL)
120752 goto err_alloc;
120753@@ -112,9 +111,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
120754 table[2].data = &net->nf_frag.frags.high_thresh;
120755 table[2].extra1 = &net->nf_frag.frags.low_thresh;
120756 table[2].extra2 = &init_net.nf_frag.frags.high_thresh;
120757- }
120758-
120759- hdr = register_net_sysctl(net, "net/netfilter", table);
120760+ hdr = register_net_sysctl(net, "net/netfilter", table);
120761+ } else
120762+ hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
120763 if (hdr == NULL)
120764 goto err_reg;
120765
120766@@ -122,8 +121,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
120767 return 0;
120768
120769 err_reg:
120770- if (!net_eq(net, &init_net))
120771- kfree(table);
120772+ kfree(table);
120773 err_alloc:
120774 return -ENOMEM;
120775 }
120776diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
120777index 263a516..692f738 100644
120778--- a/net/ipv6/ping.c
120779+++ b/net/ipv6/ping.c
120780@@ -240,6 +240,24 @@ static struct pernet_operations ping_v6_net_ops = {
120781 };
120782 #endif
120783
120784+static struct pingv6_ops real_pingv6_ops = {
120785+ .ipv6_recv_error = ipv6_recv_error,
120786+ .ip6_datagram_recv_common_ctl = ip6_datagram_recv_common_ctl,
120787+ .ip6_datagram_recv_specific_ctl = ip6_datagram_recv_specific_ctl,
120788+ .icmpv6_err_convert = icmpv6_err_convert,
120789+ .ipv6_icmp_error = ipv6_icmp_error,
120790+ .ipv6_chk_addr = ipv6_chk_addr,
120791+};
120792+
120793+static struct pingv6_ops dummy_pingv6_ops = {
120794+ .ipv6_recv_error = dummy_ipv6_recv_error,
120795+ .ip6_datagram_recv_common_ctl = dummy_ip6_datagram_recv_ctl,
120796+ .ip6_datagram_recv_specific_ctl = dummy_ip6_datagram_recv_ctl,
120797+ .icmpv6_err_convert = dummy_icmpv6_err_convert,
120798+ .ipv6_icmp_error = dummy_ipv6_icmp_error,
120799+ .ipv6_chk_addr = dummy_ipv6_chk_addr,
120800+};
120801+
120802 int __init pingv6_init(void)
120803 {
120804 #ifdef CONFIG_PROC_FS
120805@@ -247,13 +265,7 @@ int __init pingv6_init(void)
120806 if (ret)
120807 return ret;
120808 #endif
120809- pingv6_ops.ipv6_recv_error = ipv6_recv_error;
120810- pingv6_ops.ip6_datagram_recv_common_ctl = ip6_datagram_recv_common_ctl;
120811- pingv6_ops.ip6_datagram_recv_specific_ctl =
120812- ip6_datagram_recv_specific_ctl;
120813- pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
120814- pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
120815- pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
120816+ pingv6_ops = &real_pingv6_ops;
120817 return inet6_register_protosw(&pingv6_protosw);
120818 }
120819
120820@@ -262,14 +274,9 @@ int __init pingv6_init(void)
120821 */
120822 void pingv6_exit(void)
120823 {
120824- pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
120825- pingv6_ops.ip6_datagram_recv_common_ctl = dummy_ip6_datagram_recv_ctl;
120826- pingv6_ops.ip6_datagram_recv_specific_ctl = dummy_ip6_datagram_recv_ctl;
120827- pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
120828- pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
120829- pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
120830 #ifdef CONFIG_PROC_FS
120831 unregister_pernet_subsys(&ping_v6_net_ops);
120832 #endif
120833+ pingv6_ops = &dummy_pingv6_ops;
120834 inet6_unregister_protosw(&pingv6_protosw);
120835 }
120836diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
120837index 679253d0..70b653c 100644
120838--- a/net/ipv6/proc.c
120839+++ b/net/ipv6/proc.c
120840@@ -310,7 +310,7 @@ static int __net_init ipv6_proc_init_net(struct net *net)
120841 if (!proc_create("snmp6", S_IRUGO, net->proc_net, &snmp6_seq_fops))
120842 goto proc_snmp6_fail;
120843
120844- net->mib.proc_net_devsnmp6 = proc_mkdir("dev_snmp6", net->proc_net);
120845+ net->mib.proc_net_devsnmp6 = proc_mkdir_restrict("dev_snmp6", net->proc_net);
120846 if (!net->mib.proc_net_devsnmp6)
120847 goto proc_dev_snmp6_fail;
120848 return 0;
120849diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
120850index ca4700c..e44c0f9 100644
120851--- a/net/ipv6/raw.c
120852+++ b/net/ipv6/raw.c
120853@@ -388,7 +388,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
120854 {
120855 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
120856 skb_checksum_complete(skb)) {
120857- atomic_inc(&sk->sk_drops);
120858+ atomic_inc_unchecked(&sk->sk_drops);
120859 kfree_skb(skb);
120860 return NET_RX_DROP;
120861 }
120862@@ -416,7 +416,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
120863 struct raw6_sock *rp = raw6_sk(sk);
120864
120865 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
120866- atomic_inc(&sk->sk_drops);
120867+ atomic_inc_unchecked(&sk->sk_drops);
120868 kfree_skb(skb);
120869 return NET_RX_DROP;
120870 }
120871@@ -440,7 +440,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
120872
120873 if (inet->hdrincl) {
120874 if (skb_checksum_complete(skb)) {
120875- atomic_inc(&sk->sk_drops);
120876+ atomic_inc_unchecked(&sk->sk_drops);
120877 kfree_skb(skb);
120878 return NET_RX_DROP;
120879 }
120880@@ -608,7 +608,7 @@ out:
120881 return err;
120882 }
120883
120884-static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
120885+static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, unsigned int length,
120886 struct flowi6 *fl6, struct dst_entry **dstp,
120887 unsigned int flags)
120888 {
120889@@ -916,12 +916,15 @@ do_confirm:
120890 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
120891 char __user *optval, int optlen)
120892 {
120893+ struct icmp6_filter filter;
120894+
120895 switch (optname) {
120896 case ICMPV6_FILTER:
120897 if (optlen > sizeof(struct icmp6_filter))
120898 optlen = sizeof(struct icmp6_filter);
120899- if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
120900+ if (copy_from_user(&filter, optval, optlen))
120901 return -EFAULT;
120902+ raw6_sk(sk)->filter = filter;
120903 return 0;
120904 default:
120905 return -ENOPROTOOPT;
120906@@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
120907 char __user *optval, int __user *optlen)
120908 {
120909 int len;
120910+ struct icmp6_filter filter;
120911
120912 switch (optname) {
120913 case ICMPV6_FILTER:
120914@@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
120915 len = sizeof(struct icmp6_filter);
120916 if (put_user(len, optlen))
120917 return -EFAULT;
120918- if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
120919+ filter = raw6_sk(sk)->filter;
120920+ if (len > sizeof filter || copy_to_user(optval, &filter, len))
120921 return -EFAULT;
120922 return 0;
120923 default:
120924diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
120925index f1159bb..0db5dad 100644
120926--- a/net/ipv6/reassembly.c
120927+++ b/net/ipv6/reassembly.c
120928@@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
120929
120930 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
120931 {
120932- struct ctl_table *table;
120933+ ctl_table_no_const *table = NULL;
120934 struct ctl_table_header *hdr;
120935
120936- table = ip6_frags_ns_ctl_table;
120937 if (!net_eq(net, &init_net)) {
120938- table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
120939+ table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
120940 if (!table)
120941 goto err_alloc;
120942
120943@@ -645,9 +644,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
120944 /* Don't export sysctls to unprivileged users */
120945 if (net->user_ns != &init_user_ns)
120946 table[0].procname = NULL;
120947- }
120948+ hdr = register_net_sysctl(net, "net/ipv6", table);
120949+ } else
120950+ hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
120951
120952- hdr = register_net_sysctl(net, "net/ipv6", table);
120953 if (!hdr)
120954 goto err_reg;
120955
120956@@ -655,8 +655,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
120957 return 0;
120958
120959 err_reg:
120960- if (!net_eq(net, &init_net))
120961- kfree(table);
120962+ kfree(table);
120963 err_alloc:
120964 return -ENOMEM;
120965 }
120966diff --git a/net/ipv6/route.c b/net/ipv6/route.c
120967index 00b64d4..da5099e 100644
120968--- a/net/ipv6/route.c
120969+++ b/net/ipv6/route.c
120970@@ -3430,7 +3430,7 @@ struct ctl_table ipv6_route_table_template[] = {
120971
120972 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
120973 {
120974- struct ctl_table *table;
120975+ ctl_table_no_const *table;
120976
120977 table = kmemdup(ipv6_route_table_template,
120978 sizeof(ipv6_route_table_template),
120979diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
120980index ac35a28..070cc8c 100644
120981--- a/net/ipv6/sit.c
120982+++ b/net/ipv6/sit.c
120983@@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
120984 static void ipip6_dev_free(struct net_device *dev);
120985 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
120986 __be32 *v4dst);
120987-static struct rtnl_link_ops sit_link_ops __read_mostly;
120988+static struct rtnl_link_ops sit_link_ops;
120989
120990 static int sit_net_id __read_mostly;
120991 struct sit_net {
120992@@ -1749,7 +1749,7 @@ static void ipip6_dellink(struct net_device *dev, struct list_head *head)
120993 unregister_netdevice_queue(dev, head);
120994 }
120995
120996-static struct rtnl_link_ops sit_link_ops __read_mostly = {
120997+static struct rtnl_link_ops sit_link_ops = {
120998 .kind = "sit",
120999 .maxtype = IFLA_IPTUN_MAX,
121000 .policy = ipip6_policy,
121001diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
121002index 4e705ad..9ba8db8 100644
121003--- a/net/ipv6/sysctl_net_ipv6.c
121004+++ b/net/ipv6/sysctl_net_ipv6.c
121005@@ -99,7 +99,7 @@ static struct ctl_table ipv6_rotable[] = {
121006
121007 static int __net_init ipv6_sysctl_net_init(struct net *net)
121008 {
121009- struct ctl_table *ipv6_table;
121010+ ctl_table_no_const *ipv6_table;
121011 struct ctl_table *ipv6_route_table;
121012 struct ctl_table *ipv6_icmp_table;
121013 int err;
121014diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
121015index 7a6cea5..1a99e26 100644
121016--- a/net/ipv6/tcp_ipv6.c
121017+++ b/net/ipv6/tcp_ipv6.c
121018@@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
121019 }
121020 }
121021
121022+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121023+extern int grsec_enable_blackhole;
121024+#endif
121025+
121026 static __u32 tcp_v6_init_sequence(const struct sk_buff *skb)
121027 {
121028 return secure_tcpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32,
121029@@ -1280,6 +1284,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
121030 return 0;
121031
121032 reset:
121033+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121034+ if (!grsec_enable_blackhole)
121035+#endif
121036 tcp_v6_send_reset(sk, skb);
121037 discard:
121038 if (opt_skb)
121039@@ -1389,12 +1396,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
121040
121041 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest,
121042 inet6_iif(skb));
121043- if (!sk)
121044+ if (!sk) {
121045+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121046+ ret = 1;
121047+#endif
121048 goto no_tcp_socket;
121049+ }
121050
121051 process:
121052- if (sk->sk_state == TCP_TIME_WAIT)
121053+ if (sk->sk_state == TCP_TIME_WAIT) {
121054+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121055+ ret = 2;
121056+#endif
121057 goto do_time_wait;
121058+ }
121059
121060 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
121061 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
121062@@ -1446,6 +1461,10 @@ csum_error:
121063 bad_packet:
121064 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
121065 } else {
121066+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121067+ if (!grsec_enable_blackhole || (ret == 1 &&
121068+ (skb->dev->flags & IFF_LOOPBACK)))
121069+#endif
121070 tcp_v6_send_reset(NULL, skb);
121071 }
121072
121073diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
121074index e51fc3e..8f04229 100644
121075--- a/net/ipv6/udp.c
121076+++ b/net/ipv6/udp.c
121077@@ -76,6 +76,10 @@ static u32 udp6_ehashfn(const struct net *net,
121078 udp_ipv6_hash_secret + net_hash_mix(net));
121079 }
121080
121081+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121082+extern int grsec_enable_blackhole;
121083+#endif
121084+
121085 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
121086 {
121087 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
121088@@ -445,7 +449,7 @@ try_again:
121089 if (unlikely(err)) {
121090 trace_kfree_skb(skb, udpv6_recvmsg);
121091 if (!peeked) {
121092- atomic_inc(&sk->sk_drops);
121093+ atomic_inc_unchecked(&sk->sk_drops);
121094 if (is_udp4)
121095 UDP_INC_STATS_USER(sock_net(sk),
121096 UDP_MIB_INERRORS,
121097@@ -709,7 +713,7 @@ csum_error:
121098 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
121099 drop:
121100 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
121101- atomic_inc(&sk->sk_drops);
121102+ atomic_inc_unchecked(&sk->sk_drops);
121103 kfree_skb(skb);
121104 return -1;
121105 }
121106@@ -750,7 +754,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
121107 if (likely(!skb1))
121108 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
121109 if (!skb1) {
121110- atomic_inc(&sk->sk_drops);
121111+ atomic_inc_unchecked(&sk->sk_drops);
121112 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
121113 IS_UDPLITE(sk));
121114 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
121115@@ -934,6 +938,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
121116 goto csum_error;
121117
121118 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
121119+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121120+ if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
121121+#endif
121122 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
121123
121124 kfree_skb(skb);
121125diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
121126index ed0583c..606962a 100644
121127--- a/net/ipv6/xfrm6_policy.c
121128+++ b/net/ipv6/xfrm6_policy.c
121129@@ -174,7 +174,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
121130 return;
121131
121132 case IPPROTO_ICMPV6:
121133- if (!onlyproto && pskb_may_pull(skb, nh + offset + 2 - skb->data)) {
121134+ if (!onlyproto && (nh + offset + 2 < skb->data ||
121135+ pskb_may_pull(skb, nh + offset + 2 - skb->data))) {
121136 u8 *icmp;
121137
121138 nh = skb_network_header(skb);
121139@@ -188,7 +189,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
121140 #if IS_ENABLED(CONFIG_IPV6_MIP6)
121141 case IPPROTO_MH:
121142 offset += ipv6_optlen(exthdr);
121143- if (!onlyproto && pskb_may_pull(skb, nh + offset + 3 - skb->data)) {
121144+ if (!onlyproto && (nh + offset + 3 < skb->data ||
121145+ pskb_may_pull(skb, nh + offset + 3 - skb->data))) {
121146 struct ip6_mh *mh;
121147
121148 nh = skb_network_header(skb);
121149@@ -211,11 +213,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
121150 }
121151 }
121152
121153-static inline int xfrm6_garbage_collect(struct dst_ops *ops)
121154+static int xfrm6_garbage_collect(struct dst_ops *ops)
121155 {
121156 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
121157
121158- xfrm6_policy_afinfo.garbage_collect(net);
121159+ xfrm_garbage_collect_deferred(net);
121160 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
121161 }
121162
121163@@ -322,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
121164
121165 static int __net_init xfrm6_net_init(struct net *net)
121166 {
121167- struct ctl_table *table;
121168+ ctl_table_no_const *table = NULL;
121169 struct ctl_table_header *hdr;
121170
121171- table = xfrm6_policy_table;
121172 if (!net_eq(net, &init_net)) {
121173- table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
121174+ table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
121175 if (!table)
121176 goto err_alloc;
121177
121178 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
121179- }
121180+ hdr = register_net_sysctl(net, "net/ipv6", table);
121181+ } else
121182+ hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
121183
121184- hdr = register_net_sysctl(net, "net/ipv6", table);
121185 if (!hdr)
121186 goto err_reg;
121187
121188@@ -342,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
121189 return 0;
121190
121191 err_reg:
121192- if (!net_eq(net, &init_net))
121193- kfree(table);
121194+ kfree(table);
121195 err_alloc:
121196 return -ENOMEM;
121197 }
121198diff --git a/net/ipx/ipx_proc.c b/net/ipx/ipx_proc.c
121199index c1d247e..9e5949d 100644
121200--- a/net/ipx/ipx_proc.c
121201+++ b/net/ipx/ipx_proc.c
121202@@ -289,7 +289,7 @@ int __init ipx_proc_init(void)
121203 struct proc_dir_entry *p;
121204 int rc = -ENOMEM;
121205
121206- ipx_proc_dir = proc_mkdir("ipx", init_net.proc_net);
121207+ ipx_proc_dir = proc_mkdir_restrict("ipx", init_net.proc_net);
121208
121209 if (!ipx_proc_dir)
121210 goto out;
121211diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
121212index 683346d..cb0e12d 100644
121213--- a/net/irda/ircomm/ircomm_tty.c
121214+++ b/net/irda/ircomm/ircomm_tty.c
121215@@ -310,10 +310,10 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
121216 add_wait_queue(&port->open_wait, &wait);
121217
121218 pr_debug("%s(%d):block_til_ready before block on %s open_count=%d\n",
121219- __FILE__, __LINE__, tty->driver->name, port->count);
121220+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
121221
121222 spin_lock_irqsave(&port->lock, flags);
121223- port->count--;
121224+ atomic_dec(&port->count);
121225 port->blocked_open++;
121226 spin_unlock_irqrestore(&port->lock, flags);
121227
121228@@ -348,7 +348,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
121229 }
121230
121231 pr_debug("%s(%d):block_til_ready blocking on %s open_count=%d\n",
121232- __FILE__, __LINE__, tty->driver->name, port->count);
121233+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
121234
121235 schedule();
121236 }
121237@@ -358,12 +358,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
121238
121239 spin_lock_irqsave(&port->lock, flags);
121240 if (!tty_hung_up_p(filp))
121241- port->count++;
121242+ atomic_inc(&port->count);
121243 port->blocked_open--;
121244 spin_unlock_irqrestore(&port->lock, flags);
121245
121246 pr_debug("%s(%d):block_til_ready after blocking on %s open_count=%d\n",
121247- __FILE__, __LINE__, tty->driver->name, port->count);
121248+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
121249
121250 if (!retval)
121251 port->flags |= ASYNC_NORMAL_ACTIVE;
121252@@ -433,12 +433,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
121253
121254 /* ++ is not atomic, so this should be protected - Jean II */
121255 spin_lock_irqsave(&self->port.lock, flags);
121256- self->port.count++;
121257+ atomic_inc(&self->port.count);
121258 spin_unlock_irqrestore(&self->port.lock, flags);
121259 tty_port_tty_set(&self->port, tty);
121260
121261 pr_debug("%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
121262- self->line, self->port.count);
121263+ self->line, atomic_read(&self->port.count));
121264
121265 /* Not really used by us, but lets do it anyway */
121266 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
121267@@ -961,7 +961,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
121268 tty_kref_put(port->tty);
121269 }
121270 port->tty = NULL;
121271- port->count = 0;
121272+ atomic_set(&port->count, 0);
121273 spin_unlock_irqrestore(&port->lock, flags);
121274
121275 wake_up_interruptible(&port->open_wait);
121276@@ -1308,7 +1308,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
121277 seq_putc(m, '\n');
121278
121279 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
121280- seq_printf(m, "Open count: %d\n", self->port.count);
121281+ seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
121282 seq_printf(m, "Max data size: %d\n", self->max_data_size);
121283 seq_printf(m, "Max header size: %d\n", self->max_header_size);
121284
121285diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c
121286index a26c401..4396459 100644
121287--- a/net/irda/irlmp.c
121288+++ b/net/irda/irlmp.c
121289@@ -1839,7 +1839,7 @@ static void *irlmp_seq_hb_idx(struct irlmp_iter_state *iter, loff_t *off)
121290 for (element = hashbin_get_first(iter->hashbin);
121291 element != NULL;
121292 element = hashbin_get_next(iter->hashbin)) {
121293- if (!off || *off-- == 0) {
121294+ if (!off || (*off)-- == 0) {
121295 /* NB: hashbin left locked */
121296 return element;
121297 }
121298diff --git a/net/irda/irproc.c b/net/irda/irproc.c
121299index b9ac598..f88cc56 100644
121300--- a/net/irda/irproc.c
121301+++ b/net/irda/irproc.c
121302@@ -66,7 +66,7 @@ void __init irda_proc_register(void)
121303 {
121304 int i;
121305
121306- proc_irda = proc_mkdir("irda", init_net.proc_net);
121307+ proc_irda = proc_mkdir_restrict("irda", init_net.proc_net);
121308 if (proc_irda == NULL)
121309 return;
121310
121311diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
121312index 918151c..5bbe95a 100644
121313--- a/net/iucv/af_iucv.c
121314+++ b/net/iucv/af_iucv.c
121315@@ -686,10 +686,10 @@ static void __iucv_auto_name(struct iucv_sock *iucv)
121316 {
121317 char name[12];
121318
121319- sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
121320+ sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
121321 while (__iucv_get_sock_by_name(name)) {
121322 sprintf(name, "%08x",
121323- atomic_inc_return(&iucv_sk_list.autobind_name));
121324+ atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
121325 }
121326 memcpy(iucv->src_name, name, 8);
121327 }
121328diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
121329index 2a6a1fd..6c112b0 100644
121330--- a/net/iucv/iucv.c
121331+++ b/net/iucv/iucv.c
121332@@ -702,7 +702,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
121333 return NOTIFY_OK;
121334 }
121335
121336-static struct notifier_block __refdata iucv_cpu_notifier = {
121337+static struct notifier_block iucv_cpu_notifier = {
121338 .notifier_call = iucv_cpu_notify,
121339 };
121340
121341diff --git a/net/key/af_key.c b/net/key/af_key.c
121342index 83a7068..facf2f0 100644
121343--- a/net/key/af_key.c
121344+++ b/net/key/af_key.c
121345@@ -3050,10 +3050,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
121346 static u32 get_acqseq(void)
121347 {
121348 u32 res;
121349- static atomic_t acqseq;
121350+ static atomic_unchecked_t acqseq;
121351
121352 do {
121353- res = atomic_inc_return(&acqseq);
121354+ res = atomic_inc_return_unchecked(&acqseq);
121355 } while (!res);
121356 return res;
121357 }
121358diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
121359index 4b55287..bd247f7 100644
121360--- a/net/l2tp/l2tp_eth.c
121361+++ b/net/l2tp/l2tp_eth.c
121362@@ -42,12 +42,12 @@ struct l2tp_eth {
121363 struct sock *tunnel_sock;
121364 struct l2tp_session *session;
121365 struct list_head list;
121366- atomic_long_t tx_bytes;
121367- atomic_long_t tx_packets;
121368- atomic_long_t tx_dropped;
121369- atomic_long_t rx_bytes;
121370- atomic_long_t rx_packets;
121371- atomic_long_t rx_errors;
121372+ atomic_long_unchecked_t tx_bytes;
121373+ atomic_long_unchecked_t tx_packets;
121374+ atomic_long_unchecked_t tx_dropped;
121375+ atomic_long_unchecked_t rx_bytes;
121376+ atomic_long_unchecked_t rx_packets;
121377+ atomic_long_unchecked_t rx_errors;
121378 };
121379
121380 /* via l2tp_session_priv() */
121381@@ -98,10 +98,10 @@ static int l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *dev)
121382 int ret = l2tp_xmit_skb(session, skb, session->hdr_len);
121383
121384 if (likely(ret == NET_XMIT_SUCCESS)) {
121385- atomic_long_add(len, &priv->tx_bytes);
121386- atomic_long_inc(&priv->tx_packets);
121387+ atomic_long_add_unchecked(len, &priv->tx_bytes);
121388+ atomic_long_inc_unchecked(&priv->tx_packets);
121389 } else {
121390- atomic_long_inc(&priv->tx_dropped);
121391+ atomic_long_inc_unchecked(&priv->tx_dropped);
121392 }
121393 return NETDEV_TX_OK;
121394 }
121395@@ -111,12 +111,12 @@ static struct rtnl_link_stats64 *l2tp_eth_get_stats64(struct net_device *dev,
121396 {
121397 struct l2tp_eth *priv = netdev_priv(dev);
121398
121399- stats->tx_bytes = atomic_long_read(&priv->tx_bytes);
121400- stats->tx_packets = atomic_long_read(&priv->tx_packets);
121401- stats->tx_dropped = atomic_long_read(&priv->tx_dropped);
121402- stats->rx_bytes = atomic_long_read(&priv->rx_bytes);
121403- stats->rx_packets = atomic_long_read(&priv->rx_packets);
121404- stats->rx_errors = atomic_long_read(&priv->rx_errors);
121405+ stats->tx_bytes = atomic_long_read_unchecked(&priv->tx_bytes);
121406+ stats->tx_packets = atomic_long_read_unchecked(&priv->tx_packets);
121407+ stats->tx_dropped = atomic_long_read_unchecked(&priv->tx_dropped);
121408+ stats->rx_bytes = atomic_long_read_unchecked(&priv->rx_bytes);
121409+ stats->rx_packets = atomic_long_read_unchecked(&priv->rx_packets);
121410+ stats->rx_errors = atomic_long_read_unchecked(&priv->rx_errors);
121411 return stats;
121412 }
121413
121414@@ -167,15 +167,15 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb,
121415 nf_reset(skb);
121416
121417 if (dev_forward_skb(dev, skb) == NET_RX_SUCCESS) {
121418- atomic_long_inc(&priv->rx_packets);
121419- atomic_long_add(data_len, &priv->rx_bytes);
121420+ atomic_long_inc_unchecked(&priv->rx_packets);
121421+ atomic_long_add_unchecked(data_len, &priv->rx_bytes);
121422 } else {
121423- atomic_long_inc(&priv->rx_errors);
121424+ atomic_long_inc_unchecked(&priv->rx_errors);
121425 }
121426 return;
121427
121428 error:
121429- atomic_long_inc(&priv->rx_errors);
121430+ atomic_long_inc_unchecked(&priv->rx_errors);
121431 kfree_skb(skb);
121432 }
121433
121434diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
121435index 7964993..2c48a3a 100644
121436--- a/net/l2tp/l2tp_ip.c
121437+++ b/net/l2tp/l2tp_ip.c
121438@@ -608,7 +608,7 @@ static struct inet_protosw l2tp_ip_protosw = {
121439 .ops = &l2tp_ip_ops,
121440 };
121441
121442-static struct net_protocol l2tp_ip_protocol __read_mostly = {
121443+static const struct net_protocol l2tp_ip_protocol = {
121444 .handler = l2tp_ip_recv,
121445 .netns_ok = 1,
121446 };
121447diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
121448index d1ded37..c0d1e49 100644
121449--- a/net/l2tp/l2tp_ip6.c
121450+++ b/net/l2tp/l2tp_ip6.c
121451@@ -755,7 +755,7 @@ static struct inet_protosw l2tp_ip6_protosw = {
121452 .ops = &l2tp_ip6_ops,
121453 };
121454
121455-static struct inet6_protocol l2tp_ip6_protocol __read_mostly = {
121456+static const struct inet6_protocol l2tp_ip6_protocol = {
121457 .handler = l2tp_ip6_recv,
121458 };
121459
121460diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
121461index 1a3c7e0..80f8b0c 100644
121462--- a/net/llc/llc_proc.c
121463+++ b/net/llc/llc_proc.c
121464@@ -247,7 +247,7 @@ int __init llc_proc_init(void)
121465 int rc = -ENOMEM;
121466 struct proc_dir_entry *p;
121467
121468- llc_proc_dir = proc_mkdir("llc", init_net.proc_net);
121469+ llc_proc_dir = proc_mkdir_restrict("llc", init_net.proc_net);
121470 if (!llc_proc_dir)
121471 goto out;
121472
121473diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
121474index bf7023f..86a5bc6 100644
121475--- a/net/mac80211/cfg.c
121476+++ b/net/mac80211/cfg.c
121477@@ -580,7 +580,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
121478 ret = ieee80211_vif_use_channel(sdata, chandef,
121479 IEEE80211_CHANCTX_EXCLUSIVE);
121480 }
121481- } else if (local->open_count == local->monitors) {
121482+ } else if (local_read(&local->open_count) == local->monitors) {
121483 local->_oper_chandef = *chandef;
121484 ieee80211_hw_config(local, 0);
121485 }
121486@@ -3488,7 +3488,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
121487 else
121488 local->probe_req_reg--;
121489
121490- if (!local->open_count)
121491+ if (!local_read(&local->open_count))
121492 break;
121493
121494 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
121495@@ -3637,8 +3637,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
121496 if (chanctx_conf) {
121497 *chandef = sdata->vif.bss_conf.chandef;
121498 ret = 0;
121499- } else if (local->open_count > 0 &&
121500- local->open_count == local->monitors &&
121501+ } else if (local_read(&local->open_count) > 0 &&
121502+ local_read(&local->open_count) == local->monitors &&
121503 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
121504 if (local->use_chanctx)
121505 *chandef = local->monitor_chandef;
121506diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
121507index b12f615..a264a60 100644
121508--- a/net/mac80211/ieee80211_i.h
121509+++ b/net/mac80211/ieee80211_i.h
121510@@ -30,6 +30,7 @@
121511 #include <net/ieee80211_radiotap.h>
121512 #include <net/cfg80211.h>
121513 #include <net/mac80211.h>
121514+#include <asm/local.h>
121515 #include "key.h"
121516 #include "sta_info.h"
121517 #include "debug.h"
121518@@ -1112,7 +1113,7 @@ struct ieee80211_local {
121519 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
121520 spinlock_t queue_stop_reason_lock;
121521
121522- int open_count;
121523+ local_t open_count;
121524 int monitors, cooked_mntrs;
121525 /* number of interfaces with corresponding FIF_ flags */
121526 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
121527diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
121528index 553ac6d..d2480da 100644
121529--- a/net/mac80211/iface.c
121530+++ b/net/mac80211/iface.c
121531@@ -550,7 +550,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121532 break;
121533 }
121534
121535- if (local->open_count == 0) {
121536+ if (local_read(&local->open_count) == 0) {
121537 res = drv_start(local);
121538 if (res)
121539 goto err_del_bss;
121540@@ -597,7 +597,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121541 res = drv_add_interface(local, sdata);
121542 if (res)
121543 goto err_stop;
121544- } else if (local->monitors == 0 && local->open_count == 0) {
121545+ } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
121546 res = ieee80211_add_virtual_monitor(local);
121547 if (res)
121548 goto err_stop;
121549@@ -704,7 +704,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121550 atomic_inc(&local->iff_allmultis);
121551
121552 if (coming_up)
121553- local->open_count++;
121554+ local_inc(&local->open_count);
121555
121556 if (hw_reconf_flags)
121557 ieee80211_hw_config(local, hw_reconf_flags);
121558@@ -742,7 +742,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121559 err_del_interface:
121560 drv_remove_interface(local, sdata);
121561 err_stop:
121562- if (!local->open_count)
121563+ if (!local_read(&local->open_count))
121564 drv_stop(local);
121565 err_del_bss:
121566 sdata->bss = NULL;
121567@@ -909,7 +909,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121568 }
121569
121570 if (going_down)
121571- local->open_count--;
121572+ local_dec(&local->open_count);
121573
121574 switch (sdata->vif.type) {
121575 case NL80211_IFTYPE_AP_VLAN:
121576@@ -978,7 +978,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121577 atomic_set(&sdata->txqs_len[txqi->txq.ac], 0);
121578 }
121579
121580- if (local->open_count == 0)
121581+ if (local_read(&local->open_count) == 0)
121582 ieee80211_clear_tx_pending(local);
121583
121584 /*
121585@@ -1021,7 +1021,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121586 if (cancel_scan)
121587 flush_delayed_work(&local->scan_work);
121588
121589- if (local->open_count == 0) {
121590+ if (local_read(&local->open_count) == 0) {
121591 ieee80211_stop_device(local);
121592
121593 /* no reconfiguring after stop! */
121594@@ -1032,7 +1032,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121595 ieee80211_configure_filter(local);
121596 ieee80211_hw_config(local, hw_reconf_flags);
121597
121598- if (local->monitors == local->open_count)
121599+ if (local->monitors == local_read(&local->open_count))
121600 ieee80211_add_virtual_monitor(local);
121601 }
121602
121603@@ -1884,8 +1884,8 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local)
121604 */
121605 cfg80211_shutdown_all_interfaces(local->hw.wiphy);
121606
121607- WARN(local->open_count, "%s: open count remains %d\n",
121608- wiphy_name(local->hw.wiphy), local->open_count);
121609+ WARN(local_read(&local->open_count), "%s: open count remains %ld\n",
121610+ wiphy_name(local->hw.wiphy), local_read(&local->open_count));
121611
121612 mutex_lock(&local->iflist_mtx);
121613 list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
121614diff --git a/net/mac80211/main.c b/net/mac80211/main.c
121615index 3c63468..b5c285f 100644
121616--- a/net/mac80211/main.c
121617+++ b/net/mac80211/main.c
121618@@ -172,7 +172,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
121619 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
121620 IEEE80211_CONF_CHANGE_POWER);
121621
121622- if (changed && local->open_count) {
121623+ if (changed && local_read(&local->open_count)) {
121624 ret = drv_config(local, changed);
121625 /*
121626 * Goal:
121627diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
121628index b676b9f..395dd95 100644
121629--- a/net/mac80211/pm.c
121630+++ b/net/mac80211/pm.c
121631@@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
121632 struct ieee80211_sub_if_data *sdata;
121633 struct sta_info *sta;
121634
121635- if (!local->open_count)
121636+ if (!local_read(&local->open_count))
121637 goto suspend;
121638
121639 ieee80211_scan_cancel(local);
121640@@ -166,7 +166,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
121641 WARN_ON(!list_empty(&local->chanctx_list));
121642
121643 /* stop hardware - this must stop RX */
121644- if (local->open_count)
121645+ if (local_read(&local->open_count))
121646 ieee80211_stop_device(local);
121647
121648 suspend:
121649diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
121650index fda33f9..0e7d4c0 100644
121651--- a/net/mac80211/rate.c
121652+++ b/net/mac80211/rate.c
121653@@ -730,7 +730,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
121654
121655 ASSERT_RTNL();
121656
121657- if (local->open_count)
121658+ if (local_read(&local->open_count))
121659 return -EBUSY;
121660
121661 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
121662diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
121663index 666ddac..0cad93b 100644
121664--- a/net/mac80211/sta_info.c
121665+++ b/net/mac80211/sta_info.c
121666@@ -341,7 +341,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
121667 int size = sizeof(struct txq_info) +
121668 ALIGN(hw->txq_data_size, sizeof(void *));
121669
121670- txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp);
121671+ txq_data = kcalloc(size, ARRAY_SIZE(sta->sta.txq), gfp);
121672 if (!txq_data)
121673 goto free;
121674
121675diff --git a/net/mac80211/util.c b/net/mac80211/util.c
121676index 43e5aad..d117c3a 100644
121677--- a/net/mac80211/util.c
121678+++ b/net/mac80211/util.c
121679@@ -1761,7 +1761,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121680 bool sched_scan_stopped = false;
121681
121682 /* nothing to do if HW shouldn't run */
121683- if (!local->open_count)
121684+ if (!local_read(&local->open_count))
121685 goto wake_up;
121686
121687 #ifdef CONFIG_PM
121688@@ -2033,7 +2033,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121689 local->in_reconfig = false;
121690 barrier();
121691
121692- if (local->monitors == local->open_count && local->monitors > 0)
121693+ if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
121694 ieee80211_add_virtual_monitor(local);
121695
121696 /*
121697@@ -2088,7 +2088,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121698 * If this is for hw restart things are still running.
121699 * We may want to change that later, however.
121700 */
121701- if (local->open_count && (!local->suspended || reconfig_due_to_wowlan))
121702+ if (local_read(&local->open_count) && (!local->suspended || reconfig_due_to_wowlan))
121703 drv_reconfig_complete(local, IEEE80211_RECONFIG_TYPE_RESTART);
121704
121705 if (!local->suspended)
121706@@ -2112,7 +2112,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121707 flush_delayed_work(&local->scan_work);
121708 }
121709
121710- if (local->open_count && !reconfig_due_to_wowlan)
121711+ if (local_read(&local->open_count) && !reconfig_due_to_wowlan)
121712 drv_reconfig_complete(local, IEEE80211_RECONFIG_TYPE_SUSPEND);
121713
121714 list_for_each_entry(sdata, &local->interfaces, list) {
121715diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
121716index 1f93a59..96faa29 100644
121717--- a/net/mpls/af_mpls.c
121718+++ b/net/mpls/af_mpls.c
121719@@ -456,7 +456,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
121720 struct mpls_dev *mdev)
121721 {
121722 char path[sizeof("net/mpls/conf/") + IFNAMSIZ];
121723- struct ctl_table *table;
121724+ ctl_table_no_const *table;
121725 int i;
121726
121727 table = kmemdup(&mpls_dev_table, sizeof(mpls_dev_table), GFP_KERNEL);
121728@@ -1025,7 +1025,7 @@ static int mpls_platform_labels(struct ctl_table *table, int write,
121729 struct net *net = table->data;
121730 int platform_labels = net->mpls.platform_labels;
121731 int ret;
121732- struct ctl_table tmp = {
121733+ ctl_table_no_const tmp = {
121734 .procname = table->procname,
121735 .data = &platform_labels,
121736 .maxlen = sizeof(int),
121737@@ -1055,7 +1055,7 @@ static const struct ctl_table mpls_table[] = {
121738
121739 static int mpls_net_init(struct net *net)
121740 {
121741- struct ctl_table *table;
121742+ ctl_table_no_const *table;
121743
121744 net->mpls.platform_labels = 0;
121745 net->mpls.platform_label = NULL;
121746diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
121747index 6eae69a..ccccba8 100644
121748--- a/net/netfilter/Kconfig
121749+++ b/net/netfilter/Kconfig
121750@@ -1125,6 +1125,16 @@ config NETFILTER_XT_MATCH_ESP
121751
121752 To compile it as a module, choose M here. If unsure, say N.
121753
121754+config NETFILTER_XT_MATCH_GRADM
121755+ tristate '"gradm" match support'
121756+ depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
121757+ depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
121758+ ---help---
121759+ The gradm match allows to match on grsecurity RBAC being enabled.
121760+ It is useful when iptables rules are applied early on bootup to
121761+ prevent connections to the machine (except from a trusted host)
121762+ while the RBAC system is disabled.
121763+
121764 config NETFILTER_XT_MATCH_HASHLIMIT
121765 tristate '"hashlimit" match support'
121766 depends on IP6_NF_IPTABLES || IP6_NF_IPTABLES=n
121767diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
121768index 70d026d..c400590 100644
121769--- a/net/netfilter/Makefile
121770+++ b/net/netfilter/Makefile
121771@@ -140,6 +140,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
121772 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
121773 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
121774 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
121775+obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
121776 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
121777 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
121778 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
121779diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
121780index 338b404..839dcb0 100644
121781--- a/net/netfilter/ipset/ip_set_core.c
121782+++ b/net/netfilter/ipset/ip_set_core.c
121783@@ -1998,7 +1998,7 @@ done:
121784 return ret;
121785 }
121786
121787-static struct nf_sockopt_ops so_set __read_mostly = {
121788+static struct nf_sockopt_ops so_set = {
121789 .pf = PF_INET,
121790 .get_optmin = SO_IP_SET,
121791 .get_optmax = SO_IP_SET + 1,
121792diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
121793index b0f7b62..0541842 100644
121794--- a/net/netfilter/ipvs/ip_vs_conn.c
121795+++ b/net/netfilter/ipvs/ip_vs_conn.c
121796@@ -572,7 +572,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
121797 /* Increase the refcnt counter of the dest */
121798 ip_vs_dest_hold(dest);
121799
121800- conn_flags = atomic_read(&dest->conn_flags);
121801+ conn_flags = atomic_read_unchecked(&dest->conn_flags);
121802 if (cp->protocol != IPPROTO_UDP)
121803 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
121804 flags = cp->flags;
121805@@ -922,7 +922,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p, int dest_af,
121806
121807 cp->control = NULL;
121808 atomic_set(&cp->n_control, 0);
121809- atomic_set(&cp->in_pkts, 0);
121810+ atomic_set_unchecked(&cp->in_pkts, 0);
121811
121812 cp->packet_xmit = NULL;
121813 cp->app = NULL;
121814@@ -1229,7 +1229,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
121815
121816 /* Don't drop the entry if its number of incoming packets is not
121817 located in [0, 8] */
121818- i = atomic_read(&cp->in_pkts);
121819+ i = atomic_read_unchecked(&cp->in_pkts);
121820 if (i > 8 || i < 0) return 0;
121821
121822 if (!todrop_rate[i]) return 0;
121823diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
121824index 38fbc19..4272cb4 100644
121825--- a/net/netfilter/ipvs/ip_vs_core.c
121826+++ b/net/netfilter/ipvs/ip_vs_core.c
121827@@ -586,7 +586,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
121828 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
121829 /* do not touch skb anymore */
121830
121831- atomic_inc(&cp->in_pkts);
121832+ atomic_inc_unchecked(&cp->in_pkts);
121833 ip_vs_conn_put(cp);
121834 return ret;
121835 }
121836@@ -1762,7 +1762,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
121837 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
121838 pkts = sysctl_sync_threshold(ipvs);
121839 else
121840- pkts = atomic_add_return(1, &cp->in_pkts);
121841+ pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
121842
121843 if (ipvs->sync_state & IP_VS_STATE_MASTER)
121844 ip_vs_sync_conn(net, cp, pkts);
121845diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
121846index 24c5542..e9fd3e5 100644
121847--- a/net/netfilter/ipvs/ip_vs_ctl.c
121848+++ b/net/netfilter/ipvs/ip_vs_ctl.c
121849@@ -814,7 +814,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
121850 */
121851 ip_vs_rs_hash(ipvs, dest);
121852 }
121853- atomic_set(&dest->conn_flags, conn_flags);
121854+ atomic_set_unchecked(&dest->conn_flags, conn_flags);
121855
121856 /* bind the service */
121857 old_svc = rcu_dereference_protected(dest->svc, 1);
121858@@ -1694,7 +1694,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
121859 * align with netns init in ip_vs_control_net_init()
121860 */
121861
121862-static struct ctl_table vs_vars[] = {
121863+static ctl_table_no_const vs_vars[] __read_only = {
121864 {
121865 .procname = "amemthresh",
121866 .maxlen = sizeof(int),
121867@@ -2036,7 +2036,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
121868 " %-7s %-6d %-10d %-10d\n",
121869 &dest->addr.in6,
121870 ntohs(dest->port),
121871- ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
121872+ ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
121873 atomic_read(&dest->weight),
121874 atomic_read(&dest->activeconns),
121875 atomic_read(&dest->inactconns));
121876@@ -2047,7 +2047,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
121877 "%-7s %-6d %-10d %-10d\n",
121878 ntohl(dest->addr.ip),
121879 ntohs(dest->port),
121880- ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
121881+ ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
121882 atomic_read(&dest->weight),
121883 atomic_read(&dest->activeconns),
121884 atomic_read(&dest->inactconns));
121885@@ -2546,7 +2546,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
121886
121887 entry.addr = dest->addr.ip;
121888 entry.port = dest->port;
121889- entry.conn_flags = atomic_read(&dest->conn_flags);
121890+ entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
121891 entry.weight = atomic_read(&dest->weight);
121892 entry.u_threshold = dest->u_threshold;
121893 entry.l_threshold = dest->l_threshold;
121894@@ -3121,7 +3121,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
121895 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
121896 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
121897 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
121898- (atomic_read(&dest->conn_flags) &
121899+ (atomic_read_unchecked(&dest->conn_flags) &
121900 IP_VS_CONN_F_FWD_MASK)) ||
121901 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
121902 atomic_read(&dest->weight)) ||
121903@@ -3759,7 +3759,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
121904 {
121905 int idx;
121906 struct netns_ipvs *ipvs = net_ipvs(net);
121907- struct ctl_table *tbl;
121908+ ctl_table_no_const *tbl;
121909
121910 atomic_set(&ipvs->dropentry, 0);
121911 spin_lock_init(&ipvs->dropentry_lock);
121912diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
121913index 127f140..553d652 100644
121914--- a/net/netfilter/ipvs/ip_vs_lblc.c
121915+++ b/net/netfilter/ipvs/ip_vs_lblc.c
121916@@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
121917 * IPVS LBLC sysctl table
121918 */
121919 #ifdef CONFIG_SYSCTL
121920-static struct ctl_table vs_vars_table[] = {
121921+static ctl_table_no_const vs_vars_table[] __read_only = {
121922 {
121923 .procname = "lblc_expiration",
121924 .data = NULL,
121925diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
121926index 2229d2d..b32b785 100644
121927--- a/net/netfilter/ipvs/ip_vs_lblcr.c
121928+++ b/net/netfilter/ipvs/ip_vs_lblcr.c
121929@@ -289,7 +289,7 @@ struct ip_vs_lblcr_table {
121930 * IPVS LBLCR sysctl table
121931 */
121932
121933-static struct ctl_table vs_vars_table[] = {
121934+static ctl_table_no_const vs_vars_table[] __read_only = {
121935 {
121936 .procname = "lblcr_expiration",
121937 .data = NULL,
121938diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
121939index d99ad93..09bd6dc 100644
121940--- a/net/netfilter/ipvs/ip_vs_sync.c
121941+++ b/net/netfilter/ipvs/ip_vs_sync.c
121942@@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
121943 cp = cp->control;
121944 if (cp) {
121945 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
121946- pkts = atomic_add_return(1, &cp->in_pkts);
121947+ pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
121948 else
121949 pkts = sysctl_sync_threshold(ipvs);
121950 ip_vs_sync_conn(net, cp, pkts);
121951@@ -771,7 +771,7 @@ control:
121952 if (!cp)
121953 return;
121954 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
121955- pkts = atomic_add_return(1, &cp->in_pkts);
121956+ pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
121957 else
121958 pkts = sysctl_sync_threshold(ipvs);
121959 goto sloop;
121960@@ -919,7 +919,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
121961
121962 if (opt)
121963 memcpy(&cp->in_seq, opt, sizeof(*opt));
121964- atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
121965+ atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
121966 cp->state = state;
121967 cp->old_state = cp->state;
121968 /*
121969diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
121970index 258a0b0..2082f50 100644
121971--- a/net/netfilter/ipvs/ip_vs_xmit.c
121972+++ b/net/netfilter/ipvs/ip_vs_xmit.c
121973@@ -1259,7 +1259,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
121974 else
121975 rc = NF_ACCEPT;
121976 /* do not touch skb anymore */
121977- atomic_inc(&cp->in_pkts);
121978+ atomic_inc_unchecked(&cp->in_pkts);
121979 goto out;
121980 }
121981
121982@@ -1352,7 +1352,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
121983 else
121984 rc = NF_ACCEPT;
121985 /* do not touch skb anymore */
121986- atomic_inc(&cp->in_pkts);
121987+ atomic_inc_unchecked(&cp->in_pkts);
121988 goto out;
121989 }
121990
121991diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
121992index 45da11a..ef3e5dc 100644
121993--- a/net/netfilter/nf_conntrack_acct.c
121994+++ b/net/netfilter/nf_conntrack_acct.c
121995@@ -64,7 +64,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
121996 #ifdef CONFIG_SYSCTL
121997 static int nf_conntrack_acct_init_sysctl(struct net *net)
121998 {
121999- struct ctl_table *table;
122000+ ctl_table_no_const *table;
122001
122002 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
122003 GFP_KERNEL);
122004diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
122005index 0625a42..b2c15f4 100644
122006--- a/net/netfilter/nf_conntrack_core.c
122007+++ b/net/netfilter/nf_conntrack_core.c
122008@@ -1754,6 +1754,10 @@ void nf_conntrack_init_end(void)
122009 #define DYING_NULLS_VAL ((1<<30)+1)
122010 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
122011
122012+#ifdef CONFIG_GRKERNSEC_HIDESYM
122013+static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
122014+#endif
122015+
122016 int nf_conntrack_init_net(struct net *net)
122017 {
122018 int ret = -ENOMEM;
122019@@ -1778,7 +1782,11 @@ int nf_conntrack_init_net(struct net *net)
122020 if (!net->ct.stat)
122021 goto err_pcpu_lists;
122022
122023+#ifdef CONFIG_GRKERNSEC_HIDESYM
122024+ net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08x", atomic_inc_return_unchecked(&conntrack_cache_id));
122025+#else
122026 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
122027+#endif
122028 if (!net->ct.slabname)
122029 goto err_slabname;
122030
122031diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
122032index 4e78c57..ec8fb74 100644
122033--- a/net/netfilter/nf_conntrack_ecache.c
122034+++ b/net/netfilter/nf_conntrack_ecache.c
122035@@ -264,7 +264,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
122036 #ifdef CONFIG_SYSCTL
122037 static int nf_conntrack_event_init_sysctl(struct net *net)
122038 {
122039- struct ctl_table *table;
122040+ ctl_table_no_const *table;
122041
122042 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
122043 GFP_KERNEL);
122044diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
122045index bd9d315..989947e 100644
122046--- a/net/netfilter/nf_conntrack_helper.c
122047+++ b/net/netfilter/nf_conntrack_helper.c
122048@@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
122049
122050 static int nf_conntrack_helper_init_sysctl(struct net *net)
122051 {
122052- struct ctl_table *table;
122053+ ctl_table_no_const *table;
122054
122055 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
122056 GFP_KERNEL);
122057diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
122058index b65d586..beec902 100644
122059--- a/net/netfilter/nf_conntrack_proto.c
122060+++ b/net/netfilter/nf_conntrack_proto.c
122061@@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
122062
122063 static void
122064 nf_ct_unregister_sysctl(struct ctl_table_header **header,
122065- struct ctl_table **table,
122066+ ctl_table_no_const **table,
122067 unsigned int users)
122068 {
122069 if (users > 0)
122070diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
122071index fc823fa..8311af3 100644
122072--- a/net/netfilter/nf_conntrack_standalone.c
122073+++ b/net/netfilter/nf_conntrack_standalone.c
122074@@ -468,7 +468,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
122075
122076 static int nf_conntrack_standalone_init_sysctl(struct net *net)
122077 {
122078- struct ctl_table *table;
122079+ ctl_table_no_const *table;
122080
122081 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
122082 GFP_KERNEL);
122083diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
122084index 7a394df..bd91a8a 100644
122085--- a/net/netfilter/nf_conntrack_timestamp.c
122086+++ b/net/netfilter/nf_conntrack_timestamp.c
122087@@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
122088 #ifdef CONFIG_SYSCTL
122089 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
122090 {
122091- struct ctl_table *table;
122092+ ctl_table_no_const *table;
122093
122094 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
122095 GFP_KERNEL);
122096diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
122097index a5d41df..1ff49be 100644
122098--- a/net/netfilter/nf_log.c
122099+++ b/net/netfilter/nf_log.c
122100@@ -391,7 +391,7 @@ static const struct file_operations nflog_file_ops = {
122101
122102 #ifdef CONFIG_SYSCTL
122103 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
122104-static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
122105+static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
122106
122107 static int nf_log_proc_dostring(struct ctl_table *table, int write,
122108 void __user *buffer, size_t *lenp, loff_t *ppos)
122109@@ -422,13 +422,15 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
122110 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
122111 mutex_unlock(&nf_log_mutex);
122112 } else {
122113+ ctl_table_no_const nf_log_table = *table;
122114+
122115 mutex_lock(&nf_log_mutex);
122116 logger = nft_log_dereference(net->nf.nf_loggers[tindex]);
122117 if (!logger)
122118- table->data = "NONE";
122119+ nf_log_table.data = "NONE";
122120 else
122121- table->data = logger->name;
122122- r = proc_dostring(table, write, buffer, lenp, ppos);
122123+ nf_log_table.data = logger->name;
122124+ r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
122125 mutex_unlock(&nf_log_mutex);
122126 }
122127
122128diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
122129index c68c1e5..8b5d670 100644
122130--- a/net/netfilter/nf_sockopt.c
122131+++ b/net/netfilter/nf_sockopt.c
122132@@ -43,7 +43,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
122133 }
122134 }
122135
122136- list_add(&reg->list, &nf_sockopts);
122137+ pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
122138 out:
122139 mutex_unlock(&nf_sockopt_mutex);
122140 return ret;
122141@@ -53,7 +53,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
122142 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
122143 {
122144 mutex_lock(&nf_sockopt_mutex);
122145- list_del(&reg->list);
122146+ pax_list_del((struct list_head *)&reg->list);
122147 mutex_unlock(&nf_sockopt_mutex);
122148 }
122149 EXPORT_SYMBOL(nf_unregister_sockopt);
122150diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
122151index 4670821..a6c3c47d 100644
122152--- a/net/netfilter/nfnetlink_log.c
122153+++ b/net/netfilter/nfnetlink_log.c
122154@@ -84,7 +84,7 @@ static int nfnl_log_net_id __read_mostly;
122155 struct nfnl_log_net {
122156 spinlock_t instances_lock;
122157 struct hlist_head instance_table[INSTANCE_BUCKETS];
122158- atomic_t global_seq;
122159+ atomic_unchecked_t global_seq;
122160 };
122161
122162 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
122163@@ -572,7 +572,7 @@ __build_packet_message(struct nfnl_log_net *log,
122164 /* global sequence number */
122165 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
122166 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
122167- htonl(atomic_inc_return(&log->global_seq))))
122168+ htonl(atomic_inc_return_unchecked(&log->global_seq))))
122169 goto nla_put_failure;
122170
122171 if (data_len) {
122172diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
122173index 9c8fab0..5080c7c 100644
122174--- a/net/netfilter/nft_compat.c
122175+++ b/net/netfilter/nft_compat.c
122176@@ -322,14 +322,7 @@ static void nft_match_eval(const struct nft_expr *expr,
122177 return;
122178 }
122179
122180- switch (ret ? 1 : 0) {
122181- case 1:
122182- regs->verdict.code = NFT_CONTINUE;
122183- break;
122184- case 0:
122185- regs->verdict.code = NFT_BREAK;
122186- break;
122187- }
122188+ regs->verdict.code = ret ? NFT_CONTINUE : NFT_BREAK;
122189 }
122190
122191 static const struct nla_policy nft_match_policy[NFTA_MATCH_MAX + 1] = {
122192diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
122193new file mode 100644
122194index 0000000..c566332
122195--- /dev/null
122196+++ b/net/netfilter/xt_gradm.c
122197@@ -0,0 +1,51 @@
122198+/*
122199+ * gradm match for netfilter
122200